示例#1
0
        public App()
        {
            InitializeComponent();

            DependencyService.Register <MockDataStore>();
            MainPage = new MainPage();
            Xamarin.Essentials.AppTheme theme = AppInfo.RequestedTheme;
            switch (theme)
            {
            case Xamarin.Essentials.AppTheme.Dark:
                AppTheme          = "dark";
                Current.Resources = new DarkTheme();
                break;

            case Xamarin.Essentials.AppTheme.Light:
                AppTheme          = "light";
                Current.Resources = new LightTheme();
                break;

            default:
                AppTheme          = "light";
                Current.Resources = new LightTheme();
                break;
            }
        }
示例#2
0
        /// <summary>
        /// Changes to SystemPreferred Theme
        /// </summary>
        public static void ChangeToSystemPreferredTheme()
        {
            Xamarin.Essentials.AppTheme appTheme = AppInfo.RequestedTheme;

            if (appTheme == Xamarin.Essentials.AppTheme.Dark)
            {
                ChangeToDarkTheme();
            }
            else if (appTheme == Xamarin.Essentials.AppTheme.Light)
            {
                ChangeToLightTheme();
            }
            else
            {
                ChangeToLightTheme();
            }

            Settings.AddSetting(Settings.AppPrefrences.AppTheme, EnumsHelper.ConvertToString(Settings.Theme.SystemPreferred));
        }