Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

HeaderNavigationButton.tsx 2.5KB

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