2021-10-20 19:29:21 +00:00
|
|
|
import React from 'react';
|
2022-02-11 09:49:49 +00:00
|
|
|
import { Text, TouchableRipple } from 'react-native-paper';
|
2021-10-20 19:29:21 +00:00
|
|
|
|
|
|
|
import { Icon } from '../../../base/icons';
|
2022-11-22 16:13:36 +00:00
|
|
|
|
|
|
|
import { navigationStyles } from './styles';
|
2021-10-20 19:29:21 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
2022-02-11 09:49:49 +00:00
|
|
|
/**
|
|
|
|
* Is the button disabled?
|
|
|
|
*/
|
|
|
|
disabled?: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Label of the button.
|
|
|
|
*/
|
|
|
|
label?: string,
|
|
|
|
|
2021-10-20 19:29:21 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the {@code HeaderNavigationButton} is clicked/pressed.
|
|
|
|
*/
|
2022-02-11 09:49:49 +00:00
|
|
|
onPress?: Function,
|
2021-10-20 19:29:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The ImageSource to be rendered as image.
|
|
|
|
*/
|
2022-02-11 09:49:49 +00:00
|
|
|
src?: Object,
|
2021-10-20 19:29:21 +00:00
|
|
|
|
|
|
|
/**
|
2022-02-11 09:49:49 +00:00
|
|
|
* Header has two actions.
|
2021-10-20 19:29:21 +00:00
|
|
|
*/
|
2022-02-11 09:49:49 +00:00
|
|
|
twoActions?: boolean
|
2021-10-20 19:29:21 +00:00
|
|
|
}
|
|
|
|
|
2022-02-11 09:49:49 +00:00
|
|
|
const HeaderNavigationButton
|
|
|
|
= ({
|
|
|
|
disabled,
|
|
|
|
label,
|
|
|
|
onPress,
|
|
|
|
src,
|
|
|
|
twoActions
|
|
|
|
}: Props) =>
|
|
|
|
(
|
|
|
|
<>
|
|
|
|
{
|
|
|
|
src ? (
|
2022-06-08 13:26:04 +00:00
|
|
|
<TouchableRipple
|
2022-02-11 09:49:49 +00:00
|
|
|
onPress = { onPress }
|
2022-11-22 19:50:16 +00:00
|
|
|
style = { navigationStyles.headerNavigationButtonIcon } >
|
2022-02-11 09:49:49 +00:00
|
|
|
<Icon
|
2022-06-08 13:26:04 +00:00
|
|
|
size = { 24 }
|
2022-11-22 19:50:16 +00:00
|
|
|
src = { src } />
|
2022-06-08 13:26:04 +00:00
|
|
|
</TouchableRipple>
|
2022-02-11 09:49:49 +00:00
|
|
|
) : (
|
|
|
|
<TouchableRipple
|
|
|
|
disabled = { disabled }
|
|
|
|
onPress = { onPress }
|
2022-11-22 16:13:36 +00:00
|
|
|
style = { navigationStyles.headerNavigationButtonText } >
|
2022-02-11 09:49:49 +00:00
|
|
|
<Text
|
|
|
|
style = {
|
|
|
|
twoActions
|
2022-11-22 16:13:36 +00:00
|
|
|
? navigationStyles.headerNavigationTextBold
|
|
|
|
: navigationStyles.headerNavigationText
|
2022-02-11 09:49:49 +00:00
|
|
|
}>
|
|
|
|
{ label }
|
|
|
|
</Text>
|
|
|
|
</TouchableRipple>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
2021-10-20 19:29:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
export default HeaderNavigationButton;
|