diff --git a/refilc/lib/database/init.dart b/refilc/lib/database/init.dart index 1ab6867..e72bafd 100644 --- a/refilc/lib/database/init.dart +++ b/refilc/lib/database/init.dart @@ -53,6 +53,7 @@ const settingsDB = DatabaseStruct("settings", { "nav_shadow": int, "new_colors": int, "uwu_mode": int, + "new_popups": int, // quick settings "q_timetable_lesson_num": int, "q_timetable_sub_tiles": int, "q_subjects_sub_tiles": int, diff --git a/refilc/lib/models/settings.dart b/refilc/lib/models/settings.dart index d2e5d68..298e704 100644 --- a/refilc/lib/models/settings.dart +++ b/refilc/lib/models/settings.dart @@ -106,6 +106,7 @@ class SettingsProvider extends ChangeNotifier { bool _navShadow; bool _newColors; bool _uwuMode; + bool _newPopups; // quick settings bool _qTimetableLessonNum; bool _qTimetableSubTiles; @@ -178,6 +179,7 @@ class SettingsProvider extends ChangeNotifier { required bool navShadow, required bool newColors, required bool uwuMode, + required bool newPopups, required bool qTimetableLessonNum, required bool qTimetableSubTiles, required bool qSubjectsSubTiles, @@ -247,6 +249,7 @@ class SettingsProvider extends ChangeNotifier { _navShadow = navShadow, _newColors = newColors, _uwuMode = uwuMode, + _newPopups = newPopups, _qTimetableLessonNum = qTimetableLessonNum, _qTimetableSubTiles = qTimetableSubTiles, _qSubjectsSubTiles = qSubjectsSubTiles; @@ -335,6 +338,7 @@ class SettingsProvider extends ChangeNotifier { navShadow: map['nav_shadow'] == 1, newColors: map['new_colors'] == 1, uwuMode: map['uwu_mode'] == 1, + newPopups: map['new_popups'] == 1, qTimetableLessonNum: map['q_timetable_lesson_num'] == 1, qTimetableSubTiles: map['q_timetable_sub_tiles'] == 1, qSubjectsSubTiles: map['q_subjects_sub_tiles'] == 1, @@ -411,6 +415,7 @@ class SettingsProvider extends ChangeNotifier { "nav_shadow": _navShadow ? 1 : 0, "new_colors": _newColors ? 1 : 0, "uwu_mode": _uwuMode ? 1 : 0, + "new_popups": _newPopups ? 1 : 0, "q_timetable_lesson_num": _qTimetableLessonNum ? 1 : 0, "q_timetable_sub_tiles": _qTimetableSubTiles ? 1 : 0, "q_subjects_sub_tiles": _qSubjectsSubTiles ? 1 : 0, @@ -491,6 +496,7 @@ class SettingsProvider extends ChangeNotifier { navShadow: true, newColors: true, uwuMode: false, + newPopups: true, qTimetableLessonNum: true, qTimetableSubTiles: true, qSubjectsSubTiles: true, @@ -562,6 +568,7 @@ class SettingsProvider extends ChangeNotifier { bool get navShadow => _navShadow; bool get newColors => _newColors; bool get uwuMode => _uwuMode; + bool get newPopups => _newPopups; bool get qTimetableLessonNum => _qTimetableLessonNum; bool get qTimetableSubTiles => _qTimetableSubTiles; bool get qSubjectsSubTiles => _qSubjectsSubTiles; @@ -629,6 +636,7 @@ class SettingsProvider extends ChangeNotifier { bool? navShadow, bool? newColors, bool? uwuMode, + bool? newPopups, bool? qTimetableLessonNum, bool? qTimetableSubTiles, bool? qSubjectsSubTiles, @@ -817,6 +825,9 @@ class SettingsProvider extends ChangeNotifier { if (uwuMode != null && uwuMode != _uwuMode) { _uwuMode = uwuMode; } + if (newPopups != null && newPopups != _newPopups) { + _newPopups = newPopups; + } if (qTimetableLessonNum != null && qTimetableLessonNum != _qTimetableLessonNum) { _qTimetableLessonNum = qTimetableLessonNum; diff --git a/refilc_mobile_ui/lib/common/personality_card/personality_card.i18n.dart b/refilc_mobile_ui/lib/common/personality_card/personality_card.i18n.dart index 9c2d2b1..0c5cb28 100644 --- a/refilc_mobile_ui/lib/common/personality_card/personality_card.i18n.dart +++ b/refilc_mobile_ui/lib/common/personality_card/personality_card.i18n.dart @@ -49,6 +49,8 @@ extension Localization on String { "d_npc": "You're such a non-player character, we couldn't give you a personality.", "s_npc": "In-game playtime (hours)", + // other + "year_index": "Lesson Number", }, "hu_hu": { // main @@ -96,6 +98,8 @@ extension Localization on String { "d_npc": "Egy akkora nagy non-player character vagy, hogy neked semmilyen személyiség nem jutott ezen kívül.", "s_npc": "In-game playtime (óra)", + // other + "year_index": "Éves óraszám", }, "de_de": { // main @@ -144,6 +148,8 @@ extension Localization on String { "d_npc": "Du bist einfach so sehr wie ein Computer, dass wir dir nicht einmal eine Persönlichkeit geben konnten.", "s_npc": "Spielzeit (Stunden)", + // other + "year_index": "Ordinalzahl", } }; 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 d7a5ca0..b8b4c33 100644 --- a/refilc_mobile_ui/lib/common/widgets/exam/exam_viewable.dart +++ b/refilc_mobile_ui/lib/common/widgets/exam/exam_viewable.dart @@ -14,8 +14,11 @@ import 'package:refilc_kreta_api/models/exam.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/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_mobile_ui/common/widgets/exam/exam_tile.dart'; import 'package:flutter/material.dart'; +import 'package:refilc_mobile_ui/common/widgets/exam/exam_view.dart'; class ExamViewable extends StatelessWidget { const ExamViewable(this.exam, @@ -27,22 +30,25 @@ class ExamViewable extends StatelessWidget { @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () => ExamPopup.show(context: context, exam: exam), - child: ExamTile( + if (Provider.of(context).newPopups) { + return GestureDetector( + onTap: () => ExamPopup.show(context: context, exam: exam), + child: ExamTile( + exam, + showSubject: showSubject, + padding: tilePadding, + ), + ); + } + + return Viewable( + tile: ExamTile( exam, showSubject: showSubject, padding: tilePadding, ), + view: CardHandle(child: ExamView(exam)), ); - // return Viewable( - // tile: ExamTile( - // exam, - // showSubject: showSubject, - // padding: tilePadding, - // ), - // view: CardHandle(child: ExamView(exam)), - // ); } } @@ -297,7 +303,7 @@ class ExamPopup extends StatelessWidget { ], ), Text( - '${DateFormat('EEEE, MMM d, H:mm', I18n.locale.countryCode).format(lesson!.start).capital()} - ${DateFormat('H:mm').format(lesson!.end)}', + '${DateFormat('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 666cdbc..539af64 100644 --- a/refilc_mobile_ui/lib/common/widgets/lesson/lesson_viewable.dart +++ b/refilc_mobile_ui/lib/common/widgets/lesson/lesson_viewable.dart @@ -13,9 +13,17 @@ 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/panel/panel_button.dart'; +import 'package:refilc_mobile_ui/common/personality_card/personality_card.i18n.dart'; import 'package:refilc_mobile_ui/common/round_border_icon.dart'; import 'package:refilc/ui/widgets/lesson/lesson_tile.dart'; import 'package:flutter/material.dart'; +import 'package:refilc_mobile_ui/common/viewable.dart'; +import 'package:refilc_mobile_ui/common/widgets/card_handle.dart'; +import 'package:refilc_mobile_ui/common/widgets/lesson/lesson_view.dart'; +import 'package:refilc_plus/models/premium_scopes.dart'; +import 'package:refilc_plus/providers/plus_provider.dart'; +import 'package:refilc_plus/ui/mobile/plus/upsell.dart'; class LessonViewable extends StatefulWidget { const LessonViewable( @@ -62,174 +70,169 @@ class LessonViewableState extends State { if (lsn.subject.id == '' || tile.lesson.isEmpty) return tile; - return GestureDetector( - onTap: () => TimetableLessonPopup.show( - context: context, - lesson: lsn, - ), - child: LessonTile( - lsn, - swapDesc: widget.swapDesc, - showSubTiles: widget.showSubTiles, - // onTap: () => TimetableLessonPopup.show( - // context: context, - // lesson: lsn, - // ), - ), + // check if new popup needed + if (Provider.of(context).newPopups) { + return GestureDetector( + onTap: () => TimetableLessonPopup.show( + context: context, + lesson: lsn, + ), + child: 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 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 { @@ -415,11 +418,9 @@ class TimetableLessonPopup extends StatelessWidget { width: double.infinity, decoration: BoxDecoration( color: Theme.of(context).colorScheme.background, - borderRadius: BorderRadius.vertical( - top: const Radius.circular(12.0), - bottom: (lesson.description.replaceAll(' ', '') != '') - ? const Radius.circular(6.0) - : const Radius.circular(12.0), + borderRadius: const BorderRadius.vertical( + top: Radius.circular(12.0), + bottom: Radius.circular(6.0), ), ), padding: const EdgeInsets.all(14.0), @@ -521,11 +522,9 @@ class TimetableLessonPopup extends StatelessWidget { width: double.infinity, decoration: BoxDecoration( color: Theme.of(context).colorScheme.background, - borderRadius: BorderRadius.vertical( - top: const Radius.circular(6.0), - bottom: lesson.exam != '' - ? const Radius.circular(6.0) - : const Radius.circular(12.0), + borderRadius: const BorderRadius.vertical( + top: Radius.circular(6.0), + bottom: Radius.circular(6.0), ), ), padding: const EdgeInsets.all(14.0), @@ -544,6 +543,35 @@ class TimetableLessonPopup extends StatelessWidget { ], ), ), + const SizedBox( + height: 6.0, + ), + Container( + width: double.infinity, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.background, + 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), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${'year_index'.i18n}: ${lesson.lessonYearIndex}', + style: TextStyle( + color: AppColors.of(context).text.withOpacity(0.9), + fontSize: 14.0, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), if (lesson.exam != '') const SizedBox( height: 6.0, @@ -570,25 +598,34 @@ class TimetableLessonPopup extends StatelessWidget { 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, + SizedBox( + width: MediaQuery.of(context).size.width * 0.5, + child: Text( + lessonExam.description.capital(), + maxLines: 2, + overflow: TextOverflow.ellipsis, + 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, + Flexible( + child: Text( + lessonExam.mode?.description ?? 'Dolgozat', + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: AppColors.of(context) + .text + .withOpacity(0.85), + fontSize: 14.0, + fontWeight: FontWeight.w500, + ), ), ), ],