/** * 首页顶部充电站信息组件 * @邠心vbe on 2021/08/13 */ import React from 'react'; import { Pressable, StyleSheet, View, Text, Image } from 'react-native'; import { ElevationObject } from '../../../components/Button'; import utils from '../../../utils/utils'; import { ChargeStyle } from '../../charge/Charging'; import { PageList } from '../../Router'; export default TopInfo = ({stationInfo = {}}) => { const getAvailable = (type) => { const all = stationInfo.allConnector; if (all) { if (type == 'box') { return all.boxAvailable + '/' + all.boxAll; } else { return all.available + '/' + all.all; } } else { return '0/0'; } } if (stationInfo.id) { return ( startPage(PageList.chargeDetail, {stationInfo: stationInfo, action: 'view'})}> {stationInfo.name} {stationInfo.address} { stationInfo.allConnector && stationInfo.allConnector.available > 0 && Available } {stationInfo.siteType} {getAvailable('box')} {getAvailable('inc')} { utils.directMaps(stationInfo.latitude, stationInfo.longitude, stationInfo.address); }}> {stationInfo.distance} ); } else { return <>; } } const styles = StyleSheet.create({ stationBarView: { top: 16, left: 16, right: 16, height: 69, zIndex: 10, borderRadius: 6, ...$padding(12, 9), position: 'absolute', alignItems: 'center', flexDirection: 'row', backgroundColor: colorLight, ...ElevationObject(1.5) }, stationInfo: { flex: 1, height: 45, paddingLeft: 4, paddingRight: 8, justifyContent: 'space-around' }, stationTitle: { color: '#000', fontSize: 16, paddingBottom: 2 }, stationAddress: { color: '#999', fontSize: 12, }, stationAvailable: { height: 45, paddingLeft: 8, paddingRight: 8, alignItems: 'center', justifyContent: 'space-between' }, stationStatusView: { marginRight: 4, alignItems: 'center', justifyContent: 'center' }, stationStatus: { fontSize: 10, ...$padding(2, 6) }, siteTypes: { fontSize: 10, marginTop: 4, ...$padding(2, 6) }, availableIcon: { width: 23, height: 23, }, availableText: { color: textPrimary, fontSize: 13, textAlign: 'center' }, directView: { zIndex: 1, height: 45, marginLeft: 8, marginRight: 4, alignItems: 'center', justifyContent: 'space-between' }, distanceText: { color: textPrimary, fontSize: 12, } })