@miot-rn/car-component 1.0.3 → 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/airConditioningCard/index.d.ts +2 -1
- package/dist/components/airConditioningCard/index.js +8 -9
- package/dist/components/carInfoHeader/dualRangeIndicator.d.ts +2 -2
- package/dist/components/carInfoHeader/dualRangeIndicator.js +12 -12
- package/dist/components/carInfoHeader/index.d.ts +4 -3
- package/dist/components/carInfoHeader/index.js +4 -3
- package/dist/components/carInfoHeader/singleRangeIndicator.d.ts +3 -2
- package/dist/components/carInfoHeader/singleRangeIndicator.js +10 -9
- package/dist/components/titleContainer/TitleContainer.js +2 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useDualRangeData.d.ts +2 -2
- package/dist/hooks/useDualRangeData.js +13 -12
- package/dist/hooks/useParkingStatusData.js +13 -2
- package/dist/hooks/useSingleRangeData.d.ts +2 -1
- package/dist/hooks/useSingleRangeData.js +23 -15
- package/dist/modules/airconditionModule/index.js +1 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/utils/fns.d.ts +2 -0
- package/dist/utils/fns.js +8 -0
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface AirConditioningCardProps {
|
|
3
|
+
showAirc: boolean;
|
|
3
4
|
hvacStatus: boolean;
|
|
4
5
|
hvacDefrosterStatus: boolean;
|
|
5
6
|
onHvacStatusChange: (value: boolean) => void;
|
|
@@ -20,5 +21,5 @@ interface AirConditioningCardProps {
|
|
|
20
21
|
disabled?: boolean;
|
|
21
22
|
showTargetTemperature?: boolean;
|
|
22
23
|
}
|
|
23
|
-
export declare const AirConditioningCard: React.MemoExoticComponent<({ hvacStatus, hvacDefrosterStatus, onHvacStatusChange, onHvacDefrosterChange, targetTemperature, onHvacTemperatureChange, hvacTitle, hvacDefrosterTitle, hvacDefrosterSubtitle, insideTip, outsideTip, temperatureStep, maxTemperature, minTemperature, insideTemperature, outsideTemperature, showHvacDefroster, disabled, showTargetTemperature, }: AirConditioningCardProps) => React.JSX.Element>;
|
|
24
|
+
export declare const AirConditioningCard: React.MemoExoticComponent<({ showAirc, hvacStatus, hvacDefrosterStatus, onHvacStatusChange, onHvacDefrosterChange, targetTemperature, onHvacTemperatureChange, hvacTitle, hvacDefrosterTitle, hvacDefrosterSubtitle, insideTip, outsideTip, temperatureStep, maxTemperature, minTemperature, insideTemperature, outsideTemperature, showHvacDefroster, disabled, showTargetTemperature, }: AirConditioningCardProps) => React.JSX.Element>;
|
|
24
25
|
export {};
|
|
@@ -7,6 +7,7 @@ function isEffectData(value) {
|
|
|
7
7
|
return typeof value === 'number' || typeof value === 'string';
|
|
8
8
|
}
|
|
9
9
|
export const AirConditioningCard = /*#__PURE__*/memo(({
|
|
10
|
+
showAirc,
|
|
10
11
|
hvacStatus,
|
|
11
12
|
hvacDefrosterStatus,
|
|
12
13
|
onHvacStatusChange,
|
|
@@ -40,12 +41,10 @@ export const AirConditioningCard = /*#__PURE__*/memo(({
|
|
|
40
41
|
const transformTargetTemperature = useMemo(() => {
|
|
41
42
|
return typeof targetTemperature === 'string' ? parseFloat(targetTemperature) : targetTemperature;
|
|
42
43
|
}, [targetTemperature]);
|
|
43
|
-
return /*#__PURE__*/React.createElement(CardContainer, null, /*#__PURE__*/React.createElement(TitleContainer, {
|
|
44
|
+
return /*#__PURE__*/React.createElement(CardContainer, null, showAirc && /*#__PURE__*/React.createElement(TitleContainer, {
|
|
44
45
|
title: hvacTitle,
|
|
45
46
|
subtitle: isInsideTemperatureEffect || isOutsideTemperatureEffect ? /*#__PURE__*/React.createElement(View, {
|
|
46
|
-
style:
|
|
47
|
-
paddingBottom: 12
|
|
48
|
-
}]
|
|
47
|
+
style: styles.conditioning
|
|
49
48
|
}, isInsideTemperatureEffect && /*#__PURE__*/React.createElement(Text, {
|
|
50
49
|
style: {
|
|
51
50
|
color: disabled ? colorToken.contentDisabledPrimary : colorToken.contentTertiaryNormal
|
|
@@ -56,14 +55,14 @@ export const AirConditioningCard = /*#__PURE__*/memo(({
|
|
|
56
55
|
style: {
|
|
57
56
|
color: disabled ? colorToken.contentDisabledPrimary : colorToken.contentTertiaryNormal
|
|
58
57
|
}
|
|
59
|
-
}, outsideTip)) :
|
|
60
|
-
style: {
|
|
61
|
-
paddingBottom: 12
|
|
62
|
-
}
|
|
63
|
-
}) : null,
|
|
58
|
+
}, outsideTip)) : null,
|
|
64
59
|
value: hvacStatus,
|
|
65
60
|
onValueChange: onHvacStatusChange,
|
|
66
61
|
disabled: disabled
|
|
62
|
+
}), showAirc && !showTargetTemperature && !showHvacDefroster && /*#__PURE__*/React.createElement(View, {
|
|
63
|
+
style: {
|
|
64
|
+
height: 12
|
|
65
|
+
}
|
|
67
66
|
}), showTargetTemperature && /*#__PURE__*/React.createElement(View, {
|
|
68
67
|
style: styles.stepper
|
|
69
68
|
}, /*#__PURE__*/React.createElement(Stepper, {
|
|
@@ -3,8 +3,8 @@ import { StyleProp, ViewStyle } from 'react-native';
|
|
|
3
3
|
interface DualRangeIndicatorProps {
|
|
4
4
|
electricRange?: number;
|
|
5
5
|
fuelRange?: number;
|
|
6
|
-
currentElectricRange?: number | string;
|
|
7
|
-
currentFuelRange?: number | string;
|
|
6
|
+
currentElectricRange?: number | string | null;
|
|
7
|
+
currentFuelRange?: number | string | null;
|
|
8
8
|
unit?: string;
|
|
9
9
|
electricColor?: string;
|
|
10
10
|
fuelColor?: string;
|
|
@@ -7,8 +7,8 @@ import { RangeProgressBar } from "./rangeProgressBar";
|
|
|
7
7
|
export const DualRangeIndicator = ({
|
|
8
8
|
electricRange = 500,
|
|
9
9
|
fuelRange = 800,
|
|
10
|
-
currentElectricRange
|
|
11
|
-
currentFuelRange
|
|
10
|
+
currentElectricRange,
|
|
11
|
+
currentFuelRange,
|
|
12
12
|
unit = 'km',
|
|
13
13
|
electricColor,
|
|
14
14
|
fuelColor,
|
|
@@ -18,19 +18,21 @@ export const DualRangeIndicator = ({
|
|
|
18
18
|
const {
|
|
19
19
|
colorToken
|
|
20
20
|
} = useContext(ConfigContext);
|
|
21
|
+
const hasElectricValue = currentElectricRange != null && currentElectricRange !== '';
|
|
22
|
+
const hasFuelValue = currentFuelRange != null && currentFuelRange !== '';
|
|
21
23
|
const numericElectricRange = typeof currentElectricRange === 'number' ? currentElectricRange : 0;
|
|
22
24
|
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 electricProgress = useMemo(() => hasElectricValue && electricRange > 0 && typeof currentElectricRange === 'number' ? Math.min(numericElectricRange / electricRange, 1) : 0, [hasElectricValue, numericElectricRange, electricRange, currentElectricRange]);
|
|
26
|
+
const fuelProgress = useMemo(() => hasFuelValue && fuelRange > 0 && typeof currentFuelRange === 'number' ? Math.min(numericFuelRange / fuelRange, 1) : 0, [hasFuelValue, numericFuelRange, fuelRange, currentFuelRange]);
|
|
25
27
|
const renderRangeIndicator = config => {
|
|
26
28
|
const {
|
|
27
29
|
icon,
|
|
28
30
|
color,
|
|
29
31
|
currentRange,
|
|
30
|
-
progress
|
|
31
|
-
totalRange
|
|
32
|
+
progress
|
|
32
33
|
} = config;
|
|
33
|
-
const
|
|
34
|
+
const hasValue = currentRange != null && currentRange !== '';
|
|
35
|
+
const displayValue = hasValue ? typeof currentRange === 'number' ? Math.round(currentRange) : currentRange : '--';
|
|
34
36
|
return /*#__PURE__*/React.createElement(View, {
|
|
35
37
|
style: styles.rangeItem,
|
|
36
38
|
key: config.type
|
|
@@ -44,11 +46,11 @@ export const DualRangeIndicator = ({
|
|
|
44
46
|
style: styles.rangeValue,
|
|
45
47
|
numberOfLines: 1,
|
|
46
48
|
ellipsizeMode: "tail"
|
|
47
|
-
}, displayValue, /*#__PURE__*/React.createElement(Text, {
|
|
49
|
+
}, displayValue, hasValue ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
|
48
50
|
style: styles.unitSpacer
|
|
49
|
-
},
|
|
51
|
+
}, " "), /*#__PURE__*/React.createElement(Text, {
|
|
50
52
|
style: styles.unit
|
|
51
|
-
}, unit)))), showProgress ? /*#__PURE__*/React.createElement(RangeProgressBar, {
|
|
53
|
+
}, unit)) : null))), showProgress && hasValue ? /*#__PURE__*/React.createElement(RangeProgressBar, {
|
|
52
54
|
progress: progress,
|
|
53
55
|
color: color
|
|
54
56
|
}) : null));
|
|
@@ -57,7 +59,6 @@ export const DualRangeIndicator = ({
|
|
|
57
59
|
style: [styles.container, style]
|
|
58
60
|
}, renderRangeIndicator({
|
|
59
61
|
type: 'electric',
|
|
60
|
-
totalRange: electricRange,
|
|
61
62
|
currentRange: currentElectricRange,
|
|
62
63
|
icon: /*#__PURE__*/React.createElement(ElectricPower, {
|
|
63
64
|
fill: colorToken.contentPrimaryNormal
|
|
@@ -66,7 +67,6 @@ export const DualRangeIndicator = ({
|
|
|
66
67
|
progress: electricProgress
|
|
67
68
|
}), renderRangeIndicator({
|
|
68
69
|
type: 'fuel',
|
|
69
|
-
totalRange: fuelRange,
|
|
70
70
|
currentRange: currentFuelRange,
|
|
71
71
|
icon: /*#__PURE__*/React.createElement(FuelPower, {
|
|
72
72
|
fill: colorToken.contentPrimaryNormal
|
|
@@ -5,17 +5,18 @@ import { DualRangeIndicator } from './dualRangeIndicator';
|
|
|
5
5
|
import { CarImage } from './carImage';
|
|
6
6
|
import { ParkingStatus } from './parkingStatus';
|
|
7
7
|
export interface SingleRangeData {
|
|
8
|
-
currentRange
|
|
8
|
+
currentRange?: number | string | null;
|
|
9
9
|
totalRange: number;
|
|
10
|
+
currentSoc: number;
|
|
10
11
|
unit: string;
|
|
11
12
|
color?: string;
|
|
12
13
|
}
|
|
13
14
|
export interface DualRangeData {
|
|
14
|
-
currentElectricRange
|
|
15
|
+
currentElectricRange?: number | string | null;
|
|
15
16
|
electricRange: number;
|
|
16
17
|
unit: string;
|
|
17
18
|
electricColor?: string;
|
|
18
|
-
currentFuelRange
|
|
19
|
+
currentFuelRange?: number | string | null;
|
|
19
20
|
fuelRange: number;
|
|
20
21
|
fuelColor?: string;
|
|
21
22
|
}
|
|
@@ -57,14 +57,15 @@ export const CarInfoHeader = props => {
|
|
|
57
57
|
}, isDualRange && dualRangeData ? /*#__PURE__*/React.createElement(DualRangeIndicator, {
|
|
58
58
|
electricRange: dualRangeData.electricRange,
|
|
59
59
|
fuelRange: dualRangeData.fuelRange,
|
|
60
|
-
currentElectricRange:
|
|
61
|
-
currentFuelRange:
|
|
60
|
+
currentElectricRange: dualRangeData.currentElectricRange,
|
|
61
|
+
currentFuelRange: dualRangeData.currentFuelRange,
|
|
62
62
|
unit: dualRangeData.unit,
|
|
63
63
|
electricColor: dualRangeData.electricColor,
|
|
64
64
|
fuelColor: dualRangeData.fuelColor
|
|
65
65
|
}) : singleRangeData ? /*#__PURE__*/React.createElement(SingleRangeIndicator, {
|
|
66
|
-
currentRange:
|
|
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, {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
3
|
interface SingleRangeIndicatorProps {
|
|
4
|
-
currentRange?: number | string;
|
|
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 {};
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, Text } from 'react-native';
|
|
3
3
|
import { Fonts, defaultColorToken } from 'miot/ui/hyperOSUI';
|
|
4
|
-
import { RangeProgressBar } from "./rangeProgressBar";
|
|
5
4
|
import { dynamicStyleSheet } from 'miot/ui/Style/DynamicStyleSheet';
|
|
5
|
+
import { RangeProgressBar } from "./rangeProgressBar";
|
|
6
6
|
export const SingleRangeIndicator = ({
|
|
7
|
-
currentRange
|
|
7
|
+
currentRange,
|
|
8
8
|
totalRange = 100,
|
|
9
|
+
currentSoc = 0,
|
|
9
10
|
unit = 'km',
|
|
10
11
|
color,
|
|
11
12
|
style
|
|
12
13
|
}) => {
|
|
13
|
-
const
|
|
14
|
-
const displayValue = typeof currentRange === 'number' ? Math.round(currentRange) : currentRange;
|
|
15
|
-
const progress =
|
|
14
|
+
const hasValue = currentRange != null && currentRange !== '';
|
|
15
|
+
const displayValue = hasValue ? typeof currentRange === 'number' ? Math.round(currentRange) : currentRange : '--';
|
|
16
|
+
const progress = totalRange > 0 ? Math.min(currentSoc / totalRange, 1) : 0;
|
|
16
17
|
return /*#__PURE__*/React.createElement(View, {
|
|
17
18
|
style: [styles.container, style]
|
|
18
19
|
}, /*#__PURE__*/React.createElement(View, {
|
|
19
20
|
style: styles.rangeContainer
|
|
20
21
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
21
22
|
style: styles.rangeValue
|
|
22
|
-
}, displayValue), /*#__PURE__*/React.createElement(Text, {
|
|
23
|
+
}, displayValue), hasValue ? /*#__PURE__*/React.createElement(Text, {
|
|
23
24
|
style: styles.unit
|
|
24
|
-
}, unit)), /*#__PURE__*/React.createElement(RangeProgressBar, {
|
|
25
|
+
}, unit) : null), hasValue ? /*#__PURE__*/React.createElement(RangeProgressBar, {
|
|
25
26
|
progress: progress,
|
|
26
27
|
color: color
|
|
27
|
-
}));
|
|
28
|
+
}) : null);
|
|
28
29
|
};
|
|
29
30
|
const styles = dynamicStyleSheet({
|
|
30
31
|
container: {
|
|
@@ -37,7 +38,7 @@ const styles = dynamicStyleSheet({
|
|
|
37
38
|
},
|
|
38
39
|
rangeContainer: {
|
|
39
40
|
flexDirection: 'row',
|
|
40
|
-
alignItems: '
|
|
41
|
+
alignItems: 'flex-end',
|
|
41
42
|
justifyContent: 'center'
|
|
42
43
|
},
|
|
43
44
|
rangeValue: {
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export { useSeatControlData, type SeatControlDataProps, type SeatSpecs, LEVEL_IC
|
|
|
3
3
|
export * from './useSingleRangeData';
|
|
4
4
|
export * from './useDualRangeData';
|
|
5
5
|
export { ConnectStatus } from '../config';
|
|
6
|
+
export { useAirConditionData } from './useAirConditionData';
|
|
7
|
+
export { useSteeringWheelData } from './useSteeringWheelData';
|
|
6
8
|
export type { ButtonStateConfig, ControlButtonConfig, SeatConfig, OnButtonPressParams, } from '../components/seatControlGroup';
|
package/dist/hooks/index.js
CHANGED
|
@@ -3,5 +3,7 @@ export { useSeatControlData, LEVEL_ICONS, TYPE_CONFIG, SEAT_TITLES } from "./use
|
|
|
3
3
|
export * from "./useSingleRangeData";
|
|
4
4
|
export * from "./useDualRangeData";
|
|
5
5
|
export { ConnectStatus } from "../config";
|
|
6
|
+
export { useAirConditionData } from "./useAirConditionData";
|
|
7
|
+
export { useSteeringWheelData } from "./useSteeringWheelData";
|
|
6
8
|
|
|
7
9
|
// Re-export types for seat module compatibility
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Spec } from '../types';
|
|
2
2
|
export interface DualRangeDisplayData {
|
|
3
|
-
currentElectricRange: number | string;
|
|
3
|
+
currentElectricRange: number | string | null;
|
|
4
4
|
electricRange: number;
|
|
5
5
|
unit: string;
|
|
6
6
|
electricColor: string;
|
|
7
|
-
currentFuelRange: number | string;
|
|
7
|
+
currentFuelRange: number | string | null;
|
|
8
8
|
fuelRange: number;
|
|
9
9
|
fuelColor: string;
|
|
10
10
|
}
|
|
@@ -4,6 +4,7 @@ import { useSpecState } from '@miot-rn/common-component/dist/store/useGlobalSpec
|
|
|
4
4
|
import { getValueBySpecDescription } from '@miot-rn/common-component/dist/specs/instance-parser';
|
|
5
5
|
import { getLocalI18n } from '@miot-rn/common-component/dist/specs/i18n-parser';
|
|
6
6
|
import { ConfigContext } from 'miot/ui/hyperOSUI';
|
|
7
|
+
import { isNil, toNumberOrNull } from "../utils/fns";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* 双续航数据配置(单位已包含在内)
|
|
@@ -37,17 +38,17 @@ export const useDualRangeData = ({
|
|
|
37
38
|
const getDualRangeDisplayData = useCallback(() => {
|
|
38
39
|
const electricColor = colorToken.accentGreenFill;
|
|
39
40
|
const fuelColor = colorToken.contentSecondaryNormal;
|
|
40
|
-
const dcdType =
|
|
41
|
-
const cltcEstimatedExtendEange =
|
|
42
|
-
const cltcFuelEndurance =
|
|
43
|
-
const wltcPureEleCruisingEndurance =
|
|
44
|
-
const wltcFuelEndurance =
|
|
45
|
-
if (dcdType
|
|
41
|
+
const dcdType = toNumberOrNull(dcdRangeSOCTypeDisplayValue);
|
|
42
|
+
const cltcEstimatedExtendEange = toNumberOrNull(cltcEstimatedExtendEangeValue);
|
|
43
|
+
const cltcFuelEndurance = toNumberOrNull(cltcFuelEnduranceValue);
|
|
44
|
+
const wltcPureEleCruisingEndurance = toNumberOrNull(wltcPureEleCruisingEnduranceValue);
|
|
45
|
+
const wltcFuelEndurance = toNumberOrNull(wltcFuelEnduranceValue);
|
|
46
|
+
if (isNil(dcdType)) {
|
|
46
47
|
return {
|
|
47
|
-
currentElectricRange:
|
|
48
|
+
currentElectricRange: null,
|
|
48
49
|
electricRange: 100,
|
|
49
50
|
unit: distanceUnit,
|
|
50
|
-
currentFuelRange:
|
|
51
|
+
currentFuelRange: null,
|
|
51
52
|
fuelRange: 100,
|
|
52
53
|
electricColor,
|
|
53
54
|
fuelColor
|
|
@@ -57,10 +58,10 @@ export const useDualRangeData = ({
|
|
|
57
58
|
// 1. WLTC Range (Extended Range)
|
|
58
59
|
if (getValueBySpecDescription(specPowerBatteryPropertiesDCDRangeSOCTypeDisplay, 'WLTCRange') === dcdType) {
|
|
59
60
|
return {
|
|
60
|
-
currentElectricRange:
|
|
61
|
+
currentElectricRange: wltcPureEleCruisingEndurance,
|
|
61
62
|
electricRange: specPowerRangePropertiesWltcPureEleCruisingEndurance?.prop?.['value-range']?.[1] || 100,
|
|
62
63
|
unit: distanceUnit,
|
|
63
|
-
currentFuelRange:
|
|
64
|
+
currentFuelRange: wltcFuelEndurance,
|
|
64
65
|
fuelRange: specPowerRangePropertiesWltcFuelEndurance?.prop?.['value-range']?.[1] || 100,
|
|
65
66
|
electricColor,
|
|
66
67
|
fuelColor
|
|
@@ -69,10 +70,10 @@ export const useDualRangeData = ({
|
|
|
69
70
|
|
|
70
71
|
// 2. CLTC Range (Default for Extended Range)
|
|
71
72
|
return {
|
|
72
|
-
currentElectricRange:
|
|
73
|
+
currentElectricRange: cltcEstimatedExtendEange,
|
|
73
74
|
electricRange: specPowerBatteryLifeEffectivenessPropertiesCltcEstimatedExtendEange?.prop?.['value-range']?.[1] || 100,
|
|
74
75
|
unit: distanceUnit,
|
|
75
|
-
currentFuelRange:
|
|
76
|
+
currentFuelRange: cltcFuelEndurance,
|
|
76
77
|
fuelRange: specPowerRangePropertiesCltcFuelEndurance?.prop?.['value-range']?.[1] || 100,
|
|
77
78
|
electricColor,
|
|
78
79
|
fuelColor
|
|
@@ -88,9 +88,20 @@ export const useParkingStatusData = ({
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// 5. Parked
|
|
91
|
+
if (getValueBySpecDescription(specBodyGearPropertiesGearStatus, 'P') === gearStatus) {
|
|
92
|
+
return {
|
|
93
|
+
parkingIcon: parkingStatusIcon.parkingStatusIcon,
|
|
94
|
+
parkingStatus: getLocalI18n('car_title_power_status_parking'),
|
|
95
|
+
showDivider: false,
|
|
96
|
+
textStyle,
|
|
97
|
+
isLoading: false
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Default state
|
|
91
102
|
return {
|
|
92
|
-
parkingIcon:
|
|
93
|
-
parkingStatus:
|
|
103
|
+
parkingIcon: undefined,
|
|
104
|
+
parkingStatus: '',
|
|
94
105
|
showDivider: false,
|
|
95
106
|
textStyle,
|
|
96
107
|
isLoading: false
|
|
@@ -4,6 +4,7 @@ import { useSpecState } from '@miot-rn/common-component/dist/store/useGlobalSpec
|
|
|
4
4
|
import { getValueBySpecDescription } from '@miot-rn/common-component/dist/specs/instance-parser';
|
|
5
5
|
import { getLocalI18n } from '@miot-rn/common-component/dist/specs/i18n-parser';
|
|
6
6
|
import { ConfigContext } from 'miot/ui/hyperOSUI';
|
|
7
|
+
import { isNil, toNumberOrNull } from "../utils/fns";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* 单续航数据配置(单位已包含在内)
|
|
@@ -35,10 +36,11 @@ export const useSingleRangeData = ({
|
|
|
35
36
|
return 'km';
|
|
36
37
|
}, []);
|
|
37
38
|
const getRangeDisplayData = useCallback(() => {
|
|
38
|
-
if (dcdRangeSOCTypeDisplayValue
|
|
39
|
+
if (isNil(dcdRangeSOCTypeDisplayValue)) {
|
|
39
40
|
return {
|
|
40
|
-
currentRange:
|
|
41
|
+
currentRange: null,
|
|
41
42
|
totalRange: 100,
|
|
43
|
+
currentSoc: 0,
|
|
42
44
|
unit: '%',
|
|
43
45
|
color: colorToken.accentGreenContent
|
|
44
46
|
};
|
|
@@ -46,22 +48,25 @@ export const useSingleRangeData = ({
|
|
|
46
48
|
const dcdType = Number(dcdRangeSOCTypeDisplayValue);
|
|
47
49
|
let color = colorToken.accentGreenContent;
|
|
48
50
|
const lowSocWarning = Number(lowSocWarningValue);
|
|
49
|
-
const batterySoCDisplay =
|
|
50
|
-
const batteryEstimatedMileage =
|
|
51
|
-
const cltcEstimatedRange =
|
|
51
|
+
const batterySoCDisplay = toNumberOrNull(batterySoCDisplayValue);
|
|
52
|
+
const batteryEstimatedMileage = toNumberOrNull(batteryEstimatedMileageValue);
|
|
53
|
+
const cltcEstimatedRange = toNumberOrNull(cltcEstimatedRangeValue);
|
|
52
54
|
|
|
53
55
|
// Determine color based on low SOC warning level
|
|
54
56
|
if (getValueBySpecDescription(specPowerBatteryPropertiesLowSocWarning, 'Level2 Warning') === lowSocWarning) {
|
|
55
|
-
color = colorToken.accentYellowFill;
|
|
56
|
-
} else if (getValueBySpecDescription(specPowerBatteryPropertiesLowSocWarning, 'Level1 Warning') === lowSocWarning) {
|
|
57
57
|
color = colorToken.accentRedContent;
|
|
58
|
+
} else if (getValueBySpecDescription(specPowerBatteryPropertiesLowSocWarning, 'Level1 Warning') === lowSocWarning) {
|
|
59
|
+
color = colorToken.accentYellowFill;
|
|
58
60
|
}
|
|
61
|
+
const totalRange = specPowerBatteryPropertiesBatterySoCDisplay?.prop?.['value-range']?.[1] || 100;
|
|
62
|
+
const currentSoc = batterySoCDisplay || 0;
|
|
59
63
|
|
|
60
64
|
// 1. Battery SOC percentage
|
|
61
65
|
if (getValueBySpecDescription(specPowerBatteryPropertiesDCDRangeSOCTypeDisplay, 'SOC') === dcdType) {
|
|
62
66
|
return {
|
|
63
|
-
currentRange: batterySoCDisplay
|
|
64
|
-
totalRange
|
|
67
|
+
currentRange: batterySoCDisplay,
|
|
68
|
+
totalRange,
|
|
69
|
+
currentSoc,
|
|
65
70
|
unit: '%',
|
|
66
71
|
color
|
|
67
72
|
};
|
|
@@ -70,8 +75,9 @@ export const useSingleRangeData = ({
|
|
|
70
75
|
// 2. CLTC Range
|
|
71
76
|
if (getValueBySpecDescription(specPowerBatteryPropertiesDCDRangeSOCTypeDisplay, 'CLTCRange') === dcdType) {
|
|
72
77
|
return {
|
|
73
|
-
currentRange: cltcEstimatedRange
|
|
74
|
-
totalRange
|
|
78
|
+
currentRange: cltcEstimatedRange,
|
|
79
|
+
totalRange,
|
|
80
|
+
currentSoc,
|
|
75
81
|
unit: distanceUnit,
|
|
76
82
|
color
|
|
77
83
|
};
|
|
@@ -80,15 +86,17 @@ export const useSingleRangeData = ({
|
|
|
80
86
|
// 3. Battery mileage in km
|
|
81
87
|
if (getValueBySpecDescription(specPowerBatteryPropertiesDCDRangeSOCTypeDisplay, 'MiRange') === dcdType) {
|
|
82
88
|
return {
|
|
83
|
-
currentRange: batteryEstimatedMileage
|
|
84
|
-
totalRange
|
|
89
|
+
currentRange: batteryEstimatedMileage,
|
|
90
|
+
totalRange,
|
|
91
|
+
currentSoc,
|
|
85
92
|
unit: distanceUnit,
|
|
86
93
|
color
|
|
87
94
|
};
|
|
88
95
|
}
|
|
89
96
|
return {
|
|
90
|
-
currentRange:
|
|
91
|
-
totalRange
|
|
97
|
+
currentRange: null,
|
|
98
|
+
totalRange,
|
|
99
|
+
currentSoc,
|
|
92
100
|
unit: '%',
|
|
93
101
|
color: colorToken.accentGreenContent
|
|
94
102
|
};
|
|
@@ -39,6 +39,7 @@ export const AirconditionModule = ({
|
|
|
39
39
|
specHVACTemperaturePropertiesHvacTargetTemperature: specHVACTemperaturePropertiesHvacTargetTemperature
|
|
40
40
|
});
|
|
41
41
|
return /*#__PURE__*/React.createElement(AirConditioningCard, {
|
|
42
|
+
showAirc: !!specHVACStatePropertiesHvacStatus,
|
|
42
43
|
showTargetTemperature: !!specHVACTemperaturePropertiesHvacTargetTemperature,
|
|
43
44
|
hvacStatus: transformHvacStatus,
|
|
44
45
|
hvacDefrosterStatus: transformHvacDefrosterStatus,
|
package/dist/modules/index.d.ts
CHANGED
package/dist/modules/index.js
CHANGED
package/dist/utils/fns.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare function NOOP(): void;
|
|
2
|
+
export declare function isNil(value: unknown): value is null | undefined;
|
|
3
|
+
export declare function toNumberOrNull(value: unknown): number | null;
|
|
2
4
|
export declare function safeTrim(value: any): any;
|
|
3
5
|
export declare function isSameArrayElements(a: any[], b: any[]): boolean;
|
|
4
6
|
export declare function getType(o: any): string;
|
package/dist/utils/fns.js
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
// 空函数
|
|
8
8
|
export function NOOP() {}
|
|
9
|
+
export function isNil(value) {
|
|
10
|
+
return value === null || value === undefined;
|
|
11
|
+
}
|
|
12
|
+
export function toNumberOrNull(value) {
|
|
13
|
+
if (isNil(value)) return null;
|
|
14
|
+
const num = Number(value);
|
|
15
|
+
return Number.isNaN(num) ? null : num;
|
|
16
|
+
}
|
|
9
17
|
|
|
10
18
|
// 安全去除字符串首尾空格
|
|
11
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
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
|
}
|