Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

HeaderNavigationButton.tsx 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import React from 'react';
  2. import { GestureResponderEvent } from 'react-native';
  3. import { StyleType } from '../../../base/styles/functions.native';
  4. import Button from '../../../base/ui/components/native/Button';
  5. import IconButton from '../../../base/ui/components/native/IconButton';
  6. import { BUTTON_TYPES } from '../../../base/ui/constants.native';
  7. import { navigationStyles } from './styles';
  8. interface IProps {
  9. /**
  10. * Is the button disabled?
  11. */
  12. disabled?: boolean;
  13. /**
  14. * Label of the button.
  15. */
  16. label?: string;
  17. /**
  18. * Callback to invoke when the {@code HeaderNavigationButton} is clicked/pressed.
  19. */
  20. onPress?: (e?: GestureResponderEvent | React.MouseEvent) => void;
  21. /**
  22. * The ImageSource to be rendered as image.
  23. */
  24. src?: any;
  25. /**
  26. * Style of the button.
  27. */
  28. style?: StyleType;
  29. /**
  30. * Header has two actions.
  31. */
  32. twoActions?: boolean;
  33. }
  34. const HeaderNavigationButton = ({ disabled, label, onPress, src, style, twoActions }: IProps) => {
  35. let btnStyle;
  36. let labelStyle;
  37. if (disabled) {
  38. btnStyle = navigationStyles.headerNavigationButtonDisabled;
  39. labelStyle = twoActions
  40. ? navigationStyles.headerNavigationButtonLabelBoldDisabled
  41. : navigationStyles.headerNavigationButtonLabelDisabled;
  42. } else {
  43. btnStyle = navigationStyles.headerNavigationButton;
  44. labelStyle = twoActions
  45. ? navigationStyles.headerNavigationButtonLabelBold
  46. : navigationStyles.headerNavigationButtonLabel;
  47. }
  48. return (
  49. <>
  50. {
  51. src ? (
  52. <IconButton
  53. onPress = { onPress }
  54. size = { 24 }
  55. src = { src }
  56. style = { [
  57. navigationStyles.headerNavigationButton,
  58. style
  59. ] } />
  60. ) : (
  61. <Button
  62. disabled = { disabled }
  63. labelKey = { label }
  64. labelStyle = { labelStyle }
  65. onClick = { onPress }
  66. style = { [
  67. btnStyle,
  68. style
  69. ] }
  70. type = { BUTTON_TYPES.TERTIARY }
  71. useRippleColor = { false } />
  72. )}
  73. </>
  74. );
  75. };
  76. export default HeaderNavigationButton;