@miot-rn/car-component 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/README.md +325 -0
  2. package/dist/assets/i18n/ar.d.ts +55 -0
  3. package/dist/assets/i18n/ar.js +55 -0
  4. package/dist/assets/i18n/bo.d.ts +55 -0
  5. package/dist/assets/i18n/bo.js +55 -0
  6. package/dist/assets/i18n/cs.d.ts +55 -0
  7. package/dist/assets/i18n/cs.js +55 -0
  8. package/dist/assets/i18n/de.d.ts +55 -0
  9. package/dist/assets/i18n/de.js +55 -0
  10. package/dist/assets/i18n/el.d.ts +55 -0
  11. package/dist/assets/i18n/el.js +55 -0
  12. package/dist/assets/i18n/en.d.ts +55 -0
  13. package/dist/assets/i18n/en.js +55 -0
  14. package/dist/assets/i18n/es.d.ts +55 -0
  15. package/dist/assets/i18n/es.js +55 -0
  16. package/dist/assets/i18n/es_us.d.ts +55 -0
  17. package/dist/assets/i18n/es_us.js +55 -0
  18. package/dist/assets/i18n/fi.d.ts +55 -0
  19. package/dist/assets/i18n/fi.js +55 -0
  20. package/dist/assets/i18n/fr.d.ts +55 -0
  21. package/dist/assets/i18n/fr.js +55 -0
  22. package/dist/assets/i18n/he.d.ts +55 -0
  23. package/dist/assets/i18n/he.js +55 -0
  24. package/dist/assets/i18n/hu.d.ts +55 -0
  25. package/dist/assets/i18n/hu.js +55 -0
  26. package/dist/assets/i18n/id.d.ts +55 -0
  27. package/dist/assets/i18n/id.js +55 -0
  28. package/dist/assets/i18n/it.d.ts +55 -0
  29. package/dist/assets/i18n/it.js +55 -0
  30. package/dist/assets/i18n/ja.d.ts +55 -0
  31. package/dist/assets/i18n/ja.js +55 -0
  32. package/dist/assets/i18n/ko.d.ts +55 -0
  33. package/dist/assets/i18n/ko.js +55 -0
  34. package/dist/assets/i18n/nb.d.ts +55 -0
  35. package/dist/assets/i18n/nb.js +55 -0
  36. package/dist/assets/i18n/nl.d.ts +55 -0
  37. package/dist/assets/i18n/nl.js +55 -0
  38. package/dist/assets/i18n/pl.d.ts +55 -0
  39. package/dist/assets/i18n/pl.js +55 -0
  40. package/dist/assets/i18n/pt.d.ts +55 -0
  41. package/dist/assets/i18n/pt.js +55 -0
  42. package/dist/assets/i18n/pt_pt.d.ts +55 -0
  43. package/dist/assets/i18n/pt_pt.js +55 -0
  44. package/dist/assets/i18n/ro.d.ts +55 -0
  45. package/dist/assets/i18n/ro.js +55 -0
  46. package/dist/assets/i18n/ru.d.ts +55 -0
  47. package/dist/assets/i18n/ru.js +55 -0
  48. package/dist/assets/i18n/sk.d.ts +55 -0
  49. package/dist/assets/i18n/sk.js +55 -0
  50. package/dist/assets/i18n/sv.d.ts +55 -0
  51. package/dist/assets/i18n/sv.js +55 -0
  52. package/dist/assets/i18n/th.d.ts +55 -0
  53. package/dist/assets/i18n/th.js +55 -0
  54. package/dist/assets/i18n/tr.d.ts +55 -0
  55. package/dist/assets/i18n/tr.js +55 -0
  56. package/dist/assets/i18n/uk.d.ts +55 -0
  57. package/dist/assets/i18n/uk.js +55 -0
  58. package/dist/assets/i18n/vi.d.ts +55 -0
  59. package/dist/assets/i18n/vi.js +55 -0
  60. package/dist/assets/i18n/zh.d.ts +55 -0
  61. package/dist/assets/i18n/zh.js +55 -0
  62. package/dist/assets/i18n/zh_hk.d.ts +55 -0
  63. package/dist/assets/i18n/zh_hk.js +55 -0
  64. package/dist/assets/i18n/zh_tw.d.ts +55 -0
  65. package/dist/assets/i18n/zh_tw.js +55 -0
  66. package/dist/assets/image/dark/car_background_dark.png +0 -0
  67. package/dist/assets/image/default/car_background.png +0 -0
  68. package/dist/components/airConditioningCard/index.d.ts +24 -0
  69. package/dist/components/airConditioningCard/index.js +103 -0
  70. package/dist/components/carInfoHeader/carImage.d.ts +8 -0
  71. package/dist/components/carInfoHeader/carImage.js +42 -0
  72. package/dist/components/carInfoHeader/dualRangeIndicator.d.ts +15 -0
  73. package/dist/components/carInfoHeader/dualRangeIndicator.js +124 -0
  74. package/dist/components/carInfoHeader/index.d.ts +37 -0
  75. package/dist/components/carInfoHeader/index.js +118 -0
  76. package/dist/components/carInfoHeader/parkingStatus.d.ts +12 -0
  77. package/dist/components/carInfoHeader/parkingStatus.js +100 -0
  78. package/dist/components/carInfoHeader/rangeProgressBar.d.ts +14 -0
  79. package/dist/components/carInfoHeader/rangeProgressBar.js +77 -0
  80. package/dist/components/carInfoHeader/singleRangeIndicator.d.ts +11 -0
  81. package/dist/components/carInfoHeader/singleRangeIndicator.js +58 -0
  82. package/dist/components/cardContainer/index.d.ts +8 -0
  83. package/dist/components/cardContainer/index.js +22 -0
  84. package/dist/components/containerWithGap/gapWrap.d.ts +8 -0
  85. package/dist/components/containerWithGap/gapWrap.js +31 -0
  86. package/dist/components/containerWithGap/index.d.ts +12 -0
  87. package/dist/components/containerWithGap/index.js +43 -0
  88. package/dist/components/flatSelect/FlatOption.d.ts +18 -0
  89. package/dist/components/flatSelect/FlatOption.js +117 -0
  90. package/dist/components/flatSelect/FlatSelect.d.ts +14 -0
  91. package/dist/components/flatSelect/FlatSelect.js +112 -0
  92. package/dist/components/flatSelect/index.d.ts +2 -0
  93. package/dist/components/flatSelect/index.js +2 -0
  94. package/dist/components/flatSelect/index.zh-CN.md +89 -0
  95. package/dist/components/groupContainer/index.d.ts +9 -0
  96. package/dist/components/groupContainer/index.js +48 -0
  97. package/dist/components/otherSettingCard/index.d.ts +8 -0
  98. package/dist/components/otherSettingCard/index.js +40 -0
  99. package/dist/components/pageBackground/index.d.ts +7 -0
  100. package/dist/components/pageBackground/index.js +22 -0
  101. package/dist/components/seatControl/index.d.ts +34 -0
  102. package/dist/components/seatControl/index.js +98 -0
  103. package/dist/components/seatControl/seatCard.d.ts +11 -0
  104. package/dist/components/seatControl/seatCard.js +24 -0
  105. package/dist/components/seatControl/seatCardRow.d.ts +29 -0
  106. package/dist/components/seatControl/seatCardRow.js +48 -0
  107. package/dist/components/seatControlGroup/index.d.ts +40 -0
  108. package/dist/components/seatControlGroup/index.js +51 -0
  109. package/dist/components/steeringWheelHotCard/index.d.ts +17 -0
  110. package/dist/components/steeringWheelHotCard/index.js +66 -0
  111. package/dist/components/titleContainer/TitleContainer.d.ts +4 -0
  112. package/dist/components/titleContainer/TitleContainer.js +148 -0
  113. package/dist/components/titleContainer/TitleContainer.zh-CN.md +62 -0
  114. package/dist/components/titleContainer/index.d.ts +1 -0
  115. package/dist/components/titleContainer/index.js +1 -0
  116. package/dist/components/titleContainer/interface.d.ts +48 -0
  117. package/dist/components/titleContainer/interface.js +21 -0
  118. package/dist/components/warningForRunningCard/index.d.ts +6 -0
  119. package/dist/components/warningForRunningCard/index.js +20 -0
  120. package/dist/config/ConnectStatus.d.ts +7 -0
  121. package/dist/config/ConnectStatus.js +8 -0
  122. package/dist/config/index.d.ts +16 -0
  123. package/dist/config/index.js +16 -0
  124. package/dist/config/seatFunctionType.d.ts +7 -0
  125. package/dist/config/seatFunctionType.js +24 -0
  126. package/dist/config/seatGearLevel.d.ts +21 -0
  127. package/dist/config/seatGearLevel.js +19 -0
  128. package/dist/config/seatI18nKeys.d.ts +9 -0
  129. package/dist/config/seatI18nKeys.js +9 -0
  130. package/dist/config/seatPosition.d.ts +8 -0
  131. package/dist/config/seatPosition.js +8 -0
  132. package/dist/config/seatRowConfig.d.ts +6 -0
  133. package/dist/config/seatRowConfig.js +6 -0
  134. package/dist/global.d.js +0 -0
  135. package/dist/hooks/CONNECT_STATUS.d.ts +6 -0
  136. package/dist/hooks/CONNECT_STATUS.js +5 -0
  137. package/dist/hooks/index.d.ts +6 -0
  138. package/dist/hooks/index.js +7 -0
  139. package/dist/hooks/useAirConditionData.d.ts +29 -0
  140. package/dist/hooks/useAirConditionData.js +89 -0
  141. package/dist/hooks/useDualRangeData.d.ts +18 -0
  142. package/dist/hooks/useDualRangeData.js +82 -0
  143. package/dist/hooks/useParkingStatusData.d.ts +19 -0
  144. package/dist/hooks/useParkingStatusData.js +100 -0
  145. package/dist/hooks/useSeatControlData.d.ts +94 -0
  146. package/dist/hooks/useSeatControlData.js +251 -0
  147. package/dist/hooks/useSingleRangeData.d.ts +15 -0
  148. package/dist/hooks/useSingleRangeData.js +97 -0
  149. package/dist/hooks/useSteeringWheelData.d.ts +11 -0
  150. package/dist/hooks/useSteeringWheelData.js +56 -0
  151. package/dist/icons/CarInUsed.d.ts +4 -0
  152. package/dist/icons/CarInUsed.js +13 -0
  153. package/dist/icons/DeviceManage.d.ts +4 -0
  154. package/dist/icons/DeviceManage.js +13 -0
  155. package/dist/icons/ElectricPower.d.ts +4 -0
  156. package/dist/icons/ElectricPower.js +13 -0
  157. package/dist/icons/ErrorStatus.d.ts +4 -0
  158. package/dist/icons/ErrorStatus.js +13 -0
  159. package/dist/icons/FuelPower.d.ts +4 -0
  160. package/dist/icons/FuelPower.js +18 -0
  161. package/dist/icons/Loading.d.ts +4 -0
  162. package/dist/icons/Loading.js +16 -0
  163. package/dist/icons/MijiaLogo.d.ts +4 -0
  164. package/dist/icons/MijiaLogo.js +16 -0
  165. package/dist/icons/Minus.d.ts +4 -0
  166. package/dist/icons/Minus.js +15 -0
  167. package/dist/icons/ParkingStatus.d.ts +4 -0
  168. package/dist/icons/ParkingStatus.js +15 -0
  169. package/dist/icons/SeatGearHeatingLevelOne.d.ts +4 -0
  170. package/dist/icons/SeatGearHeatingLevelOne.js +22 -0
  171. package/dist/icons/SeatGearHeatingLevelThree.d.ts +4 -0
  172. package/dist/icons/SeatGearHeatingLevelThree.js +18 -0
  173. package/dist/icons/SeatGearHeatingLevelTwo.d.ts +4 -0
  174. package/dist/icons/SeatGearHeatingLevelTwo.js +22 -0
  175. package/dist/icons/SeatGearHeatingOff.d.ts +4 -0
  176. package/dist/icons/SeatGearHeatingOff.js +18 -0
  177. package/dist/icons/SeatGearVentilationLevelOne.d.ts +4 -0
  178. package/dist/icons/SeatGearVentilationLevelOne.js +17 -0
  179. package/dist/icons/SeatGearVentilationLevelThree.d.ts +4 -0
  180. package/dist/icons/SeatGearVentilationLevelThree.js +13 -0
  181. package/dist/icons/SeatGearVentilationLevelTwo.d.ts +4 -0
  182. package/dist/icons/SeatGearVentilationLevelTwo.js +17 -0
  183. package/dist/icons/SeatGearVentilationOff.d.ts +4 -0
  184. package/dist/icons/SeatGearVentilationOff.js +16 -0
  185. package/dist/icons/SentryMode.d.ts +4 -0
  186. package/dist/icons/SentryMode.js +13 -0
  187. package/dist/icons/SmartScene.d.ts +4 -0
  188. package/dist/icons/SmartScene.js +13 -0
  189. package/dist/icons/SteeringWheelFirstGear.d.ts +4 -0
  190. package/dist/icons/SteeringWheelFirstGear.js +13 -0
  191. package/dist/icons/SteeringWheelHot.d.ts +4 -0
  192. package/dist/icons/SteeringWheelHot.js +13 -0
  193. package/dist/icons/SteeringWheelSecondGear.d.ts +4 -0
  194. package/dist/icons/SteeringWheelSecondGear.js +13 -0
  195. package/dist/icons/SteeringWheelThirdGear.d.ts +4 -0
  196. package/dist/icons/SteeringWheelThirdGear.js +13 -0
  197. package/dist/icons/Warning.d.ts +4 -0
  198. package/dist/icons/Warning.js +13 -0
  199. package/dist/icons/index.d.ts +24 -0
  200. package/dist/icons/index.js +27 -0
  201. package/dist/index.d.ts +21 -0
  202. package/dist/index.js +20 -0
  203. package/dist/modules/MODULES.md +245 -0
  204. package/dist/modules/airconditionModule/README.md +262 -0
  205. package/dist/modules/airconditionModule/index.d.ts +17 -0
  206. package/dist/modules/airconditionModule/index.js +63 -0
  207. package/dist/modules/carInfoModule/README.md +418 -0
  208. package/dist/modules/carInfoModule/index.d.ts +26 -0
  209. package/dist/modules/carInfoModule/index.js +67 -0
  210. package/dist/modules/index.d.ts +2 -0
  211. package/dist/modules/index.js +2 -0
  212. package/dist/modules/seatModule/README.md +345 -0
  213. package/dist/modules/seatModule/index.d.ts +15 -0
  214. package/dist/modules/seatModule/index.js +40 -0
  215. package/dist/modules/steeringWheelModule/README.md +216 -0
  216. package/dist/modules/steeringWheelModule/index.d.ts +13 -0
  217. package/dist/modules/steeringWheelModule/index.js +31 -0
  218. package/dist/resources/i18n.d.ts +1730 -0
  219. package/dist/resources/i18n.js +84 -0
  220. package/dist/resources/images.d.ts +1 -0
  221. package/dist/resources/images.js +45 -0
  222. package/dist/spec/index.d.ts +494 -0
  223. package/dist/spec/index.js +911 -0
  224. package/dist/types.d.ts +63 -0
  225. package/dist/types.js +1 -0
  226. package/dist/utils/checkSameValue.d.ts +1 -0
  227. package/dist/utils/checkSameValue.js +11 -0
  228. package/dist/utils/fns.d.ts +5 -0
  229. package/dist/utils/fns.js +167 -0
  230. package/dist/utils/get-value-or-default.d.ts +1 -0
  231. package/dist/utils/get-value-or-default.js +4 -0
  232. package/dist/utils/getLocalI18n.d.ts +1 -0
  233. package/dist/utils/getLocalI18n.js +9 -0
  234. package/dist/utils/i18n.d.ts +1 -0
  235. package/dist/utils/i18n.js +141 -0
  236. package/dist/utils/objects.d.ts +2 -0
  237. package/dist/utils/objects.js +222 -0
  238. package/dist/utils/spec.d.ts +8 -0
  239. package/dist/utils/spec.js +171 -0
  240. package/dist/utils/types.d.ts +3 -0
  241. package/dist/utils/types.js +25 -0
  242. package/package.json +27 -0
