2021-09-13 20:41:05 +00:00
|
|
|
import React from 'react';
|
2022-08-11 14:50:03 +00:00
|
|
|
import { StackActions, useNavigation } from '@react-navigation/native';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
|
|
|
import I18n from '../../i18n';
|
2022-08-11 14:50:03 +00:00
|
|
|
import { isIOS } from '../../lib/methods/helpers';
|
2021-09-13 20:41:05 +00:00
|
|
|
import Container from './HeaderButtonContainer';
|
2022-07-06 13:23:02 +00:00
|
|
|
import Item, { IHeaderButtonItem } from './HeaderButtonItem';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-07-06 13:23:02 +00:00
|
|
|
interface IHeaderButtonCommon extends IHeaderButtonItem {
|
2022-03-24 19:55:01 +00:00
|
|
|
navigation?: any; // TODO: Evaluate proper type
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Left
|
2022-03-24 19:55:01 +00:00
|
|
|
export const Drawer = React.memo(
|
2022-03-25 14:35:25 +00:00
|
|
|
({ navigation, testID, onPress = () => navigation?.toggleDrawer(), ...props }: IHeaderButtonCommon) => (
|
2022-03-24 19:55:01 +00:00
|
|
|
<Container left>
|
|
|
|
<Item iconName='hamburguer' onPress={onPress} testID={testID} {...props} />
|
|
|
|
</Container>
|
|
|
|
)
|
|
|
|
);
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-08-11 14:50:03 +00:00
|
|
|
export const CloseModal = React.memo(({ testID, onPress, ...props }: IHeaderButtonCommon) => {
|
|
|
|
const { dispatch } = useNavigation();
|
|
|
|
return (
|
2021-09-13 20:41:05 +00:00
|
|
|
<Container left>
|
2022-08-11 14:50:03 +00:00
|
|
|
<Item
|
|
|
|
iconName='close'
|
|
|
|
onPress={arg => {
|
|
|
|
if (onPress) return onPress(arg);
|
|
|
|
dispatch(StackActions.pop());
|
|
|
|
}}
|
|
|
|
testID={testID}
|
|
|
|
{...props}
|
|
|
|
/>
|
2021-09-13 20:41:05 +00:00
|
|
|
</Container>
|
2022-08-11 14:50:03 +00:00
|
|
|
);
|
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-07-06 13:23:02 +00:00
|
|
|
export const CancelModal = React.memo(({ onPress, testID, ...props }: IHeaderButtonCommon) => (
|
2021-09-13 20:41:05 +00:00
|
|
|
<Container left>
|
|
|
|
{isIOS ? (
|
2022-07-06 13:23:02 +00:00
|
|
|
<Item title={I18n.t('Cancel')} onPress={onPress} testID={testID} {...props} />
|
2021-09-13 20:41:05 +00:00
|
|
|
) : (
|
2022-07-06 13:23:02 +00:00
|
|
|
<Item iconName='close' onPress={onPress} testID={testID} {...props} />
|
2021-09-13 20:41:05 +00:00
|
|
|
)}
|
|
|
|
</Container>
|
|
|
|
));
|
|
|
|
|
|
|
|
// Right
|
2022-07-06 13:23:02 +00:00
|
|
|
export const More = React.memo(({ onPress, testID, ...props }: IHeaderButtonCommon) => (
|
2021-09-13 20:41:05 +00:00
|
|
|
<Container>
|
2022-07-06 13:23:02 +00:00
|
|
|
<Item iconName='kebab' onPress={onPress} testID={testID} {...props} />
|
2021-09-13 20:41:05 +00:00
|
|
|
</Container>
|
|
|
|
));
|
|
|
|
|
2022-03-24 19:55:01 +00:00
|
|
|
export const Download = React.memo(({ onPress, testID, ...props }: IHeaderButtonCommon) => (
|
2021-09-13 20:41:05 +00:00
|
|
|
<Container>
|
2022-03-24 19:55:01 +00:00
|
|
|
<Item iconName='download' onPress={onPress} testID={testID} {...props} />
|
2021-09-13 20:41:05 +00:00
|
|
|
</Container>
|
|
|
|
));
|
|
|
|
|
2022-03-24 19:55:01 +00:00
|
|
|
export const Preferences = React.memo(({ onPress, testID, ...props }: IHeaderButtonCommon) => (
|
2021-09-13 20:41:05 +00:00
|
|
|
<Container>
|
2022-03-24 19:55:01 +00:00
|
|
|
<Item iconName='settings' onPress={onPress} testID={testID} {...props} />
|
2021-09-13 20:41:05 +00:00
|
|
|
</Container>
|
|
|
|
));
|
|
|
|
|
2022-03-25 14:35:25 +00:00
|
|
|
export const Legal = React.memo(
|
2022-07-06 13:23:02 +00:00
|
|
|
({ navigation, testID, onPress = () => navigation?.navigate('LegalView'), ...props }: IHeaderButtonCommon) => (
|
|
|
|
<More onPress={onPress} testID={testID} {...props} />
|
2022-03-25 14:35:25 +00:00
|
|
|
)
|
|
|
|
);
|