From e0bf8ac5e5455b72506a4d8e2e8153f7fd2ad20d Mon Sep 17 00:00:00 2001 From: Kima Date: Sun, 12 May 2024 19:23:45 +0200 Subject: [PATCH] fixed exam related popup things --- refilc/lib/ui/widgets/lesson/lesson_tile.dart | 6 +- .../common/widgets/exam/exam_viewable.dart | 3 +- .../widgets/lesson/lesson_viewable.dart | 73 ++++++++++++++++++- 3 files changed, 76 insertions(+), 6 deletions(-) diff --git a/refilc/lib/ui/widgets/lesson/lesson_tile.dart b/refilc/lib/ui/widgets/lesson/lesson_tile.dart index f2041da..c8204e0 100644 --- a/refilc/lib/ui/widgets/lesson/lesson_tile.dart +++ b/refilc/lib/ui/widgets/lesson/lesson_tile.dart @@ -8,7 +8,8 @@ import 'package:refilc_kreta_api/models/lesson.dart'; import 'package:refilc/utils/format.dart'; import 'package:refilc_mobile_ui/common/panel/panel.dart'; import 'package:refilc_mobile_ui/common/round_border_icon.dart'; -import 'package:refilc_mobile_ui/common/widgets/exam/exam_view.dart'; +// import 'package:refilc_mobile_ui/common/widgets/exam/exam_view.dart'; +import 'package:refilc_mobile_ui/common/widgets/exam/exam_viewable.dart'; import 'package:refilc_mobile_ui/common/widgets/homework/homework_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_feather_icons/flutter_feather_icons.dart'; @@ -109,7 +110,8 @@ class LessonTile extends StatelessWidget { title: exam.description != "" ? exam.description : exam.mode?.description ?? "exam".i18n, - onPressed: () => ExamView.show(exam, context: context), + // onPressed: () => ExamView.show(exam, context: context), + onPressed: () => ExamPopup.show(context: context, exam: exam), )); } } diff --git a/refilc_mobile_ui/lib/common/widgets/exam/exam_viewable.dart b/refilc_mobile_ui/lib/common/widgets/exam/exam_viewable.dart index 60a67ab..513c1cc 100644 --- a/refilc_mobile_ui/lib/common/widgets/exam/exam_viewable.dart +++ b/refilc_mobile_ui/lib/common/widgets/exam/exam_viewable.dart @@ -1,6 +1,7 @@ // ignore_for_file: use_build_context_synchronously import 'package:flutter_svg/svg.dart'; +import 'package:i18n_extension/i18n_extension.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:refilc/helpers/subject.dart'; @@ -294,7 +295,7 @@ class ExamPopup extends StatelessWidget { ], ), Text( - '${DateFormat('H:mm').format(lesson!.start)} - ${DateFormat('H:mm').format(lesson!.end)}', + '${DateFormat('EEEE, MMM d, H:mm', I18n.locale.countryCode).format(lesson!.start).capital()} - ${DateFormat('H:mm').format(lesson!.end)}', style: TextStyle( color: AppColors.of(context).text.withOpacity(0.85), diff --git a/refilc_mobile_ui/lib/common/widgets/lesson/lesson_viewable.dart b/refilc_mobile_ui/lib/common/widgets/lesson/lesson_viewable.dart index 507c65e..1b7258b 100644 --- a/refilc_mobile_ui/lib/common/widgets/lesson/lesson_viewable.dart +++ b/refilc_mobile_ui/lib/common/widgets/lesson/lesson_viewable.dart @@ -1,3 +1,4 @@ +import 'package:flutter_feather_icons/flutter_feather_icons.dart'; import 'package:flutter_svg/svg.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; @@ -8,7 +9,9 @@ import 'package:refilc/models/settings.dart'; import 'package:refilc/theme/colors/colors.dart'; import 'package:refilc/theme/colors/utils.dart'; import 'package:refilc/utils/format.dart'; +import 'package:refilc_kreta_api/models/exam.dart'; import 'package:refilc_kreta_api/models/lesson.dart'; +import 'package:refilc_kreta_api/providers/exam_provider.dart'; import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart'; import 'package:refilc_mobile_ui/common/round_border_icon.dart'; import 'package:refilc/ui/widgets/lesson/lesson_tile.dart'; @@ -283,6 +286,18 @@ class TimetableLessonPopup extends StatelessWidget { @override Widget build(BuildContext context) { + Exam? lessonExam; + + if (lesson.exam != "") { + Exam exam = Provider.of(context, listen: false) + .exams + .firstWhere((t) => t.id == lesson.exam, + orElse: () => Exam.fromJson({})); + if (exam.id != "") { + lessonExam = exam; + } + } + return Container( decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, @@ -491,9 +506,11 @@ class TimetableLessonPopup extends StatelessWidget { width: double.infinity, decoration: BoxDecoration( color: Theme.of(context).colorScheme.background, - borderRadius: const BorderRadius.vertical( - top: Radius.circular(6.0), - bottom: Radius.circular(12.0), + borderRadius: BorderRadius.vertical( + top: const Radius.circular(6.0), + bottom: lesson.exam != '' + ? const Radius.circular(6.0) + : const Radius.circular(12.0), ), ), padding: const EdgeInsets.all(14.0), @@ -512,6 +529,56 @@ class TimetableLessonPopup extends StatelessWidget { ], ), ), + if (lesson.exam != '') + const SizedBox( + height: 6.0, + ), + if (lesson.exam != '' && lessonExam != null) + Container( + width: double.infinity, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.background, + borderRadius: const BorderRadius.vertical( + top: Radius.circular(6.0), + bottom: Radius.circular(12.0)), + ), + padding: const EdgeInsets.all(14.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + const Icon( + FeatherIcons.file, + size: 20.0, + ), + const SizedBox( + width: 10.0, + ), + Text( + lessonExam.description.capital(), + style: TextStyle( + color: AppColors.of(context) + .text + .withOpacity(0.9), + fontSize: 16.0, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + Text( + lessonExam.mode?.description ?? 'Dolgozat', + style: TextStyle( + color: + AppColors.of(context).text.withOpacity(0.85), + fontSize: 14.0, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), // const SizedBox( // height: 24.0, // ),