-
Notifications
You must be signed in to change notification settings - Fork 783
Expand file tree
/
Copy pathTabNavigator.tsx
More file actions
93 lines (87 loc) · 2.1 KB
/
TabNavigator.tsx
File metadata and controls
93 lines (87 loc) · 2.1 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
import React, { useState } from 'react';
import {
View,
Text,
TouchableOpacity,
StyleSheet,
SafeAreaView,
} from 'react-native';
import { RemoteAudioPlayer } from './RemoteAudioPlayer';
import { LocalAudioPlayer } from './LocalAudioPlayer';
import { AudioTester } from './AudioTester';
type TabType = 'remote' | 'local' | 'tests';
export const TabNavigator = () => {
const [activeTab, setActiveTab] = useState<TabType>('remote');
const renderTabButton = (tab: TabType, title: string) => (
<TouchableOpacity
style={[styles.tabButton, activeTab === tab && styles.activeTabButton]}
onPress={() => setActiveTab(tab)}
>
<Text
style={[
styles.tabButtonText,
activeTab === tab && styles.activeTabButtonText,
]}
>
{title}
</Text>
</TouchableOpacity>
);
const renderContent = () => {
switch (activeTab) {
case 'remote':
return <RemoteAudioPlayer />;
case 'local':
return <LocalAudioPlayer />;
case 'tests':
return <AudioTester />;
default:
return <RemoteAudioPlayer />;
}
};
return (
<SafeAreaView style={styles.container}>
<View style={styles.tabContainer}>
{renderTabButton('remote', 'Remote Audio')}
{renderTabButton('local', 'Local Audio')}
{renderTabButton('tests', 'Tests')}
</View>
<View style={styles.contentContainer}>{renderContent()}</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f5f5f5',
},
tabContainer: {
flexDirection: 'row',
backgroundColor: '#fff',
elevation: 2,
shadowColor: '#000',
shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.2,
shadowRadius: 2,
},
tabButton: {
flex: 1,
paddingVertical: 16,
alignItems: 'center',
backgroundColor: '#fff',
},
activeTabButton: {
backgroundColor: '#1976D2',
},
tabButtonText: {
fontSize: 16,
fontWeight: '600',
color: '#666',
},
activeTabButtonText: {
color: '#fff',
},
contentContainer: {
flex: 1,
},
});