mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Can toggle performances overlay
This commit is contained in:
parent
a6ce969e89
commit
67e881af0d
@ -14,12 +14,14 @@ enum PreferencesKeyList {
|
|||||||
LOGIN_TOKENS,
|
LOGIN_TOKENS,
|
||||||
ENABLE_DARK_THEME,
|
ENABLE_DARK_THEME,
|
||||||
FORCE_MOBILE_MODE,
|
FORCE_MOBILE_MODE,
|
||||||
|
SHOW_PERFORMANCE_OVERLAY,
|
||||||
}
|
}
|
||||||
|
|
||||||
const _PreferenceKeysName = {
|
const _PreferenceKeysName = {
|
||||||
PreferencesKeyList.LOGIN_TOKENS: "login_tokens",
|
PreferencesKeyList.LOGIN_TOKENS: "login_tokens",
|
||||||
PreferencesKeyList.ENABLE_DARK_THEME: "dark_theme",
|
PreferencesKeyList.ENABLE_DARK_THEME: "dark_theme",
|
||||||
PreferencesKeyList.FORCE_MOBILE_MODE: "force_mobile_mode",
|
PreferencesKeyList.FORCE_MOBILE_MODE: "force_mobile_mode",
|
||||||
|
PreferencesKeyList.SHOW_PERFORMANCE_OVERLAY: "perfs_overlay",
|
||||||
};
|
};
|
||||||
|
|
||||||
class PreferencesHelper {
|
class PreferencesHelper {
|
||||||
@ -81,7 +83,8 @@ class PreferencesHelper {
|
|||||||
ApplicationPreferences get preferences => ApplicationPreferences(
|
ApplicationPreferences get preferences => ApplicationPreferences(
|
||||||
enableDarkMode: getBool(PreferencesKeyList.ENABLE_DARK_THEME),
|
enableDarkMode: getBool(PreferencesKeyList.ENABLE_DARK_THEME),
|
||||||
forceMobileMode: getBool(PreferencesKeyList.FORCE_MOBILE_MODE),
|
forceMobileMode: getBool(PreferencesKeyList.FORCE_MOBILE_MODE),
|
||||||
);
|
showPerformancesOverlay:
|
||||||
|
getBool(PreferencesKeyList.SHOW_PERFORMANCE_OVERLAY));
|
||||||
|
|
||||||
/// Apply new preferences
|
/// Apply new preferences
|
||||||
Future<void> setPreferences(ApplicationPreferences preferences) async {
|
Future<void> setPreferences(ApplicationPreferences preferences) async {
|
||||||
|
@ -47,12 +47,13 @@ class ComunicApplicationState extends State<ComunicApplication> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final prefs = widget.preferences.preferences;
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
home: AccountHelper.isUserIDLoaded ? InitializeWidget() : LoginRoute(),
|
home: AccountHelper.isUserIDLoaded ? InitializeWidget() : LoginRoute(),
|
||||||
theme: widget.preferences.preferences.enableDarkMode
|
theme: prefs.enableDarkMode ? ThemeData.dark() : null,
|
||||||
? ThemeData.dark()
|
showPerformanceOverlay: prefs.showPerformancesOverlay,
|
||||||
: null,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,13 @@ import 'package:flutter/cupertino.dart';
|
|||||||
class ApplicationPreferences {
|
class ApplicationPreferences {
|
||||||
bool enableDarkMode;
|
bool enableDarkMode;
|
||||||
bool forceMobileMode;
|
bool forceMobileMode;
|
||||||
|
bool showPerformancesOverlay;
|
||||||
|
|
||||||
ApplicationPreferences({
|
ApplicationPreferences({
|
||||||
@required this.enableDarkMode,
|
@required this.enableDarkMode,
|
||||||
@required this.forceMobileMode,
|
@required this.forceMobileMode,
|
||||||
|
@required this.showPerformancesOverlay,
|
||||||
}) : assert(enableDarkMode != null),
|
}) : assert(enableDarkMode != null),
|
||||||
assert(forceMobileMode != null);
|
assert(forceMobileMode != null),
|
||||||
|
assert(showPerformancesOverlay != null);
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,8 @@ class _ApplicationSettingsState extends State<ApplicationSettings> {
|
|||||||
SettingsSection _buildDebugSection() => SettingsSection(
|
SettingsSection _buildDebugSection() => SettingsSection(
|
||||||
title: tr("Debug features"),
|
title: tr("Debug features"),
|
||||||
tiles: [
|
tiles: [
|
||||||
|
|
||||||
|
// Force mobile mode
|
||||||
_PreferencesSettingsTile(
|
_PreferencesSettingsTile(
|
||||||
preferencesKey: PreferencesKeyList.FORCE_MOBILE_MODE,
|
preferencesKey: PreferencesKeyList.FORCE_MOBILE_MODE,
|
||||||
title: tr("Force mobile mode"),
|
title: tr("Force mobile mode"),
|
||||||
@ -75,6 +77,15 @@ class _ApplicationSettingsState extends State<ApplicationSettings> {
|
|||||||
onChange: _updatedSettings,
|
onChange: _updatedSettings,
|
||||||
helper: _preferencesHelper,
|
helper: _preferencesHelper,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Show performances overlay
|
||||||
|
_PreferencesSettingsTile(
|
||||||
|
preferencesKey: PreferencesKeyList.SHOW_PERFORMANCE_OVERLAY,
|
||||||
|
title: tr("Show performances overlay"),
|
||||||
|
subtitle: null,
|
||||||
|
onChange: _updatedSettings,
|
||||||
|
helper: _preferencesHelper,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user