normal_button.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import React, { ReactElement } from 'react';
  2. import {
  3. Pressable,
  4. Text,
  5. StyleSheet,
  6. ViewStyle,
  7. StyleProp
  8. } from 'react-native';
  9. interface NormalButtonProps {
  10. title: ReactElement;
  11. extendedStyle?: StyleProp<ViewStyle>;
  12. onPress: () => void;
  13. disabled?: boolean;
  14. buttonPressedStyle?: StyleProp<ViewStyle>;
  15. }
  16. const NormalButton: React.FC<NormalButtonProps> = ({
  17. title,
  18. extendedStyle,
  19. onPress,
  20. disabled,
  21. buttonPressedStyle
  22. }) => {
  23. return (
  24. <Pressable
  25. onPress={onPress}
  26. disabled={disabled}
  27. style={({ pressed }) => [
  28. styles.button,
  29. extendedStyle,
  30. pressed ? buttonPressedStyle || styles.buttonPressed : null
  31. ]}
  32. >
  33. {title}
  34. </Pressable>
  35. );
  36. };
  37. const styles = StyleSheet.create({
  38. button: {
  39. maxWidth: '100%',
  40. fontSize: 16,
  41. backgroundColor: '#025c72',
  42. justifyContent: 'center',
  43. alignItems: 'center',
  44. borderRadius: 12,
  45. padding: 20
  46. },
  47. buttonPressed: {
  48. backgroundColor: '#28495c'
  49. }
  50. });
  51. export default NormalButton;
  52. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  53. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  54. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  55. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  56. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  57. // import React, { ReactElement } from 'react';
  58. // import { Pressable, PressableProps, StyleSheet, TextStyle } from 'react-native';
  59. // interface NormalButtonProps extends PressableProps {
  60. // title: ReactElement;
  61. // extendedStyle?: TextStyle;
  62. // }
  63. // //2024-06-06 I modified the button so that it accept a forwarded ref for Navigation
  64. // const NormalButton = React.forwardRef<
  65. // React.ElementRef<typeof Pressable>,
  66. // NormalButtonProps
  67. // >(({ title, extendedStyle, onPress, disabled }, ref) => {
  68. // return (
  69. // <Pressable
  70. // ref={ref}
  71. // onPress={onPress}
  72. // disabled={disabled}
  73. // style={({ pressed }) => [
  74. // styles.button,
  75. // pressed ? styles.buttonPressed : null,
  76. // extendedStyle
  77. // ]}
  78. // >
  79. // {title}
  80. // </Pressable>
  81. // );
  82. // });
  83. // const styles = StyleSheet.create({
  84. // button: {
  85. // maxWidth: '100%',
  86. // fontSize: 16,
  87. // backgroundColor: '#025c72',
  88. // justifyContent: 'center',
  89. // alignItems: 'center',
  90. // borderRadius: 12,
  91. // padding: 20
  92. // },
  93. // buttonPressed: {
  94. // backgroundColor: '#28495c'
  95. // }
  96. // });
  97. // export default NormalButton;