コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: pawelkoter/xamarinApp
        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);
        }