forked from firka/firka
timetable: lesson list
This commit is contained in:
Submodule firka/lib/l10n updated: 5435a1c50a...6e9e2bef55
@@ -4,6 +4,7 @@ import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/l10n/app_localizations.dart';
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:firka/ui/phone/widgets/bottom_tt_icon.dart';
|
||||
import 'package:firka/ui/phone/widgets/lesson.dart';
|
||||
import 'package:firka/ui/widget/delayed_spinner.dart';
|
||||
import 'package:firka/ui/widget/firka_icon.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -27,6 +28,7 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
DateTime? active;
|
||||
_HomeTimetableScreen(this.data);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
@@ -71,6 +73,11 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
if (lessons != null && dates != null && active != null) {
|
||||
List<Widget> ttWidgets = List.empty(growable: true);
|
||||
var lessonsToday = lessons!
|
||||
.where((lesson) =>
|
||||
lesson.start.isAfter(active!) &&
|
||||
lesson.end.isBefore(active!.add(Duration(hours: 24))))
|
||||
.toList();
|
||||
|
||||
for (final date in dates!) {
|
||||
ttWidgets.add(BottomTimeTableNavIconWidget(() {
|
||||
@@ -81,6 +88,28 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
date));
|
||||
}
|
||||
|
||||
Widget noLessonsWidget = SizedBox();
|
||||
List<Widget> ttBody = List.empty(growable: true);
|
||||
|
||||
if (lessonsToday.isEmpty) {
|
||||
noLessonsWidget = Positioned.fill(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset("assets/images/logos/dave.svg",
|
||||
width: 48, height: 48),
|
||||
SizedBox(height: 12),
|
||||
Text(AppLocalizations.of(context)!.tt_no_classes_l1),
|
||||
Text(AppLocalizations.of(context)!.tt_no_classes_l2)
|
||||
]),
|
||||
);
|
||||
} else {
|
||||
for (final lesson in lessonsToday) {
|
||||
ttBody.add(LessonWidget(lessonsToday.getLessonNo(lesson), lesson));
|
||||
}
|
||||
}
|
||||
|
||||
return Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
@@ -144,17 +173,18 @@ class _HomeTimetableScreen extends State<HomeTimetableScreen> {
|
||||
),
|
||||
]),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset("assets/images/logos/dave.svg",
|
||||
width: 48, height: 48),
|
||||
SizedBox(height: 12),
|
||||
Text(AppLocalizations.of(context)!.tt_no_classes_l1),
|
||||
Text(AppLocalizations.of(context)!.tt_no_classes_l2)
|
||||
]),
|
||||
noLessonsWidget,
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height -
|
||||
MediaQuery.of(context).padding.top -
|
||||
230,
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsets.only(top: 70, left: 35, right: 35, bottom: 15),
|
||||
child: ListView(
|
||||
children: ttBody,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
|
||||
106
firka/lib/ui/phone/widgets/lesson.dart
Normal file
106
firka/lib/ui/phone/widgets/lesson.dart
Normal file
@@ -0,0 +1,106 @@
|
||||
import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/helpers/ui/firka_card.dart';
|
||||
import 'package:firka/l10n/app_localizations.dart';
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../helpers/api/model/timetable.dart';
|
||||
import '../../widget/class_icon.dart';
|
||||
|
||||
class LessonWidget extends StatelessWidget {
|
||||
final int? lessonNo;
|
||||
final Lesson lesson;
|
||||
|
||||
const LessonWidget(this.lessonNo, this.lesson, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var isSubstituted = lesson.substituteTeacher != null;
|
||||
var isDismissed = lesson.type.name == "UresOra";
|
||||
|
||||
var accent = appStyle.colors.accent;
|
||||
var secondary = appStyle.colors.secondary;
|
||||
var bgColor = appStyle.colors.a15p;
|
||||
|
||||
if (isSubstituted) {
|
||||
accent = appStyle.colors.warningAccent;
|
||||
secondary = appStyle.colors.warningText;
|
||||
bgColor = appStyle.colors.warning15p;
|
||||
}
|
||||
if (isDismissed) {
|
||||
accent = appStyle.colors.errorAccent;
|
||||
secondary = appStyle.colors.errorText;
|
||||
bgColor = appStyle.colors.error15p;
|
||||
}
|
||||
|
||||
List<Widget> elements = [];
|
||||
|
||||
elements.add(FirkaCard(
|
||||
left: [
|
||||
Card(
|
||||
// TODO: improve this to match design
|
||||
shadowColor: Colors.transparent,
|
||||
color: bgColor,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
child: Text(lessonNo.toString(),
|
||||
style: appStyle.fonts.B_12R.apply(color: secondary)),
|
||||
),
|
||||
),
|
||||
ClassIconWidget(
|
||||
color: accent,
|
||||
size: 20,
|
||||
uid: lesson.uid,
|
||||
className: lesson.name,
|
||||
category: lesson.subject?.name ?? '',
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(lesson.subject?.name ?? "N/A",
|
||||
style: appStyle.fonts.B_16SB
|
||||
.apply(color: appStyle.colors.textPrimary)),
|
||||
],
|
||||
right: [
|
||||
Text(
|
||||
isDismissed
|
||||
? AppLocalizations.of(context)!.class_dismissed
|
||||
: lesson.start.toLocal().format(context, FormatMode.hmm),
|
||||
style:
|
||||
appStyle.fonts.B_14R.apply(color: appStyle.colors.textPrimary)),
|
||||
isDismissed
|
||||
? SizedBox()
|
||||
: Card(
|
||||
shadowColor: Colors.transparent,
|
||||
color: appStyle.colors.a15p,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
child: Text(lesson.roomName ?? '?',
|
||||
style: appStyle.fonts.B_12R
|
||||
.apply(color: appStyle.colors.secondary)),
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
|
||||
if (isSubstituted) {
|
||||
elements.add(FirkaCard(
|
||||
left: [
|
||||
Text(AppLocalizations.of(context)!.class_substitution,
|
||||
style: appStyle.fonts.H_14px
|
||||
.apply(color: appStyle.colors.textPrimary))
|
||||
],
|
||||
right: [
|
||||
Text(lesson.substituteTeacher!,
|
||||
style: appStyle.fonts.B_16R
|
||||
.apply(color: appStyle.colors.textSecondary))
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
elements.add(SizedBox(height: 4));
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: elements,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user