@ledvance/base 1.0.1
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/.babelrc +31 -0
- package/.eslintignore +6 -0
- package/.eslintrc.js +27 -0
- package/.prettierignore +0 -0
- package/.prettierrc.js +1 -0
- package/.versionrc +5 -0
- package/package.json +71 -0
- package/rn-cli.config.js +8 -0
- package/src/api/native.d.ts +16 -0
- package/src/api/native.ts +161 -0
- package/src/api/nativeEventEmitter.d.ts +2 -0
- package/src/api/nativeEventEmitter.ts +24 -0
- package/src/components/Card.d.ts +9 -0
- package/src/components/Card.tsx +35 -0
- package/src/components/Cell.d.ts +9 -0
- package/src/components/Cell.tsx +41 -0
- package/src/components/ColorAdjustView.d.ts +9 -0
- package/src/components/ColorAdjustView.tsx +66 -0
- package/src/components/ColorTempAdjustView.d.ts +12 -0
- package/src/components/ColorTempAdjustView.tsx +55 -0
- package/src/components/Dialog.d.ts +10 -0
- package/src/components/Dialog.tsx +39 -0
- package/src/components/InfoText.d.ts +10 -0
- package/src/components/InfoText.tsx +44 -0
- package/src/components/LampAdjustView.d.ts +13 -0
- package/src/components/LampAdjustView.tsx +76 -0
- package/src/components/LinearGradientLine.d.ts +9 -0
- package/src/components/LinearGradientLine.tsx +65 -0
- package/src/components/Page.d.ts +11 -0
- package/src/components/Page.tsx +35 -0
- package/src/components/Spacer.d.ts +7 -0
- package/src/components/Spacer.tsx +14 -0
- package/src/components/Tag.d.ts +8 -0
- package/src/components/Tag.tsx +57 -0
- package/src/components/TextButton.d.ts +9 -0
- package/src/components/TextButton.tsx +32 -0
- package/src/components/TextField.d.ts +5 -0
- package/src/components/TextField.tsx +74 -0
- package/src/components/connect.d.ts +10 -0
- package/src/components/connect.tsx +20 -0
- package/src/components/ldvColorBrightness.d.ts +1 -0
- package/src/components/ldvColorBrightness.tsx +18 -0
- package/src/components/ldvColorSlider.d.ts +14 -0
- package/src/components/ldvColorSlider.tsx +132 -0
- package/src/components/ldvPickerView.d.ts +10 -0
- package/src/components/ldvPickerView.tsx +68 -0
- package/src/components/ldvPresetView.d.ts +2 -0
- package/src/components/ldvPresetView.tsx +89 -0
- package/src/components/ldvSaturation.d.ts +2 -0
- package/src/components/ldvSaturation.tsx +23 -0
- package/src/components/ldvSlider.d.ts +15 -0
- package/src/components/ldvSlider.tsx +104 -0
- package/src/components/ldvSwitch.d.ts +9 -0
- package/src/components/ldvSwitch.tsx +48 -0
- package/src/components/ldvTemperatureSlider.d.ts +13 -0
- package/src/components/ldvTemperatureSlider.tsx +140 -0
- package/src/components/ldvTopBar.d.ts +9 -0
- package/src/components/ldvTopBar.tsx +64 -0
- package/src/components/ldvTopName.d.ts +7 -0
- package/src/components/ldvTopName.tsx +47 -0
- package/src/components/segmentControl.d.ts +1 -0
- package/src/components/segmentControl.tsx +66 -0
- package/src/components/weekSelect.d.ts +7 -0
- package/src/components/weekSelect.tsx +95 -0
- package/src/composeLayout.tsx +148 -0
- package/src/i18n/index.d.ts +16 -0
- package/src/i18n/index.ts +36 -0
- package/src/i18n/strings.d.ts +3139 -0
- package/src/i18n/strings.ts +3234 -0
- package/src/main.tsx +9 -0
- package/src/models/GlobalParams.d.ts +14 -0
- package/src/models/GlobalParams.ts +15 -0
- package/src/models/TuyaApi.d.ts +17 -0
- package/src/models/TuyaApi.ts +37 -0
- package/src/models/combine.d.ts +26 -0
- package/src/models/combine.ts +17 -0
- package/src/models/configureStore.d.ts +9 -0
- package/src/models/configureStore.ts +33 -0
- package/src/models/index.d.ts +31 -0
- package/src/models/index.ts +22 -0
- package/src/models/modules/NativePropsSlice.d.ts +25 -0
- package/src/models/modules/NativePropsSlice.tsx +145 -0
- package/src/models/modules/Result.d.ts +14 -0
- package/src/models/modules/Result.ts +16 -0
- package/src/models/modules/common.d.ts +44 -0
- package/src/models/modules/common.ts +161 -0
- package/src/res/index.d.ts +38 -0
- package/src/res/index.ts +37 -0
- package/src/utils/ColorParser.d.ts +66 -0
- package/src/utils/ColorParser.ts +190 -0
- package/src/utils/ColorUtils.d.ts +71 -0
- package/src/utils/ColorUtils.tsx +449 -0
- package/src/utils/common.d.ts +11 -0
- package/src/utils/common.ts +54 -0
- package/src/utils/index.d.ts +24 -0
- package/src/utils/index.ts +164 -0
- package/tsconfig.json +51 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Image, Platform, Text, TouchableOpacity, View } from 'react-native'
|
|
3
|
+
import { IconFont, Utils } from 'tuya-panel-kit'
|
|
4
|
+
|
|
5
|
+
const backIcon = Platform.OS === 'ios' ? 'backIos' : 'backAndroid'
|
|
6
|
+
|
|
7
|
+
const cx = Utils.RatioUtils.convertX
|
|
8
|
+
|
|
9
|
+
interface TopBarProps {
|
|
10
|
+
title: string,
|
|
11
|
+
onBackPress: () => void,
|
|
12
|
+
rightButtonIcon?: any | {},
|
|
13
|
+
rightButtonStyle?: any | undefined,
|
|
14
|
+
onRightButtonPress?: (() => void) | undefined,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const LDVTopBar = (props: TopBarProps) => {
|
|
18
|
+
return (
|
|
19
|
+
<View
|
|
20
|
+
style={{
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
height: cx(46),
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
marginTop: Platform.OS === 'ios' ? Utils.RatioUtils.statusBarHeight : 0,
|
|
25
|
+
}}>
|
|
26
|
+
<TouchableOpacity onPress={props.onBackPress}>
|
|
27
|
+
<View style={{ flexDirection: 'row', height: cx(46), marginHorizontal: cx(20), alignItems: 'center' }}>
|
|
28
|
+
<IconFont size={cx(16)} color={'#f60'} name={backIcon} />
|
|
29
|
+
<View style={{ width: cx(5) }} />
|
|
30
|
+
<Text
|
|
31
|
+
style={{
|
|
32
|
+
maxWidth: cx(290),
|
|
33
|
+
color: '#f60',
|
|
34
|
+
fontSize: cx(16),
|
|
35
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
36
|
+
}}>{props.title}</Text>
|
|
37
|
+
</View>
|
|
38
|
+
</TouchableOpacity>
|
|
39
|
+
<View style={{ flex: 1 }} />
|
|
40
|
+
{!!props.rightButtonIcon &&
|
|
41
|
+
<TouchableOpacity
|
|
42
|
+
onPress={props.onRightButtonPress}>
|
|
43
|
+
<View
|
|
44
|
+
style={{
|
|
45
|
+
width: cx(44),
|
|
46
|
+
height: cx(44),
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
}}>
|
|
50
|
+
<Image
|
|
51
|
+
style={[
|
|
52
|
+
{ width: cx(28), height: cx(28) },
|
|
53
|
+
props.rightButtonStyle,
|
|
54
|
+
]}
|
|
55
|
+
source={{ uri: props.rightButtonIcon }} />
|
|
56
|
+
</View>
|
|
57
|
+
</TouchableOpacity>
|
|
58
|
+
}
|
|
59
|
+
<View style={{ width: cx(12) }} />
|
|
60
|
+
</View>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default LDVTopBar
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
|
|
3
|
+
import { Utils } from 'tuya-panel-kit'
|
|
4
|
+
|
|
5
|
+
const cx = Utils.RatioUtils.convertX
|
|
6
|
+
|
|
7
|
+
interface LdvTopNameProps {
|
|
8
|
+
title: string,
|
|
9
|
+
rightIcon?: string | undefined,
|
|
10
|
+
rightIconClick?: () => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const LdvTopName = (props: LdvTopNameProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<View style={styles.container}>
|
|
16
|
+
<View
|
|
17
|
+
style={{
|
|
18
|
+
flexDirection: 'row',
|
|
19
|
+
justifyContent: 'space-between',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
marginTop: cx(38),
|
|
22
|
+
}}>
|
|
23
|
+
<Text style={styles.title}>{props.title}</Text>
|
|
24
|
+
{props.rightIcon && <TouchableOpacity
|
|
25
|
+
onPress={props.rightIconClick}>
|
|
26
|
+
<Image
|
|
27
|
+
style={{ width: cx(24), height: cx(24), tintColor: '#ff6600' }}
|
|
28
|
+
source={{ uri: props.rightIcon }} />
|
|
29
|
+
</TouchableOpacity>}
|
|
30
|
+
</View>
|
|
31
|
+
</View>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
container: {
|
|
37
|
+
marginHorizontal: cx(24),
|
|
38
|
+
marginBottom: cx(12),
|
|
39
|
+
},
|
|
40
|
+
title: {
|
|
41
|
+
flex: 1,
|
|
42
|
+
color: '#f60',
|
|
43
|
+
fontSize: cx(24),
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
export default LdvTopName
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SegmentControl(props: any): JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Text, TouchableOpacity, View } from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { Utils } from 'tuya-panel-kit'
|
|
4
|
+
|
|
5
|
+
const { convertX } = Utils.RatioUtils
|
|
6
|
+
|
|
7
|
+
export default function SegmentControl(props) {
|
|
8
|
+
|
|
9
|
+
const { title1, title2, isFirst, setIsFirst, style } = props
|
|
10
|
+
|
|
11
|
+
return (<View style={{}}>
|
|
12
|
+
<View style={[{
|
|
13
|
+
backgroundColor: '#eeeeef',
|
|
14
|
+
marginHorizontal: convertX(24),
|
|
15
|
+
marginVertical: convertX(0),
|
|
16
|
+
borderRadius: convertX(8.9),
|
|
17
|
+
flexDirection: 'row',
|
|
18
|
+
}, style]}>
|
|
19
|
+
<TouchableOpacity style={
|
|
20
|
+
[{
|
|
21
|
+
flex: 1,
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
margin: convertX(2),
|
|
25
|
+
borderRadius: convertX(6.9),
|
|
26
|
+
}, isFirst ?
|
|
27
|
+
{ backgroundColor: '#fff', margin: convertX(2), borderRadius: 6.9 } :
|
|
28
|
+
{ backgroundColor: '#eeeeef' }]
|
|
29
|
+
} onPress={() => setIsFirst(true)}>
|
|
30
|
+
<Text
|
|
31
|
+
style={{
|
|
32
|
+
color: '#000',
|
|
33
|
+
fontSize: convertX(12),
|
|
34
|
+
fontFamily: isFirst ? 'helvetica_neue_lt_std_bd' : 'helvetica_neue_lt_std_roman',
|
|
35
|
+
marginVertical: convertX(10),
|
|
36
|
+
}}>
|
|
37
|
+
{title1}
|
|
38
|
+
</Text>
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
<TouchableOpacity
|
|
41
|
+
style={
|
|
42
|
+
[{
|
|
43
|
+
flex: 1,
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
margin: convertX(2),
|
|
47
|
+
borderRadius: convertX(6.9),
|
|
48
|
+
},
|
|
49
|
+
!isFirst ?
|
|
50
|
+
{ backgroundColor: '#fff' } :
|
|
51
|
+
{ backgroundColor: '#eeeeef' }]
|
|
52
|
+
}
|
|
53
|
+
onPress={() => setIsFirst(false)}>
|
|
54
|
+
<Text
|
|
55
|
+
style={{
|
|
56
|
+
color: '#000',
|
|
57
|
+
fontSize: convertX(12),
|
|
58
|
+
fontFamily: isFirst ? 'helvetica_neue_lt_std_roman' : 'helvetica_neue_lt_std_bd',
|
|
59
|
+
marginVertical: convertX(10),
|
|
60
|
+
}}>
|
|
61
|
+
{title2}
|
|
62
|
+
</Text>
|
|
63
|
+
</TouchableOpacity>
|
|
64
|
+
</View>
|
|
65
|
+
</View>)
|
|
66
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {Text, TouchableOpacity, View} from 'react-native'
|
|
3
|
+
import {Utils} from 'tuya-panel-kit'
|
|
4
|
+
import I18n from '../i18n/index'
|
|
5
|
+
|
|
6
|
+
const cx = Utils.RatioUtils.convertX
|
|
7
|
+
|
|
8
|
+
const repeatPeriod = [
|
|
9
|
+
{
|
|
10
|
+
index: 1,
|
|
11
|
+
title: I18n.getLang('timeschedule_add_schedule_weekday7_text'),
|
|
12
|
+
enabled: false,
|
|
13
|
+
}, {
|
|
14
|
+
index: 2,
|
|
15
|
+
title: I18n.getLang('timeschedule_add_schedule_weekday1_text'),
|
|
16
|
+
enabled: false,
|
|
17
|
+
}, {
|
|
18
|
+
index: 3,
|
|
19
|
+
title: I18n.getLang('timeschedule_add_schedule_weekday2_text'),
|
|
20
|
+
enabled: false,
|
|
21
|
+
}, {
|
|
22
|
+
index: 4,
|
|
23
|
+
title: I18n.getLang('timeschedule_add_schedule_weekday3_text'),
|
|
24
|
+
enabled: false,
|
|
25
|
+
}, {
|
|
26
|
+
index: 5,
|
|
27
|
+
title: I18n.getLang('timeschedule_add_schedule_weekday4_text'),
|
|
28
|
+
enabled: false,
|
|
29
|
+
}, {
|
|
30
|
+
index: 6,
|
|
31
|
+
title: I18n.getLang('timeschedule_add_schedule_weekday5_text'),
|
|
32
|
+
enabled: false,
|
|
33
|
+
}, {
|
|
34
|
+
index: 7,
|
|
35
|
+
title: I18n.getLang('timeschedule_add_schedule_weekday6_text'),
|
|
36
|
+
enabled: false,
|
|
37
|
+
},
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
export const setDataSource = (loop) => {
|
|
41
|
+
return repeatPeriod.map((item, index) => {
|
|
42
|
+
return {
|
|
43
|
+
...item,
|
|
44
|
+
enabled: loop[index] === 1,
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default (props) => {
|
|
50
|
+
|
|
51
|
+
const {value, onSelect, style} = props
|
|
52
|
+
const dataSource = setDataSource(value)
|
|
53
|
+
|
|
54
|
+
return (<View style={{
|
|
55
|
+
height: 40,
|
|
56
|
+
}}>
|
|
57
|
+
<View
|
|
58
|
+
style={[{
|
|
59
|
+
flexDirection: 'row',
|
|
60
|
+
justifyContent: 'space-between',
|
|
61
|
+
marginHorizontal: cx(20),
|
|
62
|
+
}, style]}>
|
|
63
|
+
{dataSource.map(period => {
|
|
64
|
+
return (
|
|
65
|
+
<TouchableOpacity
|
|
66
|
+
key={period.index}
|
|
67
|
+
onPress={() => {
|
|
68
|
+
onSelect(period.index)
|
|
69
|
+
}}>
|
|
70
|
+
<View
|
|
71
|
+
style={{
|
|
72
|
+
width: cx(40),
|
|
73
|
+
height: cx(40),
|
|
74
|
+
justifyContent: 'center',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
borderRadius: cx(20),
|
|
77
|
+
backgroundColor: period.enabled ? '#ffe0d4' : '#fff',
|
|
78
|
+
borderWidth: cx(1),
|
|
79
|
+
// borderColor: period.enabled ? "#fff" : 'rgba(120, 120, 128, 0.2)'
|
|
80
|
+
borderColor: '#f60',
|
|
81
|
+
}}>
|
|
82
|
+
|
|
83
|
+
<Text
|
|
84
|
+
style={{
|
|
85
|
+
color: '#f60',
|
|
86
|
+
textAlign: 'center',
|
|
87
|
+
}}>{period.title}</Text>
|
|
88
|
+
</View>
|
|
89
|
+
</TouchableOpacity>
|
|
90
|
+
)
|
|
91
|
+
})}
|
|
92
|
+
</View>
|
|
93
|
+
|
|
94
|
+
</View>)
|
|
95
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import React, {Component} from 'react'
|
|
3
|
+
import {Provider} from 'react-redux'
|
|
4
|
+
import {DevInfo, DpValue, Theme, TYSdk} from 'tuya-panel-kit'
|
|
5
|
+
import {actions, store} from './models'
|
|
6
|
+
import {addListener} from 'api/nativeEventEmitter'
|
|
7
|
+
import {NativeApi} from 'api/native'
|
|
8
|
+
import {setNativeProps} from './models/modules/NativePropsSlice'
|
|
9
|
+
import {DpSchema, GlobalParams} from './models/GlobalParams'
|
|
10
|
+
import Connect from './components/connect'
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
devInfo: DevInfo;
|
|
14
|
+
preload?: boolean;
|
|
15
|
+
ldvDevInfo: any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const TYEvent = TYSdk.event
|
|
19
|
+
const TYDevice = TYSdk.device
|
|
20
|
+
|
|
21
|
+
const theme = {
|
|
22
|
+
global: {
|
|
23
|
+
background: '#fff',
|
|
24
|
+
},
|
|
25
|
+
ldvMainBgColor: '#f60',
|
|
26
|
+
'slider.trackRadius': 15,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param {} component - 需要连接到redux store的组件,通常为即为main
|
|
32
|
+
*/
|
|
33
|
+
const composeLayout = (component: React.ComponentType) => {
|
|
34
|
+
const NavigatorLayout = component
|
|
35
|
+
const {dispatch} = store
|
|
36
|
+
|
|
37
|
+
addListener(store)
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 此处监听了`设备数据变更`事件,
|
|
41
|
+
* 每当dp点数据变更时,会将变更的dp点状态同步更新到`redux`中去。
|
|
42
|
+
* 同理当设备信息变更时,也会将变更的设备信息值同步更新到`redux`中去。
|
|
43
|
+
*/
|
|
44
|
+
TYEvent.on('deviceDataChange', data => {
|
|
45
|
+
switch (data.type) {
|
|
46
|
+
case 'dpData':
|
|
47
|
+
dispatch(actions.common.responseUpdateDp(data.payload as Record<string, DpValue>))
|
|
48
|
+
break
|
|
49
|
+
case 'deviceOnline':
|
|
50
|
+
console.log('设备在线状态', data.payload)
|
|
51
|
+
break
|
|
52
|
+
default:
|
|
53
|
+
dispatch(actions.common.deviceChange(data.payload as DevInfo))
|
|
54
|
+
break
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 此处监听了`网络状态变更事件`事件,
|
|
60
|
+
* 每当设备信息变更时,会将变更的设备信息值同步更新到`redux`中去。
|
|
61
|
+
*/
|
|
62
|
+
TYSdk.event.on('networkStateChange', data => {
|
|
63
|
+
dispatch(actions.common.deviceChange(data as any))
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
class PanelComponent extends Component<Props> {
|
|
67
|
+
/**
|
|
68
|
+
* 如果面板进入时,`devInfo`已经存在(通常都会存在的)
|
|
69
|
+
* 这里会调用 setDeviceInfo 将原始的devInfo处理一下,并置入`redux`
|
|
70
|
+
*
|
|
71
|
+
* 如果面板进入时,`devInfo`不存在,
|
|
72
|
+
* 那么会调用 getDeviceInfo 异步获取处理好的`devInfo`,并置入`redux`
|
|
73
|
+
*/
|
|
74
|
+
constructor(props: Props) {
|
|
75
|
+
super(props)
|
|
76
|
+
if (props && props.devInfo && props.devInfo.devId) {
|
|
77
|
+
TYDevice.setDeviceInfo(props.devInfo)
|
|
78
|
+
TYDevice.getDeviceInfo()
|
|
79
|
+
.then(data => {
|
|
80
|
+
dispatch(actions.common.devInfoChange(data))
|
|
81
|
+
return Promise.all([TYDevice.getDeviceState(), data])
|
|
82
|
+
})
|
|
83
|
+
.then(([dpState, devInfo]) => {
|
|
84
|
+
const isEqual = _.isEqual(dpState, devInfo.state)
|
|
85
|
+
if (isEqual) return
|
|
86
|
+
dispatch(actions.common.responseUpdateDp(dpState))
|
|
87
|
+
})
|
|
88
|
+
} else if (props.preload) {
|
|
89
|
+
// do something
|
|
90
|
+
} else {
|
|
91
|
+
TYDevice.getDeviceInfo().then(data => dispatch(actions.common.devInfoChange(data)))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.initReduxNativeProps(props.ldvDevInfo)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
initReduxNativeProps(ldvDevInfo) {
|
|
98
|
+
console.log('原生数据:', JSON.stringify(ldvDevInfo))
|
|
99
|
+
NativeApi.log('原生数据: ' + JSON.stringify(ldvDevInfo))
|
|
100
|
+
// 处理物模型协议和dps
|
|
101
|
+
const dpSchemaMap: Record<string, DpSchema> = {}
|
|
102
|
+
const dps = {}
|
|
103
|
+
JSON.parse(this.props.ldvDevInfo.schema || [])
|
|
104
|
+
.forEach(schemaItem => {
|
|
105
|
+
dpSchemaMap[schemaItem.code] = {
|
|
106
|
+
name: schemaItem.name,
|
|
107
|
+
dp: schemaItem.id,
|
|
108
|
+
type: schemaItem.type,
|
|
109
|
+
mode: schemaItem.mode,
|
|
110
|
+
property: schemaItem.property,
|
|
111
|
+
}
|
|
112
|
+
dps[schemaItem.id] = null
|
|
113
|
+
})
|
|
114
|
+
const nativeProps = {
|
|
115
|
+
devId: ldvDevInfo.devId,
|
|
116
|
+
pId: ldvDevInfo.pId,
|
|
117
|
+
familyName: ldvDevInfo.familyName,
|
|
118
|
+
dps: {...dps, ...JSON.parse(ldvDevInfo.dps)},
|
|
119
|
+
}
|
|
120
|
+
GlobalParams.dpSchemaMap = dpSchemaMap
|
|
121
|
+
NativeApi.showObj(nativeProps)
|
|
122
|
+
console.log('Redux 初始数据:', JSON.stringify(nativeProps))
|
|
123
|
+
NativeApi.log('Redux 初始数据:' + JSON.stringify(nativeProps))
|
|
124
|
+
dispatch(setNativeProps(nativeProps))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
render() {
|
|
128
|
+
return (
|
|
129
|
+
<Provider store={store}>
|
|
130
|
+
<Theme theme={theme}>
|
|
131
|
+
<Connect mapStateToProps={_.identity}>
|
|
132
|
+
{({mapStateToProps, ...props}: { mapStateToProps: any; [_: string]: any }) => {
|
|
133
|
+
const hasInit = Object.keys(props.dpState).length > 0
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
return hasInit ? <NavigatorLayout {...props} /> : null
|
|
136
|
+
}}
|
|
137
|
+
</Connect>
|
|
138
|
+
</Theme>
|
|
139
|
+
</Provider>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return PanelComponent
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
export default composeLayout
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DpValue } from 'tuya-panel-kit';
|
|
2
|
+
import Strings from './strings';
|
|
3
|
+
declare type Key = keyof typeof Strings.en;
|
|
4
|
+
declare function getLang(key: Key, defaultString?: string): string;
|
|
5
|
+
declare function getDpLang(code: string, value?: DpValue): string;
|
|
6
|
+
declare function formatString(key: string, values: string[]): string;
|
|
7
|
+
declare function formatValue(key: Key, ...values: string[]): string;
|
|
8
|
+
declare function getDpName(code: string, defaultName?: string): string;
|
|
9
|
+
declare const I18n: {
|
|
10
|
+
getLang: typeof getLang;
|
|
11
|
+
getDpLang: typeof getDpLang;
|
|
12
|
+
formatString: typeof formatString;
|
|
13
|
+
formatValue: typeof formatValue;
|
|
14
|
+
getDpName: typeof getDpName;
|
|
15
|
+
};
|
|
16
|
+
export default I18n;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {DpValue, I18N} from 'tuya-panel-kit'
|
|
2
|
+
import Strings from './strings'
|
|
3
|
+
|
|
4
|
+
type Key = keyof typeof Strings.en
|
|
5
|
+
|
|
6
|
+
function getLang(key: Key, defaultString?: string): string {
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
return new I18N(Strings).getLang(key, defaultString)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getDpLang(code: string, value?: DpValue): string {
|
|
12
|
+
return new I18N(Strings).getDpLang(code, value)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function formatString(key: string, values: string[]): string {
|
|
16
|
+
return new I18N(Strings).formatString(key, ...values)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function formatValue(key: Key, ...values: string[]): string {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
return new I18N(Strings).formatValue(key, ...values)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getDpName(code: string, defaultName?: string): string {
|
|
25
|
+
return new I18N(Strings).getDpName(code, defaultName)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const I18n = {
|
|
29
|
+
getLang,
|
|
30
|
+
getDpLang,
|
|
31
|
+
formatString,
|
|
32
|
+
formatValue,
|
|
33
|
+
getDpName,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default I18n
|