GoPathSummary.js 4.72 KB
import React, {useState, useEffect} from 'react';
import {Text, View, StyleSheet, TouchableOpacity, ScrollView} from 'react-native';
import styled from 'styled-components';
import {MaterialCommunityIcons, AntDesign} from '@expo/vector-icons';
import {useNavigation} from '@react-navigation/native';


const ShowDetail = styled.TouchableOpacity`
    flex: 2;
    position: absolute;
    right: 6px;
    bottom: 2px;
    width: 30px;
    height: 30px;
    border-radius: 50px;
`;

const Banner = styled.View`
    flex: 1;
    margin-left: 15px;
    margin-bottom: 5px;
    width: 3px;
    height: 3px;
    border-radius: 20px;
    border: 3px solid #273b96;
`;


const GoPathSummary = (props) => {
    const navigation = useNavigation();
    const [pathSummary, setPathSummary] = useState(null);
    const goPathDetail = () => {
        navigation.navigate('GoPathDetail', {'detail': props.detail});
    };

    useEffect
    (() => {
        console.log(props.summary);
        setPathSummary(props.summary);
    }, []);


    return (
        <View>
            {pathSummary ?
                <>
                    <View style={styles.container}>

                        <View style={styles.titleParagraph}>
                            <Text style={styles.hourStyle}>{pathSummary.hour1} {pathSummary.min1} 출발
                                <Text style={styles.conditionStyle}>정확</Text>
                            </Text>
                            <Text style={styles.hourStyle}>{pathSummary.hour2} {pathSummary.min2} 출발
                                <Text style={styles.conditionStyle}>여유</Text>
                            </Text>
                        </View>
                        <View style={{flexDirection: 'row', flex: 2, marginLeft: 70}}>
                            <Text style={{flex: 1, fontSize: 13, fontWeight: 'bold'}}>총소요시간: {pathSummary.totalTime}</Text>
                            <Text style={{flex: 1, fontSize: 13, fontWeight: 'bold'}}>비용: {pathSummary.payment}</Text>
                        </View>
                        <View style={{flexDirection: 'row', flex: 5, marginLeft: 70, marginTop: 20}}>
                            <View style={styles.pathType}>
                                <MaterialCommunityIcons style={{flex: 1}} color={'#273b96'} name={'train'} size={20}/>
                            </View>
                            <View style={styles.inputTile}>
                                <Text style={styles.stationStyle}>{pathSummary.firstStartStation}</Text>
                                <Text style={styles.stationStyle}>{pathSummary.lastEndStation}</Text>
                            </View>
                        </View>
                        <View style={{position: 'absolute', right: 10}}>
                            <ShowDetail onPress={goPathDetail}>
                                <AntDesign color={'darkgrey'} name={'caretright'} size={32}/>
                            </ShowDetail>
                        </View>

                    </View>
                </>
                :
                null
            }
        </View>
    );
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        flexDirection: 'column',
        paddingTop: 40,
        paddingBottom: 30,
        backgroundColor: '#ecf0f1',
        alignItems: 'center',
        justifyContent: 'center',
        borderWidth: 1,
        borderColor: 'darkgrey',
    },
    paragraph: {
        flex: 1,
        fontSize: 14,
        fontWeight: 'bold',
        textAlign: 'center',
        color: '#34495e',
    },
    titleParagraph: {
        flexDirection: 'column',
        flex: 1,
    },
    inputTile: {
        marginLeft: 6,
        flex: 4,
        color: 'grey',
    },
    inputText: {
        fontWeight: 'normal',
        fontSize: 15,
    },
    pathType: {
        flexDirection: 'column',
        flex: 0.4,
        alignItems: 'center',
        justifyContent: 'center',
        marginLeft: 5,
        marginTop: 10,
    },
    stationStyle: {
        fontWeight: 'bold',
        fontSize: 15,
    },
    idStyle: {
        marginTop: 3,
        marginBottom: 20,
        color: 'grey',
        fontSize: 14
    },
    laneStyle: {
        fontWeight: 'bold',
        fontSize: 15,
        color: '#EBA900'
    },
    cntStyle: {
        flex: 1,
        marginTop: 20,
        marginBottom: 3,
        color: 'grey',
        fontSize: 14
    },
    stationListStyle: {
        flexDirection: 'row',
        flex: 1,
    },
    hourStyle: {
        flexDirection: 'row',
        flex: 1,
        fontSize: 18,
        fontWeight: 'bold',
        marginBottom: 20,
    },
    conditionStyle: {
        paddingLeft: 10,
        fontSize: 15,
        color: 'red',
    }
});

export default GoPathSummary;