added option to use old popups and some fixes

This commit is contained in:
Kima 2024-05-22 17:47:57 +02:00
parent cd0729fa5e
commit 45ffdff324
5 changed files with 265 additions and 204 deletions

View File

@ -53,6 +53,7 @@ const settingsDB = DatabaseStruct("settings", {
"nav_shadow": int, "nav_shadow": int,
"new_colors": int, "new_colors": int,
"uwu_mode": int, "uwu_mode": int,
"new_popups": int,
// quick settings // quick settings
"q_timetable_lesson_num": int, "q_timetable_sub_tiles": int, "q_timetable_lesson_num": int, "q_timetable_sub_tiles": int,
"q_subjects_sub_tiles": int, "q_subjects_sub_tiles": int,

View File

@ -106,6 +106,7 @@ class SettingsProvider extends ChangeNotifier {
bool _navShadow; bool _navShadow;
bool _newColors; bool _newColors;
bool _uwuMode; bool _uwuMode;
bool _newPopups;
// quick settings // quick settings
bool _qTimetableLessonNum; bool _qTimetableLessonNum;
bool _qTimetableSubTiles; bool _qTimetableSubTiles;
@ -178,6 +179,7 @@ class SettingsProvider extends ChangeNotifier {
required bool navShadow, required bool navShadow,
required bool newColors, required bool newColors,
required bool uwuMode, required bool uwuMode,
required bool newPopups,
required bool qTimetableLessonNum, required bool qTimetableLessonNum,
required bool qTimetableSubTiles, required bool qTimetableSubTiles,
required bool qSubjectsSubTiles, required bool qSubjectsSubTiles,
@ -247,6 +249,7 @@ class SettingsProvider extends ChangeNotifier {
_navShadow = navShadow, _navShadow = navShadow,
_newColors = newColors, _newColors = newColors,
_uwuMode = uwuMode, _uwuMode = uwuMode,
_newPopups = newPopups,
_qTimetableLessonNum = qTimetableLessonNum, _qTimetableLessonNum = qTimetableLessonNum,
_qTimetableSubTiles = qTimetableSubTiles, _qTimetableSubTiles = qTimetableSubTiles,
_qSubjectsSubTiles = qSubjectsSubTiles; _qSubjectsSubTiles = qSubjectsSubTiles;
@ -335,6 +338,7 @@ class SettingsProvider extends ChangeNotifier {
navShadow: map['nav_shadow'] == 1, navShadow: map['nav_shadow'] == 1,
newColors: map['new_colors'] == 1, newColors: map['new_colors'] == 1,
uwuMode: map['uwu_mode'] == 1, uwuMode: map['uwu_mode'] == 1,
newPopups: map['new_popups'] == 1,
qTimetableLessonNum: map['q_timetable_lesson_num'] == 1, qTimetableLessonNum: map['q_timetable_lesson_num'] == 1,
qTimetableSubTiles: map['q_timetable_sub_tiles'] == 1, qTimetableSubTiles: map['q_timetable_sub_tiles'] == 1,
qSubjectsSubTiles: map['q_subjects_sub_tiles'] == 1, qSubjectsSubTiles: map['q_subjects_sub_tiles'] == 1,
@ -411,6 +415,7 @@ class SettingsProvider extends ChangeNotifier {
"nav_shadow": _navShadow ? 1 : 0, "nav_shadow": _navShadow ? 1 : 0,
"new_colors": _newColors ? 1 : 0, "new_colors": _newColors ? 1 : 0,
"uwu_mode": _uwuMode ? 1 : 0, "uwu_mode": _uwuMode ? 1 : 0,
"new_popups": _newPopups ? 1 : 0,
"q_timetable_lesson_num": _qTimetableLessonNum ? 1 : 0, "q_timetable_lesson_num": _qTimetableLessonNum ? 1 : 0,
"q_timetable_sub_tiles": _qTimetableSubTiles ? 1 : 0, "q_timetable_sub_tiles": _qTimetableSubTiles ? 1 : 0,
"q_subjects_sub_tiles": _qSubjectsSubTiles ? 1 : 0, "q_subjects_sub_tiles": _qSubjectsSubTiles ? 1 : 0,
@ -491,6 +496,7 @@ class SettingsProvider extends ChangeNotifier {
navShadow: true, navShadow: true,
newColors: true, newColors: true,
uwuMode: false, uwuMode: false,
newPopups: true,
qTimetableLessonNum: true, qTimetableLessonNum: true,
qTimetableSubTiles: true, qTimetableSubTiles: true,
qSubjectsSubTiles: true, qSubjectsSubTiles: true,
@ -562,6 +568,7 @@ class SettingsProvider extends ChangeNotifier {
bool get navShadow => _navShadow; bool get navShadow => _navShadow;
bool get newColors => _newColors; bool get newColors => _newColors;
bool get uwuMode => _uwuMode; bool get uwuMode => _uwuMode;
bool get newPopups => _newPopups;
bool get qTimetableLessonNum => _qTimetableLessonNum; bool get qTimetableLessonNum => _qTimetableLessonNum;
bool get qTimetableSubTiles => _qTimetableSubTiles; bool get qTimetableSubTiles => _qTimetableSubTiles;
bool get qSubjectsSubTiles => _qSubjectsSubTiles; bool get qSubjectsSubTiles => _qSubjectsSubTiles;
@ -629,6 +636,7 @@ class SettingsProvider extends ChangeNotifier {
bool? navShadow, bool? navShadow,
bool? newColors, bool? newColors,
bool? uwuMode, bool? uwuMode,
bool? newPopups,
bool? qTimetableLessonNum, bool? qTimetableLessonNum,
bool? qTimetableSubTiles, bool? qTimetableSubTiles,
bool? qSubjectsSubTiles, bool? qSubjectsSubTiles,
@ -817,6 +825,9 @@ class SettingsProvider extends ChangeNotifier {
if (uwuMode != null && uwuMode != _uwuMode) { if (uwuMode != null && uwuMode != _uwuMode) {
_uwuMode = uwuMode; _uwuMode = uwuMode;
} }
if (newPopups != null && newPopups != _newPopups) {
_newPopups = newPopups;
}
if (qTimetableLessonNum != null && if (qTimetableLessonNum != null &&
qTimetableLessonNum != _qTimetableLessonNum) { qTimetableLessonNum != _qTimetableLessonNum) {
_qTimetableLessonNum = qTimetableLessonNum; _qTimetableLessonNum = qTimetableLessonNum;

View File

@ -49,6 +49,8 @@ extension Localization on String {
"d_npc": "d_npc":
"You're such a non-player character, we couldn't give you a personality.", "You're such a non-player character, we couldn't give you a personality.",
"s_npc": "In-game playtime (hours)", "s_npc": "In-game playtime (hours)",
// other
"year_index": "Lesson Number",
}, },
"hu_hu": { "hu_hu": {
// main // main
@ -96,6 +98,8 @@ extension Localization on String {
"d_npc": "d_npc":
"Egy akkora nagy non-player character vagy, hogy neked semmilyen személyiség nem jutott ezen kívül.", "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)", "s_npc": "In-game playtime (óra)",
// other
"year_index": "Éves óraszám",
}, },
"de_de": { "de_de": {
// main // main
@ -144,6 +148,8 @@ extension Localization on String {
"d_npc": "d_npc":
"Du bist einfach so sehr wie ein Computer, dass wir dir nicht einmal eine Persönlichkeit geben konnten.", "Du bist einfach so sehr wie ein Computer, dass wir dir nicht einmal eine Persönlichkeit geben konnten.",
"s_npc": "Spielzeit (Stunden)", "s_npc": "Spielzeit (Stunden)",
// other
"year_index": "Ordinalzahl",
} }
}; };

View File

@ -14,8 +14,11 @@ import 'package:refilc_kreta_api/models/exam.dart';
import 'package:refilc_kreta_api/models/lesson.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/bottom_sheet_menu/rounded_bottom_sheet.dart';
import 'package:refilc_mobile_ui/common/round_border_icon.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:refilc_mobile_ui/common/widgets/exam/exam_tile.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:refilc_mobile_ui/common/widgets/exam/exam_view.dart';
class ExamViewable extends StatelessWidget { class ExamViewable extends StatelessWidget {
const ExamViewable(this.exam, const ExamViewable(this.exam,
@ -27,22 +30,25 @@ class ExamViewable extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( if (Provider.of<SettingsProvider>(context).newPopups) {
onTap: () => ExamPopup.show(context: context, exam: exam), return GestureDetector(
child: ExamTile( onTap: () => ExamPopup.show(context: context, exam: exam),
child: ExamTile(
exam,
showSubject: showSubject,
padding: tilePadding,
),
);
}
return Viewable(
tile: ExamTile(
exam, exam,
showSubject: showSubject, showSubject: showSubject,
padding: tilePadding, 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( 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( style: TextStyle(
color: color:
AppColors.of(context).text.withOpacity(0.85), AppColors.of(context).text.withOpacity(0.85),

View File

@ -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/models/lesson.dart';
import 'package:refilc_kreta_api/providers/exam_provider.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/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_mobile_ui/common/round_border_icon.dart';
import 'package:refilc/ui/widgets/lesson/lesson_tile.dart'; import 'package:refilc/ui/widgets/lesson/lesson_tile.dart';
import 'package:flutter/material.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 { class LessonViewable extends StatefulWidget {
const LessonViewable( const LessonViewable(
@ -62,174 +70,169 @@ class LessonViewableState extends State<LessonViewable> {
if (lsn.subject.id == '' || tile.lesson.isEmpty) return tile; if (lsn.subject.id == '' || tile.lesson.isEmpty) return tile;
return GestureDetector( // check if new popup needed
onTap: () => TimetableLessonPopup.show( if (Provider.of<SettingsProvider>(context).newPopups) {
context: context, return GestureDetector(
lesson: lsn, onTap: () => TimetableLessonPopup.show(
), context: context,
child: LessonTile( lesson: lsn,
lsn, ),
swapDesc: widget.swapDesc, child: tile,
showSubTiles: widget.showSubTiles, );
// 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<PlusProvider>(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<PlusProvider>(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 { void saveLesson() async {
@ -415,11 +418,9 @@ class TimetableLessonPopup extends StatelessWidget {
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.vertical( borderRadius: const BorderRadius.vertical(
top: const Radius.circular(12.0), top: Radius.circular(12.0),
bottom: (lesson.description.replaceAll(' ', '') != '') bottom: Radius.circular(6.0),
? const Radius.circular(6.0)
: const Radius.circular(12.0),
), ),
), ),
padding: const EdgeInsets.all(14.0), padding: const EdgeInsets.all(14.0),
@ -521,11 +522,9 @@ class TimetableLessonPopup extends StatelessWidget {
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.vertical( borderRadius: const BorderRadius.vertical(
top: const Radius.circular(6.0), top: Radius.circular(6.0),
bottom: lesson.exam != '' bottom: Radius.circular(6.0),
? const Radius.circular(6.0)
: const Radius.circular(12.0),
), ),
), ),
padding: const EdgeInsets.all(14.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 != '') if (lesson.exam != '')
const SizedBox( const SizedBox(
height: 6.0, height: 6.0,
@ -570,25 +598,34 @@ class TimetableLessonPopup extends StatelessWidget {
const SizedBox( const SizedBox(
width: 10.0, width: 10.0,
), ),
Text( SizedBox(
lessonExam.description.capital(), width: MediaQuery.of(context).size.width * 0.5,
style: TextStyle( child: Text(
color: AppColors.of(context) lessonExam.description.capital(),
.text maxLines: 2,
.withOpacity(0.9), overflow: TextOverflow.ellipsis,
fontSize: 16.0, style: TextStyle(
fontWeight: FontWeight.w600, color: AppColors.of(context)
.text
.withOpacity(0.9),
fontSize: 16.0,
fontWeight: FontWeight.w600,
),
), ),
), ),
], ],
), ),
Text( Flexible(
lessonExam.mode?.description ?? 'Dolgozat', child: Text(
style: TextStyle( lessonExam.mode?.description ?? 'Dolgozat',
color: overflow: TextOverflow.ellipsis,
AppColors.of(context).text.withOpacity(0.85), style: TextStyle(
fontSize: 14.0, color: AppColors.of(context)
fontWeight: FontWeight.w500, .text
.withOpacity(0.85),
fontSize: 14.0,
fontWeight: FontWeight.w500,
),
), ),
), ),
], ],