private async void SaveColor() { var color = Colors[ColorSelectedIndex]; var json = JsonConvert.SerializeObject(color); await _fileHelper.WriteTextAsync(Constants.ColorFile, json); var themeService = new ThemeService(); themeService.ChangeTheme(UseDarkTheme); }
public async void OnThemeSwitchToggled(object sender, ToggledEventArgs toggledEventArgs) { var themeSwith = (Switch)sender; var useDarkTheme = themeSwith.IsToggled; var themeService = new ThemeService(); themeService.ChangeTheme(useDarkTheme); Application.Current.Properties[Constants.UseDarkThemeProperty] = useDarkTheme; await Application.Current.SavePropertiesAsync(); }
protected override void OnStart() { // Handle when your app starts // check last theme used var useDarkTheme = false; if (Application.Current.Properties.ContainsKey(Constants.UseDarkThemeProperty)) { useDarkTheme = (bool)Application.Current.Properties[Constants.UseDarkThemeProperty]; } var themeService = new ThemeService(); themeService.ChangeTheme(useDarkTheme); }