From 6bf6b461194dabf92905a2a22b0074289f873db0 Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Sat, 13 Sep 2025 14:14:27 +0200 Subject: [PATCH] move scaffold from grades & tt pages to subpage fixes random white stuttering in the background --- .../lib/ui/phone/pages/home/home_grades.dart | 222 ++++++----- .../phone/pages/home/home_grades_subject.dart | 133 +++---- .../lib/ui/phone/pages/home/home_subpage.dart | 2 + .../ui/phone/pages/home/home_timetable.dart | 359 +++++++++--------- 4 files changed, 352 insertions(+), 364 deletions(-) diff --git a/firka/lib/ui/phone/pages/home/home_grades.dart b/firka/lib/ui/phone/pages/home/home_grades.dart index 9333d27..3eabb99 100644 --- a/firka/lib/ui/phone/pages/home/home_grades.dart +++ b/firka/lib/ui/phone/pages/home/home_grades.dart @@ -166,129 +166,127 @@ class _HomeGradesScreen extends FirkaState { 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, + return Padding( + padding: const EdgeInsets.only( + left: 20.0, + right: 20.0, + top: 12.0, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( children: [ - 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.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.your_subjects, - style: appStyle.fonts.H_14px - .apply(color: appStyle.colors.textSecondary), - ), - SizedBox(height: 16), - ...gradeCards, - SizedBox(height: 16), - Text( - widget.data.l10n.data, + widget.data.l10n.subject_avg, style: appStyle.fonts.B_16SB - .apply(color: appStyle.colors.textSecondary), + .apply(color: appStyle.colors.textPrimary), ), - SizedBox(height: 16), - FirkaCard( - left: [ - Text( - widget.data.l10n.subject_avg, + ], + 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: appStyle.colors.textPrimary), + .apply(color: subjectAvgColor), ), - ], - 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), - ), - ], ), ], ), - ), - ], + 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 6f6db7f..6f4ab16 100644 --- a/firka/lib/ui/phone/pages/home/home_grades_subject.dart +++ b/firka/lib/ui/phone/pages/home/home_grades_subject.dart @@ -129,89 +129,82 @@ class _HomeGradesSubjectScreen extends FirkaState { } } - return Scaffold( - backgroundColor: appStyle.colors.background, - body: Padding( - padding: const EdgeInsets.only( - left: 16.0, - right: 16.0, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + return Padding( + padding: const EdgeInsets.only( + left: 16.0, + right: 16.0, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( children: [ - Row( - children: [ - Text( - widget.data.l10n.subjects, - style: appStyle.fonts - .H_16px // TODO: Replace this with the proper font - .apply(color: appStyle.colors.textPrimary), - ) - ], - ), - SizedBox(height: 16), - SizedBox( - height: MediaQuery.of(context).size.height - - MediaQuery.of(context).padding.top - - 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_14R.apply( - color: appStyle.colors.textPrimary), - ) - ], - ), - ) - ], - ), + Text( + widget.data.l10n.subjects, + style: appStyle + .fonts.H_16px // TODO: Replace this with the proper font + .apply(color: appStyle.colors.textPrimary), + ) + ], + ), + SizedBox(height: 16), + SizedBox( + height: MediaQuery.of(context).size.height - + MediaQuery.of(context).padding.top - + 230, + child: ListView( + children: [ + FirkaCard( + left: [ Padding( padding: EdgeInsets.only(left: 4), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: gradeWidgets, + 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_14R + .apply(color: appStyle.colors.textPrimary), + ) + ], ), ) ], ), - ), - ], + Padding( + padding: EdgeInsets.only(left: 4), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: gradeWidgets, + ), + ) + ], + ), ), - )); - } else { - return Scaffold( - backgroundColor: appStyle.colors.background, - body: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [DelayedSpinnerWidget()], - ) ], ), ); + } else { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [DelayedSpinnerWidget()], + ) + ], + ); } } } diff --git a/firka/lib/ui/phone/pages/home/home_subpage.dart b/firka/lib/ui/phone/pages/home/home_subpage.dart index 95a9c13..b055715 100644 --- a/firka/lib/ui/phone/pages/home/home_subpage.dart +++ b/firka/lib/ui/phone/pages/home/home_subpage.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../../../../helpers/firka_state.dart'; +import '../../../model/style.dart'; class PageWithSubPages extends StatefulWidget { final int pageIndex; @@ -19,6 +20,7 @@ class _PageWithSubPagesState extends FirkaState { @override Widget build(BuildContext context) { return Scaffold( + backgroundColor: appStyle.colors.background, body: widget.subPages[_currentSubPage]((page) { setState(() { _currentSubPage = page; diff --git a/firka/lib/ui/phone/pages/home/home_timetable.dart b/firka/lib/ui/phone/pages/home/home_timetable.dart index 2d784ce..0a30bde 100644 --- a/firka/lib/ui/phone/pages/home/home_timetable.dart +++ b/firka/lib/ui/phone/pages/home/home_timetable.dart @@ -308,44 +308,42 @@ class _HomeTimetableScreen extends FirkaState ttEmptyCards.clear(); } - return Scaffold( - backgroundColor: appStyle.colors.background, - body: Stack(children: [ - SizedBox( - width: MediaQuery.of(context).size.width, - height: 74 + 16, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), - child: Column( + return Stack(children: [ + SizedBox( + width: MediaQuery.of(context).size.width, + height: 74 + 16, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Text( + widget.data.l10n.timetable, + style: appStyle.fonts.H_H2 + .apply(color: appStyle.colors.textPrimary), + ), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - widget.data.l10n.timetable, - style: appStyle.fonts.H_H2 - .apply(color: appStyle.colors.textPrimary), - ), - Row( - children: [ - GestureDetector( - child: Card( - color: appStyle.colors.buttonSecondaryFill, - child: Padding( - padding: const EdgeInsets.all(8), - child: FirkaIconWidget( - FirkaIconType.majesticons, - Majesticon.tableSolid, - size: 26.0, - color: appStyle.colors.accent, - ), - ), + GestureDetector( + child: Card( + color: appStyle.colors.buttonSecondaryFill, + child: Padding( + padding: const EdgeInsets.all(8), + child: FirkaIconWidget( + FirkaIconType.majesticons, + Majesticon.tableSolid, + size: 26.0, + color: appStyle.colors.accent, ), - onTap: () { - widget.pageController(1); - }, ), - /* TODO: 1.1.0 + ), + onTap: () { + widget.pageController(1); + }, + ), + /* TODO: 1.1.0 Card( color: appStyle.colors.buttonSecondaryFill, @@ -360,166 +358,163 @@ class _HomeTimetableScreen extends FirkaState ), ), */ - GestureDetector( - child: Card( - color: appStyle.colors.buttonSecondaryFill, - child: Padding( - padding: const EdgeInsets.all(8), - child: FirkaIconWidget( - FirkaIconType.majesticons, - Majesticon.settingsCogSolid, - size: 26.0, - color: appStyle.colors.accent, - ), - ), - ), - onTap: () { - showSettingsSheet( - context, - MediaQuery.of(context).size.height * 0.4, - widget.data, - widget.data.settings - .group("settings") - .subGroup("timetable_toast")); - }, - ) - ], - ), - ], - ), - SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ GestureDetector( - behavior: HitTestBehavior.translucent, - child: SizedBox( - width: 24, - height: 24, - child: FirkaIconWidget( - FirkaIconType.icons, - "dropdownLeft", - size: 24, - color: appStyle.colors.accent, + child: Card( + color: appStyle.colors.buttonSecondaryFill, + child: Padding( + padding: const EdgeInsets.all(8), + child: FirkaIconWidget( + FirkaIconType.majesticons, + Majesticon.settingsCogSolid, + size: 26.0, + color: appStyle.colors.accent, + ), ), ), - onTap: () async { - var newNow = now!.subtract(Duration(days: 7)); - if (!mounted) return; - setState(() { - now = newNow; - lessons = null; - dates = null; - }); - await initForWeek(newNow); - setState(() { - now = newNow; - }); - }, - ), - GestureDetector( - child: Row( - children: [ - Text( - now!.format(widget.data.l10n, - FormatMode.yyyymmddwedd), - style: appStyle.fonts.B_14R.apply( - color: appStyle.colors.textPrimary)), - SizedBox(width: 4), - Text("•", - style: appStyle.fonts.B_16R - .apply(color: appStyle.colors.accent)), - SizedBox(width: 4), - Text( - now!.isAWeek() - ? widget.data.l10n.a_week - : widget.data.l10n.b_week, - style: appStyle.fonts.B_14R.apply( - color: appStyle.colors.textPrimary)), - ], - ), onTap: () { - now = timeNow(); - setActiveToToday(); - _controller.jumpToPage(active); + showSettingsSheet( + context, + MediaQuery.of(context).size.height * 0.4, + widget.data, + widget.data.settings + .group("settings") + .subGroup("timetable_toast")); }, - ), - GestureDetector( - child: FirkaIconWidget( - FirkaIconType.icons, - "dropdownRight", - size: 24, - color: appStyle.colors.accent, - ), - onTap: () async { - var newNow = now!.add(Duration(days: 7)); - now = newNow; - if (now!.getMonday().getMidnight() == - timeNow().getMonday().getMidnight()) { - now = timeNow(); - } - await initForWeek(newNow); - if (!mounted) return; - setState(() { - now = newNow; - }); - }, - ), + ) ], - ) - ], - ), - ), - ), - Column( - children: [ - TransparentPointer( - child: SizedBox( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height / 1.4, - child: CarouselSlider( - items: ttDays, - carouselController: _controller, - options: CarouselOptions( - height: MediaQuery.of(context).size.height / 1.36, - viewportFraction: 1, - enableInfiniteScroll: false, - initialPage: active, - onPageChanged: (i, _) { - if (animating || !mounted) return; - setState(() { - active = i; - }); - }), - ))), - Stack( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: ttEmptyCards, ), - TransparentPointer( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: ttWidgets, - )), ], ), + SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + behavior: HitTestBehavior.translucent, + child: SizedBox( + width: 24, + height: 24, + child: FirkaIconWidget( + FirkaIconType.icons, + "dropdownLeft", + size: 24, + color: appStyle.colors.accent, + ), + ), + onTap: () async { + var newNow = now!.subtract(Duration(days: 7)); + if (!mounted) return; + setState(() { + now = newNow; + lessons = null; + dates = null; + }); + await initForWeek(newNow); + setState(() { + now = newNow; + }); + }, + ), + GestureDetector( + child: Row( + children: [ + Text( + now!.format( + widget.data.l10n, FormatMode.yyyymmddwedd), + style: appStyle.fonts.B_14R + .apply(color: appStyle.colors.textPrimary)), + SizedBox(width: 4), + Text("•", + style: appStyle.fonts.B_16R + .apply(color: appStyle.colors.accent)), + SizedBox(width: 4), + Text( + now!.isAWeek() + ? widget.data.l10n.a_week + : widget.data.l10n.b_week, + style: appStyle.fonts.B_14R + .apply(color: appStyle.colors.textPrimary)), + ], + ), + onTap: () { + now = timeNow(); + setActiveToToday(); + _controller.jumpToPage(active); + }, + ), + GestureDetector( + child: FirkaIconWidget( + FirkaIconType.icons, + "dropdownRight", + size: 24, + color: appStyle.colors.accent, + ), + onTap: () async { + var newNow = now!.add(Duration(days: 7)); + now = newNow; + if (now!.getMonday().getMidnight() == + timeNow().getMonday().getMidnight()) { + now = timeNow(); + } + await initForWeek(newNow); + if (!mounted) return; + setState(() { + now = newNow; + }); + }, + ), + ], + ) ], - ) - ])); - } else { - return Scaffold( - backgroundColor: appStyle.colors.background, - body: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [DelayedSpinnerWidget()], - ) - ], + ), + ), ), + Column( + children: [ + TransparentPointer( + child: SizedBox( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height / 1.4, + child: CarouselSlider( + items: ttDays, + carouselController: _controller, + options: CarouselOptions( + height: MediaQuery.of(context).size.height / 1.36, + viewportFraction: 1, + enableInfiniteScroll: false, + initialPage: active, + onPageChanged: (i, _) { + if (animating || !mounted) return; + setState(() { + active = i; + }); + }), + ))), + Stack( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: ttEmptyCards, + ), + TransparentPointer( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: ttWidgets, + )), + ], + ), + ], + ) + ]); + } else { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [DelayedSpinnerWidget()], + ) + ], ); } }