vn-verdnaturachat/app/containers/HeaderButton.js

108 lines
3.1 KiB
JavaScript
Raw Normal View History

2019-03-12 16:23:06 +00:00
import React from 'react';
import PropTypes from 'prop-types';
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-12-04 16:39:53 +00:00
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
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={themes[theme].headerTintColor}
2019-12-04 16:39:53 +00:00
/>
)));
2019-03-12 16:23:06 +00:00
export const CustomHeaderButtons = React.memo(props => (
<HeaderButtons
HeaderButtonComponent={CustomHeaderButton}
{...props}
/>
));
export const DrawerButton = React.memo(({ navigation, testID, ...otherProps }) => (
2019-03-12 16:23:06 +00:00
<CustomHeaderButtons left>
2020-07-27 19:53:33 +00:00
<Item title='drawer' iconName='hamburguer' onPress={navigation.toggleDrawer} testID={testID} {...otherProps} />
2019-03-12 16:23:06 +00:00
</CustomHeaderButtons>
));
export const CloseModalButton = React.memo(({
navigation, testID, onPress = () => navigation.pop(), ...props
}) => (
2019-03-12 16:23:06 +00:00
<CustomHeaderButtons left>
2020-07-27 19:53:33 +00:00
<Item title='close' iconName='close' onPress={onPress} testID={testID} {...props} />
2019-03-12 16:23:06 +00:00
</CustomHeaderButtons>
));
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-07-27 19:53:33 +00:00
: <Item title='close' iconName='close' 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>
2020-07-27 19:53:33 +00:00
<Item title='more' iconName='kebab' onPress={onPress} testID={testID} />
2019-03-12 16:23:06 +00:00
</CustomHeaderButtons>
));
export const SaveButton = React.memo(({ onPress, testID, ...props }) => (
2019-12-18 21:13:11 +00:00
<CustomHeaderButtons>
<Item title='save' iconName='download' onPress={onPress} testID={testID} {...props} />
2019-12-18 21:13:11 +00:00
</CustomHeaderButtons>
));
[NEW] User notification preferences (#2403) * Button to preferences view Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Create screen to preferences and listItem to notifications Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Refactoring NotificationPreferencesView Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * List notification preferences Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Adding translations to labels Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * SetUserPreferences api call Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Saving new user preference in API Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Fix lint Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Add in-app notification test Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Fix in app mentions preference Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Improve object in testInAppNotification Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Removing improper options for NotificationpreferencesView Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Adding API version Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Use redux in UserNotificationPrefView Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Remove in app test Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Use components from another view Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Removing verification for testing in-app notifications Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Move to ProfileView Co-authored-by: Diego Mello <diegolmello@gmail.com>
2020-08-21 13:30:11 +00:00
export const PreferencesButton = React.memo(({ onPress, testID, ...props }) => (
<CustomHeaderButtons>
<Item title='preferences' iconName='settings' onPress={onPress} testID={testID} {...props} />
</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,
testID: PropTypes.string.isRequired,
onPress: PropTypes.func
2019-03-12 16:23:06 +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
};
[NEW] User notification preferences (#2403) * Button to preferences view Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Create screen to preferences and listItem to notifications Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Refactoring NotificationPreferencesView Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * List notification preferences Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Adding translations to labels Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * SetUserPreferences api call Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Saving new user preference in API Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Fix lint Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Add in-app notification test Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Fix in app mentions preference Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Improve object in testInAppNotification Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Removing improper options for NotificationpreferencesView Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Adding API version Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Use redux in UserNotificationPrefView Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Remove in app test Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Use components from another view Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Removing verification for testing in-app notifications Signed-off-by: Ezequiel De Oliveira <ezequiel1de1oliveira@gmail.com> * Move to ProfileView Co-authored-by: Diego Mello <diegolmello@gmail.com>
2020-08-21 13:30:11 +00:00
PreferencesButton.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 };