TabInfos.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * 新版充电站信息页面
  3. * @邠心vbe on 2023/02/06
  4. */
  5. import React, { Component } from 'react';
  6. import { View, StyleSheet, ScrollView, RefreshControl } from 'react-native';
  7. import TextView from '../../components/TextView';
  8. import PagerUtil from './PagerUtil';
  9. import { MyRefreshProps } from '../../components/ThemesConfig';
  10. export default class TabInfos extends Component {
  11. constructor(props) {
  12. super(props);
  13. this.state = {
  14. refreshing: false,
  15. stationInfo: {}
  16. };
  17. }
  18. componentDidMount() {
  19. PagerUtil.addOnRefresh(this);
  20. this.onRefresh();
  21. }
  22. onRefresh() {
  23. console.log("info刷新", this.props.route.name);
  24. this.setState({
  25. refreshing: false,
  26. stationInfo: PagerUtil.getStationInfo()
  27. });
  28. }
  29. onPullRefresh() {
  30. this.setState({
  31. refreshing: true
  32. })
  33. PagerUtil.setBackRefreshing();
  34. }
  35. getOperatingHours() {
  36. if (this.state.stationInfo?.endlessService) {
  37. return "24/7";
  38. } else if (this.state.stationInfo?.operatingHours) {
  39. return this.state.stationInfo?.operatingHours;
  40. } else {
  41. return $t('charging.toBeUpdated');
  42. }
  43. }
  44. getParkingFee() {
  45. if (this.state.stationInfo?.parkingFeeFree) {
  46. return $t('charging.free');
  47. } else if (this.state.stationInfo?.parkingFee) {
  48. return this.state.stationInfo.parkingFee;
  49. } else {
  50. return $t('charging.toBeUpdated');
  51. }
  52. }
  53. render() {
  54. return (
  55. <ScrollView
  56. style={styles.container}
  57. keyboardShouldPersistTaps={isIOS ? 'never' : 'handled'}
  58. contentContainerStyle={$padding(0, 16)}
  59. refreshControl={
  60. <RefreshControl
  61. {...MyRefreshProps()}
  62. refreshing={this.state.refreshing}
  63. onRefresh={() => this.onPullRefresh()}
  64. />
  65. }>
  66. <TextView style={styles.title}>{$t('charging.siteName')}</TextView>
  67. <View style={styles.infoView}>
  68. <TextView style={styles.infoText}>{this.state.stationInfo?.name}</TextView>
  69. </View>
  70. <TextView style={styles.title}>{$t('charging.siteAddress')}</TextView>
  71. <View style={styles.infoView}>
  72. <TextView style={styles.infoText}>{this.state.stationInfo?.address}</TextView>
  73. </View>
  74. <TextView style={styles.title}>{$t('charging.parkingFees')}</TextView>
  75. <View style={styles.infoView}>
  76. <TextView style={styles.infoText}>{this.getParkingFee()}</TextView>
  77. </View>
  78. <TextView style={styles.title}>{$t('charging.operatingHours')}</TextView>
  79. <View style={styles.infoView}>
  80. <TextView style={styles.infoText}>{this.getOperatingHours()}</TextView>
  81. </View>
  82. <TextView style={styles.title}>{$t('charging.additionalInformation')}</TextView>
  83. <View style={styles.infoView}>
  84. <TextView style={styles.infoText}>{this.state.stationInfo?.additionalNotes}</TextView>
  85. </View>
  86. </ScrollView>
  87. );
  88. }
  89. }
  90. const styles = StyleSheet.create({
  91. container: {
  92. flex: 1
  93. },
  94. title: {
  95. color: '#000',
  96. fontSize: 14,
  97. fontWeight: 'bold',
  98. ...$padding(16, 0, 8),
  99. borderBottomColor: '#eee',
  100. borderBottomWidth: 1
  101. },
  102. infoView: {
  103. paddingTop: 8,
  104. paddingBottom: 16
  105. },
  106. infoText: {
  107. color: '#444',
  108. fontSize: 14
  109. }
  110. })