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';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { isIOS, isAndroid } from '../utils/deviceInfo';
|
|
|
|
import { themes } from '../constants/colors';
|
2019-07-29 16:33:28 +00:00
|
|
|
import I18n from '../i18n';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { withTheme } from '../theme';
|
2019-03-12 16:23:06 +00:00
|
|
|
|
2019-03-25 20:20:24 +00:00
|
|
|
export const headerIconSize = 23;
|
2019-03-12 16:23:06 +00:00
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
const CustomHeaderButton = React.memo(withTheme(({ theme, ...props }) => (
|
|
|
|
<HeaderButton
|
|
|
|
{...props}
|
|
|
|
IconComponent={CustomIcon}
|
|
|
|
iconSize={headerIconSize}
|
|
|
|
color={
|
|
|
|
isAndroid
|
|
|
|
? themes[theme].headerTitleColor
|
|
|
|
: themes[theme].headerTintColor
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)));
|
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>
|
|
|
|
));
|
|
|
|
|
2020-03-30 19:20:50 +00:00
|
|
|
export const CloseModalButton = React.memo(({ navigation, testID, onPress = () => navigation.pop() }) => (
|
2019-03-12 16:23:06 +00:00
|
|
|
<CustomHeaderButtons left>
|
2020-06-05 13:28:58 +00:00
|
|
|
<Item title='close' iconName='Cross' onPress={onPress} testID={testID} />
|
2019-03-12 16:23:06 +00:00
|
|
|
</CustomHeaderButtons>
|
|
|
|
));
|
|
|
|
|
2020-03-30 20:19:01 +00:00
|
|
|
export const CancelModalButton = React.memo(({ onPress, testID }) => (
|
2019-07-18 17:44:02 +00:00
|
|
|
<CustomHeaderButtons left>
|
|
|
|
{isIOS
|
2019-07-29 16:33:28 +00:00
|
|
|
? <Item title={I18n.t('Cancel')} onPress={onPress} testID={testID} />
|
2020-06-05 13:28:58 +00:00
|
|
|
: <Item title='close' iconName='Cross' onPress={onPress} testID={testID} />
|
2019-07-18 17:44:02 +00:00
|
|
|
}
|
|
|
|
</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>
|
|
|
|
));
|
|
|
|
|
2019-12-18 21:13:11 +00:00
|
|
|
export const SaveButton = React.memo(({ onPress, testID }) => (
|
|
|
|
<CustomHeaderButtons>
|
2020-06-05 13:28:58 +00:00
|
|
|
<Item title='save' iconName='download' onPress={onPress} testID={testID} />
|
2019-12-18 21:13:11 +00:00
|
|
|
</CustomHeaderButtons>
|
|
|
|
));
|
|
|
|
|
2019-03-12 16:23:06 +00:00
|
|
|
export const LegalButton = React.memo(({ navigation, testID }) => (
|
|
|
|
<MoreButton onPress={() => navigation.navigate('LegalView')} testID={testID} />
|
|
|
|
));
|
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
CustomHeaderButton.propTypes = {
|
|
|
|
theme: PropTypes.string
|
|
|
|
};
|
2019-03-12 16:23:06 +00:00
|
|
|
DrawerButton.propTypes = {
|
|
|
|
navigation: PropTypes.object.isRequired,
|
|
|
|
testID: PropTypes.string.isRequired
|
|
|
|
};
|
|
|
|
CloseModalButton.propTypes = {
|
|
|
|
navigation: PropTypes.object.isRequired,
|
2020-03-30 19:20:50 +00:00
|
|
|
testID: PropTypes.string.isRequired,
|
|
|
|
onPress: PropTypes.func
|
2019-03-12 16:23:06 +00:00
|
|
|
};
|
2020-03-30 20:19:01 +00:00
|
|
|
CancelModalButton.propTypes = {
|
2019-07-18 17:44:02 +00:00
|
|
|
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
|
|
|
|
};
|
2019-12-18 21:13:11 +00:00
|
|
|
SaveButton.propTypes = {
|
|
|
|
onPress: PropTypes.func.isRequired,
|
|
|
|
testID: PropTypes.string.isRequired
|
|
|
|
};
|
2019-03-12 16:23:06 +00:00
|
|
|
LegalButton.propTypes = {
|
|
|
|
navigation: PropTypes.object.isRequired,
|
|
|
|
testID: PropTypes.string.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export { Item };
|