Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON value '1' of type NSNumber cannot be converted to UIEdgeInsets in react-native ios version #249

Open
kawsar6848 opened this issue Jul 24, 2022 · 0 comments

Comments

@kawsar6848
Copy link

kawsar6848 commented Jul 24, 2022

Getting this error in my screen. How can I solve this. I am using react native 0.64.3 version.
import React, { useEffect, useState } from 'react';
import {
StatusBar,
View,
Text,
FlatList,
TouchableOpacity,
Image,
Dimensions,
Pressable,
TextInput,
ActivityIndicator,
} from 'react-native';
import axios from 'react-native-axios';
import { BASE_URL, LOGIN_URL } from '../components/APIs';
import { AppFont } from '../components/Constatnts';
import Icon from 'react-native-vector-icons/Ionicons';
import OutofNetwork from './OutOfNetwork';
import changeNavigationBarColor, {
hideNavigationBar,
showNavigationBar,
} from 'react-native-navigation-bar-color';
import LinearGradient from 'react-native-linear-gradient';
import { UserId, Token } from '../components/Token';
import AsyncStorage from '@react-native-async-storage/async-storage';
import UploadRequest from './UploadRequest';
import ActionSheet from 'react-native-actions-sheet';
import Filter from './Filter';
import { filterStyles } from './FilterStyles';
import {
widthPercentageToDP as wp,
heightPercentageToDP as hp,
} from 'react-native-responsive-screen';
import StyleSheet from 'react-native-media-query';
import C1loader from './C1loader';
const numColumns = 3;
const Series = () => {
const actionSheetRef = React.useRef();
const [movieInfo, setMovieInfo] = React.useState([]);
const [searching, setSearching] = useState(false);
const [showSeriesView, setShowSeriesView] = useState(true);
const [showLoader, setShowLoader] = useState(false);
const [inputData, setInputData] = useState('');
const [skipCount, setSkipCount] = useState(0);
const [showActivityLoader, setShowActivityLoader] = useState(true);
const [seriesYears, setSeriesYears] = useState([]);
const [seriesGenreArr, setSeriesGenreArr] = useState([]);
const [seriesArray, setMovieArray] = useState({
getCategoryArray: [],
getAllSeriesArray: [],
getAllSeriesGenre: [],
getAllSeriesYears: [],
categoryDataIsLoaded: 0,
});

const [data, setData] = useState({
    catName: 'Bangla Tv Series',
    catIsSelected: 2,
});

let onEndReachedCalledDuringMomentum = true;
let seriesCat = [];
let seriesAll = [];
let seriesGenre = [];
let getAllSeriesYear = [];
let limit = 0;

useEffect(() => {
    if (skipCount == 0) {
        getAllMovieCategory();
    } else {
        loadMoreSeriesData();
    }
}, [data, skipCount]);

useEffect(async () => {
    loadInitialData();
}, []);
const loadInitialData = async () => {
    await axios
        .get(BASE_URL + 'getAllSeriesGenre.php')
        .then((response) => {
            console.log("response from getAllSeriesGenre", response);
            response.data.map((val, key) => {
                if (val != '0') {
                    let pushValue = {
                        id: key + 1,
                        genre: val,
                    };
                    seriesGenre.push(pushValue);
                }
            });
            setSeriesGenreArr(seriesGenre);
        })
        .catch((err) => console.log(err));
    await axios
        .get(BASE_URL + 'getAllSeriesYears.php')
        .then((response) => {
            console.log("response from getAllSeriesYears", response);
            response.data.map((val, key) => {
                if (val != '0') {
                    let pushValue = {
                        id: key + 1,
                        year: val,
                    };
                    getAllSeriesYear.push(pushValue);
                }
            });
            setSeriesYears(getAllSeriesYear);
        })
        .catch((err) => console.log(err));
};
const getAllMovieCategory = async () => {
    if (
        seriesArray['getCategoryArray'].length == 0 ||
        seriesArray['categoryDataIsLoaded'] == 0
    ) {
        let getSkipCount = skipCount;
        setShowLoader(true);
        await axios
            .get(BASE_URL + 'getSeriesCats.php')
            .then((response) => {
                console.log("response getSeriesCats....", response);
                response.data.map((val, key) => {
                    if (val != '0') {
                        let pushValue = {
                            id: key + 1,
                            catName: val,
                        };
                        seriesCat.push(pushValue);
                    }
                });
            })
            .catch((err) => console.log(err));
        let x = ${BASE_URL}getSeries.php?category=${data.catName}&skip=${getSkipCount};
        await axios
            .get(x)
            .then((response) => {
                if (response.data.length == 0) {
                    setShowActivityLoader(false);
                } else if (response.data.length > 1 && response.data.length < 20) {
                    setShowActivityLoader(false);
                } else {
                    setShowActivityLoader(true);
                }
                response.data.map((val, key) => {
                    seriesAll.push(val);
                });
                if (seriesArray['categoryDataIsLoaded'] !=data['catIsSelected']) {
                    setMovieArray({
                        getAllSeriesArray: seriesAll,
                        getCategoryArray: seriesCat,
                        getAllSeriesGenre: seriesGenre,
                        getAllSeriesYears: getAllSeriesYear,
                        categoryDataIsLoaded: 1,
                    });
                }
                setShowLoader(false);
            })
            .catch((err) => console.log(err));
    }
};

const loadMoreSeriesData = async () => {
    let seriesAll = [];
    let getSkipCount = skipCount;
    let x = ${BASE_URL}getSeries.php?category=${data.catName}&skip=${getSkipCount};
    await axios
        .get(x)
        .then((response) => {
            console.log('response......', response.data);
            if (response.data.length == 0) {
                setShowActivityLoader(false);
            } else if (response.data.length > 1 && response.data.length < 20) {
                setShowActivityLoader(false);
            } else {
                setShowActivityLoader(true);
            }
            console.log('reponse from loadMoreSeriesData', response);
            response.data.map((val, key) => {
                seriesAll.push(val);
            });
            if (seriesArray['categoryDataIsLoaded'] != data['catIsSelected']) {
                setMovieArray({
                    ...seriesArray,
                    getAllSeriesArray: [...seriesArray.getAllSeriesArray, ...seriesAll],
                    categoryDataIsLoaded: 1,
                });
                setSkipCount(getSkipCount);
            }
            setShowLoader(false);
        })
        .catch((err) => console.log(err));
};
const _renderCategory = ({item, index}) => {
    console.log("item.id", item.id, typeof(item.id));
    console.log("data.catIsSelected", data.catIsSelected, typeof(data.catIsSelected));
    return (
      <Text style={{color: '#fff'}}>{item.id}</Text>
    );
  };
return (
    <View style={styles.container}>
        <StatusBar barStyle="light-content" backgroundColor="#000" />
        {showLoader ? <C1loader /> : null}
        <View style={{ flex: 1, paddingTop: 35 }}>
            <View style={{
                flex: 1,
                width: '100%',
                paddingHorizontal: 10,
                paddingTop: 10,
            }}>
                <View
                    style={{
                        flexDirection: 'row',
                        justifyContent: 'flex-start',
                        alignItems: 'center',
                    }}>
                    <TextInput
                        placeholder="Search here.."
                        onChangeText={(val) => onChangeSearch(val)}
                        placeholderTextColor="#959595"
                        value={inputData}
                        style={{
                            ...filterStyles.styles.searchInput,
                            width: '82%',
                            position: 'relative',
                        }}
                    />
                    <View
                        style={{
                            position: 'absolute',
                            right: wp('20%'),
                            backgroundColor: '#363637',
                            height: hp('4.5%'),
                            justifyContent: 'center',
                            paddingRight: wp('2.25%'),
                            borderTopRightRadius: 5,
                            borderBottomRightRadius: 5,
                        }}>
                        <Icon
                            name="search-outline"
                            size={14}
                            style={{ color: '#959595' }}
                        />
                    </View>
                    <TouchableOpacity
                        onPress={() => {
                            actionSheetRef.current?.show();
                        }}>
                        <Image
                            source={require('../assets/filter.png')}
                            style={{ width: 20, height: 20, marginLeft: 15 }}
                        />
                    </TouchableOpacity>
                </View>
                <View style={{ flex: 1 }}>
                    <UploadRequest />
                    <View style={{ backgroundColor: '#1C1C1C' }}>
                        <Flatlist
                            data={seriesArray.getCategoryArray}
                            renderItem={_renderCategory}
                            keyExtractor={item => item.id.toString()}
                            scrollEnabled={true}
                            horizontal={true}
                            scrollIndicatorInsets={true}
                        />
                    </View>
                </View>
            </View>
        </View>
    </View>
)

}

export default Series
const { ids, styles } = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#1C1C1C',
},
singleCategory: {
color: '#A3A3A3',
fontSize: wp('3.45%'),
lineHeight: wp('3.45%') + 5,
fontFamily: AppFont.PoppinsSemiBold,
'@media (max-width: 399px) and (min-width: 390px)': {
fontSize: wp('4.15%'),
lineHeight: wp('4.15%') + 5,
},
},
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant