-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
FooterTabBar.js
47 lines (43 loc) · 1.65 KB
/
FooterTabBar.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
'use strict';
import React from 'react';
import {
View,
Text,
Image, TouchableOpacity,
} from 'react-native';
import {TabMetadata} from './PageHistory';
import {iconData} from "./IconData";
import styles from './Styles';
import {useGlobalState} from "./Hooks";
import {FlexFrame, Icon, InterfaceText} from "./Misc";
export const FooterTabBar = ({selectedTabName, setTab}) => {
const {theme} = useGlobalState();
return (
<View style={[styles.footerBar, theme.mainTextPanel, theme.lightGreyBorder]}>
<FlexFrame dir={"row"} justifyContent={"space-between"}>
{
TabMetadata.namesWithIcons().map(({name, stringKey, icon: iconName}) => (
<FooterTabButton
key={name}
isSelected={name === selectedTabName}
stringKey={stringKey}
iconName={iconName}
setTab={setTab}
name={name}
/>
))
}
</FlexFrame>
</View>
);
};
const FooterTabButton = ({stringKey, name, iconName, isSelected, setTab}) => {
const {theme} = useGlobalState();
const onPress = () => setTab(name);
return (
<TouchableOpacity style={styles.footerButton} onPress={onPress}>
<Icon name={iconName} isSelected={isSelected} length={20}/>
<InterfaceText allowFontScaling={false} stringKey={stringKey} extraStyles={[styles.footerButtonText, theme.tertiaryText, isSelected ? theme.primaryText : undefined]} />
</TouchableOpacity>
);
};