/** * Site Information页面 * @邠心vbe on 2021/07/06 */ import React, { Component } from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default class SiteInfo extends Component { constructor(props) { super(props); this.state = { refreshId: 0, stationInfo: {} }; } componentDidMount() { if (this.props.stationInfo) { this.setState({ stationInfo: this.props.stationInfo }); } } componentDidUpdate() { if (this.props.refreshId != this.state.refreshId) { this.setState({ refreshId: this.props.refreshId, stationInfo: this.props.stationInfo }); } } getOperatingHours() { if (this.state.stationInfo.endlessService) { return "24/7"; } else if (this.state.stationInfo.operatingHours) { return this.state.stationInfo.operatingHours; } else { return 'To be updated'; } } getParkingFee() { if (this.state.stationInfo.parkingFeeFree) { return "Free"; } else if (this.state.stationInfo.parkingFee) { return this.state.stationInfo.parkingFee; } else { return 'To be updated'; } } render() { return ( Address {this.state.stationInfo.address} Operating Hours {this.getOperatingHours()} Parking Fee {this.getParkingFee()} Additional Information {this.state.stationInfo.additionalNotes} ); } } const styles = StyleSheet.create({ title: { color: '#000', fontSize: 14, fontWeight: 'bold', ...$padding(16, 0, 8), borderBottomColor: '#eee', borderBottomWidth: 1 }, infoView: { paddingTop: 8, paddingBottom: 16 }, infoText: { color: '#444', fontSize: 14 } })