@miot-rn/car-component 1.0.4 → 1.0.5
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/dist/components/carInfoHeader/index.d.ts +1 -0
- package/dist/components/carInfoHeader/index.js +1 -0
- package/dist/components/carInfoHeader/singleRangeIndicator.d.ts +2 -1
- package/dist/components/carInfoHeader/singleRangeIndicator.js +2 -2
- package/dist/hooks/useSingleRangeData.d.ts +1 -0
- package/dist/hooks/useSingleRangeData.js +11 -4
- package/package.json +2 -2
|
@@ -65,6 +65,7 @@ export const CarInfoHeader = props => {
|
|
|
65
65
|
}) : singleRangeData ? /*#__PURE__*/React.createElement(SingleRangeIndicator, {
|
|
66
66
|
currentRange: singleRangeData.currentRange,
|
|
67
67
|
totalRange: singleRangeData.totalRange,
|
|
68
|
+
currentSoc: singleRangeData.currentSoc,
|
|
68
69
|
unit: singleRangeData.unit,
|
|
69
70
|
color: singleRangeData.color
|
|
70
71
|
}) : null), /*#__PURE__*/React.createElement(View, {
|
|
@@ -3,9 +3,10 @@ import { StyleProp, ViewStyle } from 'react-native';
|
|
|
3
3
|
interface SingleRangeIndicatorProps {
|
|
4
4
|
currentRange?: number | string | null;
|
|
5
5
|
totalRange?: number;
|
|
6
|
+
currentSoc?: number;
|
|
6
7
|
unit?: string;
|
|
7
8
|
color?: string;
|
|
8
9
|
style?: StyleProp<ViewStyle>;
|
|
9
10
|
}
|
|
10
|
-
export declare const SingleRangeIndicator: ({ currentRange, totalRange, unit, color, style, }: SingleRangeIndicatorProps) => React.JSX.Element;
|
|
11
|
+
export declare const SingleRangeIndicator: ({ currentRange, totalRange, currentSoc, unit, color, style, }: SingleRangeIndicatorProps) => React.JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -6,14 +6,14 @@ import { RangeProgressBar } from "./rangeProgressBar";
|
|
|
6
6
|
export const SingleRangeIndicator = ({
|
|
7
7
|
currentRange,
|
|
8
8
|
totalRange = 100,
|
|
9
|
+
currentSoc = 0,
|
|
9
10
|
unit = 'km',
|
|
10
11
|
color,
|
|
11
12
|
style
|
|
12
13
|
}) => {
|
|
13
14
|
const hasValue = currentRange != null && currentRange !== '';
|
|
14
|
-
const numericRange = typeof currentRange === 'number' ? currentRange : 0;
|
|
15
15
|
const displayValue = hasValue ? typeof currentRange === 'number' ? Math.round(currentRange) : currentRange : '--';
|
|
16
|
-
const progress =
|
|
16
|
+
const progress = totalRange > 0 ? Math.min(currentSoc / totalRange, 1) : 0;
|
|
17
17
|
return /*#__PURE__*/React.createElement(View, {
|
|
18
18
|
style: [styles.container, style]
|
|
19
19
|
}, /*#__PURE__*/React.createElement(View, {
|
|
@@ -40,6 +40,7 @@ export const useSingleRangeData = ({
|
|
|
40
40
|
return {
|
|
41
41
|
currentRange: null,
|
|
42
42
|
totalRange: 100,
|
|
43
|
+
currentSoc: 0,
|
|
43
44
|
unit: '%',
|
|
44
45
|
color: colorToken.accentGreenContent
|
|
45
46
|
};
|
|
@@ -57,12 +58,15 @@ export const useSingleRangeData = ({
|
|
|
57
58
|
} else if (getValueBySpecDescription(specPowerBatteryPropertiesLowSocWarning, 'Level1 Warning') === lowSocWarning) {
|
|
58
59
|
color = colorToken.accentYellowFill;
|
|
59
60
|
}
|
|
61
|
+
const totalRange = specPowerBatteryPropertiesBatterySoCDisplay?.prop?.['value-range']?.[1] || 100;
|
|
62
|
+
const currentSoc = batterySoCDisplay || 0;
|
|
60
63
|
|
|
61
64
|
// 1. Battery SOC percentage
|
|
62
65
|
if (getValueBySpecDescription(specPowerBatteryPropertiesDCDRangeSOCTypeDisplay, 'SOC') === dcdType) {
|
|
63
66
|
return {
|
|
64
67
|
currentRange: batterySoCDisplay,
|
|
65
|
-
totalRange
|
|
68
|
+
totalRange,
|
|
69
|
+
currentSoc,
|
|
66
70
|
unit: '%',
|
|
67
71
|
color
|
|
68
72
|
};
|
|
@@ -72,7 +76,8 @@ export const useSingleRangeData = ({
|
|
|
72
76
|
if (getValueBySpecDescription(specPowerBatteryPropertiesDCDRangeSOCTypeDisplay, 'CLTCRange') === dcdType) {
|
|
73
77
|
return {
|
|
74
78
|
currentRange: cltcEstimatedRange,
|
|
75
|
-
totalRange
|
|
79
|
+
totalRange,
|
|
80
|
+
currentSoc,
|
|
76
81
|
unit: distanceUnit,
|
|
77
82
|
color
|
|
78
83
|
};
|
|
@@ -82,14 +87,16 @@ export const useSingleRangeData = ({
|
|
|
82
87
|
if (getValueBySpecDescription(specPowerBatteryPropertiesDCDRangeSOCTypeDisplay, 'MiRange') === dcdType) {
|
|
83
88
|
return {
|
|
84
89
|
currentRange: batteryEstimatedMileage,
|
|
85
|
-
totalRange
|
|
90
|
+
totalRange,
|
|
91
|
+
currentSoc,
|
|
86
92
|
unit: distanceUnit,
|
|
87
93
|
color
|
|
88
94
|
};
|
|
89
95
|
}
|
|
90
96
|
return {
|
|
91
97
|
currentRange: null,
|
|
92
|
-
totalRange
|
|
98
|
+
totalRange,
|
|
99
|
+
currentSoc,
|
|
93
100
|
unit: '%',
|
|
94
101
|
color: colorToken.accentGreenContent
|
|
95
102
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miot-rn/car-component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"react-native": "^0.61.0",
|
|
24
24
|
"react-native-svg": "9.5.3"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "4c8ede30130f3562da326ae8af9112d8cba4fb5a"
|
|
27
27
|
}
|