From d04b40f662203c80e3f11be14d11800abeb3f266 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 13 May 2020 18:17:50 +0200 Subject: [PATCH] Add force mobile mode preference --- lib/helpers/preferences_helper.dart | 8 +++++++- lib/models/application_preferences.dart | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/helpers/preferences_helper.dart b/lib/helpers/preferences_helper.dart index 2491d0c..e937783 100644 --- a/lib/helpers/preferences_helper.dart +++ b/lib/helpers/preferences_helper.dart @@ -10,11 +10,16 @@ import 'package:shared_preferences/shared_preferences.dart'; /// /// @author Pierre HUBERT -enum PreferencesKeyList { LOGIN_TOKENS, ENABLE_DARK_THEME } +enum PreferencesKeyList { + LOGIN_TOKENS, + ENABLE_DARK_THEME, + FORCE_MOBILE_MODE, +} const _PreferenceKeysName = { PreferencesKeyList.LOGIN_TOKENS: "login_tokens", PreferencesKeyList.ENABLE_DARK_THEME: "dark_theme", + PreferencesKeyList.FORCE_MOBILE_MODE: "force_mobile_mode", }; class PreferencesHelper { @@ -75,6 +80,7 @@ class PreferencesHelper { /// Get all settings as an [ApplicationPreferences] object ApplicationPreferences get preferences => ApplicationPreferences( enableDarkMode: getBool(PreferencesKeyList.ENABLE_DARK_THEME), + forceMobileMode: getBool(PreferencesKeyList.FORCE_MOBILE_MODE), ); /// Apply new preferences diff --git a/lib/models/application_preferences.dart b/lib/models/application_preferences.dart index ef24df3..d458705 100644 --- a/lib/models/application_preferences.dart +++ b/lib/models/application_preferences.dart @@ -6,8 +6,11 @@ import 'package:flutter/cupertino.dart'; class ApplicationPreferences { bool enableDarkMode; + bool forceMobileMode; ApplicationPreferences({ @required this.enableDarkMode, - }) : assert(enableDarkMode != null); + @required this.forceMobileMode, + }) : assert(enableDarkMode != null), + assert(forceMobileMode != null); }