normal_button.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. {({ pressed }) => (
  35. <View
  36. style={[
  37. {
  38. maxWidth: '100%',
  39. backgroundColor: pressed? '#28495c':'#025c72',
  40. justifyContent: 'center',
  41. alignItems: 'center',
  42. borderRadius: 12,
  43. padding: 20
  44. },
  45. extendedStyle,
  46. ]}
  47. >
  48. {title}
  49. </View>
  50. )}
  51. </Pressable>
  52. );
  53. };
  54. const styles = StyleSheet.create({
  55. button: {
  56. maxWidth: '100%',
  57. fontSize: 16,
  58. backgroundColor: '#025c72',
  59. justifyContent: 'center',
  60. alignItems: 'center',
  61. borderRadius: 12,
  62. padding: 20
  63. },
  64. buttonPressed: {
  65. backgroundColor: '#28495c'
  66. }
  67. });
  68. export default NormalButton;
  69. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  70. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  71. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  72. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  73. //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
  74. // import React, { ReactElement } from 'react';
  75. // import { Pressable, PressableProps, StyleSheet, TextStyle } from 'react-native';
  76. // interface NormalButtonProps extends PressableProps {
  77. // title: ReactElement;
  78. // extendedStyle?: TextStyle;
  79. // }
  80. // //2024-06-06 I modified the button so that it accept a forwarded ref for Navigation
  81. // const NormalButton = React.forwardRef<
  82. // React.ElementRef<typeof Pressable>,
  83. // NormalButtonProps
  84. // >(({ title, extendedStyle, onPress, disabled }, ref) => {
  85. // return (
  86. // <Pressable
  87. // ref={ref}
  88. // onPress={onPress}
  89. // disabled={disabled}
  90. // style={({ pressed }) => [
  91. // styles.button,
  92. // pressed ? styles.buttonPressed : null,
  93. // extendedStyle
  94. // ]}
  95. // >
  96. // {title}
  97. // </Pressable>
  98. // );
  99. // });
  100. // const styles = StyleSheet.create({
  101. // button: {
  102. // maxWidth: '100%',
  103. // fontSize: 16,
  104. // backgroundColor: '#025c72',
  105. // justifyContent: 'center',
  106. // alignItems: 'center',
  107. // borderRadius: 12,
  108. // padding: 20
  109. // },
  110. // buttonPressed: {
  111. // backgroundColor: '#28495c'
  112. // }
  113. // });
  114. // export default NormalButton;