文本输入内部焦点松散反应本机选项卡视图

如何解决文本输入内部焦点松散反应本机选项卡视图

从'react'导入React,{组件}; 导入{ 视图,文本,尺寸,KeyboardAvoidingView,StyleSheet,ScrollView,Picker,TextInput,TouchableOpacity, 图片,FlatList,SafeAreaView,键盘, I18nManager, 互动管理器 }来自“ react-native”; 从'../component/header'导入Header; 从'react-native-tab-view'导入{TabView,SceneMap,TabBar}; 从'../component/Button'导入Button; 从“ ../component/Card”导入卡; 从'../component/CardSection'导入CardSection; 从'../component/ImageCardSection'导入ImageCardSection; 从'axios'导入axios; 从'../component/Spinner'导入Spinner; 从'react-native-dropdown-picker'导入DropDownPicker; 导入“ react-native-gesture-handler” 从“ ./CarRescueScreen”导入CarRescueScreen; 从“ react-native-reanimated”导入动画;

    const initialLayout = { width: Dimensions.get('window').width };
    const numofcolumns = 4;
    
    export default function CarrescueForm() {
    
    
    
    
        React.useEffect(() => {
    
            // Update the document title using the browser API
            setServiceList([])
            setmodelList([])
            setmakeList([])
            getcar()
            getcarmanufacture()
            // getcarrescueservice()
        },[]);
    
    
    
        // React.useEffect(() => {
        //     if (index)
        //         getcarrescueservice(index + 1)
        // },[index])
        const [selectedValue,setSelectedValue] = React.useState("Select");
        const [index,setIndex] = React.useState(0);
        let [vechno,setVechno] = React.useState("");
        const [other,setother] = React.useState('');
        const [loading,setLoading] = React.useState(false);
        const [refresh,setrefresh] = React.useState(false);
        const [serviceList,setServiceList] = React.useState([]);
    
        const [selectedmakeValue,setSelectedMakeValue] = React.useState("");
        const [makeList,setmakeList] = React.useState([]);
    
        const [selectedmodelValue,setSelectedModelValue] = React.useState("");
        const [modelList,setmodelList] = React.useState([]);
    
    
    
    
    
        const [routes,setRoutes] = React.useState([
            // { key: 'first',title: 'SUV' },// { key: 'second',title: 'Sedan' },// { key: 'third',title: 'Hatchback' },]);
    
        const onIndexchange = (idx,rarray) => {
    
            console.log('index>>>',index);
            console.log('rarray>>>',rarray);
            getcarrescueservice(rarray[idx].key);
            setIndex(idx)
            if (index < idx && idx !== 0)
                setServiceList([]);
        }
        const getcar = async () => {
    
    
            try {
    
                setLoading(true);
    
    
                const response = await axios.get('http://www.xxxx');
                console.log('? Returned data:',response);
                setLoading(false);
                console.log("Its your time baby" + response.data.Status);
                if (response.data.Status > 0) {
                    console.log("Its your time baby S")
                    if ((response.data.Data).length > 0) {
                        const routArray = []
                        response.data.Data.map(carData => {
                            routArray.push({ key: carData.id,title: carData.car })
                        })
    
                        setRoutes(routArray);
                        getcarrescueservice(routArray[0].key);
    
                    }
                    console.log(response.data.data);
                }
                else {
                    alert(response.data.Message);
                    console.log(response.data.Message);
                }
    
            } catch (error) {
    
            }
    
        }
    
        const getcarrescueservice = async (carId) => {
    
    
            try {
    
                setLoading(true);
    
    
                const response = await axios.get(`http://www.xxxx`);
                console.log('? Returned data:',response);
                setLoading(false);
                console.log("Its your time baby" + response.data.Status);
                if (response.data.Status > 0) {
                    console.log("Its your time baby S")
    
                    setServiceList(response.data.Data);
                    console.log(response.data.data);
                }
                else {
                    alert(response.data.Message);
                    console.log(response.data.Message);
                }
    
            } catch (error) {
    
            }
    
        }
    
        const getcarmanufacture = async () => {
    
    
            try {
    
                setLoading(true);
    
    
                const response = await axios.get('http://www.xxxx');
                console.log('? Returned data:',response);
                setLoading(false);
                console.log("Its your time baby" + response.data.Status);
                if (response.data.Status > 0) {
                    console.log("Its your time baby S")
                    const addListData = []
    
                    await Promise.all(await response.data.Data.map(makeData => {
                        addListData.push({ label: makeData.manufacture,value: makeData.id })
                    }))
    
                    setmakeList(addListData);
                    console.log("makeList------------------->",makeList);
                }
                else {
                    alert(response.data.Message);
                    console.log(response.data.Message);
                }
    
            } catch (error) {
    
            }
    
        }
        const getcarmodel = async (makeId) => {
    
    
            try {
    
                setLoading(true);
    
                const params = new URLSearchParams();
                params.append('manufactureid',makeId);
                const response = await axios.post('http://www.xxxx',params);
                console.log('? Returned data:',response);
                setLoading(false);
                console.log("Its your time baby" + response.data.Status);
                if (response.data.Status > 0) {
                    console.log("Its your time baby S makelist")
                    const carList = []
                    await Promise.all(await response.data.Data.map(modelData => {
                        carList.push({ label: modelData.model,value: modelData.id })
                    }))
                    setmodelList(carList);
                    console.log(response.data.data);
                }
                else {
                    alert(response.data.Message);
                    console.log(response.data.Message);
                }
    
            } catch (error) {
    
            }
    
        }
    
        const onChangeItem = (item) => {
            console.log('make item is here',item.value);
            setSelectedMakeValue(item.value);
            getcarmodel(item.value)
        }
    
        const renderItem = ({ item }) => {
            console.log('itrm>>>>',item.Imageurl);
            return (
                <View style={{ flex: 1 }}>
                    {item && !item.empty && (<View style={{ flex: 1,flexDirection: 'row',justifyContent: 'center',alignItems: 'center',marginTop: 5 }}>
                        <View style={{ flex: 1,alignSelf: 'center',marginLeft: 5,borderColor: '#ffa737',borderWidth: 1 }}>
                            <View style={{ flex: 1 }}>
                                <CardSection>
                                    <Image
                                        style={styles.imageStyle}
                                        source={{ uri: `http://www.fastnsure.in/car/${item.Imageurl}` }}
                                    />
                                </CardSection>
                            </View>
                            <View style={{ flex: 2 }}>
                                <CardSection>
                                    <Text style={{ fontWeight: 'bold',color: '#000',fontSize: 12,fontFamily: 'serif',alignSelf: 'center' }}>{item.service_name}</Text>
                                </CardSection>
                            </View>
                        </View>
                    </View >)}
                </View>
    
    
    
    
            )
        }
    
        const formatdata = (data,numofcolumns) => {
            const numoffullrows = Math.floor(data.length / numofcolumns);
            let noofelementslastrow = data.length - (numoffullrows * numofcolumns);
            while (noofelementslastrow !== numofcolumns && noofelementslastrow !== 0) {
                data.push({ serviceid: `blank-${noofelementslastrow}`,empty: true });
                noofelementslastrow = noofelementslastrow + 1;
            }
            return data;
        }
        // const setVechNo = (event) => {
    
        // }
    
        const _onChangeText = name => setVechno(name);
        _input.focus();
        const renderScreen = () => {
    
            return (
                <View>
    
    
                    <ScrollView style={{ flexGrow: 1,backgroundColor: '#fff' }}>
    
                        <TextInput style={styles.textStyle}
                            ref={(c) => _input = c}
                            placeholder="Enter Vechicle No"
                            value={vechno}
                            onChangeText={(vno) => _onChangeText(vno)}
                            blurOnSubmit={false}
                        >
                        </TextInput>
                        {/* <CardSection> */}
                        {makeList && makeList.length > 0 && (
                            <DropDownPicker
                                placeholder='Select Manufacture'
                                defaultValue={selectedmakeValue && selectedmakeValue}
                                // defaultValue={selectedmakeValue}
                                items={makeList}
                                searchable={true}
                                containerStyle={{ height: 50 }}
                                style={{ backgroundColor: '#fff',borderColor: '#000',borderWidth: 1,marginRight: 5,marginTop: 5,fontFamily: 'serif' }}
                                itemStyle={{
                                    justifyContent: 'flex-start',fontFamily: 'serif'
                                }}
                                dropDownStyle={{ backgroundColor: '#fff' }}
                                onChangeItem={itm => onChangeItem(itm)}
                            />
                        )}
    
                        {/* </CardSection> */}
                        {/* <CardSection> */}
                        {modelList && modelList.length > 0 && (
                            <DropDownPicker
                                placeholder="Select Model"
                                searchable={true}
                                defaultValue={selectedmodelValue && selectedmodelValue}
                                items={modelList}
                                containerStyle={{ height: 50 }}
                                style={{ backgroundColor: '#fff',marginTop: 10,}}
                                dropDownStyle={{ backgroundColor: '#fff' }}
                                onChangeItem={item => setSelectedModelValue(
                                    item.value
                                )}
                            />
                        )}
    
                        {/* </CardSection> */}
    
                        <TextInput style={styles.textStyle}
                            autoCorrect
                            placeholder="Other details"
                            value={other}
                            onChangeText={othr => setother(othr)}
                            blurOnSubmit={true}
    
                        ></TextInput>
    
    
                        <View style={{ marginLeft: 5,marginRight: 5 }}>
                            <ImageCardSection>
                                <Text style={{ fontWeight: 'bold',color: '#fff',fontSize: 20,fontFamily: 'serif' }}>Vechicle Problem</Text>
                            </ImageCardSection>
    
                            {serviceList && serviceList.length > 0 &&
    
                                <FlatList
                                    // data={serviceList}
                                    data={formatdata(serviceList,numofcolumns)}
                                    renderItem={renderItem}
                                    numColumns={numofcolumns}
                                    exTradata={serviceList}
                                    keyExtractor={item => item.serviceid}
                                />
                            }
    
                            <Button>SUBMIT</Button>
                        </View>
    
    
    
                        {loading && <Spinner />}
    
    
                    </ScrollView>
                </View>
            )
        };
        const FirstRoute = () => (
            renderScreen()
        );
    
        const SecondRoute = () => (
            <View></View>
        );
        const ThirdRoute = () => (
            <View></View>
        );
    
        const renderScene = SceneMap({
            1: FirstRoute,2: SecondRoute,3: ThirdRoute,});
        const renderTabBar = props => (
            <TabBar
                {...props}
                renderLabel={({ route,focused,color }) => (
                    <Text style={{ color,margin: 8,fontSize: 16 }}>
                        {route.title}
                    </Text>
                )}
                indicatorStyle={{ backgroundColor: '#ffa737' }}
                style={{ backgroundColor: '#000' }}
    
    
            />
        );
    
        return (
            <>
                <Header headerText='Car Rescue Form' />
                <TabView
                    renderTabBar={props => renderTabBar(props)}
                    navigationState={{ index,routes }}
                    renderScene={renderScene}
                    onIndexChange={(idx) => onIndexchange(idx,routes)}
                    initialLayout={initialLayout}
                    onSwipestart={() => setServiceList([])}
                    keyboarddismissMode={'on-drag'}
    
                />
            </>
    
        );
    }
    
    const styles = StyleSheet.create({
        scene: {
            flex: 1,},pikerStyle: {
            height: 50,borderRadius: 5,marginBottom: 10,color: '#000'
        },textStyle: {
            height: 50,marginTop: 10
        },imageStyle: {
            alignSelf: 'center',height: 30,width: 30,}
    });

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?