| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- import React, { ReactElement } from 'react';
- import {
- Pressable,
- Text,
- StyleSheet,
- ViewStyle,
- StyleProp,
- View
- } from 'react-native';
- interface NormalButtonProps {
- title: ReactElement;
- extendedStyle?: StyleProp<ViewStyle>;
- onPress: () => void;
- disabled?: boolean;
- buttonPressedStyle?: StyleProp<ViewStyle>;
- }
- const NormalButton: React.FC<NormalButtonProps> = ({
- title,
- extendedStyle,
- onPress,
- disabled,
- buttonPressedStyle
- }) => {
- return (
-
- <Pressable
- onPress={onPress}
- disabled={disabled}
- // style={[styles.button, extendedStyle]}
- // style={({ pressed }) => [
- // pressed ? buttonPressedStyle || styles.buttonPressed : null,
- // extendedStyle,
- // ]}
- >
- {({ pressed }) => (
- <View
- style={[
- {
- maxWidth: '100%',
- backgroundColor: pressed? '#28495c':'#025c72',
- justifyContent: 'center',
- alignItems: 'center',
- borderRadius: 12,
- padding: 20
- },
- extendedStyle,
- ]}
- >
- {title}
- </View>
- )}
- </Pressable>
- );
- };
- const styles = StyleSheet.create({
- button: {
- maxWidth: '100%',
- fontSize: 16,
- backgroundColor: '#025c72',
- justifyContent: 'center',
- alignItems: 'center',
- borderRadius: 12,
- padding: 20
- },
- buttonPressed: {
- backgroundColor: '#28495c'
- }
- });
- export default NormalButton;
- //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
- //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
- //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
- //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
- //*************************PLEASE IGNORE BELOW COMMENTS. FOR MY OWN REVIEW ONLY**************************************/
- // import React, { ReactElement } from 'react';
- // import { Pressable, PressableProps, StyleSheet, TextStyle } from 'react-native';
- // interface NormalButtonProps extends PressableProps {
- // title: ReactElement;
- // extendedStyle?: TextStyle;
- // }
- // //2024-06-06 I modified the button so that it accept a forwarded ref for Navigation
- // const NormalButton = React.forwardRef<
- // React.ElementRef<typeof Pressable>,
- // NormalButtonProps
- // >(({ title, extendedStyle, onPress, disabled }, ref) => {
- // return (
- // <Pressable
- // ref={ref}
- // onPress={onPress}
- // disabled={disabled}
- // style={({ pressed }) => [
- // styles.button,
- // pressed ? styles.buttonPressed : null,
- // extendedStyle
- // ]}
- // >
- // {title}
- // </Pressable>
- // );
- // });
- // const styles = StyleSheet.create({
- // button: {
- // maxWidth: '100%',
- // fontSize: 16,
- // backgroundColor: '#025c72',
- // justifyContent: 'center',
- // alignItems: 'center',
- // borderRadius: 12,
- // padding: 20
- // },
- // buttonPressed: {
- // backgroundColor: '#28495c'
- // }
- // });
- // export default NormalButton;
|