From 0b96cd9080ffba3bc2793615f8ae45dbe2efd68c Mon Sep 17 00:00:00 2001 From: Kima Date: Fri, 3 May 2024 17:08:03 +0200 Subject: [PATCH 1/2] things things --- refilc/lib/ui/widgets/lesson/lesson_tile.dart | 4 +-- .../lib/pages/absences/absences_page.dart | 34 +++++++++++-------- .../lib/pages/home/live_card/live_card.dart | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/refilc/lib/ui/widgets/lesson/lesson_tile.dart b/refilc/lib/ui/widgets/lesson/lesson_tile.dart index 5dbbdaf..f2041da 100644 --- a/refilc/lib/ui/widgets/lesson/lesson_tile.dart +++ b/refilc/lib/ui/widgets/lesson/lesson_tile.dart @@ -246,7 +246,7 @@ class LessonTile extends StatelessWidget { ? accent.withOpacity(.15) : Theme.of(context) .colorScheme - .secondary + .tertiary .withOpacity(.15), borderRadius: BorderRadius.circular(10.0), ), @@ -398,7 +398,7 @@ class LessonTile extends StatelessWidget { ? accent.withOpacity(.15) : Theme.of(context) .colorScheme - .secondary + .tertiary .withOpacity(.15), borderRadius: BorderRadius.circular(10.0), ), diff --git a/refilc_mobile_ui/lib/pages/absences/absences_page.dart b/refilc_mobile_ui/lib/pages/absences/absences_page.dart index 6b02ce1..ff339db 100644 --- a/refilc_mobile_ui/lib/pages/absences/absences_page.dart +++ b/refilc_mobile_ui/lib/pages/absences/absences_page.dart @@ -362,6 +362,7 @@ class AbsencesPageState extends State List unexcused = []; List excused = []; + List pending = []; List absencePositions = []; List finalChartColors = []; @@ -375,13 +376,14 @@ class AbsencesPageState extends State .where((e) => e.delay == 0 && e.state == Justification.excused) .toList(); + pending = absenceProvider.absences + .where((e) => + e.delay == 0 && e.state == Justification.pending) + .toList(); value1 = excused.length; value2 = unexcused.length; - value3 = absenceProvider.absences - .where((e) => - e.delay == 0 && e.state == Justification.pending) - .length; + value3 = pending.length; title1 = "stat_1".i18n; title2 = "stat_2".i18n; suffix = " ${"hr".i18n}"; @@ -394,15 +396,15 @@ class AbsencesPageState extends State .where((e) => e.delay != 0 && e.state == Justification.excused) .toList(); + pending = absenceProvider.absences + .where((e) => + e.delay != 0 && e.state == Justification.pending) + .toList(); value1 = excused.map((e) => e.delay).fold(0, (a, b) => a + b); value2 = unexcused.map((e) => e.delay).fold(0, (a, b) => a + b); - value3 = absenceProvider.absences - .where((e) => - e.delay != 0 && e.state == Justification.pending) - .map((e) => e.delay) - .fold(0, (a, b) => a + b); + value3 = pending.map((e) => e.delay).fold(0, (a, b) => a + b); title1 = "stat_3".i18n; title2 = "stat_4".i18n; suffix = " ${"min".i18n}"; @@ -417,7 +419,7 @@ class AbsencesPageState extends State int barTotal = DateTime.now().difference(DateTime(yr, 09, 01)).inDays; - [...unexcused, ...excused].forEachIndexed((i, a) { + [...unexcused, ...excused, ...pending].forEachIndexed((i, a) { int abs = DateTime.now().difference(a.date).inDays; double startPos = (barTotal - abs) / barTotal; @@ -435,11 +437,14 @@ class AbsencesPageState extends State end: endPos, color: a.state == Justification.excused ? Colors.green - : Colors.red, + : a.state == Justification.unexcused + ? Colors.red + : Colors.orange, )); - if ([...unexcused, ...excused].length > i + 1) { + if ([...unexcused, ...excused, ...pending].length > i + 1) { int nextAbs = DateTime.now() - .difference([...unexcused, ...excused][i + 1].date) + .difference( + [...unexcused, ...excused, ...pending][i + 1].date) .inDays; double nextStartPos = (barTotal - nextAbs) / barTotal; @@ -454,7 +459,8 @@ class AbsencesPageState extends State // print(value2.toString() + '-total'); // print(absenceChartData.length.toString() + '-chartdata'); - if ((i + 1 == [...unexcused, ...excused].length) && + if ((i + 1 == + [...unexcused, ...excused, ...pending].length) && endPos < 0.999) { absenceChartData.add(AbsenceChartData( start: endPos, diff --git a/refilc_mobile_ui/lib/pages/home/live_card/live_card.dart b/refilc_mobile_ui/lib/pages/home/live_card/live_card.dart index e693e73..3cf6f4b 100644 --- a/refilc_mobile_ui/lib/pages/home/live_card/live_card.dart +++ b/refilc_mobile_ui/lib/pages/home/live_card/live_card.dart @@ -525,7 +525,7 @@ class LiveCardStateA extends State { decoration: BoxDecoration( color: Theme.of(context) .colorScheme - .secondary + .tertiary .withOpacity(.15), borderRadius: BorderRadius.circular(10.0), From 5f6ad03335b3a755b0381bbde104a49f7ff2dc07 Mon Sep 17 00:00:00 2001 From: Kima Date: Fri, 3 May 2024 17:33:14 +0200 Subject: [PATCH 2/2] some progress in lesson tile popup --- .../widgets/lesson/lesson_viewable.dart | 508 ++++++++++++------ 1 file changed, 357 insertions(+), 151 deletions(-) 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 a30dd2b..1cca668 100644 --- a/refilc_mobile_ui/lib/common/widgets/lesson/lesson_viewable.dart +++ b/refilc_mobile_ui/lib/common/widgets/lesson/lesson_viewable.dart @@ -1,9 +1,15 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; import 'package:refilc/api/providers/database_provider.dart'; import 'package:refilc/api/providers/user_provider.dart'; +import 'package:refilc/helpers/subject.dart'; +import 'package:refilc/theme/colors/colors.dart'; +import 'package:refilc/theme/colors/utils.dart'; import 'package:refilc_kreta_api/models/lesson.dart'; +import 'package:refilc_mobile_ui/common/bottom_sheet_menu/rounded_bottom_sheet.dart'; import 'package:refilc_mobile_ui/common/panel/panel_button.dart'; +import 'package:refilc_mobile_ui/common/round_border_icon.dart'; import 'package:refilc_mobile_ui/common/viewable.dart'; import 'package:refilc_mobile_ui/common/widgets/card_handle.dart'; import 'package:refilc/ui/widgets/lesson/lesson_tile.dart'; @@ -49,158 +55,164 @@ class LessonViewableState extends State { if (lsn.subject.id == '' || tile.lesson.isEmpty) return tile; - return Viewable( - tile: tile, - view: CardHandle(child: LessonView(lsn)), - actions: [ - PanelButton( - background: true, - title: Text( - "edit_lesson".i18n, - textAlign: TextAlign.center, - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - onPressed: () { - Navigator.of(context, rootNavigator: true).pop(); - - if (!Provider.of(context, listen: false) - .hasScope(PremiumScopes.timetableNotes)) { - PlusLockedFeaturePopup.show( - context: context, feature: PremiumFeature.timetableNotes); - - return; - } - - showDialog( - context: context, - builder: (context) => StatefulBuilder(builder: (context, setS) { - return AlertDialog( - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(14.0))), - title: Text("edit_lesson".i18n), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - // description - TextField( - controller: _descTxt, - decoration: InputDecoration( - border: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.grey, width: 1.5), - borderRadius: BorderRadius.circular(12.0), - ), - focusedBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.grey, width: 1.5), - borderRadius: BorderRadius.circular(12.0), - ), - contentPadding: - const EdgeInsets.symmetric(horizontal: 12.0), - hintText: 'l_desc'.i18n, - suffixIcon: IconButton( - icon: const Icon( - FeatherIcons.x, - color: Colors.grey, - size: 18.0, - ), - onPressed: () { - setState(() { - _descTxt.text = ''; - }); - }, - ), - ), - ), - // const SizedBox( - // height: 14.0, - // ), - // // class - // TextField( - // controller: _descTxt, - // onEditingComplete: () async { - // // SharedTheme? theme = await shareProvider.getThemeById( - // // context, - // // id: _paintId.text.replaceAll(' ', ''), - // // ); - - // // if (theme != null) { - // // // set theme variable - // // newThemeByID = theme; - - // // _paintId.clear(); - // // } else { - // // ScaffoldMessenger.of(context).showSnackBar( - // // CustomSnackBar( - // // content: Text("theme_not_found".i18n, - // // style: const TextStyle(color: Colors.white)), - // // backgroundColor: AppColors.of(context).red, - // // context: context, - // // ), - // // ); - // // } - // }, - // decoration: InputDecoration( - // border: OutlineInputBorder( - // borderSide: const BorderSide( - // color: Colors.grey, width: 1.5), - // borderRadius: BorderRadius.circular(12.0), - // ), - // focusedBorder: OutlineInputBorder( - // borderSide: const BorderSide( - // color: Colors.grey, width: 1.5), - // borderRadius: BorderRadius.circular(12.0), - // ), - // contentPadding: - // const EdgeInsets.symmetric(horizontal: 12.0), - // hintText: 'l_desc'.i18n, - // suffixIcon: IconButton( - // icon: const Icon( - // FeatherIcons.x, - // color: Colors.grey, - // size: 18.0, - // ), - // onPressed: () { - // setState(() { - // _descTxt.text = ''; - // }); - // }, - // ), - // ), - // ), - ], - ), - actions: [ - TextButton( - child: Text( - "cancel".i18n, - style: const TextStyle(fontWeight: FontWeight.w500), - ), - onPressed: () { - Navigator.of(context).maybePop(); - }, - ), - TextButton( - child: Text( - "done".i18n, - style: const TextStyle(fontWeight: FontWeight.w500), - ), - onPressed: () async { - saveLesson(); - - Navigator.of(context).pop(); - setState(() {}); - }, - ), - ], - ); - }), - ); - }, - ), - ], + return LessonTile( + lsn, + swapDesc: widget.swapDesc, + onTap: () => TimetableLessonPopup.show(context: context, lesson: lsn), ); + + // return Viewable( + // tile: tile, + // view: CardHandle(child: LessonView(lsn)), + // actions: [ + // PanelButton( + // background: true, + // title: Text( + // "edit_lesson".i18n, + // textAlign: TextAlign.center, + // maxLines: 2, + // overflow: TextOverflow.ellipsis, + // ), + // onPressed: () { + // Navigator.of(context, rootNavigator: true).pop(); + + // if (!Provider.of(context, listen: false) + // .hasScope(PremiumScopes.timetableNotes)) { + // PlusLockedFeaturePopup.show( + // context: context, feature: PremiumFeature.timetableNotes); + + // return; + // } + + // showDialog( + // context: context, + // builder: (context) => StatefulBuilder(builder: (context, setS) { + // return AlertDialog( + // shape: const RoundedRectangleBorder( + // borderRadius: BorderRadius.all(Radius.circular(14.0))), + // title: Text("edit_lesson".i18n), + // content: Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // // description + // TextField( + // controller: _descTxt, + // decoration: InputDecoration( + // border: OutlineInputBorder( + // borderSide: const BorderSide( + // color: Colors.grey, width: 1.5), + // borderRadius: BorderRadius.circular(12.0), + // ), + // focusedBorder: OutlineInputBorder( + // borderSide: const BorderSide( + // color: Colors.grey, width: 1.5), + // borderRadius: BorderRadius.circular(12.0), + // ), + // contentPadding: + // const EdgeInsets.symmetric(horizontal: 12.0), + // hintText: 'l_desc'.i18n, + // suffixIcon: IconButton( + // icon: const Icon( + // FeatherIcons.x, + // color: Colors.grey, + // size: 18.0, + // ), + // onPressed: () { + // setState(() { + // _descTxt.text = ''; + // }); + // }, + // ), + // ), + // ), + // // const SizedBox( + // // height: 14.0, + // // ), + // // // class + // // TextField( + // // controller: _descTxt, + // // onEditingComplete: () async { + // // // SharedTheme? theme = await shareProvider.getThemeById( + // // // context, + // // // id: _paintId.text.replaceAll(' ', ''), + // // // ); + + // // // if (theme != null) { + // // // // set theme variable + // // // newThemeByID = theme; + + // // // _paintId.clear(); + // // // } else { + // // // ScaffoldMessenger.of(context).showSnackBar( + // // // CustomSnackBar( + // // // content: Text("theme_not_found".i18n, + // // // style: const TextStyle(color: Colors.white)), + // // // backgroundColor: AppColors.of(context).red, + // // // context: context, + // // // ), + // // // ); + // // // } + // // }, + // // decoration: InputDecoration( + // // border: OutlineInputBorder( + // // borderSide: const BorderSide( + // // color: Colors.grey, width: 1.5), + // // borderRadius: BorderRadius.circular(12.0), + // // ), + // // focusedBorder: OutlineInputBorder( + // // borderSide: const BorderSide( + // // color: Colors.grey, width: 1.5), + // // borderRadius: BorderRadius.circular(12.0), + // // ), + // // contentPadding: + // // const EdgeInsets.symmetric(horizontal: 12.0), + // // hintText: 'l_desc'.i18n, + // // suffixIcon: IconButton( + // // icon: const Icon( + // // FeatherIcons.x, + // // color: Colors.grey, + // // size: 18.0, + // // ), + // // onPressed: () { + // // setState(() { + // // _descTxt.text = ''; + // // }); + // // }, + // // ), + // // ), + // // ), + // ], + // ), + // actions: [ + // TextButton( + // child: Text( + // "cancel".i18n, + // style: const TextStyle(fontWeight: FontWeight.w500), + // ), + // onPressed: () { + // Navigator.of(context).maybePop(); + // }, + // ), + // TextButton( + // child: Text( + // "done".i18n, + // style: const TextStyle(fontWeight: FontWeight.w500), + // ), + // onPressed: () async { + // saveLesson(); + + // Navigator.of(context).pop(); + // setState(() {}); + // }, + // ), + // ], + // ); + // }), + // ); + // }, + // ), + // ], + // ); } void saveLesson() async { @@ -218,3 +230,197 @@ class LessonViewableState extends State { .storeCustomLessonDescriptions(lessonDesc, userId: user.id!); } } + +class TimetableLessonPopup extends StatelessWidget { + const TimetableLessonPopup({super.key, required this.lesson}); + + final Lesson lesson; + + static void show({ + required BuildContext context, + required Lesson lesson, + }) => + showRoundedModalBottomSheet( + context, + child: TimetableLessonPopup( + lesson: lesson, + ), + showHandle: false, + ); + + // IconData _getIcon() => _featureLevels[feature] == PremiumFeatureLevel.cap + // ? FilcIcons.kupak + // : _featureLevels[feature] == PremiumFeatureLevel.ink + // ? FilcIcons.tinta + // : FilcIcons.tinta; + // Color _getColor(BuildContext context) => + // _featureLevels[feature] == PremiumFeatureLevel.gold + // ? const Color(0xFFC89B08) + // : Theme.of(context).brightness == Brightness.light + // ? const Color(0xff691A9B) + // : const Color(0xffA66FC8); + // String? _getAsset() => _featureAssets[feature]; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Theme.of(context).scaffoldBackgroundColor, + borderRadius: const BorderRadius.vertical( + top: Radius.circular(12.0), + ), + ), + child: Stack( + children: [ + SvgPicture.asset( + "assets/svg/mesh_bg.svg", + // ignore: deprecated_member_use + color: ColorsUtils().fade( + context, Theme.of(context).scaffoldBackgroundColor, + darkenAmount: 0.1, lightenAmount: 0.1), + width: MediaQuery.of(context).size.width, + ), + SizedBox( + width: MediaQuery.of(context).size.width, + child: Padding( + padding: const EdgeInsets.all(18.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 40, + height: 4, + decoration: BoxDecoration( + color: ColorsUtils().fade( + context, Theme.of(context).scaffoldBackgroundColor, + darkenAmount: 0.2, lightenAmount: 0.2), + borderRadius: BorderRadius.circular( + 2.0, + ), + ), + ), + const SizedBox( + height: 38.0, + ), + RoundBorderIcon( + icon: Icon( + SubjectIcon.resolveVariant( + context: context, subject: lesson.subject), + ), + ), + const SizedBox( + height: 55.0, + ), + Container( + width: double.infinity, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.background, + borderRadius: const BorderRadius.vertical( + top: Radius.circular(12.0), + bottom: Radius.circular(6.0), + ), + ), + padding: const EdgeInsets.all(14.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '6:09 - 4:20', + style: TextStyle( + color: AppColors.of(context).text.withOpacity(0.85), + fontSize: 14.0, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox( + height: 12.0, + ), + Text( + lesson.name, + style: TextStyle( + color: AppColors.of(context).text, + fontSize: 20.0, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox( + height: 8.0, + ), + Text( + lesson.teacher.name, + style: TextStyle( + color: AppColors.of(context).text.withOpacity(0.9), + fontSize: 14.0, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + const SizedBox( + height: 6.0, + ), + 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: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + lesson.description, + style: TextStyle( + color: AppColors.of(context).text.withOpacity(0.9), + fontSize: 14.0, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + const SizedBox( + height: 24.0, + ), + GestureDetector( + onTap: () { + Navigator.of(context, rootNavigator: true) + .pushReplacementNamed('/'); + }, + child: Container( + width: double.infinity, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.background, + borderRadius: BorderRadius.circular(12.0), + ), + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + 'view_subject'.i18n, + style: TextStyle( + color: + AppColors.of(context).text.withOpacity(0.9), + fontSize: 18.0, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), + ], + ), + ); + } +}