-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
129 lines (119 loc) · 3.41 KB
/
App.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
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
import React, {useRef, useState, useLayoutEffect} from 'react';
import {Text} from 'react-native';
import 'react-native-gesture-handler';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import {createStackNavigator} from '@react-navigation/stack';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {NavigationContainer} from '@react-navigation/native';
import Icon from 'react-native-vector-icons/Ionicons';
Icon.loadFont();
import {
Container,
Button,
StyledText,
StyledButton,
HeaderText,
StyledAnimatableView,
StyledSafeArea,
} from './styles';
function SettingsTab({navigation}) {
const [viewVisible, setStoreSwitcherVisibility] = useState(false);
const [invertCaret, setInvertCaret] = useState(false);
const [store, setStore] = useState('Kroger');
const view = useRef(null);
const bounce = async () => {
if (viewVisible) {
setInvertCaret(false);
view?.current?.fadeOutUp(800).then(() => {
setStoreSwitcherVisibility(false);
});
} else {
await setStoreSwitcherVisibility(true);
setInvertCaret(true);
view?.current?.fadeInDown(800).then((/* endState */) => {});
}
};
useLayoutEffect(() => {
navigation.setOptions({
tabBarVisible: false,
headerTitle: () => (
<Button onPress={bounce}>
<HeaderText>{`${store} ${!invertCaret ? '▼' : '▲'}`}</HeaderText>
</Button>
),
});
}, [navigation, store, viewVisible, invertCaret]);
const stores = [
'Amazon Fresh',
'Whole Foods',
'Kroger',
'Walmart..',
'Instacart',
];
return (
<StyledSafeArea>
<Container
style={{
flex: 1,
justifyContent: 'flex-start',
backgroundColor: 'white',
}}>
<Text>This is the shopping list content section....</Text>
{viewVisible && (
<StyledAnimatableView
animation={viewVisible ? 'fadeInDown' : 'fadeOutUp'}
easing="ease-out"
ref={view}
viewVisible={viewVisible}>
{stores.map((store) => (
<StyledButton
key={store}
onPress={() => {
setStore(store);
// setStoreSwitcherVisibility(false);
setInvertCaret(!invertCaret);
bounce();
}}>
<StyledText>{store}</StyledText>
</StyledButton>
))}
</StyledAnimatableView>
)}
</Container>
</StyledSafeArea>
);
}
const StackMenu = () => {
return (
<Stack.Navigator>
<Stack.Screen name="Menu" component={SettingsTab} />
</Stack.Navigator>
);
};
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
const App = () => {
return (
<SafeAreaProvider>
<NavigationContainer>
<Tab.Navigator
initialRouteName="Analytics"
screenOptions={() => ({
tabBarIcon: ({color, size}) => {
// You can return any component that you like here!
return (
<Icon
name={'ios-information-circle'}
size={size}
color={color}
/>
);
},
})}>
<Tab.Screen name="One Tab" component={StackMenu} />
</Tab.Navigator>
</NavigationContainer>
</SafeAreaProvider>
);
};
export default App;