normal_button.tsx 3.2 KB

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