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

HeaderNavigationButton.tsx 2.7KB

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