From cbeebf3f0ec55ebba46ae3c20335619037129201 Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Tue, 2 Sep 2025 18:41:07 +0200 Subject: [PATCH] home/*: fix loading spinner --- .../lib/ui/phone/pages/home/home_grades.dart | 252 +++++++++--------- .../phone/pages/home/home_grades_subject.dart | 15 +- firka/lib/ui/phone/pages/home/home_main.dart | 14 +- .../ui/phone/pages/home/home_timetable.dart | 15 +- .../phone/pages/home/home_timetable_mo.dart | 15 +- 5 files changed, 164 insertions(+), 147 deletions(-) diff --git a/firka/lib/ui/phone/pages/home/home_grades.dart b/firka/lib/ui/phone/pages/home/home_grades.dart index b234308..a9deb91 100644 --- a/firka/lib/ui/phone/pages/home/home_grades.dart +++ b/firka/lib/ui/phone/pages/home/home_grades.dart @@ -83,14 +83,15 @@ class _HomeGradesScreen extends State { @override Widget build(BuildContext context) { if (grades == null || week == null) { - return SizedBox( - height: MediaQuery.of(context).size.height / 1.35, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + return Scaffold( + backgroundColor: appStyle.colors.background, + body: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox(), - DelayedSpinnerWidget(), - SizedBox(), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [DelayedSpinnerWidget()], + ) ], ), ); @@ -154,127 +155,128 @@ class _HomeGradesScreen extends State { var subjectAvgColor = getGradeColor(subjectAvg); return Scaffold( - backgroundColor: appStyle.colors.background, body: Padding( - padding: const EdgeInsets.only( - left: 20.0, - right: 20.0, - top: 12.0, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( + backgroundColor: appStyle.colors.background, + body: Padding( + padding: const EdgeInsets.only( + left: 20.0, + right: 20.0, + top: 12.0, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - widget.data.l10n.subjects, - style: appStyle.fonts.H_H2 - .apply(color: appStyle.colors.textPrimary), - ) + Row( + children: [ + Text( + widget.data.l10n.subjects, + style: appStyle.fonts.H_H2 + .apply(color: appStyle.colors.textPrimary), + ) + ], + ), + SizedBox(height: 16), // TODO: Add graphs here + // ...gradeCards, + SizedBox( + height: MediaQuery.of(context).size.height - + MediaQuery.of(context).padding.top - + 240, + child: ListView( + children: [ + Text( + widget.data.l10n.your_subjects, + style: appStyle.fonts.H_14px + .apply(color: appStyle.colors.textSecondary), + ), + SizedBox(height: 16), + ...gradeCards, + SizedBox(height: 16), + Text( + widget.data.l10n.data, + style: appStyle.fonts.B_16SB + .apply(color: appStyle.colors.textSecondary), + ), + SizedBox(height: 16), + FirkaCard( + left: [ + Text( + widget.data.l10n.subject_avg, + style: appStyle.fonts.B_16SB + .apply(color: appStyle.colors.textPrimary), + ), + ], + right: [ + Card( + shadowColor: Colors.transparent, + color: subjectAvgColor.withAlpha(38), + child: Padding( + padding: EdgeInsets.only( + left: 8, right: 8, top: 4, bottom: 4), + child: Text( + subjectAvg.toStringAsFixed(2), + style: appStyle.fonts.B_16SB + .apply(color: subjectAvgColor), + ), + ), + ), + ], + ), + FirkaCard( + left: [ + Text( + widget.data.l10n.subject_avg_rounded, + style: appStyle.fonts.B_16SB + .apply(color: appStyle.colors.textPrimary), + ), + ], + right: [ + Card( + shadowColor: Colors.transparent, + color: subjectAvgColor.withAlpha(38), + child: Padding( + padding: EdgeInsets.only( + left: 8, right: 8, top: 4, bottom: 4), + child: Text( + subjectAvgRounded.toStringAsFixed(2), + style: appStyle.fonts.B_16SB + .apply(color: subjectAvgColor), + ), + ), + ), + ], + ), + FirkaCard(left: [ + Text( + widget.data.l10n.class_avg, + style: appStyle.fonts.B_16SB + .apply(color: appStyle.colors.textPrimary), + ), + ]), + FirkaCard( + left: [ + Text( + widget.data.l10n.class_n, + style: appStyle.fonts.B_16SB + .apply(color: appStyle.colors.textPrimary), + ), + ], + right: [ + Text( + week!.response! + .where((lesson) => + lesson.type.name != TimetableConsts.event) + .length + .toString(), + style: appStyle.fonts.B_14SB + .apply(color: appStyle.colors.textPrimary), + ), + ], + ), + ], + ), + ), ], ), - SizedBox(height: 16), // TODO: Add graphs here - // ...gradeCards, - SizedBox( - height: MediaQuery.of(context).size.height - - MediaQuery.of(context).padding.top - - 240, - child: ListView( - children: [ - Text( - widget.data.l10n.your_subjects, - style: appStyle.fonts.H_14px - .apply(color: appStyle.colors.textSecondary), - ), - SizedBox(height: 16), - ...gradeCards, - SizedBox(height: 16), - Text( - widget.data.l10n.data, - style: appStyle.fonts.B_16SB - .apply(color: appStyle.colors.textSecondary), - ), - SizedBox(height: 16), - FirkaCard( - left: [ - Text( - widget.data.l10n.subject_avg, - style: appStyle.fonts.B_16SB - .apply(color: appStyle.colors.textPrimary), - ), - ], - right: [ - Card( - shadowColor: Colors.transparent, - color: subjectAvgColor.withAlpha(38), - child: Padding( - padding: EdgeInsets.only( - left: 8, right: 8, top: 4, bottom: 4), - child: Text( - subjectAvg.toStringAsFixed(2), - style: appStyle.fonts.B_16SB - .apply(color: subjectAvgColor), - ), - ), - ), - ], - ), - FirkaCard( - left: [ - Text( - widget.data.l10n.subject_avg_rounded, - style: appStyle.fonts.B_16SB - .apply(color: appStyle.colors.textPrimary), - ), - ], - right: [ - Card( - shadowColor: Colors.transparent, - color: subjectAvgColor.withAlpha(38), - child: Padding( - padding: EdgeInsets.only( - left: 8, right: 8, top: 4, bottom: 4), - child: Text( - subjectAvgRounded.toStringAsFixed(2), - style: appStyle.fonts.B_16SB - .apply(color: subjectAvgColor), - ), - ), - ), - ], - ), - FirkaCard(left: [ - Text( - widget.data.l10n.class_avg, - style: appStyle.fonts.B_16SB - .apply(color: appStyle.colors.textPrimary), - ), - ]), - FirkaCard( - left: [ - Text( - widget.data.l10n.class_n, - style: appStyle.fonts.B_16SB - .apply(color: appStyle.colors.textPrimary), - ), - ], - right: [ - Text( - week!.response! - .where((lesson) => - lesson.type.name != TimetableConsts.event) - .length - .toString(), - style: appStyle.fonts.B_14SB - .apply(color: appStyle.colors.textPrimary), - ), - ], - ), - ], - ), - ), - ], - ), - )); + )); } } } 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 1644009..5383c0d 100644 --- a/firka/lib/ui/phone/pages/home/home_grades_subject.dart +++ b/firka/lib/ui/phone/pages/home/home_grades_subject.dart @@ -188,14 +188,15 @@ class _HomeGradesSubjectScreen extends State { ), )); } else { - return SizedBox( - height: MediaQuery.of(context).size.height / 1.35, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + return Scaffold( + backgroundColor: appStyle.colors.background, + body: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox(), - DelayedSpinnerWidget(), - SizedBox(), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [DelayedSpinnerWidget()], + ) ], ), ); diff --git a/firka/lib/ui/phone/pages/home/home_main.dart b/firka/lib/ui/phone/pages/home/home_main.dart index 6e2b286..256b001 100644 --- a/firka/lib/ui/phone/pages/home/home_main.dart +++ b/firka/lib/ui/phone/pages/home/home_main.dart @@ -13,6 +13,7 @@ import '../../../../helpers/api/model/timetable.dart'; import '../../../../helpers/debug_helper.dart'; import '../../../../helpers/update_notifier.dart'; import '../../../../main.dart'; +import '../../../model/style.dart'; import '../../widgets/home_main_welcome.dart'; import '../../widgets/lesson_big.dart'; @@ -190,7 +191,18 @@ class _HomeMainScreen extends State { ), ); } else { - return DelayedSpinnerWidget(); + return Scaffold( + backgroundColor: appStyle.colors.background, + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [DelayedSpinnerWidget()], + ) + ], + ), + ); } } } diff --git a/firka/lib/ui/phone/pages/home/home_timetable.dart b/firka/lib/ui/phone/pages/home/home_timetable.dart index 240288f..28b6a17 100644 --- a/firka/lib/ui/phone/pages/home/home_timetable.dart +++ b/firka/lib/ui/phone/pages/home/home_timetable.dart @@ -345,14 +345,15 @@ class _HomeTimetableScreen extends State { ) ])); } else { - return SizedBox( - height: MediaQuery.of(context).size.height / 1.35, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + return Scaffold( + backgroundColor: appStyle.colors.background, + body: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox(), - DelayedSpinnerWidget(), - SizedBox(), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [DelayedSpinnerWidget()], + ) ], ), ); diff --git a/firka/lib/ui/phone/pages/home/home_timetable_mo.dart b/firka/lib/ui/phone/pages/home/home_timetable_mo.dart index 478da9f..08658d0 100644 --- a/firka/lib/ui/phone/pages/home/home_timetable_mo.dart +++ b/firka/lib/ui/phone/pages/home/home_timetable_mo.dart @@ -535,14 +535,15 @@ class _HomeTimetableMonthlyScreen extends State { ), ])); } else { - return SizedBox( - height: MediaQuery.of(context).size.height / 1.35, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + return Scaffold( + backgroundColor: appStyle.colors.background, + body: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox(), - DelayedSpinnerWidget(), - SizedBox(), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [DelayedSpinnerWidget()], + ) ], ), );