mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Can toggle performances overlay
This commit is contained in:
		@@ -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 {
 | 
			
		||||
@@ -81,7 +83,8 @@ class PreferencesHelper {
 | 
			
		||||
  ApplicationPreferences get preferences => ApplicationPreferences(
 | 
			
		||||
      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 {
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
          ),
 | 
			
		||||
        ],
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user