import 'package:flutter/foundation.dart'; import 'package:wonders/common_libs.dart'; import 'package:wonders/logic/common/save_load_mixin.dart'; class SettingsLogic with ThrottledSaveLoadMixin { @override String get fileName => 'settings.dat'; late final hasCompletedOnboarding = ValueNotifier(false)..addListener(scheduleSave); late final hasDismissedSearchMessage = ValueNotifier(false)..addListener(scheduleSave); late final currentLocale = ValueNotifier(null)..addListener(scheduleSave); final bool useBlurs = defaultTargetPlatform != TargetPlatform.android; @override void copyFromJson(Map value) { hasCompletedOnboarding.value = value['hasCompletedOnboarding'] ?? false; hasDismissedSearchMessage.value = value['hasDismissedSearchMessage'] ?? false; currentLocale.value = value['currentLocale']; } @override Map toJson() { return { 'hasCompletedOnboarding': hasCompletedOnboarding.value, 'hasDismissedSearchMessage': hasDismissedSearchMessage.value, 'currentLocale': currentLocale.value, }; } Future changeLocale(Locale value) async { currentLocale.value = value.languageCode; await localeLogic.loadIfChanged(value); // Re-init controllers that have some cached data that is localized wondersLogic.init(); timelineLogic.init(); } }