forked from dooley1001/hoard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuHeader.js
More file actions
124 lines (114 loc) · 2.75 KB
/
Copy pathMenuHeader.js
File metadata and controls
124 lines (114 loc) · 2.75 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
117
118
119
120
121
122
123
124
import React from 'react';
import {
Image,
TouchableOpacity,
StyleSheet,
View,
} from 'react-native';
import T from 'components/Typography';
import Icon from 'components/Icon';
import NavigationActions from 'lib/navigator';
import createStyles, { padding, colors, typography } from 'styles';
const BACK_ICON = require('assets/bck.png');
const CLOSE_ICON = require('assets/closeicon.png');
const MENU_ICON = require('assets/sidebar.png');
const goBack = () => NavigationActions.back();
const openMenu = () => NavigationActions.openDrawer();
function LeftActionComponent({ type }) {
if (!type) {
return null;
}
if (type === 'back' || type === 'cancel') {
return (
<View style={styles.leftActionContainer}>
<TouchableOpacity onPress={goBack}>
<Image source={type === 'back' ? BACK_ICON : CLOSE_ICON} />
</TouchableOpacity>
</View>
);
} else if (typeof type === 'object'){
return (
<View style={styles.leftActionContainer}>
{type}
</View>
);
}
}
function RightActionComponent({ type }) {
if (!type) {
return null;
}
if (type === 'menu') {
return (
<TouchableOpacity onPress={openMenu}>
<Image source={MENU_ICON} />
</TouchableOpacity>
);
} else if (typeof type === 'object'){
return type;
}
}
export default function MenuHeader({
leftAction,
rightAction,
title,
multipage,
currentPage,
totalPages
}) {
const headerStyle = leftAction
? styles.titleLight
: [createStyles().header, styles.titleBold];
return (
<View style={styles.container}>
<LeftActionComponent type={leftAction} />
<View style={styles.headerContainer}>
<T.Heading style={headerStyle}>{title}</T.Heading>
</View>
{multipage &&
<View style={styles.pagerContainer}>
<T.Light style={styles.pager}>{currentPage}/{totalPages}</T.Light>
</View>
}
<View style={styles.rightActionContainer}>
<RightActionComponent type={rightAction} />
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
paddingHorizontal: padding.md,
},
headerContainer: {
},
titleBold: {
color: colors.white,
},
titleLight: {
color: colors.grayLight,
fontSize: typography.size.md,
fontWeight: typography.weight.normal,
},
pagerContainer: {
},
pager: {
color: colors.grayLight,
fontSize: typography.size.md,
fontWeight: typography.weight.normal,
},
rightActionContainer: {
justifyContent: 'center',
alignItems: 'flex-end',
flex: 1,
},
rightActionText: {
color: colors.white,
fontSize: typography.size.md,
fontWeight: typography.weight.normal,
},
leftActionContainer: {
flex: 1,
}
})