public void ChangeAppTheme(ThemeHelper.AppThemeMode theme, bool isAppLaunched) { switch (theme) { case ThemeHelper.AppThemeMode.Light: Device.BeginInvokeOnMainThread(() => { if (UIApplication.SharedApplication.ValueForKey(_statusBarKey) is UIView statusBar) { statusBar.BackgroundColor = _lightStatusBarColor; } }); break; case ThemeHelper.AppThemeMode.Dark: Device.BeginInvokeOnMainThread(() => { if (UIApplication.SharedApplication.ValueForKey(_statusBarKey) is UIView statusBar) { statusBar.BackgroundColor = _darkStatusBarColor; } }); break; } }
public void ChangeAppTheme(ThemeHelper.AppThemeMode theme, bool isAppLaunched) { var currentWindow = GetCurrentWindow(); switch (theme) { case ThemeHelper.AppThemeMode.Light: Device.BeginInvokeOnMainThread(() => { currentWindow.DecorView.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.LightStatusBar; currentWindow.SetStatusBarColor(_lightStatusBarColor); if (!isAppLaunched) { CrossCurrentActivity.Current.Activity.SetTheme(Resource.Style.MainTheme); } }); break; case ThemeHelper.AppThemeMode.Dark: Device.BeginInvokeOnMainThread(() => { currentWindow.DecorView.SystemUiVisibility = 0; currentWindow.SetStatusBarColor(_darkStatusBarColor); if (!isAppLaunched) { CrossCurrentActivity.Current.Activity.SetTheme(Resource.Style.MainDarkTheme); } }); break; } }
public void ChangeAppTheme(ThemeHelper.AppThemeMode theme, bool isAppLaunched) { // Implementation // switch (theme) // { // case ThemeHelper.AppThemeMode.Light: // Device.BeginInvokeOnMainThread(() => // { // if (UIApplication.SharedApplication.ValueForKey(_statusBarKey) is UIView statusBar) // statusBar.BackgroundColor = _lightStatusBarColor; // }); // break; // case ThemeHelper.AppThemeMode.Dark: // Device.BeginInvokeOnMainThread(() => // { // if (UIApplication.SharedApplication.ValueForKey(_statusBarKey) is UIView statusBar) // statusBar.BackgroundColor = _darkStatusBarColor; // }); // break; // } }