navigation

master
Netcup Gituser 2023-12-01 14:07:40 +01:00
parent 408be36ddf
commit 67115e06cd
2 changed files with 26 additions and 60 deletions

7
commit_and_push.sh Executable file
View File

@ -0,0 +1,7 @@
git add *
read -p "Commit message: " commit_message
git commit -m "$commit_message"
git push -u origin main

View File

@ -69,6 +69,8 @@ function ChatsTabAnim(props: any) {
); );
} }
const tabBarIcons = ['account-circle', 'calendar-month', 'map', 'chat'];
function CustomTabBar(props: BottomTabBarProps) { function CustomTabBar(props: BottomTabBarProps) {
const {state, descriptors, navigation} = props; const {state, descriptors, navigation} = props;
@ -110,8 +112,7 @@ function CustomTabBar(props: BottomTabBarProps) {
}); });
}; };
console.log('isFocused', isFocused); // TODO: retrieve colors from theme
const gradientColors = isFocused const gradientColors = isFocused
? ['#931278', '#6030da'] ? ['#931278', '#6030da']
: ['#26263f', '#26263f']; : ['#26263f', '#26263f'];
@ -120,26 +121,14 @@ function CustomTabBar(props: BottomTabBarProps) {
<TouchableOpacity <TouchableOpacity
key={route.key} key={route.key}
accessibilityRole="button" accessibilityRole="button"
accessibilityState={isFocused ? ['selected'] : []} //accessibilityState={isFocused ? ['selected'] : []}
accessibilityLabel={options.tabBarAccessibilityLabel} //accessibilityLabel={options.tabBarAccessibilityLabel}
onPress={onPress} onPress={onPress}
onLongPress={onLongPress} onLongPress={onLongPress}
style={{ style={{
/*flex: 1,
alignItems: 'center',
justifyContent: 'center',
//backgroundColor: '#26263f',
backgroundColor: 'red',
padding: 10,
borderRadius: 20,
marginRight: state.routes.length - 1 !== index ? 4 : 0,*/
flex: 1, flex: 1,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
//backgroundColor: '#26263f',
//backgroundColor: 'red',
// padding: 10,
borderRadius: 20, borderRadius: 20,
marginRight: state.routes.length - 1 !== index ? 4 : 0, marginRight: state.routes.length - 1 !== index ? 4 : 0,
}}> }}>
@ -148,18 +137,20 @@ function CustomTabBar(props: BottomTabBarProps) {
start={{x: 0, y: 1}} start={{x: 0, y: 1}}
end={{x: 1, y: 0}} end={{x: 1, y: 0}}
style={{ style={{
padding: 10, paddingTop: 4,
paddingBottom: 4,
borderRadius: 20, borderRadius: 20,
width: '100%', width: '100%',
alignItems: 'center', alignItems: 'center',
//marginRight: state.routes.length - 1 !== index ? 4 : 0,
}}> }}>
<Text <MaterialIcon
style={{ name={tabBarIcons[index]}
color: isFocused ? '#fff' : '#ccc', color={isFocused ? '#fff' : '#ccc'}
}}> size={20}
{label} />
</Text> {isFocused && (
<Text style={{color: '#fff'}}>{label.toString()}</Text>
)}
</LinearGradient> </LinearGradient>
</TouchableOpacity> </TouchableOpacity>
); );
@ -173,42 +164,10 @@ function HomeStack() {
<Tab.Navigator <Tab.Navigator
tabBar={props => <CustomTabBar {...props} />} tabBar={props => <CustomTabBar {...props} />}
screenOptions={{headerShown: false, unmountOnBlur: false}}> screenOptions={{headerShown: false, unmountOnBlur: false}}>
<Tab.Screen <Tab.Screen name="Profile" component={ProfileTabAnim} />
name="Profile" <Tab.Screen name="Calendar" component={CalendarTabAnim} />
component={ProfileTabAnim} <Tab.Screen name="Map" component={MapTabAnim} />
options={{ <Tab.Screen name="Chats" component={ChatsTabAnim} />
tabBarIcon: ({color, size}) => (
<MaterialIcon name="chat" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="Calendar"
component={CalendarTabAnim}
options={{
tabBarIcon: ({color, size}) => (
<MaterialIcon name="account-circle" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="Map"
component={MapTabAnim}
options={{
tabBarIcon: ({color, size}) => (
<MaterialIcon name="map" color={color} size={size} />
),
}}
/>
<Tab.Screen
name="Chats"
component={ChatsTabAnim}
options={{
tabBarIcon: ({color, size}) => (
<MaterialIcon name="map" color={color} size={size} />
),
}}
/>
</Tab.Navigator> </Tab.Navigator>
); );
} }