import * as React from 'react'; import {useState, useEffect} from 'react'; import { connect } from "react-redux"; import { SafeAreaView, Button, View, Text, Image, ScrollView, StyleSheet, TouchableOpacity } from 'react-native'; import {useNetInfo} from "@react-native-community/netinfo"; import NetInfo from "../../components/netstatus"; // import NetInfo from "@react-native-community/netinfo"; import CustomHeader from '../../components/header.js'; import Assets from '../../components/assets.manager.js'; import Elements from '../../components/elements.js'; import Theme from '../../components/theme.style.js'; import {Icon} from 'react-native-elements'; import DB from '../../components/storage/'; import REQUEST from '../../components/api/'; import CustomSafeArea from '../../components/safeArea.component'; const Content = require("./aboutus.json"); class About extends React.Component { constructor(props) { super(props) } state = { drop1: false, drop2: false, data: {}, connected: false } componentDidMount() { this.initAbount() } componentWillUnmount() { } initAbount = () => { NetInfo.netstatus(isConnected => { if(isConnected) { this.init() } else { Elements.nointernet2() } }) } init = async () => { this.setState({ connected: true }) await REQUEST("contact_us", "get", {}, {}, {}, async (res) => { console.log(res) if(res.status == 1 && res.data) { this.setState({ data: res.data }) } else { console.log(res.message, res.data) } }, (error) => { console.log(error) }) } fetch = (detail) => { if(!this.state.connected) return null let r = "" let d = detail.split(`"`) for(var x=0;x { if(!this.state.connected) return null return ( this.setState({ drop1: !this.state.drop1 })}> WHAT WE DO {this.state.drop1 ? {this.fetch(this.state.data.what_we_do_content)} : null} this.setState({ drop2: !this.state.drop2 })}> WHY UNIOIL {this.state.drop2 ? {this.fetch(this.state.data.why_unioil_content)} : null} ) } render() { return ( {this.state.connected ? WHO WE ARE {this.state.data.who_we_are_content} {this.renderDetails()} : null } ); } } const mapStateToProps = (state) => { return { app_theme: state.appThemeReducer.theme } } export default connect(mapStateToProps, null)(About) // export default function About(navigation) { // const [drop1, setdrop1] = useState(false) // const [drop2, setdrop2] = useState(false) // const [data, setdata] = useState({}) // const netInfo = useNetInfo() // const init = async () => { // await REQUEST("contact_us", "get", {}, {}, {}, // async (res) => { // if(res.status == 1 && res.data){ // await setdata(await res.data) // }else{ // console.log(res.message, res.data) // } // }, function(error){ // console.log(error) // }) // } // useEffect(() => { // NetInfo.fetch().then(state => { // console.log("Connection type", state.type); // console.log("Is connected?", state.isConnected); // if(state.isConnected){ // init() // }else{ // Elements.nointernet2() // } // }); // }, []) // const fetch = (detail) => { // if(!netInfo.isConnected) return null // let r = "" // let d = detail.split(`"`) // for(var x=0;x { // if(!netInfo.isConnected) return null // return ( // // // // setdrop1(!drop1)}> // WHAT WE DO // // // // // // {drop1 ? {fetch(data.what_we_do_content)} : null} // // // // setdrop2(!drop2)}> // WHY UNIOIL // // // // // // {drop2 ? {fetch(data.why_unioil_content)} : null} // // ) // } // return ( // // // {netInfo.isConnected ? // // // WHO WE ARE // {data.who_we_are_content} // {renderDetails()} // // // : null } // // ); // }