-
Notifications
You must be signed in to change notification settings - Fork 3k
/
HeaderWithCloseButton.js
91 lines (79 loc) · 2.87 KB
/
HeaderWithCloseButton.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
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
import React from 'react';
import PropTypes from 'prop-types';
import {
View, TouchableOpacity,
} from 'react-native';
import styles from '../styles/styles';
import Header from './Header';
import Icon from './Icon';
import {Close, Download, BackArrow} from './Icon/Expensicons';
const propTypes = {
/** Title of the Header */
title: PropTypes.string,
/** Method to trigger when pressing download button of the header */
onDownloadButtonPress: PropTypes.func,
/** Method to trigger when pressing close button of the header */
onCloseButtonPress: PropTypes.func,
/** Method to trigger when pressing back button of the header */
onBackButtonPress: PropTypes.func,
/** Whether we should show a back icon */
shouldShowBackButton: PropTypes.bool,
/** Fontsize for the text in the Header */
textSize: PropTypes.oneOf(['default', 'large']),
/** Whether we should show a border on the bottom of the Header */
shouldShowBorderBottom: PropTypes.bool,
};
const defaultProps = {
title: '',
onDownloadButtonPress: () => {},
onCloseButtonPress: () => {},
onBackButtonPress: () => {},
shouldShowBackButton: false,
textSize: 'large',
shouldShowBorderBottom: false,
};
const HeaderWithCloseButton = props => (
<View style={[styles.headerBar, props.shouldShowBorderBottom && styles.borderBottom]}>
<View style={[
styles.dFlex,
styles.flexRow,
styles.alignItemsCenter,
styles.flexGrow1,
styles.justifyContentBetween,
styles.overflowHidden,
]}
>
{props.shouldShowBackButton && (
<TouchableOpacity
onPress={props.onBackButtonPress}
style={[styles.touchableButtonImage]}
>
<Icon src={BackArrow} />
</TouchableOpacity>
)}
<Header title={props.title} textSize={props.textSize} />
<View style={[styles.reportOptions, styles.flexRow]}>
{
props.title === 'Attachment' && (
<TouchableOpacity
onPress={props.onDownloadButtonPress}
style={[styles.touchableButtonImage]}
>
<Icon src={Download} />
</TouchableOpacity>
)
}
<TouchableOpacity
onPress={props.onCloseButtonPress}
style={[styles.touchableButtonImage]}
>
<Icon src={Close} />
</TouchableOpacity>
</View>
</View>
</View>
);
HeaderWithCloseButton.propTypes = propTypes;
HeaderWithCloseButton.defaultProps = defaultProps;
HeaderWithCloseButton.displayName = 'HeaderWithCloseButton';
export default HeaderWithCloseButton;