diff --git a/refilc_kreta_api/lib/models/subject.dart b/refilc_kreta_api/lib/models/subject.dart index be153c9..f0ca6f7 100644 --- a/refilc_kreta_api/lib/models/subject.dart +++ b/refilc_kreta_api/lib/models/subject.dart @@ -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) { diff --git a/refilc_mobile_ui/lib/common/hero_scrollview.dart b/refilc_mobile_ui/lib/common/hero_scrollview.dart index 6041c13..37ee49b 100644 --- a/refilc_mobile_ui/lib/common/hero_scrollview.dart +++ b/refilc_mobile_ui/lib/common/hero_scrollview.dart @@ -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 { } }), 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), + ), ), - ), ], ), ), diff --git a/refilc_mobile_ui/lib/pages/grades/grade_subject_view.dart b/refilc_mobile_ui/lib/pages/grades/grade_subject_view.dart index c7e86e4..ffe7875 100644 --- a/refilc_mobile_ui/lib/pages/grades/grade_subject_view.dart +++ b/refilc_mobile_ui/lib/pages/grades/grade_subject_view.dart @@ -96,6 +96,38 @@ class _GradeSubjectViewState extends State { void buildTiles(List subjectGrades) { List 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 { onRefresh: () async {}, color: Theme.of(context).colorScheme.secondary, child: HeroScrollView( + showTitleUnscroll: false, onClose: () { if (_sheetController != null && gradeCalcMode) { _sheetController!.close(); diff --git a/refilc_mobile_ui/lib/pages/grades/grades_page.dart b/refilc_mobile_ui/lib/pages/grades/grades_page.dart index a1c5ff9..e180df9 100644 --- a/refilc_mobile_ui/lib/pages/grades/grades_page.dart +++ b/refilc_mobile_ui/lib/pages/grades/grades_page.dart @@ -94,7 +94,14 @@ class GradesPageState extends State { void generateTiles() { List 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));