forked from firka/student-legacy
progress in new subject page
This commit is contained in:
parent
98efdfd8cf
commit
7f88c8c3e1
@ -1,3 +1,5 @@
|
||||
import 'package:refilc_kreta_api/models/teacher.dart';
|
||||
|
||||
import 'category.dart';
|
||||
|
||||
class GradeSubject {
|
||||
@ -6,6 +8,7 @@ class GradeSubject {
|
||||
String name;
|
||||
String? renamedTo;
|
||||
double? customRounding;
|
||||
Teacher? teacher;
|
||||
|
||||
bool get isRenamed => renamedTo != null;
|
||||
bool get hasCustomRounding => customRounding != null;
|
||||
@ -17,6 +20,7 @@ class GradeSubject {
|
||||
this.renamedTo,
|
||||
// v5
|
||||
this.customRounding,
|
||||
this.teacher,
|
||||
});
|
||||
|
||||
factory GradeSubject.fromJson(Map json) {
|
||||
|
@ -1,18 +1,21 @@
|
||||
import 'package:refilc/theme/colors/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:refilc/utils/format.dart';
|
||||
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
|
||||
|
||||
class HeroScrollView extends StatefulWidget {
|
||||
const HeroScrollView(
|
||||
{super.key,
|
||||
required this.child,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
this.italic = false,
|
||||
this.navBarItems = const [],
|
||||
this.onClose,
|
||||
this.iconSize = 64.0,
|
||||
this.scrollController});
|
||||
const HeroScrollView({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
this.italic = false,
|
||||
this.navBarItems = const [],
|
||||
this.onClose,
|
||||
this.iconSize = 64.0,
|
||||
this.scrollController,
|
||||
this.showTitleUnscroll = true,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final String title;
|
||||
@ -22,6 +25,7 @@ class HeroScrollView extends StatefulWidget {
|
||||
final double iconSize;
|
||||
final ScrollController? scrollController;
|
||||
final bool italic;
|
||||
final bool showTitleUnscroll;
|
||||
|
||||
@override
|
||||
HeroScrollViewState createState() => HeroScrollViewState();
|
||||
@ -97,34 +101,43 @@ class HeroScrollViewState extends State<HeroScrollView> {
|
||||
}
|
||||
}),
|
||||
actions: widget.navBarItems,
|
||||
expandedHeight: 145.69,
|
||||
expandedHeight: 155.69,
|
||||
stretch: true,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background: Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: Icon(
|
||||
widget.icon,
|
||||
size: widget.iconSize,
|
||||
color: AppColors.of(context).text.withOpacity(.15),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 46.0),
|
||||
child: RoundBorderIcon(
|
||||
color: AppColors.of(context).text.withOpacity(.9),
|
||||
width: 1.5,
|
||||
padding: 12.0,
|
||||
icon: Icon(
|
||||
widget.icon,
|
||||
size: widget.iconSize / 2,
|
||||
color: AppColors.of(context).text.withOpacity(.8),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.only(top: 82),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Text(
|
||||
widget.title.capital(),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 36.0,
|
||||
color: AppColors.of(context).text.withOpacity(.9),
|
||||
fontStyle: widget.italic ? FontStyle.italic : null,
|
||||
fontWeight: FontWeight.bold),
|
||||
if (widget.showTitleUnscroll)
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.only(top: 82),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Text(
|
||||
widget.title.capital(),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 36.0,
|
||||
color: AppColors.of(context).text.withOpacity(.9),
|
||||
fontStyle: widget.italic ? FontStyle.italic : null,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -96,6 +96,38 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
||||
void buildTiles(List<Grade> subjectGrades) {
|
||||
List<Widget> tiles = [];
|
||||
|
||||
tiles.add(Panel(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.subject.renamedTo ?? widget.subject.name.capital(),
|
||||
style: const TextStyle(
|
||||
fontSize: 20.0,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8.0,
|
||||
),
|
||||
Text(
|
||||
((widget.subject.teacher?.isRenamed ?? false) &&
|
||||
settingsProvider.renamedTeachersEnabled
|
||||
? widget.subject.teacher?.renamedTo
|
||||
: widget.subject.teacher?.name.capital()) ??
|
||||
'',
|
||||
style: const TextStyle(
|
||||
fontSize: 14.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.6,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
if (showGraph(subjectGrades)) {
|
||||
tiles.add(gradeGraph);
|
||||
} else {
|
||||
@ -269,6 +301,7 @@ class _GradeSubjectViewState extends State<GradeSubjectView> {
|
||||
onRefresh: () async {},
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
child: HeroScrollView(
|
||||
showTitleUnscroll: false,
|
||||
onClose: () {
|
||||
if (_sheetController != null && gradeCalcMode) {
|
||||
_sheetController!.close();
|
||||
|
@ -94,7 +94,14 @@ class GradesPageState extends State<GradesPage> {
|
||||
|
||||
void generateTiles() {
|
||||
List<GradeSubject> subjects = gradeProvider.grades
|
||||
.map((e) => e.subject)
|
||||
.map((e) => GradeSubject(
|
||||
category: e.subject.category,
|
||||
id: e.subject.id,
|
||||
name: e.subject.name,
|
||||
renamedTo: e.subject.renamedTo,
|
||||
customRounding: e.subject.customRounding,
|
||||
teacher: e.teacher,
|
||||
))
|
||||
.toSet()
|
||||
.toList()
|
||||
..sort((a, b) => a.name.compareTo(b.name));
|
||||
|
Loading…
x
Reference in New Issue
Block a user