ScrollView不允许我从组件下拉列表中进行选择

问题描述 投票:0回答:1

首先,让我分享我的代码以及当前执行的结果。

return(
    <DismissKeyBoard>
    <View>   
       <Formik
            initialValues ={{user: 'User ', place: '', description: '', comments: '',datePosted: new Date(), location: '', eventDate: ''}}
            onSubmit ={logInfo}>
            {props =>(
                <SafeAreaView style={styles.container}>
                <ScrollView>
                <View style={styles.form}>    

                <Text  style={styles.text}>Pick a place for the event</Text>

                <GooglePlacesAutocomplete
                         placeholder='Insert place to find'
                         minLength={2}
                         keyboardAppearance={'light'}
                         fetchDetails={false} 
                         onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
                             {props.values.location= data.description}
                                 console.log("hello",props.values.location);
                                }}

                            styles={{
                            textInputContainer: {
                                backgroundColor: 'rgba(0,0,0,0)',
                                borderTopWidth: 0,
                                borderBottomWidth:0,
                                width: '100%',
                                },
                             textInput: {
                                fontSize: 16
                                },
                             predefinedPlacesDescription: {
                                color: '#1faadb',
                                height:'100%',
                                },
                            }}

                            query={{
                                key: '',
                                language: 'en', // language of the results
                              }}

                        />


                   <View style={styles.container}>    
                    <Text
                        placeholder= {props.values.user}
                        onChangeText = {props.handleChange('user')}
                        values = {props.values.user} 
                        style={styles.text}>{props.values.user}</Text>
                    <TextInput
                        placeholder= 'Place (e.g Honolulu)'
                        onChangeText = {props.handleChange('place')}
                        values = {props.values.place} 
                        style={styles.text}/>
                    <TextInput
                        placeholder= 'Description (e.g This is located...)'
                        onChangeText = {props.handleChange('description')}
                        values = {props.values.description} 
                        style={styles.text}/>
                    <TextInput
                        placeholder= 'Comment (e.g This is fun because...)'
                        onChangeText = {props.handleChange('comments')}
                        values = {props.values.comments} 
                        style={styles.text}/>
                    <Text  style={styles.text} >Pick a date for the event</Text>
                    <DatePicker
                        date={props.values.eventDate}
                        onDateChange={(date) => {props.values.eventDate= date}}
                        values = {props.values.eventDate} />
                    {/* <Text  style={styles.text}>Location</Text> */}

                    <View  style={styles.viewbtn}>
                        <TouchableOpacity onPress={props.handleSubmit} style={styles.btn} ><Text style={styles.txtbtn} >Submit</Text></TouchableOpacity>
                        {/* <Button title="Submit" onPress={props.handleSubmit}  /> */}
                    </View>

                    </View>    

            </View>
            </ScrollView>
            </SafeAreaView>

            )}
        </Formik> 
    </View>      
    </DismissKeyBoard>           
    )
}

const styles = StyleSheet.create({
    container:{
       // flex:1,
        paddingTop:20,
      //  margin: 10,
        alignItems: 'center'
    },
    // form:{
    //     alignItems: 'flex-start',
    //     paddingTop:40,

    // },
    text:{
        borderBottomWidth: StyleSheet.hairlineWidth,
        borderColor: 'black',
        paddingTop:15, 
    },
    viewbtn:{
        paddingTop:15,
    },
    btn:{
        backgroundColor: 'purple',
        padding:20,
        margin:20,
        width: 100,
        justifyContent: 'center',
        alignItems: 'center',
        borderRadius : 5,
    },
    txtbtn:{
        fontWeight: 'bold',
        fontSize: 14,
        color: 'orange'
    },
})

enter image description here

问题

当我单击GooglePlacesAutoComplete时,我可以看到位置列表,但是当我单击找到的任何位置时,它都不会输入。

观察

  1. [<GooglePlacesAutocomplete />不在ScrollView内时,我看不到建议。
  2. [当<GooglePlacesAutocomplete />不在任何其他<View></View>内时,它可以很好地工作。

警告

使用上面的代码,我还会收到此警告消息。

所需结果

我希望<GooglePlacesAutocomplete />组件显示在表单顶部,而没有任何奇怪的错误,并且其功能正常运行。 (最好如图所示)

编辑

我正在从import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';导入https://github.com/FaridSafi/react-native-google-places-autocomplete

我不是GUI方面的专家,非常感谢您的解释。如果需要其他信息,我将非常乐意提供。

谢谢你。

首先,让我分享我的代码以及当前执行的结果。 return(

[[[[]

reactjs react-native user-interface components scrollview
1个回答
-1
投票
© www.soinside.com 2019 - 2024. All rights reserved.