forked from Project-N-E-K-O/N.E.K.O.-RN
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path_layout.tsx
More file actions
116 lines (108 loc) · 3.01 KB
/
_layout.tsx
File metadata and controls
116 lines (108 loc) · 3.01 KB
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
import { Tabs } from 'expo-router';
import React from 'react';
import { Ionicons } from '@expo/vector-icons';
import { Platform, StyleSheet, TouchableOpacity, View, Text } from 'react-native';
import { BlurView } from 'expo-blur';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import * as Haptics from 'expo-haptics';
import { useTheme } from '@/constants/ThemeContext';
function GlassTabBar({ state, descriptors, navigation }: any) {
const theme = useTheme();
const cc = theme.colors;
const insets = useSafeAreaInsets();
return (
<BlurView
intensity={theme.isDark ? 40 : 60}
tint={theme.isDark ? 'dark' : 'light'}
style={[
styles.tabBar,
{
paddingBottom: Math.max(insets.bottom, 8),
borderColor: cc.border,
},
]}
>
{state.routes.map((route: any, index: number) => {
const { options } = descriptors[route.key];
const isFocused = state.index === index;
const label = options.title ?? route.name;
const Icon = options.tabBarIcon;
const onPress = () => {
if (Platform.OS === 'ios') {
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
}
const event = navigation.emit({ type: 'tabPress', target: route.key, canPreventDefault: true });
if (!isFocused && !event.defaultPrevented) {
navigation.navigate(route.name);
}
};
return (
<TouchableOpacity
key={route.key}
onPress={onPress}
style={[
styles.tabItem,
isFocused && { backgroundColor: cc.accentSoft },
]}
activeOpacity={0.7}
>
{Icon && <Icon size={22} color={isFocused ? cc.accent : cc.textMuted} />}
<Text
style={[
styles.tabLabel,
{ color: isFocused ? cc.accent : cc.textMuted },
]}
>
{label}
</Text>
</TouchableOpacity>
);
})}
</BlurView>
);
}
const styles = StyleSheet.create({
tabBar: {
flexDirection: 'row',
borderTopWidth: 1,
paddingTop: 6,
},
tabItem: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
gap: 3,
paddingVertical: 6,
borderRadius: 12,
},
tabLabel: {
fontSize: 11,
fontWeight: '500',
},
});
export default function TabLayout() {
const theme = useTheme();
return (
<Tabs
tabBar={(props) => <GlassTabBar {...props} />}
screenOptions={{
headerShown: false,
}}
>
<Tabs.Screen
name="index"
options={{
title: 'Home',
tabBarIcon: ({ color, size }) => <Ionicons name="home-outline" size={size} color={color} />,
}}
/>
<Tabs.Screen
name="main"
options={{
title: 'Main UI',
tabBarIcon: ({ color, size }) => <Ionicons name="happy-outline" size={size} color={color} />,
}}
/>
</Tabs>
);
}