diff --git a/firka/lib/ui/phone/pages/home/home_grades.dart b/firka/lib/ui/phone/pages/home/home_grades.dart index 69e13b7b..b7185c16 100644 --- a/firka/lib/ui/phone/pages/home/home_grades.dart +++ b/firka/lib/ui/phone/pages/home/home_grades.dart @@ -33,6 +33,7 @@ class HomeGradesScreen extends StatefulWidget { String activeSubjectUid = ""; String subjectName = ""; +List subjectInfo = []; class _HomeGradesScreen extends FirkaState { ApiResponse>? grades; @@ -168,6 +169,7 @@ void updateListener() async { onTap: () { activeSubjectUid = subject.uid; subjectName = subject.name; + subjectInfo = subjects.where((s) => s.uid == subject.uid).toList(); widget.pageController(1); }, )); @@ -177,6 +179,7 @@ void updateListener() async { onTap: () { activeSubjectUid = subject.uid; subjectName = subject.name; + subjectInfo = subjects.where((s) => s.uid == subject.uid).toList(); widget.pageController(1); }, )); diff --git a/firka/lib/ui/phone/pages/home/home_grades_subject.dart b/firka/lib/ui/phone/pages/home/home_grades_subject.dart index 04a4b8cb..674f44b0 100644 --- a/firka/lib/ui/phone/pages/home/home_grades_subject.dart +++ b/firka/lib/ui/phone/pages/home/home_grades_subject.dart @@ -4,8 +4,11 @@ import 'package:firka/helpers/ui/common_bottom_sheets.dart'; import 'package:firka/helpers/ui/firka_card.dart'; import 'package:firka/helpers/ui/grade.dart'; import 'package:firka/ui/phone/pages/home/home_grades.dart'; +import 'package:firka/ui/widget/class_icon.dart'; +import 'package:firka/ui/widget/firka_icon.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:majesticons_flutter/majesticons_flutter.dart'; import '../../../../helpers/firka_state.dart'; import '../../../../helpers/update_notifier.dart'; @@ -16,9 +19,10 @@ class HomeGradesSubjectScreen extends StatefulWidget { final AppInitialization data; final UpdateNotifier updateNotifier; final UpdateNotifier finishNotifier; + final void Function(int) pageController; const HomeGradesSubjectScreen( - this.data, this.updateNotifier, this.finishNotifier, + this.data, this.updateNotifier, this.finishNotifier, this.pageController, {super.key}); @override @@ -139,14 +143,31 @@ class _HomeGradesSubjectScreen extends FirkaState { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( + Column( children: [ - Text( - widget.data.l10n.subjects, - style: appStyle - .fonts.H_16px // TODO: Replace this with the proper font - .apply(color: appStyle.colors.textPrimary), - ) + Row( + children: [ + Transform.translate( + offset: const Offset(-4, 0), + child: GestureDetector( + child: FirkaIconWidget( + FirkaIconType.majesticons, Majesticon.chevronLeftLine, + color: appStyle.colors.textSecondary), + onTap: () { + widget.pageController(0); + }, + ), + ), + Transform.translate( + offset: const Offset(-4, 1), + child: Text( + widget.data.l10n.subjects, + style: appStyle.fonts.B_16R + .apply(color: appStyle.colors.textPrimary), + ), + ) + ], + ), ], ), SizedBox(height: 16), @@ -156,34 +177,38 @@ class _HomeGradesSubjectScreen extends FirkaState { 230, child: ListView( children: [ - FirkaCard( - left: [ - Padding( - padding: EdgeInsets.only(left: 4), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width / 1.45, - child: Text( - aGrade.subject.name, - style: appStyle.fonts.H_H2 - .apply(color: appStyle.colors.textPrimary), - ), - ), - Text( - aGrade.teacher, // For some reason the teacher's - // name isn't stored in the subject, so we need - // to get *a* grade, and then get the teacher's - // name from there :3 - style: appStyle.fonts.B_16R - .apply(color: appStyle.colors.textPrimary), - ) - ], + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Card( + shadowColor: const Color.fromRGBO(0, 0, 0, 0), + color: appStyle.colors.a15p, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16)), + child: Padding( + padding: EdgeInsetsGeometry.all(6), + child: ClassIconWidget( + uid: aGrade.subject.uid, + className: aGrade.subject.name, + category: aGrade.subject.category.name!, + color: appStyle.colors.accent, + ), ), - ) - ], - ), + ), + SizedBox(height: 8), + Text( + aGrade.subject.name, + style: appStyle.fonts.H_H2 + .apply(color: appStyle.colors.textPrimary), + ), + SizedBox(height: 2), + Text( + aGrade.teacher, + style: appStyle.fonts.B_16R + .apply(color: appStyle.colors.textSecondary), + ), + SizedBox(height: 15) + ]), Padding( padding: EdgeInsets.only(left: 4), child: Column( @@ -207,14 +232,31 @@ class _HomeGradesSubjectScreen extends FirkaState { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( + Column( children: [ - Text( - widget.data.l10n.subjects, - style: appStyle - .fonts.H_16px // TODO: Replace this with the proper font - .apply(color: appStyle.colors.textPrimary), - ) + Row( + children: [ + Transform.translate( + offset: const Offset(-4, 0), + child: GestureDetector( + child: FirkaIconWidget( + FirkaIconType.majesticons, Majesticon.chevronLeftLine, + color: appStyle.colors.textSecondary), + onTap: () { + widget.pageController(0); + }, + ), + ), + Transform.translate( + offset: const Offset(-4, 1), + child: Text( + widget.data.l10n.subjects, + style: appStyle.fonts.B_16R + .apply(color: appStyle.colors.textPrimary), + ), + ) + ], + ), ], ), SizedBox(height: 16), @@ -224,26 +266,32 @@ class _HomeGradesSubjectScreen extends FirkaState { 230, child: ListView( children: [ - FirkaCard( - left: [ - Padding( - padding: EdgeInsets.only(left: 4), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width / 1.45, - child: Text( - subjectName, - style: appStyle.fonts.H_H2 - .apply(color: appStyle.colors.textPrimary), - ), - ), - ], + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Card( + shadowColor: const Color.fromRGBO(0, 0, 0, 0), + color: appStyle.colors.a15p, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16)), + child: Padding( + padding: EdgeInsetsGeometry.all(6), + child: ClassIconWidget( + uid: subjectInfo.first.uid, + className: subjectInfo.first.name, + category: subjectInfo.first.category.name!, + color: appStyle.colors.accent, + ), ), - ) - ], - ), + ), + SizedBox(height: 8), + Text( + subjectInfo.first.name, + style: appStyle.fonts.H_H2 + .apply(color: appStyle.colors.textPrimary), + ), + SizedBox(height: 15) + ]), SizedBox( height: MediaQuery.of(context).size.height - MediaQuery.of(context).padding.top - 320, child: Center( diff --git a/firka/lib/ui/phone/screens/home/home_screen.dart b/firka/lib/ui/phone/screens/home/home_screen.dart index 027b081d..ae555ee3 100644 --- a/firka/lib/ui/phone/screens/home/home_screen.dart +++ b/firka/lib/ui/phone/screens/home/home_screen.dart @@ -916,8 +916,8 @@ class _HomeSubPage extends State { return PageWithSubPages([ (cb) => HomeGradesScreen(widget.data, widget._updateNotifier, widget._updateFinishNotifier, cb), - (cb) => HomeGradesSubjectScreen(widget.data, - widget._updateNotifier, widget._updateFinishNotifier) + (cb) => HomeGradesSubjectScreen(widget.data, widget._updateNotifier, + widget._updateFinishNotifier, cb), ], subPageActive, subPageBack, pageIndex: 0); case HomePage.timetable: return PageWithSubPages([ @@ -935,10 +935,10 @@ class _HomeSubPage extends State { case HomePage.grades: activeSubjectUid = subPageData!; return PageWithSubPages([ - (cb) => HomeGradesSubjectScreen(widget.data, - widget._updateNotifier, widget._updateFinishNotifier), + (cb) => HomeGradesSubjectScreen(widget.data, widget._updateNotifier, + widget._updateFinishNotifier, cb), (cb) => HomeGradesScreen(widget.data, widget._updateNotifier, - widget._updateFinishNotifier, cb) + widget._updateFinishNotifier, cb), ], subPageActive, subPageBack, pageIndex: 0); case HomePage.timetable: return PageWithSubPages([ @@ -959,8 +959,8 @@ class _HomeSubPage extends State { return PageWithSubPages([ (cb) => HomeGradesScreen(widget.data, widget._updateNotifier, widget._updateFinishNotifier, cb), - (cb) => HomeGradesSubjectScreen( - widget.data, widget._updateNotifier, widget._updateFinishNotifier) + (cb) => HomeGradesSubjectScreen(widget.data, widget._updateNotifier, + widget._updateFinishNotifier, cb), ], subPageActive, subPageBack, pageIndex: 0); case HomePage.timetable: return PageWithSubPages([