@@ -0,0 +1,103 @@
1
+ import React, { useContext, memo, useMemo } from 'react';
2
+ import { Text, View, StyleSheet } from 'react-native';
3
+ import { Stepper, Separator, ColumnSeparator, LargeVariantSwitch, ConfigContext } from 'miot/ui/hyperOSUI';
4
+ import { TitleContainer } from "../titleContainer";
5
+ import { CardContainer } from "../cardContainer";
6
+ function isEffectData(value) {
7
+ return typeof value === 'number' || typeof value === 'string';
8
+ }
9
+ export const AirConditioningCard = /*#__PURE__*/memo(({
10
+ hvacStatus,
11
+ hvacDefrosterStatus,
12
+ onHvacStatusChange,
13
+ onHvacDefrosterChange,
14
+ targetTemperature,
15
+ onHvacTemperatureChange,
16
+ hvacTitle,
17
+ hvacDefrosterTitle,
18
+ hvacDefrosterSubtitle = '',
19
+ insideTip = '',
20
+ outsideTip = '',
21
+ temperatureStep,
22
+ maxTemperature,
23
+ minTemperature,
24
+ insideTemperature,
25
+ outsideTemperature,
26
+ showHvacDefroster = false,
27
+ disabled = false,
28
+ showTargetTemperature = false
29
+ }) => {
30
+ const {
31
+ colorToken
32
+ } = useContext(ConfigContext);
33
+ const {
34
+ isInsideTemperatureEffect,
35
+ isOutsideTemperatureEffect
36
+ } = useMemo(() => ({
37
+ isInsideTemperatureEffect: isEffectData(insideTemperature),
38
+ isOutsideTemperatureEffect: isEffectData(outsideTemperature)
39
+ }), [insideTemperature, outsideTemperature]);
40
+ const transformTargetTemperature = useMemo(() => {
41
+ return typeof targetTemperature === 'string' ? parseFloat(targetTemperature) : targetTemperature;
42
+ }, [targetTemperature]);
43
+ return /*#__PURE__*/React.createElement(CardContainer, null, /*#__PURE__*/React.createElement(TitleContainer, {
44
+ title: hvacTitle,
45
+ subtitle: isInsideTemperatureEffect || isOutsideTemperatureEffect ? /*#__PURE__*/React.createElement(View, {
46
+ style: [styles.conditioning, showTargetTemperature ? {} : {
47
+ paddingBottom: 12
48
+ }]
49
+ }, isInsideTemperatureEffect && /*#__PURE__*/React.createElement(Text, {
50
+ style: {
51
+ color: disabled ? colorToken.mj_color_gray_text_6 : colorToken.mj_color_gray_text_4
52
+ }
53
+ }, insideTip), isInsideTemperatureEffect && isOutsideTemperatureEffect && /*#__PURE__*/React.createElement(ColumnSeparator, {
54
+ style: styles.column
55
+ }), isOutsideTemperatureEffect && /*#__PURE__*/React.createElement(Text, {
56
+ style: {
57
+ color: disabled ? colorToken.mj_color_gray_text_6 : colorToken.mj_color_gray_text_4
58
+ }
59
+ }, outsideTip)) : showTargetTemperature ? /*#__PURE__*/React.createElement(View, {
60
+ style: {
61
+ paddingBottom: 12
62
+ }
63
+ }) : null,
64
+ value: hvacStatus,
65
+ onValueChange: onHvacStatusChange,
66
+ disabled: disabled
67
+ }), showTargetTemperature && /*#__PURE__*/React.createElement(View, {
68
+ style: styles.stepper
69
+ }, /*#__PURE__*/React.createElement(Stepper, {
70
+ step: temperatureStep,
71
+ symbolType: "celsius",
72
+ value: transformTargetTemperature,
73
+ disabled: !hvacStatus || disabled,
74
+ onChange: onHvacTemperatureChange,
75
+ min: minTemperature,
76
+ max: maxTemperature
77
+ })), showHvacDefroster && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Separator, {
78
+ style: styles.separator
79
+ }), /*#__PURE__*/React.createElement(LargeVariantSwitch, {
80
+ title: hvacDefrosterTitle,
81
+ disabled: disabled,
82
+ subtitle: hvacDefrosterSubtitle,
83
+ value: hvacDefrosterStatus,
84
+ onValueChange: onHvacDefrosterChange
85
+ })));
86
+ });
87
+ const styles = StyleSheet.create({
88
+ stepper: {
89
+ alignItems: 'center'
90
+ },
91
+ conditioning: {
92
+ flexDirection: 'row',
93
+ alignItems: 'center'
94
+ },
95
+ separator: {
96
+ marginHorizontal: 20,
97
+ marginVertical: 4
98
+ },
99
+ column: {
100
+ height: 8,
101
+ marginHorizontal: 8
102
+ }
103
+ });
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle, ImageSourcePropType } from 'react-native';
3
+ interface CarImageProps {
4
+ source?: ImageSourcePropType;
5
+ style?: StyleProp<ViewStyle>;
6
+ }
7
+ export declare const CarImage: ({ source, style }: CarImageProps) => React.JSX.Element;
8
+ export {};
@@ -0,0 +1,42 @@
1
+ import React, { useContext } from 'react';
2
+ import { View, Image, StyleSheet } from 'react-native';
3
+ import { ConfigContext } from 'miot/ui/hyperOSUI';
4
+ import { MijiaLogo } from "../../icons";
5
+ export const CarImage = ({
6
+ source,
7
+ style
8
+ }) => {
9
+ const {
10
+ colorToken
11
+ } = useContext(ConfigContext);
12
+ return /*#__PURE__*/React.createElement(View, {
13
+ style: [styles.container, style]
14
+ }, source ? /*#__PURE__*/React.createElement(Image, {
15
+ source: source,
16
+ style: styles.image,
17
+ resizeMode: "contain"
18
+ }) : /*#__PURE__*/React.createElement(View, {
19
+ style: styles.placeholder
20
+ }, /*#__PURE__*/React.createElement(MijiaLogo, {
21
+ fill: colorToken.mj_color_gray_icon_2
22
+ })));
23
+ };
24
+ const styles = StyleSheet.create({
25
+ container: {
26
+ width: '100%',
27
+ alignItems: 'center',
28
+ justifyContent: 'center'
29
+ },
30
+ image: {
31
+ width: '100%',
32
+ height: undefined,
33
+ aspectRatio: 2
34
+ },
35
+ placeholder: {
36
+ width: '100%',
37
+ height: undefined,
38
+ aspectRatio: 2,
39
+ alignItems: 'center',
40
+ justifyContent: 'center'
41
+ }
42
+ });
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+ interface DualRangeIndicatorProps {
4
+ electricRange?: number;
5
+ fuelRange?: number;
6
+ currentElectricRange?: number | string;
7
+ currentFuelRange?: number | string;
8
+ unit?: string;
9
+ electricColor?: string;
10
+ fuelColor?: string;
11
+ showProgress?: boolean;
12
+ style?: StyleProp<ViewStyle>;
13
+ }
14
+ export declare const DualRangeIndicator: ({ electricRange, fuelRange, currentElectricRange, currentFuelRange, unit, electricColor, fuelColor, showProgress, style, }: DualRangeIndicatorProps) => React.JSX.Element;
15
+ export {};
@@ -0,0 +1,124 @@
1
+ import React, { useContext, useMemo } from 'react';
2
+ import { View, Text } from 'react-native';
3
+ import { ConfigContext, Fonts, defaultColorToken } from 'miot/ui/hyperOSUI';
4
+ import { dynamicStyleSheet } from 'miot/ui/Style/DynamicStyleSheet';
5
+ import { ElectricPower, FuelPower } from "../../icons";
6
+ import { RangeProgressBar } from "./rangeProgressBar";
7
+ export const DualRangeIndicator = ({
8
+ electricRange = 500,
9
+ fuelRange = 800,
10
+ currentElectricRange = 0,
11
+ currentFuelRange = 0,
12
+ unit = 'km',
13
+ electricColor,
14
+ fuelColor,
15
+ showProgress = false,
16
+ style
17
+ }) => {
18
+ const {
19
+ colorToken
20
+ } = useContext(ConfigContext);
21
+ const numericElectricRange = typeof currentElectricRange === 'number' ? currentElectricRange : 0;
22
+ const numericFuelRange = typeof currentFuelRange === 'number' ? currentFuelRange : 0;
23
+ const electricProgress = useMemo(() => electricRange > 0 && typeof currentElectricRange === 'number' ? Math.min(numericElectricRange / electricRange, 1) : 0, [numericElectricRange, electricRange]);
24
+ const fuelProgress = useMemo(() => fuelRange > 0 && typeof currentFuelRange === 'number' ? Math.min(numericFuelRange / fuelRange, 1) : 0, [numericFuelRange, fuelRange]);
25
+ const renderRangeIndicator = config => {
26
+ const {
27
+ icon,
28
+ color,
29
+ currentRange,
30
+ progress,
31
+ totalRange
32
+ } = config;
33
+ const displayValue = typeof currentRange === 'number' ? Math.round(currentRange) : currentRange;
34
+ return /*#__PURE__*/React.createElement(View, {
35
+ style: styles.rangeItem,
36
+ key: config.type
37
+ }, /*#__PURE__*/React.createElement(View, {
38
+ style: styles.rangeContent
39
+ }, /*#__PURE__*/React.createElement(View, {
40
+ style: styles.rangeTop
41
+ }, icon, /*#__PURE__*/React.createElement(View, {
42
+ style: styles.valueContainer
43
+ }, /*#__PURE__*/React.createElement(Text, {
44
+ style: styles.rangeValue,
45
+ numberOfLines: 1,
46
+ ellipsizeMode: "tail"
47
+ }, displayValue, /*#__PURE__*/React.createElement(Text, {
48
+ style: styles.unitSpacer
49
+ }, ' '), /*#__PURE__*/React.createElement(Text, {
50
+ style: styles.unit
51
+ }, unit)))), showProgress ? /*#__PURE__*/React.createElement(RangeProgressBar, {
52
+ progress: progress,
53
+ color: color
54
+ }) : null));
55
+ };
56
+ return /*#__PURE__*/React.createElement(View, {
57
+ style: [styles.container, style]
58
+ }, renderRangeIndicator({
59
+ type: 'electric',
60
+ totalRange: electricRange,
61
+ currentRange: currentElectricRange,
62
+ icon: /*#__PURE__*/React.createElement(ElectricPower, {
63
+ fill: colorToken.mj_color_gray_icon_1
64
+ }),
65
+ color: electricColor,
66
+ progress: electricProgress
67
+ }), renderRangeIndicator({
68
+ type: 'fuel',
69
+ totalRange: fuelRange,
70
+ currentRange: currentFuelRange,
71
+ icon: /*#__PURE__*/React.createElement(FuelPower, {
72
+ fill: colorToken.mj_color_gray_icon_1
73
+ }),
74
+ color: fuelColor,
75
+ progress: fuelProgress
76
+ }));
77
+ };
78
+ const styles = dynamicStyleSheet({
79
+ container: {
80
+ flexDirection: 'row',
81
+ alignItems: 'center',
82
+ justifyContent: 'center',
83
+ height: 60,
84
+ width: '100%'
85
+ },
86
+ rangeItem: {
87
+ alignItems: 'center',
88
+ justifyContent: 'center',
89
+ marginHorizontal: 15,
90
+ flex: 1
91
+ },
92
+ rangeContent: {
93
+ alignItems: 'center',
94
+ justifyContent: 'center'
95
+ },
96
+ rangeTop: {
97
+ flexDirection: 'row',
98
+ alignItems: 'center',
99
+ justifyContent: 'center',
100
+ paddingHorizontal: 8
101
+ },
102
+ valueContainer: {
103
+ alignItems: 'flex-end',
104
+ justifyContent: 'center',
105
+ paddingHorizontal: 4
106
+ },
107
+ icon: {
108
+ width: 30,
109
+ height: 30
110
+ },
111
+ rangeValue: {
112
+ color: defaultColorToken.mj_color_gray_text_1,
113
+ includeFontPadding: false,
114
+ ...Fonts.mj_text_custom_20_M
115
+ },
116
+ unitSpacer: {
117
+ fontSize: 6
118
+ },
119
+ unit: {
120
+ color: defaultColorToken.mj_color_gray_text_1,
121
+ includeFontPadding: false,
122
+ ...Fonts.mj_text_custom_14_M
123
+ }
124
+ });
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
+ import { SingleRangeIndicator } from './singleRangeIndicator';
4
+ import { DualRangeIndicator } from './dualRangeIndicator';
5
+ import { CarImage } from './carImage';
6
+ import { ParkingStatus } from './parkingStatus';
7
+ export interface SingleRangeData {
8
+ currentRange: number | string;
9
+ totalRange: number;
10
+ unit: string;
11
+ color?: string;
12
+ }
13
+ export interface DualRangeData {
14
+ currentElectricRange: number | string;
15
+ electricRange: number;
16
+ unit: string;
17
+ electricColor?: string;
18
+ currentFuelRange: number | string;
19
+ fuelRange: number;
20
+ fuelColor?: string;
21
+ }
22
+ export interface ParkingStatusData {
23
+ status?: string;
24
+ icon?: React.ReactElement;
25
+ showDivider?: boolean;
26
+ textStyle?: StyleProp<TextStyle>;
27
+ isLoading?: boolean;
28
+ }
29
+ export interface CarInfoHeaderProps {
30
+ singleRangeData?: SingleRangeData;
31
+ dualRangeData?: DualRangeData;
32
+ parkingStatus?: ParkingStatusData;
33
+ containerStyle?: StyleProp<ViewStyle>;
34
+ }
35
+ export declare const CarInfoHeader: (props: CarInfoHeaderProps) => React.JSX.Element;
36
+ export default CarInfoHeader;
37
+ export { SingleRangeIndicator, DualRangeIndicator, CarImage, ParkingStatus };
@@ -0,0 +1,118 @@
1
+ import React from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import { Device } from 'miot';
4
+ import { SingleRangeIndicator } from "./singleRangeIndicator";
5
+ import { DualRangeIndicator } from "./dualRangeIndicator";
6
+ import { CarImage } from "./carImage";
7
+ import { ParkingStatus } from "./parkingStatus";
8
+
9
+ /**
10
+ * 单续航数据配置
11
+ */
12
+
13
+ /**
14
+ * 双续航数据配置
15
+ */
16
+
17
+ /**
18
+ * 驻车状态数据配置
19
+ */
20
+
21
+ /**
22
+ * CarInfoHeader 组件 Props 类型
23
+ */
24
+
25
+ /**
26
+ * 车辆信息头部组件
27
+ *
28
+ * 展示车辆续航信息(单续航/双续航)和驻车状态
29
+ *
30
+ * @example
31
+ * // 单续航模式
32
+ * <CarInfoHeader
33
+ * singleRangeData={{ currentRange: 150, totalRange: 500, unit: 'km' }}
34
+ * />
35
+ *
36
+ * @example
37
+ * // 双续航模式
38
+ * <CarInfoHeader
39
+ * dualRangeData={{
40
+ * currentElectricRange: 100, electricRange: 200,
41
+ * currentFuelRange: 400, fuelRange: 800, unit: 'km'
42
+ * }}
43
+ * />
44
+ */
45
+ export const CarInfoHeader = props => {
46
+ const {
47
+ singleRangeData,
48
+ dualRangeData,
49
+ parkingStatus,
50
+ containerStyle
51
+ } = props;
52
+ const isDualRange = !!dualRangeData;
53
+ return /*#__PURE__*/React.createElement(View, {
54
+ style: [styles.container, containerStyle]
55
+ }, /*#__PURE__*/React.createElement(View, {
56
+ style: styles.rangeSection
57
+ }, isDualRange && dualRangeData ? /*#__PURE__*/React.createElement(DualRangeIndicator, {
58
+ electricRange: dualRangeData.electricRange,
59
+ fuelRange: dualRangeData.fuelRange,
60
+ currentElectricRange: typeof dualRangeData.currentElectricRange === 'number' ? dualRangeData.currentElectricRange : 0,
61
+ currentFuelRange: typeof dualRangeData.currentFuelRange === 'number' ? dualRangeData.currentFuelRange : 0,
62
+ unit: dualRangeData.unit,
63
+ electricColor: dualRangeData.electricColor,
64
+ fuelColor: dualRangeData.fuelColor
65
+ }) : singleRangeData ? /*#__PURE__*/React.createElement(SingleRangeIndicator, {
66
+ currentRange: typeof singleRangeData.currentRange === 'number' ? singleRangeData.currentRange : 0,
67
+ totalRange: singleRangeData.totalRange,
68
+ unit: singleRangeData.unit,
69
+ color: singleRangeData.color
70
+ }) : null), /*#__PURE__*/React.createElement(View, {
71
+ style: styles.imageSection
72
+ }, /*#__PURE__*/React.createElement(CarImage, {
73
+ source: Device.iconURL ? {
74
+ uri: Device.iconURL
75
+ } : undefined
76
+ })), parkingStatus ? /*#__PURE__*/React.createElement(View, {
77
+ style: styles.statusSection
78
+ }, /*#__PURE__*/React.createElement(ParkingStatus, {
79
+ isLoading: parkingStatus.isLoading,
80
+ status: parkingStatus.status,
81
+ icon: parkingStatus.icon,
82
+ showDivider: parkingStatus.showDivider,
83
+ textStyle: parkingStatus.textStyle
84
+ })) : null);
85
+ };
86
+ export default CarInfoHeader;
87
+ const styles = StyleSheet.create({
88
+ container: {
89
+ alignItems: 'center',
90
+ alignSelf: 'center',
91
+ width: '100%',
92
+ maxWidth: 336,
93
+ maxHeight: 336,
94
+ aspectRatio: 1,
95
+ overflow: 'hidden',
96
+ marginVertical: 20
97
+ },
98
+ rangeSection: {
99
+ flex: 1,
100
+ width: '100%',
101
+ justifyContent: 'flex-start'
102
+ },
103
+ imageSection: {
104
+ flex: 2,
105
+ width: '100%',
106
+ alignItems: 'center',
107
+ justifyContent: 'center'
108
+ },
109
+ statusSection: {
110
+ flex: 1,
111
+ width: '100%',
112
+ alignItems: 'center',
113
+ justifyContent: 'center'
114
+ }
115
+ });
116
+
117
+ // 导出子组件
118
+ export { SingleRangeIndicator, DualRangeIndicator, CarImage, ParkingStatus };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
+ interface ParkingStatusProps {
4
+ isLoading?: boolean;
5
+ status?: string | Record<string, string>;
6
+ icon?: React.ReactElement;
7
+ showDivider?: boolean;
8
+ style?: StyleProp<ViewStyle>;
9
+ textStyle?: StyleProp<TextStyle>;
10
+ }
11
+ export declare const ParkingStatus: ({ isLoading, status, icon, showDivider, style, textStyle, }: ParkingStatusProps) => React.JSX.Element;
12
+ export {};
@@ -0,0 +1,100 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { View, Text, Animated, Easing } from 'react-native';
3
+ import { dynamicStyleSheet } from 'miot/ui/Style/DynamicStyleSheet';
4
+ import { Fonts, defaultColorToken } from 'miot/ui/hyperOSUI';
5
+ export const ParkingStatus = ({
6
+ isLoading = false,
7
+ status = '',
8
+ icon,
9
+ showDivider = false,
10
+ style,
11
+ textStyle
12
+ }) => {
13
+ const rotateAnim = useRef(new Animated.Value(0)).current;
14
+ useEffect(() => {
15
+ if (isLoading) {
16
+ Animated.loop(Animated.timing(rotateAnim, {
17
+ toValue: 1,
18
+ duration: 1000,
19
+ easing: Easing.linear,
20
+ useNativeDriver: true
21
+ })).start();
22
+ } else {
23
+ rotateAnim.stopAnimation(() => {
24
+ rotateAnim.setValue(0);
25
+ });
26
+ }
27
+ return () => {
28
+ rotateAnim.stopAnimation();
29
+ };
30
+ }, [isLoading, rotateAnim]);
31
+ const rotateStyle = {
32
+ transform: [{
33
+ rotate: rotateAnim.interpolate({
34
+ inputRange: [0, 1],
35
+ outputRange: ['0deg', '360deg']
36
+ })
37
+ }]
38
+ };
39
+ return /*#__PURE__*/React.createElement(View, {
40
+ style: [styles.container, style]
41
+ }, /*#__PURE__*/React.createElement(View, {
42
+ style: styles.iconContainer
43
+ }, isLoading ? /*#__PURE__*/React.createElement(Animated.View, {
44
+ style: [styles.iconWrapper, rotateStyle]
45
+ }, icon || null) : /*#__PURE__*/React.createElement(View, {
46
+ style: styles.iconWrapper
47
+ }, icon || null)), showDivider && status ? /*#__PURE__*/React.createElement(View, {
48
+ style: styles.divider
49
+ }) : null, status ? /*#__PURE__*/React.createElement(Text, {
50
+ style: [styles.statusText, textStyle],
51
+ numberOfLines: 3,
52
+ ellipsizeMode: "tail"
53
+ }, status) : null);
54
+ };
55
+ const styles = dynamicStyleSheet({
56
+ container: {
57
+ flexDirection: 'row',
58
+ alignItems: 'center',
59
+ paddingHorizontal: 16
60
+ },
61
+ iconContainer: {
62
+ width: 16,
63
+ height: 16,
64
+ justifyContent: 'center',
65
+ alignItems: 'center',
66
+ marginRight: 2
67
+ },
68
+ iconWrapper: {
69
+ width: 16,
70
+ height: 16,
71
+ justifyContent: 'center',
72
+ alignItems: 'center'
73
+ },
74
+ icon: {
75
+ width: 16,
76
+ height: 16
77
+ },
78
+ defaultIconContainer: {
79
+ width: 24,
80
+ height: 24,
81
+ justifyContent: 'center',
82
+ alignItems: 'center'
83
+ },
84
+ defaultIcon: {
85
+ width: 16,
86
+ height: 16
87
+ },
88
+ divider: {
89
+ width: 1,
90
+ height: 10,
91
+ backgroundColor: defaultColorToken.mj_color_gray_divider_1,
92
+ marginHorizontal: 4
93
+ },
94
+ statusText: {
95
+ ...Fonts.FontTextRegular,
96
+ color: defaultColorToken.mj_color_gray_text_4,
97
+ includeFontPadding: false,
98
+ textAlign: 'center'
99
+ }
100
+ });
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+ interface RangeProgressBarProps {
4
+ progress?: number;
5
+ color?: string;
6
+ width?: number;
7
+ height?: number;
8
+ borderRadius?: number;
9
+ showDivider?: boolean;
10
+ unfilledColor?: string;
11
+ style?: StyleProp<ViewStyle>;
12
+ }
13
+ export declare const RangeProgressBar: ({ progress, color, width, height, borderRadius, showDivider, unfilledColor, style, }: RangeProgressBarProps) => React.JSX.Element;
14
+ export {};
@@ -0,0 +1,77 @@
1
+ import React, { useContext, useMemo } from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import { ConfigContext } from 'miot/ui/hyperOSUI';
4
+ export const RangeProgressBar = ({
5
+ progress = 0,
6
+ color,
7
+ width = 76,
8
+ height = 3,
9
+ borderRadius = 3,
10
+ showDivider = true,
11
+ unfilledColor,
12
+ style
13
+ }) => {
14
+ const {
15
+ colorToken
16
+ } = useContext(ConfigContext);
17
+ const clamped = useMemo(() => {
18
+ if (Number.isNaN(progress)) return 0;
19
+ return Math.min(Math.max(progress, 0), 1);
20
+ }, [progress]);
21
+ const effectiveUnfilled = unfilledColor || colorToken.mj_color_gray_fill_1;
22
+ const fillColor = color || colorToken.mj_color_green_1;
23
+ const rawFilled = clamped * width;
24
+ const hasGap = clamped > 0 && clamped < 1;
25
+ const filledWidth = Math.max(0, Math.min(width, hasGap ? rawFilled - 1 / 2 : rawFilled));
26
+ const unfilledWidth = Math.max(0, width - filledWidth - 1);
27
+ return /*#__PURE__*/React.createElement(View, {
28
+ style: [styles.container, {
29
+ width,
30
+ height
31
+ }, style]
32
+ }, filledWidth > 0 ? /*#__PURE__*/React.createElement(View, {
33
+ style: [styles.filled, {
34
+ width: filledWidth,
35
+ height,
36
+ backgroundColor: fillColor,
37
+ borderTopLeftRadius: borderRadius,
38
+ borderBottomLeftRadius: borderRadius,
39
+ borderTopRightRadius: hasGap ? 0 : borderRadius,
40
+ borderBottomRightRadius: hasGap ? 0 : borderRadius
41
+ }]
42
+ }) : null, showDivider ? /*#__PURE__*/React.createElement(View, {
43
+ style: styles.divider
44
+ }) : null, unfilledWidth > 0 ? /*#__PURE__*/React.createElement(View, {
45
+ style: [styles.unfilled, {
46
+ width: unfilledWidth,
47
+ height,
48
+ backgroundColor: effectiveUnfilled,
49
+ borderTopRightRadius: borderRadius,
50
+ borderBottomRightRadius: borderRadius,
51
+ borderTopLeftRadius: filledWidth > 0 ? 0 : borderRadius,
52
+ borderBottomLeftRadius: filledWidth > 0 ? 0 : borderRadius
53
+ }]
54
+ }) : null);
55
+ };
56
+ const styles = StyleSheet.create({
57
+ container: {
58
+ position: 'relative',
59
+ flexDirection: 'row',
60
+ alignItems: 'center'
61
+ },
62
+ filled: {
63
+ borderTopLeftRadius: 0,
64
+ borderTopRightRadius: 0,
65
+ borderBottomLeftRadius: 0,
66
+ borderBottomRightRadius: 0
67
+ },
68
+ unfilled: {
69
+ borderTopLeftRadius: 0,
70
+ borderTopRightRadius: 0,
71
+ borderBottomLeftRadius: 0,
72
+ borderBottomRightRadius: 0
73
+ },
74
+ divider: {
75
+ width: 1
76
+ }
77
+ });
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+ interface SingleRangeIndicatorProps {
4
+ currentRange?: number | string;
5
+ totalRange?: number;
6
+ unit?: string;
7
+ color?: string;
8
+ style?: StyleProp<ViewStyle>;
9
+ }
10
+ export declare const SingleRangeIndicator: ({ currentRange, totalRange, unit, color, style, }: SingleRangeIndicatorProps) => React.JSX.Element;
11
+ export {};