forked from firka/firka
firka: stream home items in progressively, keep spinner until all fetch
This commit is contained in:
@@ -115,7 +115,9 @@ class _InitializationScreenState extends State<InitializationScreen> {
|
|||||||
providers: [
|
providers: [
|
||||||
BlocProvider<ThemeCubit>.value(value: themeCubit),
|
BlocProvider<ThemeCubit>.value(value: themeCubit),
|
||||||
BlocProvider<SettingsCubit>.value(value: settingsCubit),
|
BlocProvider<SettingsCubit>.value(value: settingsCubit),
|
||||||
BlocProvider<ProfilePictureCubit>.value(value: profilePictureCubit),
|
BlocProvider<ProfilePictureCubit>.value(
|
||||||
|
value: profilePictureCubit,
|
||||||
|
),
|
||||||
BlocProvider<ReauthCubit>.value(value: reauthCubit),
|
BlocProvider<ReauthCubit>.value(value: reauthCubit),
|
||||||
BlocProvider<HomeRefreshCubit>.value(value: homeRefreshCubit),
|
BlocProvider<HomeRefreshCubit>.value(value: homeRefreshCubit),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -861,7 +861,8 @@ Future<void> showHomeworkBottomSheet(
|
|||||||
shadow: true,
|
shadow: true,
|
||||||
child: Card(
|
child: Card(
|
||||||
color: appStyle.colors.card,
|
color: appStyle.colors.card,
|
||||||
shadowColor: context.watch<ThemeCubit>().state.isLightMode
|
shadowColor:
|
||||||
|
context.watch<ThemeCubit>().state.isLightMode
|
||||||
? null
|
? null
|
||||||
: Colors.transparent,
|
: Colors.transparent,
|
||||||
child: Align(
|
child: Align(
|
||||||
|
|||||||
@@ -46,9 +46,7 @@ class FirkaCard extends StatelessWidget {
|
|||||||
shadow: shadow,
|
shadow: shadow,
|
||||||
child: Card(
|
child: Card(
|
||||||
color: color ?? appStyle.colors.card,
|
color: color ?? appStyle.colors.card,
|
||||||
shadowColor: isLight && shadow
|
shadowColor: isLight && shadow ? null : Colors.transparent,
|
||||||
? null
|
|
||||||
: Colors.transparent,
|
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topLeft: Radius.circular(
|
topLeft: Radius.circular(
|
||||||
@@ -96,9 +94,7 @@ class FirkaCard extends StatelessWidget {
|
|||||||
shadow: shadow,
|
shadow: shadow,
|
||||||
child: Card(
|
child: Card(
|
||||||
color: color ?? appStyle.colors.card,
|
color: color ?? appStyle.colors.card,
|
||||||
shadowColor: isLight && shadow
|
shadowColor: isLight && shadow ? null : Colors.transparent,
|
||||||
? null
|
|
||||||
: Colors.transparent,
|
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topLeft: Radius.circular(
|
topLeft: Radius.circular(
|
||||||
|
|||||||
@@ -217,16 +217,13 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
Widget? nextTest;
|
Widget? nextTest;
|
||||||
bool lessonActive = false;
|
bool lessonActive = false;
|
||||||
|
|
||||||
if (lessons != null && noticeBoard != null && lessons!.isNotEmpty) {
|
if (lessons != null && lessons!.isNotEmpty) {
|
||||||
if (now.isBefore(lessons!.first.start)) {
|
if (now.isBefore(lessons!.first.start)) {
|
||||||
welcomeWidget = StartingSoonWidget(widget.data.l10n, now, lessons!);
|
welcomeWidget = StartingSoonWidget(widget.data.l10n, now, lessons!);
|
||||||
} else {
|
} else {
|
||||||
var currentLesson = lessons!.firstWhereOrNull(
|
var currentLesson = lessons!.firstWhereOrNull(
|
||||||
(lesson) => now.isAfter(lesson.start) && now.isBefore(lesson.end),
|
(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 prevLesson = lessons!.getPrevLesson(now);
|
||||||
var nextLesson = lessons!.getNextLesson(now);
|
var nextLesson = lessons!.getNextLesson(now);
|
||||||
int? lessonIndex;
|
int? lessonIndex;
|
||||||
@@ -244,7 +241,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
prevLesson,
|
prevLesson,
|
||||||
nextLesson,
|
nextLesson,
|
||||||
lessons!,
|
lessons!,
|
||||||
tests!,
|
tests ?? [],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,15 +304,13 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (student != null &&
|
if (student != null && lessons != null) {
|
||||||
grades != null &&
|
final infoItems = infoBoard ?? [];
|
||||||
noticeBoard != null &&
|
final gradeItems = grades ?? [];
|
||||||
lessons != null &&
|
final homeworkItems = homework ?? [];
|
||||||
homework != null &&
|
final noticeBoardWidgets = <(Widget, DateTime)>[];
|
||||||
tests != null) {
|
|
||||||
List<(Widget, DateTime)> noticeBoardWidgets = List.empty(growable: true);
|
|
||||||
|
|
||||||
for (final item in infoBoard!) {
|
for (final item in infoItems) {
|
||||||
noticeBoardWidgets.add((
|
noticeBoardWidgets.add((
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: InfoBoardItemWidget(item),
|
child: InfoBoardItemWidget(item),
|
||||||
@@ -327,7 +322,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final grade in grades!) {
|
for (final grade in gradeItems) {
|
||||||
noticeBoardWidgets.add((
|
noticeBoardWidgets.add((
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: FirkaCard(
|
child: FirkaCard(
|
||||||
@@ -374,7 +369,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final entry in homework!) {
|
for (final entry in homeworkItems) {
|
||||||
noticeBoardWidgets.add((
|
noticeBoardWidgets.add((
|
||||||
HomeworkWidget(widget.data, entry),
|
HomeworkWidget(widget.data, entry),
|
||||||
entry.creationDate,
|
entry.creationDate,
|
||||||
|
|||||||
Reference in New Issue
Block a user