Skip to content

Commit

Permalink
feat: close #359
Browse files Browse the repository at this point in the history
  • Loading branch information
lucien144 committed Aug 31, 2022
1 parent 71d208e commit 531306c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/components/post/post_list_item.dart
Expand Up @@ -80,7 +80,7 @@ class _PostListItemState extends ConsumerState<PostListItem> {
),
child: GestureDetector(
onDoubleTap: () {
if (!_post!.canBeRated) {
if (!_post!.canBeRated || !MainRepository().settings.quickRating) {
return null;
}

Expand Down
7 changes: 7 additions & 0 deletions lib/controllers/SettingsProvider.dart
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions lib/model/Settings.dart
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions lib/pages/settings_screen.dart
Expand Up @@ -27,6 +27,7 @@ class SettingsScreen extends StatefulWidget {
class _SettingsScreenState extends State<SettingsScreen> {
bool _compactMode = false;
bool _autocorrect = false;
bool _quickRating = true;
DefaultView _defaultView = DefaultView.latest;
FirstUnreadEnum _firstUnread = FirstUnreadEnum.button;
LaunchModeEnum _linksMode = LaunchModeEnum.platformDefault;
Expand All @@ -39,6 +40,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_defaultView = MainRepository().settings.defaultView;
_firstUnread = MainRepository().settings.firstUnread;
_linksMode = MainRepository().settings.linksMode;
_quickRating = MainRepository().settings.quickRating;
AnalyticsProvider().setScreen('Settings', 'SettingsPage');
}

Expand Down Expand Up @@ -119,27 +121,26 @@ class _SettingsScreenState extends State<SettingsScreen> {
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) {
setState(() => _compactMode = value);
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).',
),
),
],
Expand Down

0 comments on commit 531306c

Please sign in to comment.