You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Button.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // @flow
  2. import React from 'react';
  3. import { View } from 'react-native';
  4. import { Button as PaperButton } from 'react-native-paper';
  5. import { Icon } from '../../../base/icons';
  6. let buttonContent;
  7. /**
  8. * The type of the React {@code Component} props of {@link Button}
  9. */
  10. type Props = {
  11. /**
  12. * Button content.
  13. */
  14. content?: string,
  15. /**
  16. * Is the button icon type?
  17. */
  18. iconButton?: boolean,
  19. /**
  20. * Style for the icon
  21. */
  22. iconStyle?: Object,
  23. /**
  24. * Size of the icon.
  25. */
  26. iconSize?: number,
  27. /**
  28. * Icon component source.
  29. */
  30. iconSrc?: Object,
  31. /**
  32. * Button mode.
  33. */
  34. mode?: string,
  35. /**
  36. * Style of button's inner content.
  37. */
  38. contentStyle?: Object,
  39. /**
  40. * The action to be performed when the button is pressed.
  41. */
  42. onPress?: Function,
  43. /**
  44. * An external style object passed to the component.
  45. */
  46. style?: Object,
  47. /**
  48. * Theme to be applied.
  49. */
  50. theme?: Object
  51. };
  52. /**
  53. * Close button component.
  54. *
  55. * @returns {React$Element<any>}
  56. */
  57. function Button({
  58. iconButton,
  59. iconStyle,
  60. iconSize,
  61. iconSrc,
  62. content,
  63. contentStyle,
  64. mode,
  65. onPress,
  66. style,
  67. theme
  68. }: Props) {
  69. if (iconButton) {
  70. buttonContent
  71. = (<View
  72. /* eslint-disable-next-line react-native/no-inline-styles */
  73. style = {{
  74. height: 0,
  75. width: 0
  76. }}>
  77. <Icon
  78. size = { iconSize }
  79. src = { iconSrc }
  80. style = { iconStyle } />
  81. </View>);
  82. } else {
  83. buttonContent = content;
  84. }
  85. return (
  86. <PaperButton
  87. contentStyle = { contentStyle }
  88. mode = { mode }
  89. onPress = { onPress }
  90. style = { style }
  91. theme = { theme }>
  92. { buttonContent }
  93. </PaperButton>
  94. );
  95. }
  96. export default Button;