Пример #1
0
        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;
            }
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
 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;
     // }
 }