-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add api to change status bar and navigation bar colors
- Loading branch information
Showing
13 changed files
with
194 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
examples/expo/src/examples/AndroidStatusBarNavigationBarScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { useEffect } from 'react' | ||
import { Platform, Text, View } from 'react-native' | ||
import { UnistylesRuntime, createStyleSheet, useStyles } from 'react-native-unistyles' | ||
import { Button, DemoScreen } from '../components' | ||
|
||
export const AndroidStatusBarNavigationBarScreen: React.FunctionComponent = () => { | ||
const { styles, theme } = useStyles(stylesheet) | ||
|
||
useEffect(() => () => { | ||
UnistylesRuntime.statusBar.setColor() | ||
UnistylesRuntime.navigationBar.setColor() | ||
}, []) | ||
|
||
return ( | ||
<DemoScreen> | ||
<View style={styles.container}> | ||
<Text style={styles.text}> | ||
This screen presents how to change status bar / navigation bar colors with UnistylesRuntime | ||
</Text> | ||
{Platform.OS !== 'android' && ( | ||
<Text style={styles.bold}> | ||
Please open Android emulator to see the effect | ||
</Text> | ||
)} | ||
<Button | ||
color={theme.colors.accent} | ||
title="Set status bar color" | ||
onPress={() => UnistylesRuntime.statusBar.setColor(theme.colors.accent)} | ||
/> | ||
<Button | ||
color={theme.colors.accent} | ||
title="Set navigation bar color" | ||
onPress={() => UnistylesRuntime.navigationBar.setColor(theme.colors.accent)} | ||
/> | ||
</View> | ||
</DemoScreen> | ||
) | ||
} | ||
|
||
const stylesheet = createStyleSheet(theme => ({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
paddingHorizontal: 20, | ||
backgroundColor: theme.colors.backgroundColor, | ||
rowGap: 20 | ||
}, | ||
text: { | ||
textAlign: 'center', | ||
color: theme.colors.typography, | ||
fontSize: 14 | ||
}, | ||
bold: { | ||
fontWeight: 'bold' | ||
} | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters