From e071fc15d117691b75b05066e54f72ae9f91566b Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Sat, 28 Feb 2026 11:10:01 +0100 Subject: [PATCH] firka: stream home items in progressively, keep spinner until all fetch --- firka/lib/app/initialization_screen.dart | 4 ++- .../ui/components/common_bottom_sheets.dart | 3 ++- firka/lib/ui/components/firka_card.dart | 8 ++---- firka/lib/ui/phone/pages/home/home_main.dart | 25 ++++++++----------- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/firka/lib/app/initialization_screen.dart b/firka/lib/app/initialization_screen.dart index 6dcb9c8..038ea37 100644 --- a/firka/lib/app/initialization_screen.dart +++ b/firka/lib/app/initialization_screen.dart @@ -115,7 +115,9 @@ class _InitializationScreenState extends State { providers: [ BlocProvider.value(value: themeCubit), BlocProvider.value(value: settingsCubit), - BlocProvider.value(value: profilePictureCubit), + BlocProvider.value( + value: profilePictureCubit, + ), BlocProvider.value(value: reauthCubit), BlocProvider.value(value: homeRefreshCubit), ], diff --git a/firka/lib/ui/components/common_bottom_sheets.dart b/firka/lib/ui/components/common_bottom_sheets.dart index ac6f756..b0117a4 100644 --- a/firka/lib/ui/components/common_bottom_sheets.dart +++ b/firka/lib/ui/components/common_bottom_sheets.dart @@ -861,7 +861,8 @@ Future showHomeworkBottomSheet( shadow: true, child: Card( color: appStyle.colors.card, - shadowColor: context.watch().state.isLightMode + shadowColor: + context.watch().state.isLightMode ? null : Colors.transparent, child: Align( diff --git a/firka/lib/ui/components/firka_card.dart b/firka/lib/ui/components/firka_card.dart index e72370f..02ba429 100644 --- a/firka/lib/ui/components/firka_card.dart +++ b/firka/lib/ui/components/firka_card.dart @@ -46,9 +46,7 @@ class FirkaCard extends StatelessWidget { shadow: shadow, child: Card( color: color ?? appStyle.colors.card, - shadowColor: isLight && shadow - ? null - : Colors.transparent, + shadowColor: isLight && shadow ? null : Colors.transparent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular( @@ -96,9 +94,7 @@ class FirkaCard extends StatelessWidget { shadow: shadow, child: Card( color: color ?? appStyle.colors.card, - shadowColor: isLight && shadow - ? null - : Colors.transparent, + shadowColor: isLight && shadow ? null : Colors.transparent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular( diff --git a/firka/lib/ui/phone/pages/home/home_main.dart b/firka/lib/ui/phone/pages/home/home_main.dart index 988656a..44ff104 100644 --- a/firka/lib/ui/phone/pages/home/home_main.dart +++ b/firka/lib/ui/phone/pages/home/home_main.dart @@ -217,16 +217,13 @@ class _HomeMainScreen extends FirkaState { Widget? nextTest; bool lessonActive = false; - if (lessons != null && noticeBoard != null && lessons!.isNotEmpty) { + if (lessons != null && lessons!.isNotEmpty) { if (now.isBefore(lessons!.first.start)) { welcomeWidget = StartingSoonWidget(widget.data.l10n, now, lessons!); } else { var currentLesson = lessons!.firstWhereOrNull( (lesson) => now.isAfter(lesson.start) && now.isBefore(lesson.end), ); - // "fun" fact if your clock was exactly when the class ends then isBefore - // and isAfter would fail, so to work around that we just add 1ms to the - // current time var prevLesson = lessons!.getPrevLesson(now); var nextLesson = lessons!.getNextLesson(now); int? lessonIndex; @@ -244,7 +241,7 @@ class _HomeMainScreen extends FirkaState { prevLesson, nextLesson, lessons!, - tests!, + tests ?? [], ); } } @@ -307,15 +304,13 @@ class _HomeMainScreen extends FirkaState { } } - if (student != null && - grades != null && - noticeBoard != null && - lessons != null && - homework != null && - tests != null) { - List<(Widget, DateTime)> noticeBoardWidgets = List.empty(growable: true); + if (student != null && lessons != null) { + final infoItems = infoBoard ?? []; + final gradeItems = grades ?? []; + final homeworkItems = homework ?? []; + final noticeBoardWidgets = <(Widget, DateTime)>[]; - for (final item in infoBoard!) { + for (final item in infoItems) { noticeBoardWidgets.add(( GestureDetector( child: InfoBoardItemWidget(item), @@ -327,7 +322,7 @@ class _HomeMainScreen extends FirkaState { )); } - for (final grade in grades!) { + for (final grade in gradeItems) { noticeBoardWidgets.add(( GestureDetector( child: FirkaCard( @@ -374,7 +369,7 @@ class _HomeMainScreen extends FirkaState { )); } - for (final entry in homework!) { + for (final entry in homeworkItems) { noticeBoardWidgets.add(( HomeworkWidget(widget.data, entry), entry.creationDate,