@eohjsc/react-native-smart-city 0.4.42 → 0.4.43
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 +19 -24
- package/package.json +14 -12
- package/src/commons/Action/ItemQuickAction.js +1 -0
- package/src/commons/ActionGroup/ColorPickerTemplate.js +3 -4
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +7 -10
- 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 +75 -32
- 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 +10 -8
- package/src/commons/DateTimeRangeChange/index.js +3 -3
- package/src/commons/Device/HistoryChart.js +1 -1
- package/src/commons/Device/HorizontalBarChart.js +3 -4
- package/src/commons/Device/LinearChart.js +3 -5
- 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/Highcharts/index.js +111 -0
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +1 -23
- package/src/commons/Modal/ModalCustom.js +2 -2
- 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 +2 -0
- package/src/commons/Unit/HeaderUnit/index.js +15 -8
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +1 -59
- package/src/commons/icon/index.js +57 -0
- package/src/configs/AccessibilityLabel.js +2 -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 +101 -46
- 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 +17 -3
- package/src/screens/Device/components/__test__/VisualChart.test.js +12 -15
- package/src/screens/Device/detail.js +49 -36
- package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +20 -18
- package/src/screens/Device/styles.js +3 -0
- package/src/screens/Sharing/InfoMemberUnit.js +3 -1
- package/src/screens/Sharing/MemberList.js +16 -3
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +2 -0
- 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/utils/Monitor.js +2 -2
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +0 -289
package/android/build.gradle
CHANGED
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
// original location:
|
|
11
11
|
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
12
12
|
|
|
13
|
-
def DEFAULT_COMPILE_SDK_VERSION =
|
|
14
|
-
def DEFAULT_BUILD_TOOLS_VERSION = '
|
|
15
|
-
def DEFAULT_MIN_SDK_VERSION =
|
|
16
|
-
def DEFAULT_TARGET_SDK_VERSION =
|
|
13
|
+
def DEFAULT_COMPILE_SDK_VERSION = 33
|
|
14
|
+
def DEFAULT_BUILD_TOOLS_VERSION = '33.0.0'
|
|
15
|
+
def DEFAULT_MIN_SDK_VERSION = 24
|
|
16
|
+
def DEFAULT_TARGET_SDK_VERSION = 33
|
|
17
17
|
|
|
18
18
|
def safeExtGet(prop, fallback) {
|
|
19
19
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
apply plugin: 'com.android.library'
|
|
23
|
-
apply plugin: 'maven'
|
|
23
|
+
apply plugin: 'maven-publish'
|
|
24
24
|
|
|
25
25
|
buildscript {
|
|
26
26
|
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
@@ -38,9 +38,6 @@ buildscript {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
apply plugin: 'com.android.library'
|
|
42
|
-
apply plugin: 'maven'
|
|
43
|
-
|
|
44
41
|
android {
|
|
45
42
|
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
46
43
|
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
@@ -106,17 +103,17 @@ def configureReactNativePom(def pom) {
|
|
|
106
103
|
afterEvaluate { project ->
|
|
107
104
|
// some Gradle build hooks ref:
|
|
108
105
|
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
|
|
109
|
-
task androidJavadoc(type: Javadoc) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
106
|
+
// task androidJavadoc(type: Javadoc) {
|
|
107
|
+
// source = android.sourceSets.main.java.srcDirs
|
|
108
|
+
// classpath += files(android.bootClasspath)
|
|
109
|
+
// classpath += files(project.getConfigurations().getByName('compile').asList())
|
|
110
|
+
// include '**/*.java'
|
|
111
|
+
// }
|
|
112
|
+
|
|
113
|
+
// task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
|
|
114
|
+
// classifier = 'javadoc'
|
|
115
|
+
// from androidJavadoc.destinationDir
|
|
116
|
+
// }
|
|
120
117
|
|
|
121
118
|
task androidSourcesJar(type: Jar) {
|
|
122
119
|
classifier = 'sources'
|
|
@@ -135,15 +132,13 @@ afterEvaluate { project ->
|
|
|
135
132
|
|
|
136
133
|
artifacts {
|
|
137
134
|
archives androidSourcesJar
|
|
138
|
-
archives androidJavadocJar
|
|
135
|
+
// archives androidJavadocJar
|
|
139
136
|
}
|
|
140
137
|
|
|
141
138
|
task installArchives(type: Upload) {
|
|
142
139
|
configuration = configurations.archives
|
|
143
|
-
repositories.
|
|
144
|
-
|
|
145
|
-
repository url: "file://${projectDir}/../android/maven"
|
|
146
|
-
configureReactNativePom pom
|
|
140
|
+
repositories.maven {
|
|
141
|
+
url = uri("file://${projectDir}/../android/maven")
|
|
147
142
|
}
|
|
148
143
|
}
|
|
149
144
|
}
|
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.43",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -65,7 +65,9 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@react-native-community/clipboard": "*",
|
|
67
67
|
"react": "*",
|
|
68
|
-
"react-native": "*"
|
|
68
|
+
"react-native": "*",
|
|
69
|
+
"react-native-modal": "*",
|
|
70
|
+
"react-native-modal-datetime-picker": "*"
|
|
69
71
|
},
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@babel/core": "^7.12.9",
|
|
@@ -101,7 +103,6 @@
|
|
|
101
103
|
"@ant-design/icons-react-native": "^2.2.1",
|
|
102
104
|
"@ant-design/react-native": "^4.0.5",
|
|
103
105
|
"@babel/helper-environment-visitor": "^7.16.7",
|
|
104
|
-
"@eohjsc/highcharts": "^1.0.9",
|
|
105
106
|
"@eohjsc/react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
106
107
|
"@formatjs/intl-getcanonicallocales": "^1.4.5",
|
|
107
108
|
"@formatjs/intl-numberformat": "^5.6.2",
|
|
@@ -111,15 +112,14 @@
|
|
|
111
112
|
"@miblanchard/react-native-slider": "^2.2.0",
|
|
112
113
|
"@react-native-clipboard/clipboard": "^1.11.1",
|
|
113
114
|
"@react-native-community/async-storage": "^1.12.1",
|
|
114
|
-
"@react-native-community/cameraroll": "
|
|
115
|
+
"@react-native-community/cameraroll": "4.1.2",
|
|
115
116
|
"@react-native-community/checkbox": "^0.5.5",
|
|
116
|
-
"@react-native-community/datetimepicker": "
|
|
117
|
+
"@react-native-community/datetimepicker": "^7.0.1",
|
|
117
118
|
"@react-native-community/geolocation": "^2.0.2",
|
|
118
119
|
"@react-native-community/masked-view": "^0.1.10",
|
|
119
120
|
"@react-native-community/netinfo": "^9.3.4",
|
|
120
121
|
"@react-native-community/segmented-control": "^2.1.1",
|
|
121
122
|
"@react-native-community/slider": "^3.0.3",
|
|
122
|
-
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
|
|
123
123
|
"@react-native-picker/picker": "^1.16.7",
|
|
124
124
|
"@react-navigation/bottom-tabs": "^5.8.0",
|
|
125
125
|
"@react-navigation/drawer": "^5.9.0",
|
|
@@ -130,6 +130,7 @@
|
|
|
130
130
|
"apisauce": "^2.1.5",
|
|
131
131
|
"axios": "^0.19.2",
|
|
132
132
|
"base-64": "^1.0.0",
|
|
133
|
+
"buffer": "^6.0.3",
|
|
133
134
|
"deprecated-react-native-prop-types": "^2.3.0",
|
|
134
135
|
"dotenv": "^8.2.0",
|
|
135
136
|
"google-libphonenumber": "^3.2.10",
|
|
@@ -137,7 +138,8 @@
|
|
|
137
138
|
"i18n-js": "^3.7.1",
|
|
138
139
|
"i18next": "^20.1.0",
|
|
139
140
|
"lodash": "^4.17.19",
|
|
140
|
-
"lottie-
|
|
141
|
+
"lottie-ios": "3.4.1",
|
|
142
|
+
"lottie-react-native": "5.1.4",
|
|
141
143
|
"moment": "^2.27.0",
|
|
142
144
|
"moment-timezone": "^0.5.32",
|
|
143
145
|
"numeral": "^2.0.6",
|
|
@@ -171,7 +173,7 @@
|
|
|
171
173
|
"react-native-draggable-flatlist": "^2.6.2",
|
|
172
174
|
"react-native-fast-image": "^8.3.2",
|
|
173
175
|
"react-native-geocoder": "^0.5.0",
|
|
174
|
-
"react-native-gesture-handler": "^
|
|
176
|
+
"react-native-gesture-handler": "^2.10.0",
|
|
175
177
|
"react-native-get-location": "^2.0.0",
|
|
176
178
|
"react-native-image-crop-picker": "^0.37.2",
|
|
177
179
|
"react-native-image-resizer": "^1.4.5",
|
|
@@ -181,8 +183,8 @@
|
|
|
181
183
|
"react-native-localize": "^1.4.1",
|
|
182
184
|
"react-native-maps": "0.27.1",
|
|
183
185
|
"react-native-maps-directions": "^1.8.0",
|
|
184
|
-
"react-native-modal": "^
|
|
185
|
-
"react-native-modal-datetime-picker": "
|
|
186
|
+
"react-native-modal": "^13.0.1",
|
|
187
|
+
"react-native-modal-datetime-picker": "15.0.0",
|
|
186
188
|
"react-native-new-snap-carousel": "^3.9.3",
|
|
187
189
|
"react-native-onesignal": "^4.3.1",
|
|
188
190
|
"react-native-pager-view": "^5.4.1",
|
|
@@ -201,7 +203,7 @@
|
|
|
201
203
|
"react-native-udp": "^4.1.3",
|
|
202
204
|
"react-native-version-check": "^3.4.2",
|
|
203
205
|
"react-native-vlc-media-player": "^1.0.41",
|
|
204
|
-
"react-native-webview": "
|
|
206
|
+
"react-native-webview": "^12.0.2",
|
|
205
207
|
"react-native-wheel-color-picker": "^1.2.0",
|
|
206
208
|
"react-native-wheel-scrollview-picker": "^1.2.2",
|
|
207
209
|
"react-native-wifi-reborn": "^4.5.0",
|
|
@@ -209,8 +211,8 @@
|
|
|
209
211
|
"string-format": "^2.0.0",
|
|
210
212
|
"sync-directory": "^5.1.7",
|
|
211
213
|
"timezone-mock": "^1.1.3",
|
|
214
|
+
"uuid": "^9.0.0",
|
|
212
215
|
"uuid-by-string": "^3.0.2",
|
|
213
|
-
"uuidv4": "^6.2.13",
|
|
214
216
|
"validator": "^13.1.1",
|
|
215
217
|
"victory-native": "^35.0.1"
|
|
216
218
|
},
|
|
@@ -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,
|
|
@@ -49,13 +49,10 @@ const NumberUpDownActionTemplate = ({
|
|
|
49
49
|
|
|
50
50
|
const doActionAndWatchConfig = useCallback(
|
|
51
51
|
async (actionData, actionValue) => {
|
|
52
|
-
let data = actionValue;
|
|
53
|
-
if (
|
|
54
|
-
data =
|
|
55
|
-
|
|
56
|
-
data.config_id = config;
|
|
57
|
-
data.config_value = actionValue;
|
|
58
|
-
}
|
|
52
|
+
let data = { value: actionValue, temperature: actionValue };
|
|
53
|
+
if (allow_config_store_value && config) {
|
|
54
|
+
data.config_id = config;
|
|
55
|
+
data.config_value = actionValue;
|
|
59
56
|
}
|
|
60
57
|
await doAction(actionData, data);
|
|
61
58
|
if (!is_managed_by_backend) {
|
|
@@ -122,7 +119,7 @@ const NumberUpDownActionTemplate = ({
|
|
|
122
119
|
<IconOutline name="down" size={32} color={Colors.Primary} />
|
|
123
120
|
</TouchableOpacity>
|
|
124
121
|
|
|
125
|
-
<Text accessibilityLabel={'
|
|
122
|
+
<Text accessibilityLabel={'text_format'} type="H2">
|
|
126
123
|
{value !== undefined ? (
|
|
127
124
|
text_format.replace('{number}', value)
|
|
128
125
|
) : (
|
|
@@ -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;
|