1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-24 11:58:51 +00:00

Can toggle performances overlay

This commit is contained in:
Pierre HUBERT 2020-05-13 18:26:21 +02:00
parent a6ce969e89
commit 67e881af0d
4 changed files with 25 additions and 7 deletions

View File

@ -14,12 +14,14 @@ enum PreferencesKeyList {
LOGIN_TOKENS,
ENABLE_DARK_THEME,
FORCE_MOBILE_MODE,
SHOW_PERFORMANCE_OVERLAY,
}
const _PreferenceKeysName = {
PreferencesKeyList.LOGIN_TOKENS: "login_tokens",
PreferencesKeyList.ENABLE_DARK_THEME: "dark_theme",
PreferencesKeyList.FORCE_MOBILE_MODE: "force_mobile_mode",
PreferencesKeyList.SHOW_PERFORMANCE_OVERLAY: "perfs_overlay",
};
class PreferencesHelper {
@ -79,9 +81,10 @@ 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),
);
enableDarkMode: getBool(PreferencesKeyList.ENABLE_DARK_THEME),
forceMobileMode: getBool(PreferencesKeyList.FORCE_MOBILE_MODE),
showPerformancesOverlay:
getBool(PreferencesKeyList.SHOW_PERFORMANCE_OVERLAY));
/// Apply new preferences
Future<void> setPreferences(ApplicationPreferences preferences) async {

View File

@ -47,12 +47,13 @@ class ComunicApplicationState extends State<ComunicApplication> {
@override
Widget build(BuildContext context) {
final prefs = widget.preferences.preferences;
return MaterialApp(
debugShowCheckedModeBanner: false,
home: AccountHelper.isUserIDLoaded ? InitializeWidget() : LoginRoute(),
theme: widget.preferences.preferences.enableDarkMode
? ThemeData.dark()
: null,
theme: prefs.enableDarkMode ? ThemeData.dark() : null,
showPerformanceOverlay: prefs.showPerformancesOverlay,
);
}
}

View File

@ -7,10 +7,13 @@ import 'package:flutter/cupertino.dart';
class ApplicationPreferences {
bool enableDarkMode;
bool forceMobileMode;
bool showPerformancesOverlay;
ApplicationPreferences({
@required this.enableDarkMode,
@required this.forceMobileMode,
@required this.showPerformancesOverlay,
}) : assert(enableDarkMode != null),
assert(forceMobileMode != null);
assert(forceMobileMode != null),
assert(showPerformancesOverlay != null);
}

View File

@ -67,6 +67,8 @@ class _ApplicationSettingsState extends State<ApplicationSettings> {
SettingsSection _buildDebugSection() => SettingsSection(
title: tr("Debug features"),
tiles: [
// Force mobile mode
_PreferencesSettingsTile(
preferencesKey: PreferencesKeyList.FORCE_MOBILE_MODE,
title: tr("Force mobile mode"),
@ -75,6 +77,15 @@ class _ApplicationSettingsState extends State<ApplicationSettings> {
onChange: _updatedSettings,
helper: _preferencesHelper,
),
// Show performances overlay
_PreferencesSettingsTile(
preferencesKey: PreferencesKeyList.SHOW_PERFORMANCE_OVERLAY,
title: tr("Show performances overlay"),
subtitle: null,
onChange: _updatedSettings,
helper: _preferencesHelper,
),
],
);