template_0205
This commit is contained in:
25
RN_TEMPLATE/app/theme/context.utils.ts
Normal file
25
RN_TEMPLATE/app/theme/context.utils.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { Theme } from "./types"
|
||||
|
||||
const systemui = require("expo-system-ui")
|
||||
|
||||
/**
|
||||
* Set the system UI background color to the given color. This is only available if the app has
|
||||
* installed expo-system-ui.
|
||||
*
|
||||
* @param color The color to set the system UI background to
|
||||
*/
|
||||
export const setSystemUIBackgroundColor = (color: string) => {
|
||||
if (systemui) {
|
||||
systemui.setBackgroundColorAsync(color)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the app's native background color to match the theme.
|
||||
* This is only available if the app has installed expo-system-ui
|
||||
*
|
||||
* @param theme The theme object to use for the background color
|
||||
*/
|
||||
export const setImperativeTheming = (theme: Theme) => {
|
||||
setSystemUIBackgroundColor(theme.colors.background)
|
||||
}
|
||||
Reference in New Issue
Block a user