2019-03-12 16:23:06 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2019-08-07 13:51:34 +00:00
|
|
|
import { HeaderButtons, HeaderButton, Item } from 'react-navigation-header-buttons';
|
2019-03-12 16:23:06 +00:00
|
|
|
|
|
|
|
import { CustomIcon } from '../lib/Icons';
|
|
|
|
import { isIOS } from '../utils/deviceInfo';
|
2019-03-29 19:36:07 +00:00
|
|
|
import { COLOR_PRIMARY, COLOR_WHITE } from '../constants/colors';
|
2019-07-29 16:33:28 +00:00
|
|
|
import I18n from '../i18n';
|
2019-03-12 16:23:06 +00:00
|
|
|
|
2019-03-29 19:36:07 +00:00
|
|
|
const color = isIOS ? COLOR_PRIMARY : COLOR_WHITE;
|
2019-03-25 20:20:24 +00:00
|
|
|
export const headerIconSize = 23;
|
2019-03-12 16:23:06 +00:00
|
|
|
|
|
|
|
const CustomHeaderButton = React.memo(props => (
|
2019-03-25 20:20:24 +00:00
|
|
|
<HeaderButton {...props} IconComponent={CustomIcon} iconSize={headerIconSize} color={color} />
|
2019-03-12 16:23:06 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
export const CustomHeaderButtons = React.memo(props => (
|
|
|
|
<HeaderButtons
|
|
|
|
HeaderButtonComponent={CustomHeaderButton}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
2019-05-20 20:43:50 +00:00
|
|
|
export const DrawerButton = React.memo(({ navigation, testID, ...otherProps }) => (
|
2019-03-12 16:23:06 +00:00
|
|
|
<CustomHeaderButtons left>
|
2019-05-20 20:43:50 +00:00
|
|
|
<Item title='drawer' iconName='customize' onPress={navigation.toggleDrawer} testID={testID} {...otherProps} />
|
2019-03-12 16:23:06 +00:00
|
|
|
</CustomHeaderButtons>
|
|
|
|
));
|
|
|
|
|
|
|
|
export const CloseModalButton = React.memo(({ navigation, testID }) => (
|
|
|
|
<CustomHeaderButtons left>
|
|
|
|
<Item title='close' iconName='cross' onPress={() => navigation.pop()} testID={testID} />
|
|
|
|
</CustomHeaderButtons>
|
|
|
|
));
|
|
|
|
|
2019-07-18 17:44:02 +00:00
|
|
|
export const CloseShareExtensionButton = React.memo(({ onPress, testID }) => (
|
|
|
|
<CustomHeaderButtons left>
|
|
|
|
{isIOS
|
2019-07-29 16:33:28 +00:00
|
|
|
? <Item title={I18n.t('Cancel')} onPress={onPress} testID={testID} />
|
2019-07-18 17:44:02 +00:00
|
|
|
: <Item title='close' iconName='cross' onPress={onPress} testID={testID} />
|
|
|
|
}
|
|
|
|
</CustomHeaderButtons>
|
|
|
|
));
|
|
|
|
|
2019-03-12 16:23:06 +00:00
|
|
|
export const MoreButton = React.memo(({ onPress, testID }) => (
|
|
|
|
<CustomHeaderButtons>
|
|
|
|
<Item title='more' iconName='menu' onPress={onPress} testID={testID} />
|
|
|
|
</CustomHeaderButtons>
|
|
|
|
));
|
|
|
|
|
|
|
|
export const LegalButton = React.memo(({ navigation, testID }) => (
|
|
|
|
<MoreButton onPress={() => navigation.navigate('LegalView')} testID={testID} />
|
|
|
|
));
|
|
|
|
|
|
|
|
DrawerButton.propTypes = {
|
|
|
|
navigation: PropTypes.object.isRequired,
|
|
|
|
testID: PropTypes.string.isRequired
|
|
|
|
};
|
|
|
|
CloseModalButton.propTypes = {
|
|
|
|
navigation: PropTypes.object.isRequired,
|
|
|
|
testID: PropTypes.string.isRequired
|
|
|
|
};
|
2019-07-18 17:44:02 +00:00
|
|
|
CloseShareExtensionButton.propTypes = {
|
|
|
|
onPress: PropTypes.func.isRequired,
|
|
|
|
testID: PropTypes.string.isRequired
|
|
|
|
};
|
2019-03-12 16:23:06 +00:00
|
|
|
MoreButton.propTypes = {
|
|
|
|
onPress: PropTypes.func.isRequired,
|
|
|
|
testID: PropTypes.string.isRequired
|
|
|
|
};
|
|
|
|
LegalButton.propTypes = {
|
|
|
|
navigation: PropTypes.object.isRequired,
|
|
|
|
testID: PropTypes.string.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export { Item };
|