{"size": 1631, "ext": "js", "max_stars_repo_path": "src/App.js", "max_stars_repo_name": "scorpionknifes/CryptoTrackerSyloApp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/App.js", "max_issues_repo_name": "scorpionknifes/CryptoTrackerSyloApp", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/App.js", "max_forks_repo_name": "scorpionknifes/CryptoTrackerSyloApp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 34.7021276596, "max_line_length": 96, "alphanum_fraction": 0.5910484365}
import React, { useState, useEffect, useContext } from 'react'
import { View, BackHandler,TouchableOpacity } from 'react-native';
import { TimeSelectComponent, SearchBarComponent } from './components';
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
import { TokenScreen, TrackerScreen } from './screens'
import TrackerProivider, { TrackerContext } from './context/TrackerContext';

const App = () => {
    const [scene, changeScene] = useState(true);

    useEffect(() => {
        const backAction = () => {
            if (scene) {
                BackHandler.exitApp()
            } else {
                changeScene(false)
            }
        };
        const backHandler = BackHandler.addEventListener(
            "hardwareBackPress",
            backAction
        );
        return () => backHandler.remove();
    }, []);

    return (
        <TrackerProivider changeScene={changeScene}>
            <Body scene={scene} />
        </TrackerProivider>
    );
}

const Body = (props) => {
    const { darkTheme, setDarkTheme } = useContext(TrackerContext);
    return (<View style={{ flex: 1, backgroundColor: darkTheme ? 'black' : 'white' }}>
        <SearchBarComponent />
        <TimeSelectComponent />
        {props.scene ? <TrackerScreen /> : <TokenScreen />}
        <View style={{ position: 'absolute', bottom: 0, alignSelf: 'flex-end' }}>
            <TouchableOpacity onPress={() => setDarkTheme(!darkTheme)}>
                <FontAwesome5 name='moon' size={24} color={darkTheme ? '#F6F6F6' : '#495162'} />
            </TouchableOpacity>
        </View>
    </View>)
}

export default App;