forked from firka/firka
impl lesson/small widget
This commit is contained in:
@@ -24,7 +24,7 @@ extension DurationExtension on Duration {
|
||||
}
|
||||
}
|
||||
|
||||
enum FormatMode { yearly, grades, welcome }
|
||||
enum FormatMode { yearly, grades, welcome, hmm }
|
||||
|
||||
enum Cycle { morning, day, afternoon, night }
|
||||
|
||||
@@ -60,6 +60,8 @@ extension DateExtension on DateTime {
|
||||
return format(context, FormatMode.yearly);
|
||||
case FormatMode.yearly:
|
||||
return DateFormat('MMMM dd').format(this);
|
||||
case FormatMode.hmm:
|
||||
return DateFormat('h:mm').format(this);
|
||||
case FormatMode.welcome:
|
||||
return DateFormat('EEE, MMM d').format(this);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/ui/phone/widgets/home_main_starting_soon.dart';
|
||||
import 'package:firka/ui/phone/widgets/lesson_small.dart';
|
||||
import 'package:firka/ui/widget/delayed_spinner.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -69,11 +70,18 @@ class _HomeMainScreen extends State<HomeMainScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget startingSoon = SizedBox();
|
||||
Widget nextClass = SizedBox();
|
||||
|
||||
if (lessons != null &&
|
||||
lessons!.isNotEmpty &&
|
||||
now.isBefore(lessons!.first.start)) {
|
||||
startingSoon = StartingSoonWidget(now, lessons!);
|
||||
}
|
||||
if (lessons != null && lessons!.isNotEmpty) {
|
||||
var nextLessons = lessons!.where((lesson) => lesson.start.isAfter(now));
|
||||
if (nextLessons.isNotEmpty) nextClass = LessonSmallWidget(nextLessons.first);
|
||||
}
|
||||
|
||||
if (student != null && lessons != null) {
|
||||
return Flexible(
|
||||
child: Padding(
|
||||
@@ -88,6 +96,7 @@ class _HomeMainScreen extends State<HomeMainScreen> {
|
||||
WelcomeWidget(now, student!, lessons!),
|
||||
SizedBox(height: 48),
|
||||
startingSoon,
|
||||
nextClass
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
46
firka/lib/ui/phone/widgets/lesson_small.dart
Normal file
46
firka/lib/ui/phone/widgets/lesson_small.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:firka/helpers/extensions.dart';
|
||||
import 'package:firka/helpers/ui/firka_card.dart';
|
||||
import 'package:firka/ui/model/style.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../helpers/api/model/timetable.dart';
|
||||
import '../../widget/class_icon_widget.dart';
|
||||
|
||||
class LessonSmallWidget extends StatelessWidget {
|
||||
final Lesson lesson;
|
||||
|
||||
const LessonSmallWidget(this.lesson, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
FirkaCard(
|
||||
left: [
|
||||
ClassIconWidget(
|
||||
color: wearStyle.colors.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: [
|
||||
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)),
|
||||
),
|
||||
),
|
||||
Text("${lesson.start.toLocal().format(context, FormatMode.hmm)} - ${lesson.end.toLocal().format(context, FormatMode.hmm)}", style: appStyle.fonts.B_14R.apply(color: appStyle.colors.textPrimary)),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user