DialogIdleFee.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import React, { useState } from 'react';
  2. import { Modal, View, Text, Pressable, StyleSheet } from 'react-native';
  3. import { ElevationObject } from '../../components/Button';
  4. import TextView from '../../components/TextView';
  5. import utils from '../../utils/utils';
  6. const DialogIdleFee = ({
  7. idleFeeConfig
  8. }) => {
  9. const [visible, showModal] = useState(false)
  10. return (
  11. <>
  12. <Pressable
  13. style={styles.cardView}
  14. onPress={() => showModal(true)}>
  15. <MaterialCommunityIcons
  16. name={"car-clock"}
  17. size={32}
  18. color={colorAccent}
  19. />
  20. <TextView style={styles.label}>This site has idle fees enabled.</TextView>
  21. <FontAwesome6
  22. name={"angle-right"}
  23. size={16}
  24. color={colorCancel}
  25. />
  26. </Pressable>
  27. <Modal
  28. visible={visible}
  29. transparent={true}
  30. animationType="fade"
  31. statusBarTranslucent={true}>
  32. <View style={styles.layer}>
  33. <View style={styles.dialog}>
  34. <TextView style={styles.title}>Idle Fees</TextView>
  35. <View style={styles.message}>
  36. { utils.isNotEmpty(idleFeeConfig.repeatDay) && <>
  37. <TextView style={styles.idleFeeLabel}>Effective Days: </TextView>
  38. <TextView style={styles.idleFeeText}>{utils.join(idleFeeConfig.repeatDay, ", ")}</TextView>
  39. </>
  40. }
  41. <TextView style={styles.idleFeeLabel}>Effective Time:</TextView>
  42. { idleFeeConfig.allDay
  43. ? <TextView style={styles.idleFeeText}>All day</TextView>
  44. : (utils.isNotEmpty(idleFeeConfig.startTime) && utils.isNotEmpty(idleFeeConfig.endTime)) &&
  45. <TextView style={styles.idleFeeText}>{idleFeeConfig.startTime + " - " + idleFeeConfig.endTime}</TextView>
  46. }
  47. { utils.isNotEmpty(idleFeeConfig.idleGracePeriod) &&
  48. <>
  49. <TextView style={styles.idleFeeLabel}>Grace Period: </TextView>
  50. <TextView style={styles.idleFeeText}>{idleFeeConfig.idleGracePeriod} min</TextView>
  51. </>
  52. }
  53. <TextView style={styles.idleFeeLabel}>Charging Rate: </TextView>
  54. <TextView style={styles.idleFeeText}>{idleFeeConfig.idleFee}/{idleFeeConfig.idleInterval} min </TextView>
  55. { utils.isNotEmpty(idleFeeConfig.idleFeeCap) &&
  56. <>
  57. <TextView style={styles.idleFeeLabel}>Idle Fee Cap: </TextView>
  58. <TextView style={styles.idleFeeText}>{idleFeeConfig.idleFeeCap}</TextView>
  59. </>
  60. }
  61. </View>
  62. {/* <TextView style={styles.message}>{
  63. "Grace Period of " + idleFeeConfig.idleGracePeriod + " Minutes. Rates are" + idleFeeConfig.idleFee + " per " + idleFeeConfig.idleInterval + " Min. Idle Fee is capped at " + idleFeeConfig.idleFeeCap
  64. }</TextView> */}
  65. <View style={ui.flexc}>
  66. <Button
  67. style={styles.confirmButton}
  68. text={$t("nav.ok")}
  69. borderRadius={0}
  70. onClick={() => showModal(false)}/>
  71. </View>
  72. </View>
  73. </View>
  74. </Modal>
  75. </>
  76. )};
  77. const B = ({children}) => {
  78. return <Text style={{fontWeight: "bold"}}>{children}</Text>
  79. }
  80. export default DialogIdleFee;
  81. const styles = StyleSheet.create({
  82. cardView: {
  83. padding: 12,
  84. borderRadius: 10,
  85. marginBottom: 12,
  86. alignItems: 'center',
  87. flexDirection: 'row',
  88. ...ElevationObject(5),
  89. backgroundColor: colorLight,
  90. justifyContent: 'space-between'
  91. },
  92. layer: {
  93. flex: 1,
  94. alignItems: 'center',
  95. justifyContent: 'center',
  96. backgroundColor: 'rgba(0,0,0,.5)'
  97. },
  98. dialog: {
  99. width: Dialog.dialogWidth,
  100. borderRadius: isIOS ? 16 : 12,
  101. overflow: 'hidden',
  102. backgroundColor: colorLight
  103. },
  104. label: {
  105. flex: 1,
  106. color: textPrimary,
  107. fontSize: 14,
  108. fontWeight: 'bold',
  109. paddingLeft: 14
  110. },
  111. title: {
  112. paddingTop: 24,
  113. color: textPrimary,
  114. fontSize: 18,
  115. fontWeight: 'bold',
  116. textAlign: "center"
  117. },
  118. message: {
  119. color: textPrimary,
  120. fontSize: 14,
  121. paddingTop: 16,
  122. paddingLeft: 24,
  123. paddingRight: 24,
  124. paddingBottom: 32
  125. },
  126. idleFeeLabel: {
  127. color: textPrimary,
  128. fontSize: 14,
  129. paddingTop: 12,
  130. fontWeight: "bold"
  131. },
  132. idleFeeText: {
  133. color: textPrimary,
  134. fontSize: 14,
  135. paddingTop: 4
  136. },
  137. cancelButton: {
  138. flex: 1,
  139. borderRadius: 0,
  140. backgroundColor: "#F0F0F0"
  141. },
  142. confirmButton: {
  143. flex: 1,
  144. borderRadius: 0,
  145. backgroundColor: colorAccent
  146. }
  147. })