Skip to content

Commit

Permalink
Merge branch 'develop' into fixBug/SizeText
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamCallao committed Mar 18, 2024
2 parents 6148f23 + 223ab94 commit 59523fd
Show file tree
Hide file tree
Showing 13 changed files with 914 additions and 3 deletions.
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dependencies": {
"@expo-google-fonts/alex-brush": "^0.2.3",
"@expo-google-fonts/montserrat": "^0.2.3",
"@react-native-community/datetimepicker": "^7.6.2",
"@react-native-firebase/analytics": "^19.0.0",
"@react-native-firebase/app": "^19.0.0",
"@react-native-firebase/auth": "^19.0.0",
Expand All @@ -26,6 +27,7 @@
"expo-font": "^11.10.3",
"expo-status-bar": "~1.11.1",
"react": "18.2.0",
"react-hook-form": "^7.51.0",
"react-native": "0.73.4",
"react-native-modal": "^13.0.1",
"react-native-popup-menu": "^0.16.1",
Expand Down
5 changes: 4 additions & 1 deletion src/components/ClientDebit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { theme } from "../../constants";
import { useFocusEffect } from "@react-navigation/native";
import Modal from "../modals/SimpleModal";
import { StatusBar } from "expo-status-bar";
import { useNavigation } from "@react-navigation/native";
const screenWidth = Dimensions.get('window').width;

