@eohjsc/react-native-smart-city 0.4.39 → 0.4.41
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/android/build.gradle +1 -1
- package/package.json +2 -2
- package/src/commons/Action/ItemQuickAction.js +1 -0
- package/src/commons/ActionGroup/ColorPickerTemplate.js +3 -4
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -5
- package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OnOffTemplate/index.js +6 -5
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -17
- package/src/commons/ActionGroup/SliderRangeTemplate.js +5 -3
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +6 -20
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +6 -6
- package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +2 -2
- package/src/commons/ActionGroup/TimerActionTemplate.js +3 -2
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +133 -135
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +37 -14
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +71 -31
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +13 -17
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +44 -48
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +56 -22
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +123 -21
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +12 -16
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +73 -38
- package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +11 -15
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +11 -15
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +21 -31
- package/src/commons/ActionGroup/__test__/index.test.js +36 -21
- package/src/commons/ActionGroup/index.js +4 -7
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +0 -5
- package/src/commons/Dashboard/MyUnit/index.js +2 -2
- package/src/commons/FlatListDnD/__test__/index.test.js +27 -25
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +1 -22
- package/src/commons/HeaderAni/index.js +12 -2
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +1 -23
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +5 -3
- package/src/commons/Processing/index.js +1 -0
- package/src/commons/Processing/styles.js +3 -0
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +1 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +1 -58
- package/src/commons/icon/index.js +57 -0
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +52 -51
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -2
- package/src/hooks/useMqtt.js +5 -2
- package/src/iot/mqtt.js +2 -0
- package/src/navigations/UnitStack.js +2 -2
- package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
- package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -2
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +31 -32
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +19 -2
- package/src/screens/Automate/AddNewAction/__test__/{SetupSensor.test.js → SetupConfigCondition.test.js} +97 -0
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +69 -68
- package/src/screens/ChangePosition/__test__/index.test.js +34 -32
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +1 -11
- package/src/screens/Device/__test__/detail.test.js +40 -45
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -2
- package/src/screens/Device/components/ChartWrapper.js +14 -12
- package/src/screens/Device/components/SensorDisplayItem.js +18 -2
- package/src/screens/Device/components/VisualChart.js +7 -1
- package/src/screens/Device/components/__test__/VisualChart.test.js +0 -3
- package/src/screens/Device/detail.js +32 -14
- package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +20 -18
- package/src/screens/Device/styles.js +3 -0
- package/src/screens/Sharing/MemberList.js +16 -3
- package/src/screens/Sharing/__test__/SelectPermission.test.js +96 -137
- package/src/screens/Template/__test__/EditTemplate.test.js +48 -45
- package/src/screens/Unit/SelectAddToFavorites.js +1 -0
- package/src/screens/Unit/__test__/SelectAddress.test.js +4 -11
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +1 -11
- package/src/utils/Apis/axios.js +1 -0
- package/src/utils/I18n/translations/en.js +2 -0
- package/src/utils/I18n/translations/vi.js +2 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +0 -289
package/android/build.gradle
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
12
12
|
|
|
13
13
|
def DEFAULT_COMPILE_SDK_VERSION = 33
|
|
14
|
-
def DEFAULT_BUILD_TOOLS_VERSION = '
|
|
14
|
+
def DEFAULT_BUILD_TOOLS_VERSION = '33.0.0'
|
|
15
15
|
def DEFAULT_MIN_SDK_VERSION = 24
|
|
16
16
|
def DEFAULT_TARGET_SDK_VERSION = 33
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.41",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
"react-native-permissions": "3.4.0",
|
|
194
194
|
"react-native-popover-view": "^4.0.3",
|
|
195
195
|
"react-native-progress": "^5.0.0",
|
|
196
|
-
"react-native-reanimated": "
|
|
196
|
+
"react-native-reanimated": "1.10.1",
|
|
197
197
|
"react-native-responsive-fontsize": "^0.5.1",
|
|
198
198
|
"react-native-safe-area-context": "^3.1.1",
|
|
199
199
|
"react-native-screens": "^2.9.0",
|
|
@@ -43,8 +43,8 @@ export const WheelColorPicker = ({ color, onChangeColorComplete, onStart }) => {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
let hexColorTemp = '#fff';
|
|
46
|
-
const ColorPickerTemplate = memo(({
|
|
47
|
-
const { configuration = {} } =
|
|
46
|
+
const ColorPickerTemplate = memo(({ item = {}, doAction, sensor }) => {
|
|
47
|
+
const { configuration = {} } = item;
|
|
48
48
|
const { config = undefined } = configuration;
|
|
49
49
|
const [configValues] = useConfigGlobalState('configValues');
|
|
50
50
|
|
|
@@ -76,8 +76,7 @@ const ColorPickerTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
76
76
|
setIsChangeColor(false);
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
|
-
|
|
80
|
-
[configuration?.action_color_data, doAction, isChangeColor]
|
|
79
|
+
[configuration?.action_color_data, doAction, isChangeColor, setAction]
|
|
81
80
|
);
|
|
82
81
|
|
|
83
82
|
useEffect(() => {
|
|
@@ -11,12 +11,12 @@ import { watchMultiConfigs } from '../../iot/Monitor';
|
|
|
11
11
|
import { DEVICE_TYPE, AccessibilityLabel } from '../../configs/Constants';
|
|
12
12
|
|
|
13
13
|
const NumberUpDownActionTemplate = ({
|
|
14
|
-
|
|
14
|
+
item = {},
|
|
15
15
|
doAction,
|
|
16
16
|
sensor = {},
|
|
17
17
|
isWidgetOrder,
|
|
18
18
|
}) => {
|
|
19
|
-
const { configuration = {}, title } =
|
|
19
|
+
const { configuration = {}, title } = item;
|
|
20
20
|
const {
|
|
21
21
|
action_data,
|
|
22
22
|
max_value,
|
|
@@ -122,7 +122,7 @@ const NumberUpDownActionTemplate = ({
|
|
|
122
122
|
<IconOutline name="down" size={32} color={Colors.Primary} />
|
|
123
123
|
</TouchableOpacity>
|
|
124
124
|
|
|
125
|
-
<Text accessibilityLabel={'
|
|
125
|
+
<Text accessibilityLabel={'text_format'} type="H2">
|
|
126
126
|
{value !== undefined ? (
|
|
127
127
|
text_format.replace('{number}', value)
|
|
128
128
|
) : (
|
|
@@ -10,9 +10,9 @@ import { useUnwatchLGDeviceConfigControl } from '../../../hooks/IoT';
|
|
|
10
10
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
11
11
|
import { DEVICE_TYPE, AccessibilityLabel } from '../../../configs/Constants';
|
|
12
12
|
|
|
13
|
-
const OnOffSmartLock = memo(({
|
|
13
|
+
const OnOffSmartLock = memo(({ item = {}, doAction, sensor = {} }) => {
|
|
14
14
|
const t = useTranslations();
|
|
15
|
-
const { configuration = {} } =
|
|
15
|
+
const { configuration = {} } = item;
|
|
16
16
|
const { action_on_data, action_off_data, config, is_on_value } =
|
|
17
17
|
configuration;
|
|
18
18
|
const { is_managed_by_backend, device_type } = sensor;
|
|
@@ -8,8 +8,7 @@ import { AccessibilityLabel } from '../../../configs/Constants';
|
|
|
8
8
|
import IconComponent from '../../IconComponent';
|
|
9
9
|
|
|
10
10
|
const OnOffButtonTemplate = memo(
|
|
11
|
-
({ isOn, triggerAction, actionGroup = {}, isLight = false }) => {
|
|
12
|
-
const { configuration = {}, id } = actionGroup;
|
|
11
|
+
({ isOn, triggerAction, actionGroup = {}, isLight = false, item }) => {
|
|
13
12
|
const {
|
|
14
13
|
icon_on,
|
|
15
14
|
icon_off,
|
|
@@ -17,7 +16,7 @@ const OnOffButtonTemplate = memo(
|
|
|
17
16
|
icon_kit_off_data,
|
|
18
17
|
text_on,
|
|
19
18
|
text_off,
|
|
20
|
-
} =
|
|
19
|
+
} = actionGroup;
|
|
21
20
|
const icon = useMemo(() => {
|
|
22
21
|
if (isOn) {
|
|
23
22
|
return icon_kit_on_data?.icon || icon_on;
|
|
@@ -31,7 +30,7 @@ const OnOffButtonTemplate = memo(
|
|
|
31
30
|
<TouchableOpacity
|
|
32
31
|
style={styles.bigCircle}
|
|
33
32
|
onPress={triggerAction}
|
|
34
|
-
accessibilityLabel={`${AccessibilityLabel.ON_OFF_BUTTON}-${id}`}
|
|
33
|
+
accessibilityLabel={`${AccessibilityLabel.ON_OFF_BUTTON}-${item?.id}`}
|
|
35
34
|
>
|
|
36
35
|
<View style={styles.smallCircle}>
|
|
37
36
|
<IconComponent
|
|
@@ -46,7 +45,7 @@ const OnOffButtonTemplate = memo(
|
|
|
46
45
|
styles.textBig,
|
|
47
46
|
{ color: isOn ? Colors.Gray8 : Colors.Gray6 },
|
|
48
47
|
]}
|
|
49
|
-
accessibilityLabel={`${AccessibilityLabel.SENSOR_STATUS}-${id}`}
|
|
48
|
+
accessibilityLabel={`${AccessibilityLabel.SENSOR_STATUS}-${item?.id}`}
|
|
50
49
|
>
|
|
51
50
|
{isOn ? text_on : text_off}
|
|
52
51
|
</Text>
|
|
@@ -8,8 +8,8 @@ import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
|
8
8
|
import { useConfigGlobalState } from '../../../iot/states';
|
|
9
9
|
|
|
10
10
|
const SwitchButtonTemplate = memo(
|
|
11
|
-
({
|
|
12
|
-
const { configuration = {}, id } =
|
|
11
|
+
({ item = {}, isLight = false, doAction }) => {
|
|
12
|
+
const { configuration = {}, id } = item;
|
|
13
13
|
const {
|
|
14
14
|
action_off_data,
|
|
15
15
|
action_on_data,
|
|
@@ -58,9 +58,9 @@ const SwitchButtonTemplate = memo(
|
|
|
58
58
|
</Text>
|
|
59
59
|
</View>
|
|
60
60
|
|
|
61
|
-
{!!
|
|
61
|
+
{!!item.title && !isLight && (
|
|
62
62
|
<Text type="H3" semibold center>
|
|
63
|
-
{
|
|
63
|
+
{item.title}
|
|
64
64
|
</Text>
|
|
65
65
|
)}
|
|
66
66
|
</>
|
|
@@ -22,8 +22,8 @@ const getComponent = (template) => {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const OnOffTemplate = memo(({
|
|
26
|
-
const { configuration = {} } =
|
|
25
|
+
const OnOffTemplate = memo(({ item = {}, doAction, sensor = {} }) => {
|
|
26
|
+
const { configuration = {} } = item;
|
|
27
27
|
const {
|
|
28
28
|
action_on_data,
|
|
29
29
|
action_off_data,
|
|
@@ -119,16 +119,17 @@ const OnOffTemplate = memo(({ actionGroup = {}, doAction, sensor = {} }) => {
|
|
|
119
119
|
}, [getIsOnValue, device_type]);
|
|
120
120
|
|
|
121
121
|
const Component = useMemo(() => {
|
|
122
|
-
return getComponent(
|
|
123
|
-
}, [
|
|
122
|
+
return getComponent(item.template);
|
|
123
|
+
}, [item.template]);
|
|
124
124
|
|
|
125
125
|
return (
|
|
126
126
|
<View style={styles.wrap}>
|
|
127
127
|
<Component
|
|
128
128
|
isOn={tempIsOn}
|
|
129
129
|
triggerAction={triggerAction}
|
|
130
|
-
actionGroup={
|
|
130
|
+
actionGroup={configuration}
|
|
131
131
|
disabled={!action_on_data && !action_off_data}
|
|
132
|
+
item={item}
|
|
132
133
|
/>
|
|
133
134
|
</View>
|
|
134
135
|
);
|
|
@@ -6,8 +6,8 @@ import { Colors } from '../../configs';
|
|
|
6
6
|
import styles from './OneBigButtonTemplateStyle';
|
|
7
7
|
import IconComponent from '../IconComponent';
|
|
8
8
|
|
|
9
|
-
const OneBigButtonTemplate = memo(({
|
|
10
|
-
const { configuration = {} } =
|
|
9
|
+
const OneBigButtonTemplate = memo(({ item = {}, doAction, sensor }) => {
|
|
10
|
+
const { configuration = {} } = item;
|
|
11
11
|
const { text, action_data, icon } = configuration;
|
|
12
12
|
|
|
13
13
|
const onPressDoAction = useCallback(() => {
|
|
@@ -29,9 +29,9 @@ const OneBigButtonTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
|
|
|
29
29
|
</View>
|
|
30
30
|
</TouchableOpacity>
|
|
31
31
|
</View>
|
|
32
|
-
{!!
|
|
32
|
+
{!!item.title && (
|
|
33
33
|
<Text type="H3" semibold center>
|
|
34
|
-
{
|
|
34
|
+
{item.title}
|
|
35
35
|
</Text>
|
|
36
36
|
)}
|
|
37
37
|
</>
|
|
@@ -12,9 +12,7 @@ import styles from './OptionsDropdownActionTemplateStyle';
|
|
|
12
12
|
import { AccessibilityLabel, DEVICE_TYPE } from '../../configs/Constants';
|
|
13
13
|
import IconComponent from '../../commons/IconComponent';
|
|
14
14
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
15
|
-
import
|
|
16
|
-
import SvgCurrentState from '../../../assets/images/Device/current-state.svg';
|
|
17
|
-
import SvgWindStrength from '../../../assets/images/Device/wind-strength.svg';
|
|
15
|
+
import { getIcon } from '../icon';
|
|
18
16
|
|
|
19
17
|
function getOptionValue(option, allow_config_store_value) {
|
|
20
18
|
if (option?.value_text && !allow_config_store_value) {
|
|
@@ -24,13 +22,13 @@ function getOptionValue(option, allow_config_store_value) {
|
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
const OptionsDropdownActionTemplate = ({
|
|
27
|
-
|
|
25
|
+
item = {},
|
|
28
26
|
doAction,
|
|
29
27
|
sensor = {},
|
|
30
28
|
isWidgetOrder,
|
|
31
29
|
}) => {
|
|
32
30
|
const t = useTranslations();
|
|
33
|
-
const { configuration = {}, title = '' } =
|
|
31
|
+
const { configuration = {}, title = '' } = item;
|
|
34
32
|
const {
|
|
35
33
|
action_data,
|
|
36
34
|
options = [],
|
|
@@ -110,16 +108,7 @@ const OptionsDropdownActionTemplate = ({
|
|
|
110
108
|
}, [config, selectedOption?.text, t]);
|
|
111
109
|
|
|
112
110
|
const iconSvg = useMemo(() => {
|
|
113
|
-
|
|
114
|
-
case 'door-state-1':
|
|
115
|
-
return <SvgDoorState width={24} height={24} />;
|
|
116
|
-
case 'curent-state-1':
|
|
117
|
-
return <SvgCurrentState width={24} height={24} />;
|
|
118
|
-
case 'wind-strength-1':
|
|
119
|
-
return <SvgWindStrength width={24} height={24} />;
|
|
120
|
-
default:
|
|
121
|
-
return () => <></>;
|
|
122
|
-
}
|
|
111
|
+
return getIcon(icon);
|
|
123
112
|
}, [icon]);
|
|
124
113
|
|
|
125
114
|
return (
|
|
@@ -179,7 +168,7 @@ const OptionsDropdownActionTemplate = ({
|
|
|
179
168
|
{t('write_not_available')}
|
|
180
169
|
</Text>
|
|
181
170
|
)}
|
|
182
|
-
{options.map((
|
|
171
|
+
{options.map((option, index) => (
|
|
183
172
|
<View key={index} style={styles.rowContainer}>
|
|
184
173
|
<RadioCircle active={selectedIndex === index} />
|
|
185
174
|
<TouchableOpacity
|
|
@@ -191,7 +180,7 @@ const OptionsDropdownActionTemplate = ({
|
|
|
191
180
|
setSelectedIndex(index);
|
|
192
181
|
}}
|
|
193
182
|
>
|
|
194
|
-
<Text style={styles.text}>{
|
|
183
|
+
<Text style={styles.text}>{option?.text}</Text>
|
|
195
184
|
</TouchableOpacity>
|
|
196
185
|
</View>
|
|
197
186
|
))}
|
|
@@ -18,9 +18,9 @@ import { DEVICE_TYPE } from '../../configs/Constants';
|
|
|
18
18
|
import _TextInput from '../Form/TextInput';
|
|
19
19
|
|
|
20
20
|
const SliderRangeTemplate = memo(
|
|
21
|
-
({
|
|
21
|
+
({ item = {}, doAction, sensor, isWidgetOrder }) => {
|
|
22
22
|
const t = useTranslations();
|
|
23
|
-
const { configuration = {} } =
|
|
23
|
+
const { configuration = {} } = item;
|
|
24
24
|
const [configValues] = useConfigGlobalState('configValues');
|
|
25
25
|
const {
|
|
26
26
|
config = undefined,
|
|
@@ -56,6 +56,7 @@ const SliderRangeTemplate = memo(
|
|
|
56
56
|
|
|
57
57
|
const getTextInputValue = useMemo(() => {
|
|
58
58
|
if ([null, undefined, NaN].includes(valueBrightness)) {
|
|
59
|
+
/* istanbul ignore next */
|
|
59
60
|
return 0;
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -70,6 +71,7 @@ const SliderRangeTemplate = memo(
|
|
|
70
71
|
}
|
|
71
72
|
setValueBrightness(value);
|
|
72
73
|
if (timeout.current) {
|
|
74
|
+
/* istanbul ignore next */
|
|
73
75
|
clearTimeout(timeout.current);
|
|
74
76
|
}
|
|
75
77
|
if (value !== '') {
|
|
@@ -90,7 +92,7 @@ const SliderRangeTemplate = memo(
|
|
|
90
92
|
style={(isWidgetOrder && styles.wrapOrderItem) || styles.viewBrightness}
|
|
91
93
|
>
|
|
92
94
|
<Text type="H4" style={styles.LeftTextBrightness}>
|
|
93
|
-
{
|
|
95
|
+
{item?.title || item?.label || t('brightness')}
|
|
94
96
|
</Text>
|
|
95
97
|
|
|
96
98
|
<View style={styles.wrap}>
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
import { notImplemented } from '../../../utils/Utils';
|
|
26
26
|
|
|
27
27
|
const SmartTiviActionTemplate = memo(
|
|
28
|
-
({
|
|
28
|
+
({ item, doAction, scrollEnabled = true }) => {
|
|
29
29
|
const t = useTranslations();
|
|
30
30
|
const FakeDataChannel = [
|
|
31
31
|
{
|
|
@@ -50,7 +50,7 @@ const SmartTiviActionTemplate = memo(
|
|
|
50
50
|
},
|
|
51
51
|
];
|
|
52
52
|
const onPressButton = useCallback(
|
|
53
|
-
(button
|
|
53
|
+
(button) => () => {
|
|
54
54
|
switch (button) {
|
|
55
55
|
case SMART_TIVI_BUTTON.ONOFF_BUTTON:
|
|
56
56
|
case SMART_TIVI_BUTTON.EXIT_BUTTON:
|
|
@@ -74,8 +74,8 @@ const SmartTiviActionTemplate = memo(
|
|
|
74
74
|
},
|
|
75
75
|
[t]
|
|
76
76
|
);
|
|
77
|
-
const iconChannels = useCallback((
|
|
78
|
-
switch (
|
|
77
|
+
const iconChannels = useCallback((iconChannel) => {
|
|
78
|
+
switch (iconChannel.icon) {
|
|
79
79
|
case 'disney':
|
|
80
80
|
return <Disney style={styles.iconChannel} />;
|
|
81
81
|
case 'youtube':
|
|
@@ -186,16 +186,16 @@ const SmartTiviActionTemplate = memo(
|
|
|
186
186
|
</View>
|
|
187
187
|
<View style={styles.channelTV}>
|
|
188
188
|
{!!FakeDataChannel &&
|
|
189
|
-
FakeDataChannel.map((
|
|
189
|
+
FakeDataChannel.map((fakeChannel, index) => {
|
|
190
190
|
return (
|
|
191
191
|
<RectangleButton
|
|
192
192
|
key={index}
|
|
193
193
|
type="row"
|
|
194
194
|
onPress={onPressButton(
|
|
195
195
|
SMART_TIVI_BUTTON.CHANNEL_BUTTON,
|
|
196
|
-
|
|
196
|
+
fakeChannel
|
|
197
197
|
)}
|
|
198
|
-
icon={iconChannels(
|
|
198
|
+
icon={iconChannels(fakeChannel)}
|
|
199
199
|
wrapStyle={styles.buttonChannel}
|
|
200
200
|
index={index}
|
|
201
201
|
/>
|
|
@@ -9,10 +9,7 @@ import { watchMultiConfigs } from '../../iot/Monitor';
|
|
|
9
9
|
import IconComponent from '../IconComponent';
|
|
10
10
|
import styles from './StatesGridActionTemplateStyle';
|
|
11
11
|
import { DEVICE_TYPE, AccessibilityLabel } from '../../configs/Constants';
|
|
12
|
-
import
|
|
13
|
-
import SvgCirculator from '../../../assets/images/Device/circulator.svg';
|
|
14
|
-
import SvgAuo from '../../../assets/images/Device/auto.svg';
|
|
15
|
-
import SvgAirDry from '../../../assets/images/Device/air-dry.svg';
|
|
12
|
+
import { getIcon } from '../icon';
|
|
16
13
|
|
|
17
14
|
const buttonStyle = {
|
|
18
15
|
OFF: {
|
|
@@ -67,18 +64,7 @@ const GridItem = ({ item, doAction, sensor }) => {
|
|
|
67
64
|
const iconKit = !!icon_kit_data && icon_kit_data.icon;
|
|
68
65
|
|
|
69
66
|
const iconSvg = useMemo(() => {
|
|
70
|
-
|
|
71
|
-
case 'clean-1':
|
|
72
|
-
return <SvgClean width={24} height={24} />;
|
|
73
|
-
case 'circulator-1':
|
|
74
|
-
return <SvgCirculator width={24} height={24} />;
|
|
75
|
-
case 'auto-1':
|
|
76
|
-
return <SvgAuo width={24} height={24} />;
|
|
77
|
-
case 'air-dry-1':
|
|
78
|
-
return <SvgAirDry width={24} height={24} />;
|
|
79
|
-
default:
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
67
|
+
return getIcon(icon);
|
|
82
68
|
}, [icon]);
|
|
83
69
|
|
|
84
70
|
return (
|
|
@@ -108,12 +94,12 @@ const GridItem = ({ item, doAction, sensor }) => {
|
|
|
108
94
|
};
|
|
109
95
|
|
|
110
96
|
const StatesGridActionTemplate = ({
|
|
111
|
-
|
|
97
|
+
item = {},
|
|
112
98
|
doAction,
|
|
113
99
|
sensor = {},
|
|
114
100
|
isWidgetOrder,
|
|
115
101
|
}) => {
|
|
116
|
-
const { configuration = {}, title } =
|
|
102
|
+
const { configuration = {}, title } = item;
|
|
117
103
|
|
|
118
104
|
// eslint-disable-next-line no-unused-vars
|
|
119
105
|
const [configValues, setConfigValues] = useConfigGlobalState('configValues');
|
|
@@ -143,10 +129,10 @@ const StatesGridActionTemplate = ({
|
|
|
143
129
|
options?.length < 4 && styles.justifyContentAround,
|
|
144
130
|
]}
|
|
145
131
|
>
|
|
146
|
-
{options.map((
|
|
132
|
+
{options.map((option, index) => (
|
|
147
133
|
<GridItem
|
|
148
134
|
key={index}
|
|
149
|
-
item={
|
|
135
|
+
item={option}
|
|
150
136
|
index={index}
|
|
151
137
|
doAction={doAction}
|
|
152
138
|
sensor={sensor}
|
|
@@ -7,14 +7,14 @@ import { mockSCStore } from '../../../../context/mockStore';
|
|
|
7
7
|
import ThreeButtonDefault from '../components/ThreeButtonDefault';
|
|
8
8
|
import ThreeButtonCircle from '../components/ThreeButtonCircle';
|
|
9
9
|
|
|
10
|
-
const wrapComponent = (
|
|
10
|
+
const wrapComponent = (item) => (
|
|
11
11
|
<SCProvider initState={mockSCStore({})}>
|
|
12
|
-
<ThreeButtonTemplate
|
|
12
|
+
<ThreeButtonTemplate item={item} doAction={jest.fn()} />
|
|
13
13
|
</SCProvider>
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
describe('Test ThreeButtonTemplate', () => {
|
|
17
|
-
let
|
|
17
|
+
let displayItem = {
|
|
18
18
|
configuration: {
|
|
19
19
|
action1: '2b949045-8e03-4c07-a855-7794ade2e69c',
|
|
20
20
|
action1_data: {
|
|
@@ -64,7 +64,7 @@ describe('Test ThreeButtonTemplate', () => {
|
|
|
64
64
|
|
|
65
65
|
it('render ThreeButtonDefault', async () => {
|
|
66
66
|
await act(async () => {
|
|
67
|
-
wrapper = renderer.create(wrapComponent(
|
|
67
|
+
wrapper = renderer.create(wrapComponent(displayItem));
|
|
68
68
|
});
|
|
69
69
|
const instance = wrapper.root;
|
|
70
70
|
const ThreeButtonDefaults = instance.findAllByType(ThreeButtonDefault);
|
|
@@ -72,8 +72,8 @@ describe('Test ThreeButtonTemplate', () => {
|
|
|
72
72
|
});
|
|
73
73
|
it('render ThreeButtonCircle', async () => {
|
|
74
74
|
const actionGroupCT = {
|
|
75
|
-
...
|
|
76
|
-
configuration: { ...
|
|
75
|
+
...displayItem,
|
|
76
|
+
configuration: { ...displayItem?.configuration, layout: 'circle' },
|
|
77
77
|
};
|
|
78
78
|
await act(async () => {
|
|
79
79
|
wrapper = renderer.create(wrapComponent(actionGroupCT));
|
|
@@ -8,8 +8,8 @@ import IconComponent from '../../IconComponent';
|
|
|
8
8
|
import ThreeButtonCircle from './components/ThreeButtonCircle';
|
|
9
9
|
import ThreeButtonDefault from './components/ThreeButtonDefault';
|
|
10
10
|
|
|
11
|
-
const ThreeButtonTemplate = memo(({
|
|
12
|
-
const { configuration } =
|
|
11
|
+
const ThreeButtonTemplate = memo(({ item, doAction, isWidgetOrder }) => {
|
|
12
|
+
const { configuration } = item;
|
|
13
13
|
const {
|
|
14
14
|
text1,
|
|
15
15
|
action1_data,
|
|
@@ -16,9 +16,9 @@ import { useUnwatchLGDeviceConfigControl } from '../../hooks/IoT';
|
|
|
16
16
|
import BottomScrollPicker from '../BottomScrollPicker';
|
|
17
17
|
import { DEVICE_TYPE } from '../../configs/Constants';
|
|
18
18
|
|
|
19
|
-
const TimerActionTemplate = ({
|
|
19
|
+
const TimerActionTemplate = ({ item = {}, doAction, sensor = {} }) => {
|
|
20
20
|
const t = useTranslations();
|
|
21
|
-
const { configuration = {}, title } =
|
|
21
|
+
const { configuration = {}, title } = item;
|
|
22
22
|
const [showTime, setShowTime] = useState(false);
|
|
23
23
|
const [showHour, setShowHour] = useState(false);
|
|
24
24
|
|
|
@@ -156,6 +156,7 @@ const TimerActionTemplate = ({ actionGroup = {}, doAction, sensor = {} }) => {
|
|
|
156
156
|
|
|
157
157
|
const onSwitchOff = useCallback(() => {
|
|
158
158
|
if (!isTimerOn) {
|
|
159
|
+
/* istanbul ignore next */
|
|
159
160
|
return;
|
|
160
161
|
}
|
|
161
162
|
const { reset_value } = configuration;
|