Lines Matching refs:theme
11 In this tutorial, we are going to build a module that stores the user's preferred app theme - eithe…
115 ## 4. Get, set, and persist the theme preference value
119 To read the value on iOS, we can look for a `UserDefaults` string under the key `"theme"`, and fall…
130 Function("setTheme") { (theme: String) -> Void in
131 UserDefaults.standard.set(theme, forKey:"theme")
135 UserDefaults.standard.string(forKey: "theme") ?? "system"
143 To read the value, we can look for a `SharedPreferences` string under the key `"theme"`, and fall b…
159 Function("setTheme") { theme: String ->
160 getPreferences().edit().putString("theme", theme).commit()
164 return@Function getPreferences().getString("theme", "system")
188 export function setTheme(theme: string): void {
189 return ExpoSettingsModule.setTheme(theme);
202 const theme = Settings.getTheme();
203 // Toggle between dark and light theme
204 const nextTheme = theme === 'dark' ? 'light' : 'dark';
209 <Button title={`Set theme to ${nextTheme}`} onPress={() => Settings.setTheme(nextTheme)} />
215 …. When you reload the app, you'll see the theme has changed. This is because we're never fetching …
217 ## 5. Emit change events for the theme value
219 …theme value by emitting a change event when the value changes. We'll use the [Events](/modules/mod…
232 Function("setTheme") { (theme: String) -> Void in
233 UserDefaults.standard.set(theme, forKey:"theme")
235 "theme": theme
240 UserDefaults.standard.string(forKey: "theme") ?? "system"
265 Function("setTheme") { theme: String ->
266 getPreferences().edit().putString("theme", theme).commit()
267 [email protected]("onChangeTheme", bundleOf("theme" to theme))
271 return@Function getPreferences().getString("theme", "system")
293 theme: string;
304 export function setTheme(theme: string): void {
305 return ExpoSettingsModule.setTheme(theme);
317 const [theme, setTheme] = React.useState<string>(Settings.getTheme());
320 const subscription = Settings.addThemeListener(({ theme: newTheme }) => {
327 // Toggle between dark and light theme
328 const nextTheme = theme === 'dark' ? 'light' : 'dark';
333 <Button title={`Set theme to ${nextTheme}`} onPress={() => Settings.setTheme(nextTheme)} />
341 …the `Settings.setTheme()` API in its current form, because we can set the theme to any string valu…
354 Function("setTheme") { (theme: Theme) -> Void in
355 UserDefaults.standard.set(theme.rawValue, forKey:"theme")
357 "theme": theme.rawValue
362 UserDefaults.standard.string(forKey: "theme") ?? Theme.system.rawValue
392 Function("setTheme") { theme: Theme ->
393 getPreferences().edit().putString("theme", theme.value).commit()
394 [email protected]("onChangeTheme", bundleOf("theme" to theme.value))
398 return@Function getPreferences().getString("theme", Theme.SYSTEM.value)
429 theme: Theme;
440 export function setTheme(theme: Theme): void {
441 return ExpoSettingsModule.setTheme(theme);
447 If we change `Settings.setTheme(nextTheme)` to `Settings.setTheme("not-a-real-theme")`, TypeScript …
452 → Caused by: EnumNoSuchValueException: 'not-a-real-theme' is not present in Theme enum, it must be …
455 We can see from the last line of the error message that `not-a-real-theme` is not a valid value for…