-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fixBug/SizeText
- Loading branch information
Showing
13 changed files
with
914 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.