@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.
- package/README.md +325 -0
- package/dist/assets/i18n/ar.d.ts +55 -0
- package/dist/assets/i18n/ar.js +55 -0
- package/dist/assets/i18n/bo.d.ts +55 -0
- package/dist/assets/i18n/bo.js +55 -0
- package/dist/assets/i18n/cs.d.ts +55 -0
- package/dist/assets/i18n/cs.js +55 -0
- package/dist/assets/i18n/de.d.ts +55 -0
- package/dist/assets/i18n/de.js +55 -0
- package/dist/assets/i18n/el.d.ts +55 -0
- package/dist/assets/i18n/el.js +55 -0
- package/dist/assets/i18n/en.d.ts +55 -0
- package/dist/assets/i18n/en.js +55 -0
- package/dist/assets/i18n/es.d.ts +55 -0
- package/dist/assets/i18n/es.js +55 -0
- package/dist/assets/i18n/es_us.d.ts +55 -0
- package/dist/assets/i18n/es_us.js +55 -0
- package/dist/assets/i18n/fi.d.ts +55 -0
- package/dist/assets/i18n/fi.js +55 -0
- package/dist/assets/i18n/fr.d.ts +55 -0
- package/dist/assets/i18n/fr.js +55 -0
- package/dist/assets/i18n/he.d.ts +55 -0
- package/dist/assets/i18n/he.js +55 -0
- package/dist/assets/i18n/hu.d.ts +55 -0
- package/dist/assets/i18n/hu.js +55 -0
- package/dist/assets/i18n/id.d.ts +55 -0
- package/dist/assets/i18n/id.js +55 -0
- package/dist/assets/i18n/it.d.ts +55 -0
- package/dist/assets/i18n/it.js +55 -0
- package/dist/assets/i18n/ja.d.ts +55 -0
- package/dist/assets/i18n/ja.js +55 -0
- package/dist/assets/i18n/ko.d.ts +55 -0
- package/dist/assets/i18n/ko.js +55 -0
- package/dist/assets/i18n/nb.d.ts +55 -0
- package/dist/assets/i18n/nb.js +55 -0
- package/dist/assets/i18n/nl.d.ts +55 -0
- package/dist/assets/i18n/nl.js +55 -0
- package/dist/assets/i18n/pl.d.ts +55 -0
- package/dist/assets/i18n/pl.js +55 -0
- package/dist/assets/i18n/pt.d.ts +55 -0
- package/dist/assets/i18n/pt.js +55 -0
- package/dist/assets/i18n/pt_pt.d.ts +55 -0
- package/dist/assets/i18n/pt_pt.js +55 -0
- package/dist/assets/i18n/ro.d.ts +55 -0
- package/dist/assets/i18n/ro.js +55 -0
- package/dist/assets/i18n/ru.d.ts +55 -0
- package/dist/assets/i18n/ru.js +55 -0
- package/dist/assets/i18n/sk.d.ts +55 -0
- package/dist/assets/i18n/sk.js +55 -0
- package/dist/assets/i18n/sv.d.ts +55 -0
- package/dist/assets/i18n/sv.js +55 -0
- package/dist/assets/i18n/th.d.ts +55 -0
- package/dist/assets/i18n/th.js +55 -0
- package/dist/assets/i18n/tr.d.ts +55 -0
- package/dist/assets/i18n/tr.js +55 -0
- package/dist/assets/i18n/uk.d.ts +55 -0
- package/dist/assets/i18n/uk.js +55 -0
- package/dist/assets/i18n/vi.d.ts +55 -0
- package/dist/assets/i18n/vi.js +55 -0
- package/dist/assets/i18n/zh.d.ts +55 -0
- package/dist/assets/i18n/zh.js +55 -0
- package/dist/assets/i18n/zh_hk.d.ts +55 -0
- package/dist/assets/i18n/zh_hk.js +55 -0
- package/dist/assets/i18n/zh_tw.d.ts +55 -0
- package/dist/assets/i18n/zh_tw.js +55 -0
- package/dist/assets/image/dark/car_background_dark.png +0 -0
- package/dist/assets/image/default/car_background.png +0 -0
- package/dist/components/airConditioningCard/index.d.ts +24 -0
- package/dist/components/airConditioningCard/index.js +103 -0
- package/dist/components/carInfoHeader/carImage.d.ts +8 -0
- package/dist/components/carInfoHeader/carImage.js +42 -0
- package/dist/components/carInfoHeader/dualRangeIndicator.d.ts +15 -0
- package/dist/components/carInfoHeader/dualRangeIndicator.js +124 -0
- package/dist/components/carInfoHeader/index.d.ts +37 -0
- package/dist/components/carInfoHeader/index.js +118 -0
- package/dist/components/carInfoHeader/parkingStatus.d.ts +12 -0
- package/dist/components/carInfoHeader/parkingStatus.js +100 -0
- package/dist/components/carInfoHeader/rangeProgressBar.d.ts +14 -0
- package/dist/components/carInfoHeader/rangeProgressBar.js +77 -0
- package/dist/components/carInfoHeader/singleRangeIndicator.d.ts +11 -0
- package/dist/components/carInfoHeader/singleRangeIndicator.js +58 -0
- package/dist/components/cardContainer/index.d.ts +8 -0
- package/dist/components/cardContainer/index.js +22 -0
- package/dist/components/containerWithGap/gapWrap.d.ts +8 -0
- package/dist/components/containerWithGap/gapWrap.js +31 -0
- package/dist/components/containerWithGap/index.d.ts +12 -0
- package/dist/components/containerWithGap/index.js +43 -0
- package/dist/components/flatSelect/FlatOption.d.ts +18 -0
- package/dist/components/flatSelect/FlatOption.js +117 -0
- package/dist/components/flatSelect/FlatSelect.d.ts +14 -0
- package/dist/components/flatSelect/FlatSelect.js +112 -0
- package/dist/components/flatSelect/index.d.ts +2 -0
- package/dist/components/flatSelect/index.js +2 -0
- package/dist/components/flatSelect/index.zh-CN.md +89 -0
- package/dist/components/groupContainer/index.d.ts +9 -0
- package/dist/components/groupContainer/index.js +48 -0
- package/dist/components/otherSettingCard/index.d.ts +8 -0
- package/dist/components/otherSettingCard/index.js +40 -0
- package/dist/components/pageBackground/index.d.ts +7 -0
- package/dist/components/pageBackground/index.js +22 -0
- package/dist/components/seatControl/index.d.ts +34 -0
- package/dist/components/seatControl/index.js +98 -0
- package/dist/components/seatControl/seatCard.d.ts +11 -0
- package/dist/components/seatControl/seatCard.js +24 -0
- package/dist/components/seatControl/seatCardRow.d.ts +29 -0
- package/dist/components/seatControl/seatCardRow.js +48 -0
- package/dist/components/seatControlGroup/index.d.ts +40 -0
- package/dist/components/seatControlGroup/index.js +51 -0
- package/dist/components/steeringWheelHotCard/index.d.ts +17 -0
- package/dist/components/steeringWheelHotCard/index.js +66 -0
- package/dist/components/titleContainer/TitleContainer.d.ts +4 -0
- package/dist/components/titleContainer/TitleContainer.js +148 -0
- package/dist/components/titleContainer/TitleContainer.zh-CN.md +62 -0
- package/dist/components/titleContainer/index.d.ts +1 -0
- package/dist/components/titleContainer/index.js +1 -0
- package/dist/components/titleContainer/interface.d.ts +48 -0
- package/dist/components/titleContainer/interface.js +21 -0
- package/dist/components/warningForRunningCard/index.d.ts +6 -0
- package/dist/components/warningForRunningCard/index.js +20 -0
- package/dist/config/ConnectStatus.d.ts +7 -0
- package/dist/config/ConnectStatus.js +8 -0
- package/dist/config/index.d.ts +16 -0
- package/dist/config/index.js +16 -0
- package/dist/config/seatFunctionType.d.ts +7 -0
- package/dist/config/seatFunctionType.js +24 -0
- package/dist/config/seatGearLevel.d.ts +21 -0
- package/dist/config/seatGearLevel.js +19 -0
- package/dist/config/seatI18nKeys.d.ts +9 -0
- package/dist/config/seatI18nKeys.js +9 -0
- package/dist/config/seatPosition.d.ts +8 -0
- package/dist/config/seatPosition.js +8 -0
- package/dist/config/seatRowConfig.d.ts +6 -0
- package/dist/config/seatRowConfig.js +6 -0
- package/dist/global.d.js +0 -0
- package/dist/hooks/CONNECT_STATUS.d.ts +6 -0
- package/dist/hooks/CONNECT_STATUS.js +5 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useAirConditionData.d.ts +29 -0
- package/dist/hooks/useAirConditionData.js +89 -0
- package/dist/hooks/useDualRangeData.d.ts +18 -0
- package/dist/hooks/useDualRangeData.js +82 -0
- package/dist/hooks/useParkingStatusData.d.ts +19 -0
- package/dist/hooks/useParkingStatusData.js +100 -0
- package/dist/hooks/useSeatControlData.d.ts +94 -0
- package/dist/hooks/useSeatControlData.js +251 -0
- package/dist/hooks/useSingleRangeData.d.ts +15 -0
- package/dist/hooks/useSingleRangeData.js +97 -0
- package/dist/hooks/useSteeringWheelData.d.ts +11 -0
- package/dist/hooks/useSteeringWheelData.js +56 -0
- package/dist/icons/CarInUsed.d.ts +4 -0
- package/dist/icons/CarInUsed.js +13 -0
- package/dist/icons/DeviceManage.d.ts +4 -0
- package/dist/icons/DeviceManage.js +13 -0
- package/dist/icons/ElectricPower.d.ts +4 -0
- package/dist/icons/ElectricPower.js +13 -0
- package/dist/icons/ErrorStatus.d.ts +4 -0
- package/dist/icons/ErrorStatus.js +13 -0
- package/dist/icons/FuelPower.d.ts +4 -0
- package/dist/icons/FuelPower.js +18 -0
- package/dist/icons/Loading.d.ts +4 -0
- package/dist/icons/Loading.js +16 -0
- package/dist/icons/MijiaLogo.d.ts +4 -0
- package/dist/icons/MijiaLogo.js +16 -0
- package/dist/icons/Minus.d.ts +4 -0
- package/dist/icons/Minus.js +15 -0
- package/dist/icons/ParkingStatus.d.ts +4 -0
- package/dist/icons/ParkingStatus.js +15 -0
- package/dist/icons/SeatGearHeatingLevelOne.d.ts +4 -0
- package/dist/icons/SeatGearHeatingLevelOne.js +22 -0
- package/dist/icons/SeatGearHeatingLevelThree.d.ts +4 -0
- package/dist/icons/SeatGearHeatingLevelThree.js +18 -0
- package/dist/icons/SeatGearHeatingLevelTwo.d.ts +4 -0
- package/dist/icons/SeatGearHeatingLevelTwo.js +22 -0
- package/dist/icons/SeatGearHeatingOff.d.ts +4 -0
- package/dist/icons/SeatGearHeatingOff.js +18 -0
- package/dist/icons/SeatGearVentilationLevelOne.d.ts +4 -0
- package/dist/icons/SeatGearVentilationLevelOne.js +17 -0
- package/dist/icons/SeatGearVentilationLevelThree.d.ts +4 -0
- package/dist/icons/SeatGearVentilationLevelThree.js +13 -0
- package/dist/icons/SeatGearVentilationLevelTwo.d.ts +4 -0
- package/dist/icons/SeatGearVentilationLevelTwo.js +17 -0
- package/dist/icons/SeatGearVentilationOff.d.ts +4 -0
- package/dist/icons/SeatGearVentilationOff.js +16 -0
- package/dist/icons/SentryMode.d.ts +4 -0
- package/dist/icons/SentryMode.js +13 -0
- package/dist/icons/SmartScene.d.ts +4 -0
- package/dist/icons/SmartScene.js +13 -0
- package/dist/icons/SteeringWheelFirstGear.d.ts +4 -0
- package/dist/icons/SteeringWheelFirstGear.js +13 -0
- package/dist/icons/SteeringWheelHot.d.ts +4 -0
- package/dist/icons/SteeringWheelHot.js +13 -0
- package/dist/icons/SteeringWheelSecondGear.d.ts +4 -0
- package/dist/icons/SteeringWheelSecondGear.js +13 -0
- package/dist/icons/SteeringWheelThirdGear.d.ts +4 -0
- package/dist/icons/SteeringWheelThirdGear.js +13 -0
- package/dist/icons/Warning.d.ts +4 -0
- package/dist/icons/Warning.js +13 -0
- package/dist/icons/index.d.ts +24 -0
- package/dist/icons/index.js +27 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +20 -0
- package/dist/modules/MODULES.md +245 -0
- package/dist/modules/airconditionModule/README.md +262 -0
- package/dist/modules/airconditionModule/index.d.ts +17 -0
- package/dist/modules/airconditionModule/index.js +63 -0
- package/dist/modules/carInfoModule/README.md +418 -0
- package/dist/modules/carInfoModule/index.d.ts +26 -0
- package/dist/modules/carInfoModule/index.js +67 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +2 -0
- package/dist/modules/seatModule/README.md +345 -0
- package/dist/modules/seatModule/index.d.ts +15 -0
- package/dist/modules/seatModule/index.js +40 -0
- package/dist/modules/steeringWheelModule/README.md +216 -0
- package/dist/modules/steeringWheelModule/index.d.ts +13 -0
- package/dist/modules/steeringWheelModule/index.js +31 -0
- package/dist/resources/i18n.d.ts +1730 -0
- package/dist/resources/i18n.js +84 -0
- package/dist/resources/images.d.ts +1 -0
- package/dist/resources/images.js +45 -0
- package/dist/spec/index.d.ts +494 -0
- package/dist/spec/index.js +911 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.js +1 -0
- package/dist/utils/checkSameValue.d.ts +1 -0
- package/dist/utils/checkSameValue.js +11 -0
- package/dist/utils/fns.d.ts +5 -0
- package/dist/utils/fns.js +167 -0
- package/dist/utils/get-value-or-default.d.ts +1 -0
- package/dist/utils/get-value-or-default.js +4 -0
- package/dist/utils/getLocalI18n.d.ts +1 -0
- package/dist/utils/getLocalI18n.js +9 -0
- package/dist/utils/i18n.d.ts +1 -0
- package/dist/utils/i18n.js +141 -0
- package/dist/utils/objects.d.ts +2 -0
- package/dist/utils/objects.js +222 -0
- package/dist/utils/spec.d.ts +8 -0
- package/dist/utils/spec.js +171 -0
- package/dist/utils/types.d.ts +3 -0
- package/dist/utils/types.js +25 -0
- package/package.json +27 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
# CarInfoModule — 车辆信息模块
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
车辆信息头部展示模块,集成电量/续航进度条和驻车状态显示。自动根据传入的 specs 判断单续航或双续航模式。
|
|
6
|
+
|
|
7
|
+
## 引用方式
|
|
8
|
+
|
|
9
|
+
本模块支持三种引用粒度,开发者可根据需要选择:
|
|
10
|
+
|
|
11
|
+
| 引用方式 | 说明 | 适用场景 |
|
|
12
|
+
|---------|------|---------|
|
|
13
|
+
| **Module(推荐)** | 完整模块,内含数据层 + UI 层 | 标准业务场景,开箱即用 |
|
|
14
|
+
| **Hooks** | 仅数据层 | 需要自定义 UI,复用数据逻辑 |
|
|
15
|
+
| **Component** | 仅 UI 层(`CarInfoHeader`) | 已有数据源,仅需渲染 UI |
|
|
16
|
+
|
|
17
|
+
**可用 Hooks:**
|
|
18
|
+
|
|
19
|
+
| Hook | 说明 |
|
|
20
|
+
|------|------|
|
|
21
|
+
| `useSingleRangeData` | 单续航数据(电量百分比/预估里程/进度条颜色) |
|
|
22
|
+
| `useDualRangeData` | 双续航数据(纯电续航 + 燃油续航) |
|
|
23
|
+
| `useParkingStatusData` | 驻车状态(图标/文案/哨兵模式) |
|
|
24
|
+
|
|
25
|
+
## 文件
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
carInfoModule/
|
|
29
|
+
└── index.tsx
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 1. Module 用法(完整模块)
|
|
35
|
+
|
|
36
|
+
### Props
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
interface CarInfoModuleProps {
|
|
40
|
+
specs: CarInfoSpecs;
|
|
41
|
+
connectStatus?: ConnectStatusValue; // 默认 ConnectStatus.CONNECTING
|
|
42
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Specs 定义
|
|
47
|
+
|
|
48
|
+
#### 单续航相关
|
|
49
|
+
|
|
50
|
+
| Spec | 用途 | 必填 |
|
|
51
|
+
|------|------|------|
|
|
52
|
+
| `specPowerBatteryPropertiesBatterySoCDisplay` | 电池 SOC 百分比显示 | 否 |
|
|
53
|
+
| `specPowerBatteryPropertiesLowSocWarning` | 低电量警告等级(Level1/Level2) | 否 |
|
|
54
|
+
| `specPowerBatteryPropertiesBatteryEstimatedMileage` | 电池预估里程 | 否 |
|
|
55
|
+
| `specPowerBatteryPropertiesDCDRangeSOCTypeDisplay` | 续航显示类型(SOC/CLTCRange/MiRange) | 否 |
|
|
56
|
+
| `specPowerBatteryPropertiesCLTCEstimatedRange` | CLTC 工况预估续航 | 否 |
|
|
57
|
+
|
|
58
|
+
#### 双续航相关(存在任一则启用双续航模式)
|
|
59
|
+
|
|
60
|
+
| Spec | 用途 | 必填 |
|
|
61
|
+
|------|------|------|
|
|
62
|
+
| `specPowerBatteryLifeEffectivenessPropertiesCltcEstimatedExtendEange` | CLTC 增程续航里程 | 否 |
|
|
63
|
+
| `specPowerRangePropertiesCltcFuelEndurance` | CLTC 燃油续航里程 | 否 |
|
|
64
|
+
| `specPowerRangePropertiesWltcPureEleCruisingEndurance` | WLTC 纯电续航里程 | 否 |
|
|
65
|
+
| `specPowerRangePropertiesWltcFuelEndurance` | WLTC 燃油续航里程 | 否 |
|
|
66
|
+
|
|
67
|
+
#### 驻车状态相关
|
|
68
|
+
|
|
69
|
+
| Spec | 用途 | 必填 |
|
|
70
|
+
|------|------|------|
|
|
71
|
+
| `specBodyGearPropertiesGearStatus` | 档位状态(P/R/N/D) | 否 |
|
|
72
|
+
| `specBodyPowerModePropertiesPowerModeState` | 电源模式(Off/Awake) | 否 |
|
|
73
|
+
| `specDoorCentralLockPropertiesCentralLockState` | 中控锁状态(Locked/Unlocked) | 否 |
|
|
74
|
+
| `specSentryInfoPropertiesSentryWorkMode` | 哨兵模式(ON/StandBy/Alert/Alarm) | 否 |
|
|
75
|
+
|
|
76
|
+
### 核心逻辑
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
rangeType = 存在任一双续航 spec ? 'dual' : 'single'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 示例
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { CarInfoModule } from '@miot-rn/car-component/dist/modules';
|
|
86
|
+
import { ConnectStatus } from '@miot-rn/car-component/dist/config';
|
|
87
|
+
|
|
88
|
+
<CarInfoModule
|
|
89
|
+
specs={{
|
|
90
|
+
specPowerBatteryPropertiesBatterySoCDisplay: batterySocSpec,
|
|
91
|
+
specPowerBatteryPropertiesLowSocWarning: lowSocSpec,
|
|
92
|
+
specPowerBatteryPropertiesBatteryEstimatedMileage: mileageSpec,
|
|
93
|
+
specPowerBatteryPropertiesDCDRangeSOCTypeDisplay: dcdTypeSpec,
|
|
94
|
+
specBodyGearPropertiesGearStatus: gearSpec,
|
|
95
|
+
specBodyPowerModePropertiesPowerModeState: powerModeSpec,
|
|
96
|
+
specDoorCentralLockPropertiesCentralLockState: lockSpec,
|
|
97
|
+
}}
|
|
98
|
+
connectStatus={ConnectStatus.CONNECTED}
|
|
99
|
+
/>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 2. Hooks 用法
|
|
105
|
+
|
|
106
|
+
### 2.1 `useSingleRangeData` — 单续航数据
|
|
107
|
+
|
|
108
|
+
#### 引入
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { useSingleRangeData } from '@miot-rn/car-component/dist/hooks/useSingleRangeData';
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### 入参
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
interface UseSingleRangeDataProps {
|
|
118
|
+
specPowerBatteryPropertiesBatterySoCDisplay: Spec;
|
|
119
|
+
specPowerBatteryPropertiesLowSocWarning: Spec;
|
|
120
|
+
specPowerBatteryPropertiesBatteryEstimatedMileage: Spec;
|
|
121
|
+
specPowerBatteryPropertiesDCDRangeSOCTypeDisplay: Spec;
|
|
122
|
+
specPowerBatteryPropertiesCLTCEstimatedRange: Spec;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### 返回值
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
interface RangeDisplayData {
|
|
130
|
+
currentRange: number | string; // 当前续航值
|
|
131
|
+
totalRange: number; // 总续航量(进度条满值)
|
|
132
|
+
unit: string; // 单位:'%' 或 i18n 的 'km'
|
|
133
|
+
color: string; // 进度条颜色(绿/黄/红)
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### 显示类型(由 `DCDRangeSOCTypeDisplay` 决定)
|
|
138
|
+
|
|
139
|
+
| 类型 | 显示内容 | 单位 |
|
|
140
|
+
|------|----------|------|
|
|
141
|
+
| SOC | 电池电量百分比 | % |
|
|
142
|
+
| CLTCRange | CLTC 预估续航 | km(i18n) |
|
|
143
|
+
| MiRange | 电池预估里程 | km(i18n) |
|
|
144
|
+
|
|
145
|
+
#### 进度条颜色(由 `LowSocWarning` 决定)
|
|
146
|
+
|
|
147
|
+
| 警告等级 | 颜色 |
|
|
148
|
+
|----------|------|
|
|
149
|
+
| 正常 | `mjcard_color_green_2`(绿色) |
|
|
150
|
+
| Level2 Warning | `mjcard_color_yellow_2`(黄色) |
|
|
151
|
+
| Level1 Warning | `mjcard_color_red_2`(红色) |
|
|
152
|
+
|
|
153
|
+
#### 示例
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import { useSingleRangeData } from '@miot-rn/car-component/dist/hooks/useSingleRangeData';
|
|
157
|
+
|
|
158
|
+
const MyRangeDisplay = ({ specs }) => {
|
|
159
|
+
const rangeData = useSingleRangeData({
|
|
160
|
+
specPowerBatteryPropertiesBatterySoCDisplay: specs.batterySoc,
|
|
161
|
+
specPowerBatteryPropertiesLowSocWarning: specs.lowSoc,
|
|
162
|
+
specPowerBatteryPropertiesBatteryEstimatedMileage: specs.mileage,
|
|
163
|
+
specPowerBatteryPropertiesDCDRangeSOCTypeDisplay: specs.dcdType,
|
|
164
|
+
specPowerBatteryPropertiesCLTCEstimatedRange: specs.cltcRange,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<View>
|
|
169
|
+
<Text style={{ color: rangeData.color }}>
|
|
170
|
+
{rangeData.currentRange} {rangeData.unit}
|
|
171
|
+
</Text>
|
|
172
|
+
<ProgressBar
|
|
173
|
+
progress={Number(rangeData.currentRange) / rangeData.totalRange}
|
|
174
|
+
color={rangeData.color}
|
|
175
|
+
/>
|
|
176
|
+
</View>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### 2.2 `useDualRangeData` — 双续航数据
|
|
184
|
+
|
|
185
|
+
#### 引入
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
import { useDualRangeData } from '@miot-rn/car-component/dist/hooks/useDualRangeData';
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### 入参
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
interface UseDualRangeDataProps {
|
|
195
|
+
specPowerBatteryPropertiesDCDRangeSOCTypeDisplay: Spec;
|
|
196
|
+
specPowerBatteryLifeEffectivenessPropertiesCltcEstimatedExtendEange: Spec;
|
|
197
|
+
specPowerRangePropertiesCltcFuelEndurance: Spec;
|
|
198
|
+
specPowerRangePropertiesWltcPureEleCruisingEndurance: Spec;
|
|
199
|
+
specPowerRangePropertiesWltcFuelEndurance: Spec;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### 返回值
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
interface DualRangeDisplayData {
|
|
207
|
+
currentElectricRange: number | string; // 当前纯电续航('--' 表示无数据)
|
|
208
|
+
electricRange: number; // 纯电续航满值
|
|
209
|
+
unit: string; // 单位 km(i18n)
|
|
210
|
+
electricColor: string; // 纯电进度条颜色
|
|
211
|
+
currentFuelRange: number | string; // 当前燃油续航('--' 表示无数据)
|
|
212
|
+
fuelRange: number; // 燃油续航满值
|
|
213
|
+
fuelColor: string; // 燃油进度条颜色
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### 数据源选择(由 `DCDRangeSOCTypeDisplay` 决定)
|
|
218
|
+
|
|
219
|
+
| 类型 | 纯电数据源 | 燃油数据源 |
|
|
220
|
+
|------|-----------|-----------|
|
|
221
|
+
| WLTCRange | `WltcPureEleCruisingEndurance` | `WltcFuelEndurance` |
|
|
222
|
+
| 默认(CLTC) | `CltcEstimatedExtendEange` | `CltcFuelEndurance` |
|
|
223
|
+
|
|
224
|
+
#### 示例
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
import { useDualRangeData } from '@miot-rn/car-component/dist/hooks/useDualRangeData';
|
|
228
|
+
|
|
229
|
+
const MyDualRangeDisplay = ({ specs }) => {
|
|
230
|
+
const dualData = useDualRangeData({
|
|
231
|
+
specPowerBatteryPropertiesDCDRangeSOCTypeDisplay: specs.dcdType,
|
|
232
|
+
specPowerBatteryLifeEffectivenessPropertiesCltcEstimatedExtendEange: specs.cltcExtend,
|
|
233
|
+
specPowerRangePropertiesCltcFuelEndurance: specs.cltcFuel,
|
|
234
|
+
specPowerRangePropertiesWltcPureEleCruisingEndurance: specs.wltcElec,
|
|
235
|
+
specPowerRangePropertiesWltcFuelEndurance: specs.wltcFuel,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<View style={{ flexDirection: 'row' }}>
|
|
240
|
+
<View>
|
|
241
|
+
<Text>纯电: {dualData.currentElectricRange} {dualData.unit}</Text>
|
|
242
|
+
</View>
|
|
243
|
+
<View>
|
|
244
|
+
<Text>燃油: {dualData.currentFuelRange} {dualData.unit}</Text>
|
|
245
|
+
</View>
|
|
246
|
+
</View>
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### 2.3 `useParkingStatusData` — 驻车状态数据
|
|
254
|
+
|
|
255
|
+
#### 引入
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import { useParkingStatusData } from '@miot-rn/car-component/dist/hooks/useParkingStatusData';
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
#### 入参
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
interface UseParkingStatusDataProps {
|
|
265
|
+
specBodyGearPropertiesGearStatus: Spec;
|
|
266
|
+
specBodyPowerModePropertiesPowerModeState: Spec;
|
|
267
|
+
specDoorCentralLockPropertiesCentralLockState: Spec;
|
|
268
|
+
specSentryInfoPropertiesSentryWorkMode?: Spec; // 可选
|
|
269
|
+
connectStatus?: ConnectStatusValue; // 默认 CONNECTING
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
#### 返回值
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
interface ParkingStatusInfo {
|
|
277
|
+
parkingIcon?: React.ReactElement; // 状态图标
|
|
278
|
+
parkingStatus: string | Record<string, string>; // 状态文案(i18n)
|
|
279
|
+
showDivider: boolean; // 是否显示分割线(哨兵模式时)
|
|
280
|
+
textStyle: StyleProp<TextStyle>; // 文案样式
|
|
281
|
+
isLoading?: boolean; // 是否加载中
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
#### 状态判断流程
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
连接中 → Loading 图标 + "连接中"
|
|
289
|
+
电源 Off/Awake + 中控锁 Locked → "已锁车"(哨兵模式时显示哨兵图标 + 分割线)
|
|
290
|
+
档位 R/N/D → "行驶中"
|
|
291
|
+
其他 → "已驻车"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### 示例
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
import { useParkingStatusData } from '@miot-rn/car-component/dist/hooks/useParkingStatusData';
|
|
298
|
+
import { ConnectStatus } from '@miot-rn/car-component/dist/config';
|
|
299
|
+
|
|
300
|
+
const MyParkingStatus = ({ specs, connectStatus }) => {
|
|
301
|
+
const status = useParkingStatusData({
|
|
302
|
+
specBodyGearPropertiesGearStatus: specs.gear,
|
|
303
|
+
specBodyPowerModePropertiesPowerModeState: specs.powerMode,
|
|
304
|
+
specDoorCentralLockPropertiesCentralLockState: specs.lock,
|
|
305
|
+
specSentryInfoPropertiesSentryWorkMode: specs.sentry,
|
|
306
|
+
connectStatus,
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
return (
|
|
310
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
311
|
+
{status.isLoading && <ActivityIndicator />}
|
|
312
|
+
{status.parkingIcon}
|
|
313
|
+
{status.showDivider && <View style={styles.divider} />}
|
|
314
|
+
<Text style={status.textStyle}>{status.parkingStatus}</Text>
|
|
315
|
+
</View>
|
|
316
|
+
);
|
|
317
|
+
};
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## 3. Component 用法(`CarInfoHeader`)
|
|
323
|
+
|
|
324
|
+
适用于已有数据源,仅需渲染车辆信息头部 UI 的场景。
|
|
325
|
+
|
|
326
|
+
### 引入
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
import { CarInfoHeader } from '@miot-rn/car-component/dist/components/carInfoHeader';
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Props
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
interface CarInfoHeaderProps {
|
|
336
|
+
singleRangeData?: SingleRangeData; // 传入则显示单续航模式
|
|
337
|
+
dualRangeData?: DualRangeData; // 传入则显示双续航模式(优先于单续航)
|
|
338
|
+
parkingStatus?: ParkingStatusData; // 驻车状态
|
|
339
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
interface SingleRangeData {
|
|
343
|
+
currentRange: number | string;
|
|
344
|
+
totalRange: number;
|
|
345
|
+
unit: string;
|
|
346
|
+
color?: string;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
interface DualRangeData {
|
|
350
|
+
currentElectricRange: number | string;
|
|
351
|
+
electricRange: number;
|
|
352
|
+
unit: string;
|
|
353
|
+
electricColor?: string;
|
|
354
|
+
currentFuelRange: number | string;
|
|
355
|
+
fuelRange: number;
|
|
356
|
+
fuelColor?: string;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
interface ParkingStatusData {
|
|
360
|
+
status?: string;
|
|
361
|
+
icon?: React.ReactElement;
|
|
362
|
+
showDivider?: boolean;
|
|
363
|
+
textStyle?: StyleProp<TextStyle>;
|
|
364
|
+
isLoading?: boolean;
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### 渲染结构
|
|
369
|
+
|
|
370
|
+
```
|
|
371
|
+
Container (1:2:1 flex 垂直布局, 最大 336x336)
|
|
372
|
+
├── 续航指示器区域 (flex 1)
|
|
373
|
+
│ ├── SingleRangeIndicator (单续航: 数值 + 进度条)
|
|
374
|
+
│ └── DualRangeIndicator (双续航: 纯电 + 燃油并排)
|
|
375
|
+
├── 车辆图片区域 (flex 2)
|
|
376
|
+
│ └── CarImage (Device.iconURL 或 MijiaLogo 占位)
|
|
377
|
+
└── 驻车状态区域 (flex 1)
|
|
378
|
+
└── ParkingStatus (图标 + 分割线 + 状态文案)
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### 示例
|
|
382
|
+
|
|
383
|
+
```tsx
|
|
384
|
+
import { CarInfoHeader } from '@miot-rn/car-component/dist/components/carInfoHeader';
|
|
385
|
+
|
|
386
|
+
// 单续航
|
|
387
|
+
<CarInfoHeader
|
|
388
|
+
singleRangeData={{
|
|
389
|
+
currentRange: 75,
|
|
390
|
+
totalRange: 100,
|
|
391
|
+
unit: '%',
|
|
392
|
+
color: '#4CAF50',
|
|
393
|
+
}}
|
|
394
|
+
parkingStatus={{
|
|
395
|
+
status: '已锁车',
|
|
396
|
+
isLoading: false,
|
|
397
|
+
}}
|
|
398
|
+
/>
|
|
399
|
+
|
|
400
|
+
// 双续航
|
|
401
|
+
<CarInfoHeader
|
|
402
|
+
dualRangeData={{
|
|
403
|
+
currentElectricRange: 120,
|
|
404
|
+
electricRange: 200,
|
|
405
|
+
currentFuelRange: 450,
|
|
406
|
+
fuelRange: 800,
|
|
407
|
+
unit: 'km',
|
|
408
|
+
}}
|
|
409
|
+
/>
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### 子组件导出
|
|
413
|
+
|
|
414
|
+
`CarInfoHeader` 同时导出以下子组件,支持更细粒度的 UI 复用:
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
export { SingleRangeIndicator, DualRangeIndicator, CarImage, ParkingStatus };
|
|
418
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { Spec } from '../../types';
|
|
4
|
+
import { ConnectStatusValue } from '../../config';
|
|
5
|
+
export interface CarInfoSpecs {
|
|
6
|
+
specPowerBatteryPropertiesBatterySoCDisplay?: Spec;
|
|
7
|
+
specPowerBatteryPropertiesLowSocWarning?: Spec;
|
|
8
|
+
specPowerBatteryPropertiesBatteryEstimatedMileage?: Spec;
|
|
9
|
+
specPowerBatteryPropertiesDCDRangeSOCTypeDisplay?: Spec;
|
|
10
|
+
specPowerBatteryPropertiesCLTCEstimatedRange?: Spec;
|
|
11
|
+
specPowerBatteryLifeEffectivenessPropertiesCltcEstimatedExtendEange?: Spec;
|
|
12
|
+
specPowerRangePropertiesCltcFuelEndurance?: Spec;
|
|
13
|
+
specPowerRangePropertiesWltcPureEleCruisingEndurance?: Spec;
|
|
14
|
+
specPowerRangePropertiesWltcFuelEndurance?: Spec;
|
|
15
|
+
specBodyGearPropertiesGearStatus?: Spec;
|
|
16
|
+
specBodyPowerModePropertiesPowerModeState?: Spec;
|
|
17
|
+
specDoorCentralLockPropertiesCentralLockState?: Spec;
|
|
18
|
+
specSentryInfoPropertiesSentryWorkMode?: Spec;
|
|
19
|
+
}
|
|
20
|
+
export interface CarInfoModuleProps {
|
|
21
|
+
specs: CarInfoSpecs;
|
|
22
|
+
connectStatus?: ConnectStatusValue;
|
|
23
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
24
|
+
}
|
|
25
|
+
export declare const CarInfoModule: ({ specs, connectStatus, containerStyle }: CarInfoModuleProps) => React.JSX.Element;
|
|
26
|
+
export default CarInfoModule;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { CarInfoHeader } from "../../components/carInfoHeader";
|
|
4
|
+
import { useSingleRangeData, useDualRangeData, useParkingStatusData, ConnectStatus } from "../../hooks";
|
|
5
|
+
export const CarInfoModule = ({
|
|
6
|
+
specs,
|
|
7
|
+
connectStatus = ConnectStatus.CONNECTING,
|
|
8
|
+
containerStyle
|
|
9
|
+
}) => {
|
|
10
|
+
// 判断 rangeType 类型
|
|
11
|
+
const rangeType = useMemo(() => {
|
|
12
|
+
return specs.specPowerBatteryLifeEffectivenessPropertiesCltcEstimatedExtendEange || specs.specPowerRangePropertiesWltcFuelEndurance || specs.specPowerRangePropertiesWltcPureEleCruisingEndurance || specs.specPowerRangePropertiesCltcFuelEndurance ? 'dual' : 'single';
|
|
13
|
+
}, [specs.specPowerBatteryLifeEffectivenessPropertiesCltcEstimatedExtendEange, specs.specPowerRangePropertiesWltcFuelEndurance, specs.specPowerRangePropertiesWltcPureEleCruisingEndurance, specs.specPowerRangePropertiesCltcFuelEndurance]);
|
|
14
|
+
|
|
15
|
+
// 单续航数据
|
|
16
|
+
const singleRangeData = useSingleRangeData({
|
|
17
|
+
specPowerBatteryPropertiesBatterySoCDisplay: specs.specPowerBatteryPropertiesBatterySoCDisplay,
|
|
18
|
+
specPowerBatteryPropertiesLowSocWarning: specs.specPowerBatteryPropertiesLowSocWarning,
|
|
19
|
+
specPowerBatteryPropertiesBatteryEstimatedMileage: specs.specPowerBatteryPropertiesBatteryEstimatedMileage,
|
|
20
|
+
specPowerBatteryPropertiesDCDRangeSOCTypeDisplay: specs.specPowerBatteryPropertiesDCDRangeSOCTypeDisplay,
|
|
21
|
+
specPowerBatteryPropertiesCLTCEstimatedRange: specs.specPowerBatteryPropertiesCLTCEstimatedRange
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// 双续航数据
|
|
25
|
+
const dualRangeData = useDualRangeData({
|
|
26
|
+
specPowerBatteryPropertiesDCDRangeSOCTypeDisplay: specs.specPowerBatteryPropertiesDCDRangeSOCTypeDisplay,
|
|
27
|
+
specPowerBatteryLifeEffectivenessPropertiesCltcEstimatedExtendEange: specs.specPowerBatteryLifeEffectivenessPropertiesCltcEstimatedExtendEange,
|
|
28
|
+
specPowerRangePropertiesCltcFuelEndurance: specs.specPowerRangePropertiesCltcFuelEndurance,
|
|
29
|
+
specPowerRangePropertiesWltcPureEleCruisingEndurance: specs.specPowerRangePropertiesWltcPureEleCruisingEndurance,
|
|
30
|
+
specPowerRangePropertiesWltcFuelEndurance: specs.specPowerRangePropertiesWltcFuelEndurance
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// 驻车状态数据
|
|
34
|
+
const parkingStatusInfo = useParkingStatusData({
|
|
35
|
+
specBodyGearPropertiesGearStatus: specs.specBodyGearPropertiesGearStatus,
|
|
36
|
+
specBodyPowerModePropertiesPowerModeState: specs.specBodyPowerModePropertiesPowerModeState,
|
|
37
|
+
specDoorCentralLockPropertiesCentralLockState: specs.specDoorCentralLockPropertiesCentralLockState,
|
|
38
|
+
specSentryInfoPropertiesSentryWorkMode: specs.specSentryInfoPropertiesSentryWorkMode,
|
|
39
|
+
connectStatus
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// 构建传递给 CarInfoHeader 的 props
|
|
43
|
+
const getCarInfoHeaderProps = () => {
|
|
44
|
+
// 转换 parkingStatus,确保 status 为 string 类型
|
|
45
|
+
const parkingStatus = {
|
|
46
|
+
status: typeof parkingStatusInfo.parkingStatus === 'string' ? parkingStatusInfo.parkingStatus : undefined,
|
|
47
|
+
icon: parkingStatusInfo.parkingIcon,
|
|
48
|
+
showDivider: parkingStatusInfo.showDivider,
|
|
49
|
+
textStyle: parkingStatusInfo.textStyle,
|
|
50
|
+
isLoading: parkingStatusInfo?.isLoading
|
|
51
|
+
};
|
|
52
|
+
if (rangeType === 'single') {
|
|
53
|
+
return {
|
|
54
|
+
singleRangeData,
|
|
55
|
+
parkingStatus,
|
|
56
|
+
containerStyle
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
dualRangeData,
|
|
61
|
+
parkingStatus,
|
|
62
|
+
containerStyle
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
return /*#__PURE__*/React.createElement(CarInfoHeader, getCarInfoHeaderProps());
|
|
66
|
+
};
|
|
67
|
+
export default CarInfoModule;
|