-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathApp.js
157 lines (146 loc) · 5.62 KB
/
App.js
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import React from 'react'
import {
Image,
SafeAreaView,
StyleSheet,
View
} from 'react-native'
import TipProvider, { Tip } from './Tip'
import Icon from 'react-native-vector-icons/Ionicons'
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'
import HomeScreen from './HomeScreen'
import AnotherScreen from './AnotherScreen'
export const ThemeContext = React.createContext('light')
const Tab = createMaterialTopTabNavigator()
const HomeStack = createStackNavigator()
const AnotherStack = createStackNavigator()
function HomeStackScreen() {
return (
<HomeStack.Navigator>
<HomeStack.Screen name="Home"
options={{ title: 'react-native-tip examples' }}
component={HomeScreen} />
</HomeStack.Navigator>
)
}
function AnotherStackScreen() {
return (
<AnotherStack.Navigator>
<AnotherStack.Screen name="AnotherScreen" component={AnotherScreen} />
</AnotherStack.Navigator>
)
}
const App = () => {
const [isDarkMode, setIsDarkMode] = React.useState(false)
const onToggleDarkMode = () => setIsDarkMode(previousState => !previousState)
return (
<ThemeContext.Provider value={{ isDarkMode, onToggleDarkMode }}>
<SafeAreaView style={styles.container}>
<NavigationContainer>
<Tab.Navigator
tabBarPosition="bottom"
lazy={false}
tabBarOptions={{
activeTintColor: 'white',
inactiveTintColor: 'grey',
tabStyle: { padding: 0 },
iconStyle: {
width: '100%',
height: '100%',
alignItems: 'center',
justifyContent: 'center'
},
style: { backgroundColor: '#1a1a1a' },
showLabel: false,
showIcon: true,
renderIndicator: () => null
}}
>
<Tab.Screen
name="HomeScreen"
component={HomeStackScreen}
options={{
tabBarIcon: ({ focused, color }) =>
<Tip
id='tab1'
title="This is tab 1"
body="Description..."
pulseColor="white"
>
<View style={{ borderRadius: 50, padding: 5 }}>
<Icon
name='home'
color={color}
size={35}
/>
</View>
</Tip>
}}
/>
<Tab.Screen
name="AnotherScreen"
component={AnotherStackScreen}
options={{
tabBarIcon: ({ focused, color }) =>
<Tip
id='tab2'
title="This is tab 2"
body="Description Description..."
pulseColor="white"
>
<View style={{ borderRadius: 50, padding: 5 }}>
<Icon
name='settings-outline'
color={color}
size={35}
/>
</View>
</Tip>
}}
/>
</Tab.Navigator>
</NavigationContainer>
<TipProvider
overlayOpacity={0.5}
titleStyle={{
fontWeight: 'bold',
fontSize: 18,
marginBottom: 10
}}
bodyStyle={{
fontSize: 16
}}
tipContainerStyle={{
padding: 20,
borderRadius: 20,
maxWidth: 350,
elevation: 5
}}
darkMode={isDarkMode}
prevNextTextStyle={{
}}
prevNextButtonStyle={{
}}
/>
</SafeAreaView>
</ThemeContext.Provider>
)
}
export default App
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white'
},
title: {
color: 'black',
padding: 20,
fontSize: 24,
textAlign: 'center',
fontWeight: 'bold',
position: 'absolute',
top: 10
}
})