From 531306cc2f62660887846a590397eaa885f9cd91 Mon Sep 17 00:00:00 2001 From: lucien144 Date: Wed, 31 Aug 2022 16:12:26 +0200 Subject: [PATCH] feat: close #359 --- lib/components/post/post_list_item.dart | 2 +- lib/controllers/SettingsProvider.dart | 7 +++++++ lib/model/Settings.dart | 1 + lib/pages/settings_screen.dart | 27 +++++++++++++------------ 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/components/post/post_list_item.dart b/lib/components/post/post_list_item.dart index befdbc0..05a3194 100644 --- a/lib/components/post/post_list_item.dart +++ b/lib/components/post/post_list_item.dart @@ -80,7 +80,7 @@ class _PostListItemState extends ConsumerState { ), child: GestureDetector( onDoubleTap: () { - if (!_post!.canBeRated) { + if (!_post!.canBeRated || !MainRepository().settings.quickRating) { return null; } diff --git a/lib/controllers/SettingsProvider.dart b/lib/controllers/SettingsProvider.dart index 03459c2..14bee4e 100644 --- a/lib/controllers/SettingsProvider.dart +++ b/lib/controllers/SettingsProvider.dart @@ -57,6 +57,12 @@ class SettingsProvider { _settings.useCompactMode = mode; } + bool get quickRating => _settings.quickRating; + set quickRating(bool mode) { + _box.put('quickRating', mode); + _settings.quickRating = mode; + } + bool get useAutocorrect => _settings.useAutocorrect; set useAutocorrect(bool autocorrect) { _box.put('useAutocorrect', autocorrect); @@ -95,6 +101,7 @@ class SettingsProvider { _settings.fontSize = _box.get('fontSize', defaultValue: Settings().fontSize); _settings.defaultView = _box.get('defaultView', defaultValue: Settings().defaultView); _settings.latestView = _box.get('latestView', defaultValue: Settings().latestView); + _settings.quickRating = _box.get('quickRating', defaultValue: Settings().quickRating); _settings.useCompactMode = _box.get('useCompactMode', defaultValue: Settings().useCompactMode); _settings.useAutocorrect = _box.get('useAutocorrect', defaultValue: Settings().useAutocorrect); _settings.firstUnread = _box.get('firstUnread', defaultValue: Settings().firstUnread); diff --git a/lib/model/Settings.dart b/lib/model/Settings.dart index 1aecb76..7cc46bb 100644 --- a/lib/model/Settings.dart +++ b/lib/model/Settings.dart @@ -8,6 +8,7 @@ import 'package:url_launcher/url_launcher.dart'; class Settings { bool useCompactMode = false; bool useAutocorrect = true; + bool quickRating = true; // Settings -> what is the default view when app restart? DefaultView defaultView = DefaultView.history; // Save the last screen view diff --git a/lib/pages/settings_screen.dart b/lib/pages/settings_screen.dart index 9d170c3..d9f6213 100644 --- a/lib/pages/settings_screen.dart +++ b/lib/pages/settings_screen.dart @@ -27,6 +27,7 @@ class SettingsScreen extends StatefulWidget { class _SettingsScreenState extends State { bool _compactMode = false; bool _autocorrect = false; + bool _quickRating = true; DefaultView _defaultView = DefaultView.latest; FirstUnreadEnum _firstUnread = FirstUnreadEnum.button; LaunchModeEnum _linksMode = LaunchModeEnum.platformDefault; @@ -39,6 +40,7 @@ class _SettingsScreenState extends State { _defaultView = MainRepository().settings.defaultView; _firstUnread = MainRepository().settings.firstUnread; _linksMode = MainRepository().settings.linksMode; + _quickRating = MainRepository().settings.quickRating; AnalyticsProvider().setScreen('Settings', 'SettingsPage'); } @@ -119,16 +121,13 @@ class _SettingsScreenState extends State { title: Text('Autocorrect'), ), SettingsTile.switchTile( - onToggle: (bool value) { - setState(() => _compactMode = value); - MainRepository().settings.useCompactMode = value; - }, - initialValue: _compactMode, - leading: Icon(Icons.view_compact, color: colors.grey), - title: Text('Kompaktní zobrazení'), - description: Text( - 'Kompaktní zobrazení je zobrazení obrázků po stranách pokud to obsah příspěvku dovoluje (nedojde tak k narušení kontextu).', - ), + onToggle: (bool value) { + setState(() => _quickRating = value); + MainRepository().settings.quickRating = value; + }, + initialValue: _quickRating, + leading: Icon(MdiIcons.thumbsUpDown, color: colors.grey), + title: Text('Rychlé hodnocení') ), SettingsTile.switchTile( onToggle: (bool value) { @@ -136,10 +135,12 @@ class _SettingsScreenState extends State { MainRepository().settings.useCompactMode = value; }, initialValue: _compactMode, - leading: Icon(MdiIcons.thumbsUpDown, color: colors.grey), - title: Text('Rychlé hodnocení'), + leading: Icon(Icons.view_compact, color: colors.grey), + title: Text('Kompaktní zobrazení'), description: Text( - 'Umožňit hodnocení příspěvku double-tapem?', + 'Kompaktní zobrazení: zobrazuje obrázky po stranách pokud to obsah příspěvku dovoluje (nedojde tak k narušení kontextu).' + '\n' + 'Rychlé hodnocení: možnost hodnotit příspěvek na dvojklik (double-tap).', ), ), ],