diff --git a/firka/lib/helpers/ui/common_bottom_sheets.dart b/firka/lib/helpers/ui/common_bottom_sheets.dart index e1f040f5..f4750ad6 100644 --- a/firka/lib/helpers/ui/common_bottom_sheets.dart +++ b/firka/lib/helpers/ui/common_bottom_sheets.dart @@ -1,3 +1,6 @@ +import 'package:firka/helpers/api/model/generic.dart'; +import 'package:firka/helpers/api/model/grade.dart'; +import 'package:firka/helpers/debug_helper.dart'; import 'package:firka/helpers/extensions.dart'; import 'package:firka/helpers/settings/setting.dart'; import 'package:flutter/material.dart'; @@ -5,9 +8,11 @@ import 'package:flutter_svg/svg.dart'; import '../../main.dart'; import '../../ui/model/style.dart'; +import '../../ui/phone/widgets/lesson.dart'; import '../../ui/widget/class_icon.dart'; import '../api/model/timetable.dart'; import 'firka_card.dart'; +import 'grade.dart'; Future showLessonBottomSheet( BuildContext context, @@ -165,3 +170,111 @@ Future showLessonBottomSheet( }, ); } + +Future showGradeBottomSheet( + BuildContext context, AppInitialization data, Grade grade) async { + // grade.recordDate + showModalBottomSheet( + context: context, + elevation: 100, + isScrollControlled: true, + enableDrag: true, + backgroundColor: Colors.transparent, + barrierColor: appStyle.colors.a15p, + constraints: BoxConstraints( + maxHeight: MediaQuery.of(context).size.height * 0.32, + ), + builder: (BuildContext context) { + return Stack( + children: [ + Positioned.fill( + child: GestureDetector( + onTap: () => Navigator.pop(context), + behavior: HitTestBehavior.opaque, + child: Container(color: Colors.transparent), + ), + ), + Align( + alignment: Alignment.bottomCenter, + child: Container( + decoration: BoxDecoration( + color: appStyle.colors.background, + borderRadius: BorderRadius.vertical(top: Radius.circular(16)), + ), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [GradeWidget(grade)], + ), + SizedBox(height: 4), + Padding( + padding: const EdgeInsets.only(left: 6), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(grade.topic ?? grade.type.description!, + style: appStyle.fonts.H_18px + .apply(color: appStyle.colors.textPrimary)), + grade.mode?.description != null + ? SizedBox( + width: + MediaQuery.of(context).size.width / 1.45, + child: Text( + grade.mode!.description!, + style: appStyle.fonts.B_14R.apply( + color: appStyle.colors.textSecondary), + ), + ) + : SizedBox(), + SizedBox( + height: 20, + ), + LessonWidget( + data, + [], + -1, + Lesson( + uid: "-1", + date: "", + start: grade.creationDate, + end: grade.creationDate, + name: grade.subject.name, + type: NameUidDesc( + uid: "", name: "", description: ""), + state: NameUidDesc( + uid: "", name: "", description: ""), + canStudentEditHomework: false, + isHomeworkComplete: false, + attachments: [], + isDigitalLesson: false, + digitalSupportDeviceTypeList: [], + createdAt: timeNow(), + subject: grade.subject, + lastModifiedAt: timeNow()), + null, + null, + placeholderMode: true, + ), + FirkaCard(left: [ + Text( + "${data.l10n.tt_added}${grade.creationDate}", + style: appStyle.fonts.B_14R + .apply(color: appStyle.colors.textPrimary), + ) + ]) + ], + ), + ), + ], + ), + ), + ), + ), + ], + ); + }, + ); +} diff --git a/firka/lib/l10n b/firka/lib/l10n index 5329e7ef..c47608d5 160000 --- a/firka/lib/l10n +++ b/firka/lib/l10n @@ -1 +1 @@ -Subproject commit 5329e7efd298f5cbae203f08f254c9f481e53c38 +Subproject commit c47608d59e884c52d66a5c7f25fd915f04b7bc14 diff --git a/firka/lib/ui/phone/pages/home/home_grades_subject.dart b/firka/lib/ui/phone/pages/home/home_grades_subject.dart index c8091e92..6f6db7fb 100644 --- a/firka/lib/ui/phone/pages/home/home_grades_subject.dart +++ b/firka/lib/ui/phone/pages/home/home_grades_subject.dart @@ -1,5 +1,6 @@ import 'package:firka/helpers/api/model/grade.dart'; import 'package:firka/helpers/extensions.dart'; +import 'package:firka/helpers/ui/common_bottom_sheets.dart'; import 'package:firka/helpers/ui/firka_card.dart'; import 'package:firka/helpers/ui/grade.dart'; import 'package:firka/ui/phone/pages/home/home_grades.dart'; @@ -89,36 +90,41 @@ class _HomeGradesSubjectScreen extends FirkaState { height: 8, )); for (var grade in group.value) { - gradeWidgets.add(FirkaCard( - left: [ - Row( - children: [ - GradeWidget(grade), - SizedBox(width: 8), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width / 1.45, - child: Text(grade.topic ?? grade.type.description!, - style: appStyle.fonts.B_14SB - .apply(color: appStyle.colors.textPrimary)), - ), - grade.mode?.description != null - ? SizedBox( - width: MediaQuery.of(context).size.width / 1.45, - child: Text( - grade.mode!.description!, - style: appStyle.fonts.B_14R.apply( - color: appStyle.colors.textSecondary), - ), - ) - : SizedBox(), - ], - ) - ], - ) - ], + gradeWidgets.add(GestureDetector( + child: FirkaCard( + left: [ + Row( + children: [ + GradeWidget(grade), + SizedBox(width: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width / 1.45, + child: Text(grade.topic ?? grade.type.description!, + style: appStyle.fonts.B_14SB + .apply(color: appStyle.colors.textPrimary)), + ), + grade.mode?.description != null + ? SizedBox( + width: MediaQuery.of(context).size.width / 1.45, + child: Text( + grade.mode!.description!, + style: appStyle.fonts.B_14R.apply( + color: appStyle.colors.textSecondary), + ), + ) + : SizedBox(), + ], + ) + ], + ) + ], + ), + onTap: () { + showGradeBottomSheet(context, widget.data, grade); + }, )); } } diff --git a/firka/lib/ui/phone/pages/home/home_main.dart b/firka/lib/ui/phone/pages/home/home_main.dart index 85c6880c..11ef765b 100644 --- a/firka/lib/ui/phone/pages/home/home_main.dart +++ b/firka/lib/ui/phone/pages/home/home_main.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:firka/helpers/api/model/grade.dart'; import 'package:firka/helpers/extensions.dart'; +import 'package:firka/helpers/ui/common_bottom_sheets.dart'; import 'package:firka/ui/phone/widgets/home_main_starting_soon.dart'; import 'package:firka/ui/phone/widgets/info_board_item.dart'; import 'package:firka/ui/phone/widgets/lesson_small.dart'; @@ -225,36 +226,41 @@ class _HomeMainScreen extends FirkaState { for (final grade in grades!) { noticeBoardWidgets.add(( - FirkaCard( - left: [ - Row( - children: [ - GradeWidget(grade), - SizedBox(width: 8), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width / 1.45, - child: Text(grade.topic ?? grade.type.description!, - style: appStyle.fonts.B_14SB - .apply(color: appStyle.colors.textPrimary)), - ), - grade.mode?.description != null - ? SizedBox( - width: MediaQuery.of(context).size.width / 1.45, - child: Text( - grade.mode!.description!, - style: appStyle.fonts.B_14R.apply( - color: appStyle.colors.textSecondary), - ), - ) - : SizedBox(), - ], - ) - ], - ) - ], + GestureDetector( + child: FirkaCard( + left: [ + Row( + children: [ + GradeWidget(grade), + SizedBox(width: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width / 1.45, + child: Text(grade.topic ?? grade.type.description!, + style: appStyle.fonts.B_14SB + .apply(color: appStyle.colors.textPrimary)), + ), + grade.mode?.description != null + ? SizedBox( + width: MediaQuery.of(context).size.width / 1.45, + child: Text( + grade.mode!.description!, + style: appStyle.fonts.B_14R.apply( + color: appStyle.colors.textSecondary), + ), + ) + : SizedBox(), + ], + ) + ], + ) + ], + ), + onTap: () { + showGradeBottomSheet(context, widget.data, grade); + }, ), grade.recordDate )); diff --git a/firka/lib/ui/phone/widgets/lesson.dart b/firka/lib/ui/phone/widgets/lesson.dart index 83806757..d0b4f951 100644 --- a/firka/lib/ui/phone/widgets/lesson.dart +++ b/firka/lib/ui/phone/widgets/lesson.dart @@ -22,10 +22,11 @@ class LessonWidget extends StatelessWidget { final Lesson lesson; final Test? test; final Lesson? nextLesson; + final bool? placeholderMode; const LessonWidget(this.data, this.week, this.lessonNo, this.lesson, this.test, this.nextLesson, - {super.key}); + {super.key, this.placeholderMode}); @override Widget build(BuildContext context) { @@ -69,25 +70,28 @@ class LessonWidget extends StatelessWidget { : appStyle.colors.card, shadow: !isDismissed, left: [ - SizedBox( - width: 18, - height: 18, - child: Stack( - children: [ - SvgPicture.asset( - "assets/icons/subtract.svg", - color: bgColor, + placeholderMode == true + ? SizedBox() + : SizedBox( width: 18, height: 18, + child: Stack( + children: [ + SvgPicture.asset( + "assets/icons/subtract.svg", + color: bgColor, + width: 18, + height: 18, + ), + Padding( + padding: EdgeInsets.only(left: 5), + child: Text(lessonNo.toString(), + style: + appStyle.fonts.B_12R.apply(color: secondary)), + ) + ], + ), ), - Padding( - padding: EdgeInsets.only(left: 5), - child: Text(lessonNo.toString(), - style: appStyle.fonts.B_12R.apply(color: secondary)), - ) - ], - ), - ), Transform.translate( offset: Offset(-4, 0), child: Card( @@ -121,24 +125,30 @@ class LessonWidget extends StatelessWidget { .apply(color: appStyle.colors.textPrimary)), ], right: [ - Text( - isDismissed - ? data.l10n.class_dismissed - : lesson.start.toLocal().format(data.l10n, FormatMode.hmm), - style: appStyle.fonts.B_14R - .apply(color: appStyle.colors.textPrimary)), - isDismissed + placeholderMode == true ? 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)), - ), - ), + : Text( + isDismissed + ? data.l10n.class_dismissed + : lesson.start + .toLocal() + .format(data.l10n, FormatMode.hmm), + style: appStyle.fonts.B_14R + .apply(color: appStyle.colors.textPrimary)), + placeholderMode == true + ? SizedBox() + : 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)), + ), + ), ], ), ));