@@ -99,31 +99,34 @@ private async void DetectCustomLocations()
99
99
100
100
private void DetectApplicationTheme ( )
101
101
{
102
- if ( localSettings . Values [ "theme" ] . ToString ( ) == "Light" )
103
- {
104
- ThemeValue = ThemeStyle . Light ;
105
- App . Current . RequestedTheme = ApplicationTheme . Light ;
106
- }
107
- else if ( localSettings . Values [ "theme" ] . ToString ( ) == "Dark" )
108
- {
109
- ThemeValue = ThemeStyle . Dark ;
110
- App . Current . RequestedTheme = ApplicationTheme . Dark ;
111
- }
112
- else
113
- {
114
- var uiSettings = new UISettings ( ) ;
115
- var color = uiSettings . GetColorValue ( UIColorType . Background ) ;
116
- if ( color == Colors . White )
117
- {
118
- ThemeValue = ThemeStyle . System ;
119
- App . Current . RequestedTheme = ApplicationTheme . Light ;
120
- }
121
- else
122
- {
123
- ThemeValue = ThemeStyle . System ;
124
- App . Current . RequestedTheme = ApplicationTheme . Dark ;
125
- }
126
- }
102
+ if ( localSettings . Values [ "theme" ] != null )
103
+ {
104
+ if ( localSettings . Values [ "theme" ] . ToString ( ) == "Light" )
105
+ {
106
+ ThemeValue = ThemeStyle . Light ;
107
+ App . Current . RequestedTheme = ApplicationTheme . Light ;
108
+ return ;
109
+ }
110
+ else if ( localSettings . Values [ "theme" ] . ToString ( ) == "Dark" )
111
+ {
112
+ ThemeValue = ThemeStyle . Dark ;
113
+ App . Current . RequestedTheme = ApplicationTheme . Dark ;
114
+ return ;
115
+ }
116
+ }
117
+
118
+ var uiSettings = new UISettings ( ) ;
119
+ var color = uiSettings . GetColorValue ( UIColorType . Background ) ;
120
+ if ( color == Colors . White )
121
+ {
122
+ ThemeValue = ThemeStyle . System ;
123
+ App . Current . RequestedTheme = ApplicationTheme . Light ;
124
+ }
125
+ else
126
+ {
127
+ ThemeValue = ThemeStyle . System ;
128
+ App . Current . RequestedTheme = ApplicationTheme . Dark ;
129
+ }
127
130
}
128
131
129
132
private FormFactorMode _FormFactor = FormFactorMode . Regular ;
0 commit comments