-
Notifications
You must be signed in to change notification settings - Fork 0
/
TabNavigator.js
66 lines (59 loc) · 1.57 KB
/
TabNavigator.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
// TabNavigator.js
import React, { useState } from "react";
import { View, Text, Image, TouchableOpacity, StyleSheet } from "react-native";
const TabNavigator = ({ tabs }) => {
const [activeTab, setActiveTab] = useState(0);
const renderScreen = () => {
const TabComponent = tabs[activeTab].component;
return <TabComponent />;
};
return (
<View style={styles.container}>
{renderScreen()}
<View style={styles.navigationBar}>
{tabs.map((tab, index) => (
<TouchableOpacity
key={index}
style={[
styles.tabButton,
{
backgroundColor:
index === activeTab ? "#e0e0e0" : "transparent",
},
]}
onPress={() => setActiveTab(index)}
>
{tab.icon && (
<Image
source={tab.icon}
style={{ width: 27, height: 27 }} // 아이콘의 크기 조정
/>
)}
</TouchableOpacity>
))}
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
navigationBar: {
flexDirection: "row",
backgroundColor: "#f0f0f0",
justifyContent: "space-between", // 아이템 간의 간격을 최대로 설정
paddingVertical: 5,
paddingHorizontal: 15,
height: 90, // 네비게이션 바의 높이를 조정
},
tabButton: {
width: 75,
justifyContent: "center",
alignItems: "center",
borderRadius: 30,
margin: 1,
marginBottom: 30,
},
});
export default TabNavigator;