From b5b0046ef5b38ccd31ba940b6998e62607b09852 Mon Sep 17 00:00:00 2001 From: Kima Date: Tue, 18 Jun 2024 14:44:53 +0200 Subject: [PATCH] =?UTF-8?q?things=E2=84=A2=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- refilc/lib/models/self_note.dart | 2 +- .../lib/pages/notes/notes_page.dart | 39 ++++++-- .../lib/screens/settings/settings_helper.dart | 23 ++++- .../settings/settings_screen.i18n.dart | 12 ++- .../settings/submenu/personalize_screen.dart | 97 +++++++++++++++++-- 5 files changed, 151 insertions(+), 22 deletions(-) diff --git a/refilc/lib/models/self_note.dart b/refilc/lib/models/self_note.dart index cbaf42b..281a264 100644 --- a/refilc/lib/models/self_note.dart +++ b/refilc/lib/models/self_note.dart @@ -60,7 +60,7 @@ class TodoItem { ); } - get toJson => { + Map get toJson => { 'id': id, 'title': title, 'content': content, diff --git a/refilc_mobile_ui/lib/pages/notes/notes_page.dart b/refilc_mobile_ui/lib/pages/notes/notes_page.dart index 5921b59..eac27c6 100644 --- a/refilc_mobile_ui/lib/pages/notes/notes_page.dart +++ b/refilc_mobile_ui/lib/pages/notes/notes_page.dart @@ -88,6 +88,7 @@ class NotesPageState extends State with TickerProviderStateMixin { // todo tiles List toDoTiles = []; + // TODO: FIX THIS ASAP if (hw.isNotEmpty && Provider.of(context, listen: false) .hasScope(PremiumScopes.unlimitedSelfNotes)) { @@ -98,13 +99,23 @@ class NotesPageState extends State with TickerProviderStateMixin { '${(e.subject.isRenamed ? e.subject.renamedTo : e.subject.name) ?? ''}, ${e.content.escapeHtml()}', isTicked: doneItems[e.id] ?? false, onTap: (p0) async { + print(p0); + print(doneItems); if (!doneItems.containsKey(e.id)) { doneItems.addAll({e.id: p0}); } else { doneItems[e.id] = p0; } + print(doneItems); + print(doneItems[e.id]); + print(user.id); await databaseProvider.userStore .storeToDoItem(doneItems, userId: user.id!); + + setState(() {}); + + print( + await databaseProvider.userQuery.toDoItems(userId: user.id!)); }, ))); } @@ -116,10 +127,20 @@ class NotesPageState extends State with TickerProviderStateMixin { description: e.content, isTicked: e.done, onTap: (p0) async { - todoItems.firstWhere((element) => element.id == e.id).done = p0; + final todoItemIndex = + todoItems.indexWhere((element) => element.id == e.id); + if (todoItemIndex != -1) { + TodoItem todoItem = todoItems[todoItemIndex]; + Map todoItemJson = todoItem.toJson; + todoItemJson['done'] = p0; + todoItem = TodoItem.fromJson(todoItemJson); + todoItems[todoItemIndex] = todoItem; + await databaseProvider.userStore + .storeSelfTodoItems(todoItems, userId: user.id!); + } - await databaseProvider.userStore - .storeSelfTodoItems(todoItems, userId: user.id!); + // await databaseProvider.userStore + // .storeSelfTodoItems(todoItems, userId: user.id!); }, ))); } @@ -468,13 +489,13 @@ class NotesPageState extends State with TickerProviderStateMixin { ], ), onTap: () { - if (!Provider.of(context, listen: false) - .hasScope(PremiumScopes.unlimitedSelfNotes)) { - PlusLockedFeaturePopup.show( - context: context, feature: PremiumFeature.selfNotes); + // if (!Provider.of(context, listen: false) + // .hasScope(PremiumScopes.unlimitedSelfNotes)) { + // PlusLockedFeaturePopup.show( + // context: context, feature: PremiumFeature.selfNotes); - return; - } + // return; + // } showTaskCreation(context); }, diff --git a/refilc_mobile_ui/lib/screens/settings/settings_helper.dart b/refilc_mobile_ui/lib/screens/settings/settings_helper.dart index 7ae7920..4cc2e37 100644 --- a/refilc_mobile_ui/lib/screens/settings/settings_helper.dart +++ b/refilc_mobile_ui/lib/screens/settings/settings_helper.dart @@ -128,13 +128,34 @@ class SettingsHelper { // } // } - static void fontFamily(BuildContext context) { + static void fontFamily(BuildContext context, + {required Function() showDialog}) { SettingsProvider settings = Provider.of(context, listen: false); showBottomSheetMenu( context, items: List.generate(fontList.length, (index) { + // if (index == fontList.length) { + // return BottomSheetMenuItem( + // onPressed: showDialog, + // title: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // SettingsLocalization('custom').i18n, + // ), + // if (fontList.contains(settings.fontFamily) == false && + // settings.fontFamily != '') + // Icon( + // Icons.check_circle, + // color: Theme.of(context).colorScheme.secondary, + // ), + // ], + // ), + // ); + // } + String font = fontList[index]; return BottomSheetMenuItem( onPressed: () { diff --git a/refilc_mobile_ui/lib/screens/settings/settings_screen.i18n.dart b/refilc_mobile_ui/lib/screens/settings/settings_screen.i18n.dart index dff11ea..3351848 100644 --- a/refilc_mobile_ui/lib/screens/settings/settings_screen.i18n.dart +++ b/refilc_mobile_ui/lib/screens/settings/settings_screen.i18n.dart @@ -5,7 +5,8 @@ extension SettingsLocalization on String { { "en_en": { "heads_up": "Heads up!", - "export_warning": "Exported grades are currently not yet viewable in reFilc, you'll only be able to view them manually in JSON format. In the future, this functionality will be extended and you will be able to view the tickets in the app interface.", + "export_warning": + "Exported grades are currently not yet viewable in reFilc, you'll only be able to view them manually in JSON format. In the future, this functionality will be extended and you will be able to view the tickets in the app interface.", "personal_details": "Personal Details", "open_dkt": "Open DCS", "edit_nickname": "Edit Nickname", @@ -126,10 +127,12 @@ extension SettingsLocalization on String { "new_popups": "New Popups", "export_method": "Export Method", "grade_exporting": "Grade Exporting", + "custom": "Custom", }, "hu_hu": { "heads_up": "Figyelem!", - "export_warning": "Az exportált jegyek jelenleg még nem megtekinthetők a reFilc-ben, csak te magad tudod átnézni őket JSON formátumban. A jövőben ez a funkció bővülni fog, és a jegyeket meg is tekintheted majd a reFilc felületén.", + "export_warning": + "Az exportált jegyek jelenleg még nem megtekinthetők a reFilc-ben, csak te magad tudod átnézni őket JSON formátumban. A jövőben ez a funkció bővülni fog, és a jegyeket meg is tekintheted majd a reFilc felületén.", "personal_details": "Személyes információk", "open_dkt": "DKT megnyitása", "edit_nickname": "Becenév szerkesztése", @@ -250,10 +253,12 @@ extension SettingsLocalization on String { "new_popups": "Új felugró ablakok", "export_method": "Exportálási mód", "grade_exporting": "Jegy exportálás", + "custom": "Egyedi", }, "de_de": { "heads_up": "Achtung!", - "export_warning": "Exportierte Tickets sind derzeit noch nicht in reFilc einsehbar, Sie können sie nur selbst im JSON- Format überprüfen. In Zukunft wird diese Funktionalität erweitert und Sie werden die Tickets in der reFilc-Oberfläche anzeigen können", + "export_warning": + "Exportierte Tickets sind derzeit noch nicht in reFilc einsehbar, Sie können sie nur selbst im JSON- Format überprüfen. In Zukunft wird diese Funktionalität erweitert und Sie werden die Tickets in der reFilc-Oberfläche anzeigen können", "personal_details": "Persönliche Angaben", "open_dkt": "Öffnen RDZ", "edit_nickname": "Spitznamen bearbeiten", @@ -374,6 +379,7 @@ extension SettingsLocalization on String { "new_popups": "Neue Popups", "export_method": "Exportmethode", "grade_exporting": "Noten exportieren", + "custom": "Benutzerdefiniert", }, }; diff --git a/refilc_mobile_ui/lib/screens/settings/submenu/personalize_screen.dart b/refilc_mobile_ui/lib/screens/settings/submenu/personalize_screen.dart index 696fa33..e1872fa 100644 --- a/refilc_mobile_ui/lib/screens/settings/submenu/personalize_screen.dart +++ b/refilc_mobile_ui/lib/screens/settings/submenu/personalize_screen.dart @@ -79,6 +79,8 @@ class PersonalizeSettingsScreenState extends State late AnimationController _hideContainersController; + final TextEditingController _customFontFamily = TextEditingController(); + late List editedShit; late List otherShit; @@ -927,15 +929,94 @@ class PersonalizeSettingsScreenState extends State children: [ PanelButton( onPressed: () { - if (!Provider.of(context, listen: false) - .hasScope(PremiumScopes.customFont)) { - PlusLockedFeaturePopup.show( - context: context, - feature: PremiumFeature.fontChange); - return; - } + // if (!Provider.of(context, listen: false) + // .hasScope(PremiumScopes.customFont)) { + // PlusLockedFeaturePopup.show( + // context: context, + // feature: PremiumFeature.fontChange); + // return; + // } - SettingsHelper.fontFamily(context); + SettingsHelper.fontFamily( + context, + showDialog: () => showDialog( + context: context, + builder: (context) => AlertDialog( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(14.0))), + contentPadding: + const EdgeInsets.only(top: 10.0), + title: Text("custom".i18n), + content: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 24.0, vertical: 10.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextField( + controller: _customFontFamily, + 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: "ff_name".i18n, + suffixIcon: IconButton( + icon: const Icon( + FeatherIcons.x, + color: Colors.grey, + ), + onPressed: () { + setState(() { + _customFontFamily.text = ""; + }); + }, + ), + ), + ), + ], + ), + ), + actions: [ + TextButton( + child: Text( + "cancel".i18n, + style: const TextStyle( + fontWeight: FontWeight.w500), + ), + onPressed: () { + Navigator.of(context).maybePop(); + }, + ), + TextButton( + child: Text( + "next".i18n, + style: const TextStyle( + fontWeight: FontWeight.w500), + ), + onPressed: () async { + settingsProvider.update( + fontFamily: _customFontFamily.text); + + Navigator.of(context).pop(true); + }, + ), + ], + ), + ), + ); setState(() {}); }, title: Text(