Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

HeaderNavigationButton.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React from 'react';
  2. import { Text, TouchableRipple } from 'react-native-paper';
  3. import { Icon } from '../../../base/icons';
  4. import { navigationStyles } from './styles';
  5. type Props = {
  6. /**
  7. * Is the button disabled?
  8. */
  9. disabled?: boolean,
  10. /**
  11. * Label of the button.
  12. */
  13. label?: string,
  14. /**
  15. * Callback to invoke when the {@code HeaderNavigationButton} is clicked/pressed.
  16. */
  17. onPress?: Function,
  18. /**
  19. * The ImageSource to be rendered as image.
  20. */
  21. src?: Object,
  22. /**
  23. * Header has two actions.
  24. */
  25. twoActions?: boolean
  26. }
  27. const HeaderNavigationButton
  28. = ({
  29. disabled,
  30. label,
  31. onPress,
  32. src,
  33. twoActions
  34. }: Props) =>
  35. (
  36. <>
  37. {
  38. src ? (
  39. <TouchableRipple
  40. onPress = { onPress }
  41. style = { navigationStyles.headerNavigationButtonIcon } >
  42. <Icon
  43. size = { 24 }
  44. src = { src } />
  45. </TouchableRipple>
  46. ) : (
  47. <TouchableRipple
  48. disabled = { disabled }
  49. onPress = { onPress }
  50. style = { navigationStyles.headerNavigationButtonText } >
  51. <Text
  52. style = {
  53. twoActions
  54. ? navigationStyles.headerNavigationTextBold
  55. : navigationStyles.headerNavigationText
  56. }>
  57. { label }
  58. </Text>
  59. </TouchableRipple>
  60. )}
  61. </>
  62. );
  63. export default HeaderNavigationButton;