forked from firka/firka
fix: event card on timetable
This commit is contained in:
@@ -33,10 +33,8 @@ class TimeTableDayWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget ttBody;
|
||||
|
||||
if (lessons.isEmpty) {
|
||||
ttBody = Column(
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
@@ -71,95 +69,93 @@ class TimeTableDayWidget extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
List<Widget> ttLessons = List.empty(growable: true);
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
var event = events[i];
|
||||
ttLessons.add(
|
||||
FirkaCard.single(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text(
|
||||
event.name,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
}
|
||||
|
||||
List<Widget> ttLessons = List.empty(growable: true);
|
||||
for (final event in events) {
|
||||
ttLessons.add(
|
||||
FirkaCard.single(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text(
|
||||
event.name,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (events.isNotEmpty) {
|
||||
ttLessons.add(SizedBox());
|
||||
}
|
||||
|
||||
var showBreak = data.settings
|
||||
.group("settings")
|
||||
.subGroup("timetable_toast")
|
||||
.boolean("breaks");
|
||||
|
||||
for (var i = 0; i < lessons.length; i++) {
|
||||
var lesson = lessons[i];
|
||||
var nextLesson = lessons.length > i + 1 ? lessons[i + 1] : null;
|
||||
ttLessons.add(
|
||||
LessonWidget(
|
||||
data,
|
||||
lesson,
|
||||
tests.firstWhereOrNull(
|
||||
(test) => test.lessonNumber == lesson.lessonNumber,
|
||||
),
|
||||
active: timeNow().isBetween(
|
||||
i > 0 ? lessons[i - 1].end : lesson.start,
|
||||
lesson.end,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!showBreak || nextLesson == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var breakMins = nextLesson.start.difference(lesson.end).inMinutes;
|
||||
ttLessons.add(
|
||||
FirkaCard(
|
||||
color: appStyle.colors.cardTranslucent,
|
||||
margin: EdgeInsets.all(0),
|
||||
padding: EdgeInsets.symmetric(vertical: 11, horizontal: 16),
|
||||
shadow: false,
|
||||
left: [
|
||||
Text(
|
||||
initData.l10n.breakTxt,
|
||||
style: appStyle.fonts.B_14SB.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
right: [
|
||||
Text(
|
||||
"$breakMins ${breakMins > 1 ? initData.l10n.starting_min_plural : initData.l10n.starting_min}",
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
ttBody = Padding(
|
||||
padding: const EdgeInsets.only(top: 70 + 16 + 20, left: 20, right: 20),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 16,
|
||||
children: [...ttLessons, SizedBox(height: 55)],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ttBody;
|
||||
if (events.isNotEmpty) {
|
||||
ttLessons.add(SizedBox());
|
||||
}
|
||||
|
||||
var showBreak = data.settings
|
||||
.group("settings")
|
||||
.subGroup("timetable_toast")
|
||||
.boolean("breaks");
|
||||
|
||||
for (var i = 0; i < lessons.length; i++) {
|
||||
var lesson = lessons[i];
|
||||
var nextLesson = lessons.length > i + 1 ? lessons[i + 1] : null;
|
||||
ttLessons.add(
|
||||
LessonWidget(
|
||||
data,
|
||||
lesson,
|
||||
tests.firstWhereOrNull(
|
||||
(test) => test.lessonNumber == lesson.lessonNumber,
|
||||
),
|
||||
active: timeNow().isBetween(
|
||||
i > 0 ? lessons[i - 1].end : lesson.start,
|
||||
lesson.end,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!showBreak || nextLesson == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var breakMins = nextLesson.start.difference(lesson.end).inMinutes;
|
||||
ttLessons.add(
|
||||
FirkaCard(
|
||||
color: appStyle.colors.cardTranslucent,
|
||||
margin: EdgeInsets.all(0),
|
||||
padding: EdgeInsets.symmetric(vertical: 11, horizontal: 16),
|
||||
shadow: false,
|
||||
left: [
|
||||
Text(
|
||||
initData.l10n.breakTxt,
|
||||
style: appStyle.fonts.B_14SB.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
right: [
|
||||
Text(
|
||||
"$breakMins ${breakMins > 1 ? initData.l10n.starting_min_plural : initData.l10n.starting_min}",
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 70 + 16 + 20, left: 20, right: 20),
|
||||
child: ListView.separated(
|
||||
separatorBuilder: (context, index) => SizedBox(height: 16),
|
||||
itemBuilder: (context, index) {
|
||||
if (ttLessons.length == index) {
|
||||
return SizedBox(height: 55);
|
||||
}
|
||||
return ttLessons[index];
|
||||
},
|
||||
itemCount: ttLessons.length + 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user