const ClientDebit = ({ clientInfo }) => {
Expand Down Expand Up @@ -47,13 +48,15 @@ const ClientDebit = ({ clientInfo }) => {
setModalVisible(!modalVisible);
};

const navigation = useNavigation();

return (
<View style={clientDebitStyles.container}>
<StatusBar style="ligth" backgroundColor={statusBarColor} />
<Modal isVisible={modalVisible} onClose={toggleModal} />
<Text style={clientDebitStyles.text}> {vBalance} Bs</Text>
<View style={clientDebitStyles.spaceButtons}>
<TouchableOpacity onPress={() => {}} style={clientDebitStyles.button}>
<TouchableOpacity onPress={() => navigation.navigate("AutomaticPayScreen")} style={clientDebitStyles.button}>
<Text style={clientDebitStyles.textButton}>Automático</Text>
</TouchableOpacity>
<TouchableOpacity
Expand Down
82 changes: 82 additions & 0 deletions src/components/DateInputField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React, {useState} from 'react';
import { Text, TextInput, StyleSheet, View } from 'react-native';
import { theme } from '../../constants';
import { Controller } from 'react-hook-form';
import DateTimePicker from '@react-native-community/datetimepicker';
import { formatDate } from 'date-fns';

const DateInputField = ({ control, name, title, type = 'default' }) => {

const [selectedDate, setSelectedDate] = useState(new Date());
const [showDatePicker, setShowDatePicker] = useState(false);

const handleDateChange = (event, selectedDate) => {
const currentDate = selectedDate;
setShowDatePicker(false);
setSelectedDate(currentDate);
console.log('selectedDate', selectedDate);
};

return (
<View style={styles.container}>
<Text style={styles.label}>{title}</Text>
<Controller
control={control}
name={name}
defaultValue=""
render={({ field: { onChange, value } }) => (
<TextInput
style={styles.input}
onFocus={() => setShowDatePicker(true)}
onChangeText={onChange}
value={formatDate(selectedDate, 'dd/MM/yyyy', { awareOfUnicodeTokens: true })}
keyboardType={type === 'numeric' ? 'numeric' : 'default'}
/>

)}
/>
{showDatePicker && (
<DateTimePicker
testID="dateTimePicker"
value={selectedDate}
mode="date"
is24Hour={true}
display="default"
onChange={handleDateChange}
/>
)}
</View>
);
};

const styles = StyleSheet.create({
container: {
marginHorizontal: 20,
marginBottom: 10,
width: 145,
},
label: {
color: 'gray',
fontSize: 18,
marginBottom: 5,
paddingLeft: 10
},
input: {
height: 46,
borderColor: 'gray',
paddingHorizontal: 10,
backgroundColor: theme.colors.otherWhite,
borderRadius: 22,
fontSize: 18,
fontWeight: "bold",
textAlign: 'center',
},
error: {
color: 'red',
fontSize: 12,
marginTop: 1,
paddingLeft: 10
},
});

export default DateInputField;
113 changes: 113 additions & 0 deletions src/components/DropdownSelector2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// DropdownSelector.js
import React, { useState, useCallback } from "react";
import { View, Text } from "react-native";
import { FontAwesome5 } from "@expo/vector-icons";
import { Menu, MenuOptions, MenuOption, MenuTrigger } from "react-native-popup-menu";
import { theme } from '../../constants';
import { StyleSheet, Dimensions } from 'react-native';
const screenWidth = Dimensions.get('window').width;

const DropdownSelector = ({ title, options, selectedOption, onOptionChange, size=200 }) => {
const [menuVisible, setMenuVisible] = useState(false);

const toggleMenu = () => {
setMenuVisible(prevState => !prevState);
};

return (
<View>
<Text style={styles.title}>{title}</Text>
<Menu opened={menuVisible} onBackdropPress={() => setMenuVisible(false)}>
<MenuTrigger onPress={toggleMenu} style={styles.trigger}>
<View style={styles.menuTrigger}>
<View style={styles.menuTriggerInter}>
<Text style={styles.triggerText}>
{selectedOption.charAt(0).toUpperCase() + selectedOption.slice(1)}
</Text>
</View>
<FontAwesome5 name={menuVisible ? "chevron-up" : "chevron-down"} size={20} color="white" />
</View>
</MenuTrigger>
<MenuOptions customStyles={{ optionsContainer: styles.optionsContainer, optionsWrapper: styles.optionsWrapper, }}>
{options.map((option) => (
<MenuOption key={option} onSelect={() => { onOptionChange(option); setMenuVisible(false); }}>
<View style={{ flexDirection: "row", alignItems: "center" }}>
<Text style={styles.optionsText}>{option}</Text>
{selectedOption === option && (
<FontAwesome5 name="check" size={17} color="white" style={{ marginLeft: 10 }} />
)}
</View>
</MenuOption>
))}
</MenuOptions>
</Menu>
</View>
);
};

const styles = StyleSheet.create({
title: {
color: 'gray',
fontSize: 18,
marginBottom: 5,
paddingLeft: 10
},
container: {
marginHorizontal: 20,
borderRadius: 20,
backgroundColor: theme.colors.skyBlue,
padding: 7,
flexDirection: "row",
justifyContent: 'flex-end',
},
label: {
flexDirection: "row",
alignItems: "center",
justifyContent: 'center',
borderRadius: 20,
flex:1
},
optionText: {
fontSize: 16,
fontWeight: "bold",
},
optionsText: {
color: theme.colors.primary,
fontSize: 16,
fontWeight: "bold",
},
menuTrigger: {
flexDirection: "row",
alignItems: 'center',
justifyContent: 'space-between',
paddingVertical: 12,
paddingHorizontal: 25,
backgroundColor: theme.colors.tertiary,
borderRadius: 22,
width: "auto",
maxWidth: screenWidth - 40,
alignSelf: "center",
},
menuTriggerInter: {
flexDirection: "row",
alignItems: 'center',
justifyContent: 'center',
},
triggerText: {
color: theme.colors.primary,
fontSize: 16,
fontWeight: "bold",
marginRight: 12,
},
optionsContainer: {
paddingVertical: 15,
marginTop: 55,
marginLeft: 0,
borderRadius: 20,
backgroundColor: theme.colors.tertiary,
},
optionsWrapper: {
marginLeft: 20,
},
});
export default DropdownSelector;
81 changes: 81 additions & 0 deletions src/components/InputField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React, {useState} from 'react';
import { Text, TextInput, StyleSheet, View } from 'react-native';
import { theme } from '../../constants';
import { Controller } from 'react-hook-form';

const InputField = ({ control, name, title, type = 'default', rules = {}, errors ={} }) => {

const [isFocused, setIsFocused] = useState(false);

const InputStyle = isFocused ? styles.inputFocused : styles.input;
return (
<View style={styles.container}>
<Text style={styles.label}>{title}</Text>
<Controller
control={control}
name={name}
defaultValue=""
rules={rules}
render={({ field: { onChange, value } }) => (
<TextInput
style={InputStyle}
onChangeText={onChange}
onFocus={() => setIsFocused(true)}
onBlur={() => setIsFocused(false)}
value={value}
keyboardType={type === 'numeric' ? 'numeric' : 'default'}
/>
)}
/>
{errors[name] && (
<Text style={styles.error}>{errors[name].message}</Text>
)}
</View>
);
};


const styles = StyleSheet.create({
container: {
marginHorizontal: 20,
marginBottom: 10,
},
label: {
color: 'gray',
fontSize: 18,
marginBottom: 5,
paddingLeft: 10
},
input: {
height: 46,
width: "auto",
minWidth: 245,
paddingHorizontal: 10,
backgroundColor: theme.colors.otherWhite,
borderRadius: 22,
fontSize: 18,
fontWeight: "bold",

},
inputFocused:{
height: 46,
width: "auto",
minWidth: 245,
paddingHorizontal: 10,
backgroundColor: theme.colors.otherWhite,
borderRadius: 22,
fontSize: 18,
fontWeight: "bold",
borderWidth: 2,
borderColor: theme.colors.black,

},
error: {
color: 'red',
fontSize: 12,
marginTop: 1,
paddingLeft: 10
},
});

export default InputField;
Loading

0 comments on commit 59523fd

Please sign in to comment.