-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnavbar.tsx
53 lines (48 loc) · 1.47 KB
/
navbar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React, { useState } from 'react';
import { SafeAreaView, Button, View, StyleSheet, ScrollView } from 'react-native';
import changeNavigationBarColor from 'react-native-navigation-bar-color';
import { hideNavigationBar } from 'react-native-navigation-bar-color';
import { showNavigationBar } from 'react-native-navigation-bar-color';
export default function App() {
const [isHidden, setIsHidden] = useState(false);
const colors = [
'#FF5733', '#33FF57', '#3357FF', '#FF33A1', '#33FFF6',
'#F3FF33', '#8D33FF', '#FF8833', '#33FFD1', '#FF3333'
];
const toggleNavigationBar = () => {
if (isHidden) {
showNavigationBar();
setIsHidden(false);
} else {
hideNavigationBar();
setIsHidden(true);
}
};
return (
<SafeAreaView style={styles.container}>
<ScrollView>
<Button title={isHidden ? 'Show Navigation Bar' : 'Hide Navigation Bar'} onPress={toggleNavigationBar} />
{colors.map((color, index) => (
<View style={styles.buttonContainer} key={index}>
<Button
title={`Set to Color ${index + 1}`}
color={color}
onPress={() => changeNavigationBarColor(color, true, true)}
/>
</View>
))}
</ScrollView>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
marginTop:100,
},
buttonContainer: {
marginVertical: 5,
marginHorizontal: 20,
}
});