@ledvance/ui-biz-bundle 1.1.55 → 1.1.56
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/package.json
CHANGED
|
@@ -2,8 +2,7 @@ import { useDps } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
|
2
2
|
import { FlagPageProps } from "./FlagPage";
|
|
3
3
|
import { SceneNodeTransitionMode } from "@ledvance/ui-biz-bundle/src/modules/scene/SceneInfo";
|
|
4
4
|
import { WORK_MODE, nToHS, parseJSON, toFixed } from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
5
|
-
import {
|
|
6
|
-
import { FlagItemInfo, FlagUiInfo, defFlagList, def2FlagList, def3FlagList } from "./FlagInfo";
|
|
5
|
+
import { FlagItemInfo, FlagUiInfo, defFlagList } from "./FlagInfo";
|
|
7
6
|
import { hex2Int } from "@ledvance/base/src/utils/common";
|
|
8
7
|
import { spliceByStep } from "@ledvance/base/src/utils/common";
|
|
9
8
|
import { useMemo, useState } from "react";
|
|
@@ -222,7 +221,16 @@ export function dp2Obj(dp: string, option?: FlagOption): FlagItemInfo | undefine
|
|
|
222
221
|
|
|
223
222
|
}
|
|
224
223
|
|
|
225
|
-
export async function getRemoteFlag(devId: string) {
|
|
224
|
+
export async function getRemoteFlag(devId: string, isRefresh?: boolean) {
|
|
225
|
+
if (isRefresh){
|
|
226
|
+
const res = await NativeApi.putJson(devId, featureId, JSON.stringify(defFlagList))
|
|
227
|
+
if (res.success){
|
|
228
|
+
return {
|
|
229
|
+
success: true,
|
|
230
|
+
data: defFlagList
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
226
234
|
const res = await NativeApi.getJson(devId, featureId)
|
|
227
235
|
const isNormalData = Array.isArray(parseJSON(res?.data))
|
|
228
236
|
if (res.success && isNormalData) {
|
|
@@ -236,7 +244,7 @@ export async function getRemoteFlag(devId: string) {
|
|
|
236
244
|
if (res.success) {
|
|
237
245
|
return {
|
|
238
246
|
success: true,
|
|
239
|
-
data:
|
|
247
|
+
data: defFlagList
|
|
240
248
|
}
|
|
241
249
|
}
|
|
242
250
|
return { success: false }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useMemo } from "react";
|
|
2
2
|
import Page from "@ledvance/base/src/components/Page";
|
|
3
3
|
import { useDeviceId, useDeviceInfo, useFlagMode, useFlags, useMoods } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
4
|
-
import { FlatList } from "react-native";
|
|
4
|
+
import { FlatList, Image, TouchableOpacity, View } from "react-native";
|
|
5
5
|
import Spacer from "@ledvance/base/src/components/Spacer";
|
|
6
6
|
import { Utils } from "tuya-panel-kit";
|
|
7
7
|
import FlagItem from "./FlagItem";
|
|
@@ -19,6 +19,7 @@ import { Result } from "@ledvance/base/src/models/modules/Result";
|
|
|
19
19
|
import { useDps } from "@ledvance/base/src/models/modules/NativePropsSlice";
|
|
20
20
|
import { ColorUtils, WORK_MODE } from "@tuya/tuya-panel-lamp-sdk/lib/utils";
|
|
21
21
|
import TextField from "@ledvance/base/src/components/TextField";
|
|
22
|
+
import { showDialog } from "@ledvance/base/src/utils/common";
|
|
22
23
|
const cx = Utils.RatioUtils.convertX
|
|
23
24
|
|
|
24
25
|
export interface FlagPageProps {
|
|
@@ -108,8 +109,8 @@ const FlagPage = () => {
|
|
|
108
109
|
state.flags = state.searchText !== '' ? cloneDeep(flags).filter(flag => flag.name.includes(state.searchText)) : cloneDeep(flags)
|
|
109
110
|
}, [state.searchText, flags])
|
|
110
111
|
|
|
111
|
-
const getRemoteFlagInfo = async () => {
|
|
112
|
-
const res = await getRemoteFlag(devInfo.devId)
|
|
112
|
+
const getRemoteFlagInfo = async (isRefresh?: boolean) => {
|
|
113
|
+
const res = await getRemoteFlag(devInfo.devId, isRefresh)
|
|
113
114
|
if (res.success) {
|
|
114
115
|
let cloneFlag: FlagUiInfo[] = cloneDeep(res.data) || []
|
|
115
116
|
state.flags = cloneFlag
|
|
@@ -212,14 +213,33 @@ const FlagPage = () => {
|
|
|
212
213
|
}
|
|
213
214
|
}}
|
|
214
215
|
>
|
|
215
|
-
<
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
216
|
+
<View style={{flexDirection: 'row', display: 'flex', alignItems: 'center'}}>
|
|
217
|
+
<TextField
|
|
218
|
+
value={state.searchText}
|
|
219
|
+
onChangeText={text => {
|
|
220
|
+
state.searchText = text
|
|
221
|
+
}}
|
|
222
|
+
placeholder={I18n.getLang('country_selection_textfield_headline_search')}
|
|
223
|
+
style={{ marginHorizontal: cx(24), flex: 1 }}
|
|
224
|
+
/>
|
|
225
|
+
<TouchableOpacity style={{paddingRight: cx(24)}}
|
|
226
|
+
onPress={() =>{
|
|
227
|
+
showDialog({
|
|
228
|
+
method: 'confirm',
|
|
229
|
+
title: I18n.getLang('flag_resetbutton'),
|
|
230
|
+
subTitle: I18n.getLang('flag_resetdescription'),
|
|
231
|
+
onConfirm: async (_, {close}) =>{
|
|
232
|
+
close()
|
|
233
|
+
state.loading = true
|
|
234
|
+
await getRemoteFlagInfo(true)
|
|
235
|
+
state.loading = false
|
|
236
|
+
}
|
|
237
|
+
})
|
|
238
|
+
}}
|
|
239
|
+
>
|
|
240
|
+
<Image source={res.ic_refresh} style={{width: cx(24), height: cx(24)}}/>
|
|
241
|
+
</TouchableOpacity>
|
|
242
|
+
</View>
|
|
223
243
|
<FlatList
|
|
224
244
|
data={state.flags}
|
|
225
245
|
renderItem={({ item }) => <FlagItem
|