-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenHeader.tsx
121 lines (101 loc) · 3.07 KB
/
ScreenHeader.tsx
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
117
118
119
120
121
import React, { FunctionComponent, useEffect, useState, useCallback } from 'react'
// Hooks
import { useNavigation } from '@react-navigation/native';
import { useTranslation } from 'react-i18next';
// Styles
import { Metrics, Colors, Fonts } from '../Theme';
// Utils
import AnimateDown from 'App/Helpers/MenuRenderer'
// Redux
// Components
import { StyleSheet, StatusBar, Text, View, TouchableOpacity } from 'react-native';
import Back from 'App/Assets/Images/Back'
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {
Menu,
MenuOptions,
MenuOption,
MenuTrigger,
renderers,
} from 'react-native-popup-menu';
import { SafeAreaView } from 'react-native-safe-area-context';
interface ScreenHeaderProps {
title: string,
back?: boolean,
menu?: boolean,
onBackPress?: () => void,
}
const ScreenHeader: FunctionComponent<ScreenHeaderProps> = ({
title,
back,
menu,
onBackPress,
}) => {
const { t } = useTranslation();
const navigation = useNavigation()
const onBackPressInternal = () => {
navigation.goBack()
onBackPress && onBackPress()
}
return (
<SafeAreaView style={{ backgroundColor: Colors.yellow }} edges={["top"]}>
<View style={styles.container}>
<StatusBar backgroundColor={Colors.statusBar} barStyle="light-content"/>
<TouchableOpacity style={styles.back} onPress={onBackPressInternal} disabled={!back} >
<Icon name="chevron-left" size={30} color={back ? Colors.black : Colors.transparent} />
</TouchableOpacity>
<Text style={styles.title}>{title}</Text>
<Menu renderer={AnimateDown} >
<MenuTrigger style={[styles.menuTrigger, !menu && { opacity: 0 }]} disabled={!menu} >
<Icon name="dots-vertical" size={30} color={Colors.black} />
</MenuTrigger>
<MenuOptions style={{ }}>
<MenuOption customStyles={{ optionWrapper: styles.menuItemWrapper }} onSelect={() => { navigation.navigate("SettingsScreen") }} >
<Text style={styles.menuItem}>{t("menu.itemSettings")}</Text>
</MenuOption>
</MenuOptions>
</Menu>
</View>
</SafeAreaView>
)
}
const styles = StyleSheet.create({
container: {
flexDirection: "row",
width: "100%",
height: Metrics.navBarHeight,
alignSelf: "stretch",
alignItems: "center",
justifyContent: 'space-between',
backgroundColor: Colors.yellow,
},
back: {
paddingHorizontal: Metrics.doubleBaseMargin,
paddingVertical: Metrics.baseMargin,
},
title: {
...Fonts.style.heading,
alignSelf: "center",
paddingTop: 3,
marginBottom: 7,
color: Colors.text
},
menuTrigger: {
width: Metrics.navBarHeight,
height: Metrics.navBarHeight,
alignItems: "center",
justifyContent: "center"
},
menuItemWrapper: {
height: Metrics.buttonHeight,
alignItems: "flex-end",
justifyContent: "center",
backgroundColor: Colors.yellow,
},
menuItem: {
...Fonts.style.regular,
marginHorizontal: Metrics.doubleBaseMargin,
color: Colors.text,
},
})
export default ScreenHeader