Browse Source

fixing datepicker erro - ios

master
analuizaff 4 years ago
parent
commit
6ce0d040f8
  1. 98
      src/app/screens/PluviometerSharingDataScreen.js

98
src/app/screens/PluviometerSharingDataScreen.js

@ -18,6 +18,7 @@ import DateTimePicker from '@react-native-community/datetimepicker';
import { FontAwesome5 } from '@expo/vector-icons'; import { FontAwesome5 } from '@expo/vector-icons';
import { showMessage } from "react-native-flash-message"; import { showMessage } from "react-native-flash-message";
import moment from 'moment'; import moment from 'moment';
import colors from "../config/colors";
const validationSchema = Yup.object().shape({ const validationSchema = Yup.object().shape({
pluviometer: Yup.number().required().min(1).max(10000).label("pluviometer"), pluviometer: Yup.number().required().min(1).max(10000).label("pluviometer"),
@ -121,63 +122,63 @@ function PluviometerSharingDataScreen(props) {
<TouchableOpacity style={styles.datepickerStyle} <TouchableOpacity style={styles.datepickerStyle}
onPress={() => setShow(true)}> onPress={() => setShow(true)}>
<View style={styles.datePickerView}> <View style={styles.datePickerView}>
<View style={{ flexDirection:"row", justifyContent:"space-between", width: 280 }}>
<Text style={{fontSize: 16, marginLeft: 15}}>{date.format('DD/MM/YYYY')}</Text>
<View style={{ flexDirection: "row", justifyContent: "space-between", width: 280 }}>
<Text style={{ fontSize: 16, marginLeft: 15 }}>{date.format('DD/MM/YYYY')}</Text>
<FontAwesome5 style={styles.dateIcon} name="calendar-day" size={24} color="grey" /> <FontAwesome5 style={styles.dateIcon} name="calendar-day" size={24} color="grey" />
</View> </View>
{Platform.OS !== 'ios' && show && renderDatePicker()}
{Platform.OS !== 'ios' && show && renderDatePicker()}
{Platform.OS === 'ios' && show && ( {Platform.OS === 'ios' && show && (
<Modal
transparent={true}
animationType="slide"
visible={show}
supportedOrientations={['portrait']}
onRequestClose={() => setShow(false)}>
<View style={{ flex: 1 }}>
<Modal
transparent={true}
animationType="slide"
visible={show}
supportedOrientations={['portrait']}
onRequestClose={() => setShow(false)}>
<View style={{ flex: 1 }}>
<TouchableHighlight
style={{
flex: 1,
alignItems: 'flex-end',
flexDirection: 'row',
}}
activeOpacity={1}
visible={show}
onPress={() => setShow(false)}>
<TouchableHighlight <TouchableHighlight
underlayColor={'#f8f4f4'}
style={{ style={{
flex: 1, flex: 1,
alignItems: 'flex-end',
flexDirection: 'row',
borderTopColor: 'primary',
borderTopWidth: 1,
}} }}
activeOpacity={1}
visible={show}>
onPress={() => setShow(false)}
<TouchableHighlight
underlayColor={''}
onPress={() => console.log('Datepicker press')}>
<View
style={{ style={{
flex: 1,
borderTopColor: 'primary',
borderTopWidth: 1,
}}
onPress={() => console.log('Datepicker press')}>
<View
style={{
backgroundColor: '#f8f8ff',
height: 256,
overflow: 'hidden',
}}>
<View style={{ marginTop:20 }}>
{ renderDatePicker }
</View>
<TouchableHighlight
underlayColor={'transparent'}
onPress={() => onCancelPress()}
style={(styles.btnText, styles.btnCancel)}>
<Text>Cancelar</Text>
</TouchableHighlight>
<TouchableHighlight
underlayColor={'transparent'}
onPress={() => onDonePress()}
style={(styles.btnText, styles.btnDone)}>
<Text>OK</Text>
</TouchableHighlight>
backgroundColor: '#f8f8ff',
height: 256,
overflow: 'hidden',
}}>
<View style={{ marginTop: 20 }}>
{renderDatePicker()}
</View> </View>
</TouchableHighlight>
<TouchableHighlight
underlayColor={'transparent'}
onPress={() => console.log('Datepicker press')}
style={(styles.btnText, styles.btnCancel)}>
<Text>Cancelar</Text>
</TouchableHighlight>
<TouchableHighlight
underlayColor={'transparent'}
onPress={() => console.log('Datepicker press')}
style={(styles.btnText, styles.btnDone)}>
<Text>Ok</Text>
</TouchableHighlight>
</View>
</TouchableHighlight> </TouchableHighlight>
</View>
</Modal>
</TouchableHighlight>
</View>
</Modal>
)} )}
</View> </View>
</TouchableOpacity> </TouchableOpacity>
@ -234,7 +235,8 @@ const styles = StyleSheet.create({
paddingHorizontal: 20, paddingHorizontal: 20,
flexDirection: "row", flexDirection: "row",
alignItems: "center", alignItems: "center",
justifyContent: "center"
justifyContent: "center",
color: colors.primary,
}, },
btnCancel: { btnCancel: {
left: 0, left: 0,

Loading…
Cancel
Save