diff --git a/lib/api/irc_api.dart b/lib/api/irc_api.dart index 3a548d98..3bb1f561 100644 --- a/lib/api/irc_api.dart +++ b/lib/api/irc_api.dart @@ -185,7 +185,7 @@ enum Command { none, } -// https://stackoverflow.com/questions/50081213/how-do-i-use-hexadecimal-color-strings-in-flutter +/// https://stackoverflow.com/questions/50081213/how-do-i-use-hexadecimal-color-strings-in-flutter extension HexColor on Color { /// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#". static Color fromHex(String hexString) { @@ -194,11 +194,4 @@ extension HexColor on Color { buffer.write(hexString.replaceFirst('#', '')); return Color(int.parse(buffer.toString(), radix: 16)); } - - /// Prefixes a hash sign if [leadingHashSign] is set to `true` (default is `true`). - String toHex({bool leadingHashSign = true}) => '${leadingHashSign ? '#' : ''}' - '${alpha.toRadixString(16).padLeft(2, '0')}' - '${red.toRadixString(16).padLeft(2, '0')}' - '${green.toRadixString(16).padLeft(2, '0')}' - '${blue.toRadixString(16).padLeft(2, '0')}'; } diff --git a/lib/core/settings/settings_store.dart b/lib/core/settings/settings_store.dart index 23dd2e42..df616af6 100644 --- a/lib/core/settings/settings_store.dart +++ b/lib/core/settings/settings_store.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:mobx/mobx.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -6,21 +7,19 @@ part 'settings_store.g.dart'; class SettingsStore = _SettingsStoreBase with _$SettingsStore; abstract class _SettingsStoreBase with Store { - late final SharedPreferences prefs; - late ReactionDisposer disposeSetter; - Future init() async { - // debugPrint('Created settings provider!'); - // prefs = await SharedPreferences.getInstance(); + // Retrieve the instance that will allow us to store and persist settings. + final prefs = await SharedPreferences.getInstance(); - // // Initialize settings from stored preferences if any. - // videoEnabled = prefs.getBool('video_enabled') ?? videoEnabled; + // Initialize settings from stored preferences if any. + videoEnabled = prefs.getBool('video_enabled') ?? videoEnabled; - // // Set up autorun to store setting anytime they're changed. - // disposeSetter = autorun((_) { - // debugPrint('video changed'); - // prefs.setBool('video_enabled', videoEnabled); - // }); + // Set up autorun to store setting anytime they're changed. + // The ReactionDisposer will not be needed since settings will always exist. + autorun((_) { + debugPrint('video changed'); + prefs.setBool('video_enabled', videoEnabled); + }); } @observable