@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
package/.babelrc
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"presets": ["module:metro-react-native-babel-preset"],
|
|
3
|
+
"plugins": [
|
|
4
|
+
["@babel/plugin-proposal-decorators", { "legacy": true }],
|
|
5
|
+
["module-resolver", {
|
|
6
|
+
"cwd": "babelrc",
|
|
7
|
+
"root": ["./src"],
|
|
8
|
+
"extensions": [
|
|
9
|
+
".ts",
|
|
10
|
+
".tsx",
|
|
11
|
+
".js",
|
|
12
|
+
".jsx",
|
|
13
|
+
".json"
|
|
14
|
+
],
|
|
15
|
+
"alias": {
|
|
16
|
+
"@api": "./src/api",
|
|
17
|
+
"@components": "./src/components",
|
|
18
|
+
"@config": "./src/config",
|
|
19
|
+
"@i18n": "./src/i18n",
|
|
20
|
+
"@models": "./src/models",
|
|
21
|
+
"@res": "./src/res",
|
|
22
|
+
"@utils": "./src/utils"
|
|
23
|
+
}
|
|
24
|
+
}]
|
|
25
|
+
],
|
|
26
|
+
"env": {
|
|
27
|
+
"production": {
|
|
28
|
+
"plugins": ["transform-remove-console"]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
root: true,
|
|
5
|
+
extends: ['tuya/react-native'],
|
|
6
|
+
rules: {
|
|
7
|
+
'one-var': 0,
|
|
8
|
+
'@typescript-eslint/no-unused-vars': 0,
|
|
9
|
+
'react/jsx-props-no-spreading': 0,
|
|
10
|
+
},
|
|
11
|
+
settings: {
|
|
12
|
+
'import/resolver': {
|
|
13
|
+
alias: {
|
|
14
|
+
map: [
|
|
15
|
+
['@api', path.resolve(__dirname, './src/api')],
|
|
16
|
+
['@components', path.resolve(__dirname, './src/components')],
|
|
17
|
+
['@config', path.resolve(__dirname, './src/config')],
|
|
18
|
+
['@i18n', path.resolve(__dirname, './src/i18n')],
|
|
19
|
+
['@models', path.resolve(__dirname, './src/models')],
|
|
20
|
+
['@res', path.resolve(__dirname, './src/res')],
|
|
21
|
+
['@utils', path.resolve(__dirname, './src/utils')],
|
|
22
|
+
],
|
|
23
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
package/.prettierignore
ADDED
|
File without changes
|
package/.prettierrc.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('eslint-config-tuya/.prettierrc.js');
|
package/.versionrc
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rnVersion": "5.30",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"name": "@ledvance/base",
|
|
5
|
+
"pid": [],
|
|
6
|
+
"uiid": "",
|
|
7
|
+
"version": "1.0.1",
|
|
8
|
+
"scripts": {},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@reduxjs/toolkit": "^1.8.6",
|
|
11
|
+
"@tuya/tuya-panel-api": "^1.12.0",
|
|
12
|
+
"ahooks": "^2.x",
|
|
13
|
+
"buffer": "^6.0.3",
|
|
14
|
+
"dayjs": "^1.11.5",
|
|
15
|
+
"events": "^1.1.1",
|
|
16
|
+
"lodash": "^4.17.19",
|
|
17
|
+
"moment": "^2.20.1",
|
|
18
|
+
"prop-types": "^15.6.1",
|
|
19
|
+
"react": "16.8.3",
|
|
20
|
+
"react-addons-shallow-compare": "^15.6.2",
|
|
21
|
+
"react-native": "0.59.10",
|
|
22
|
+
"react-native-render-html": "^6.3.4",
|
|
23
|
+
"react-native-svg": "5.5.1",
|
|
24
|
+
"react-redux": "^7.2.1",
|
|
25
|
+
"redux": "^4.0.0",
|
|
26
|
+
"redux-actions": "^2.6.1",
|
|
27
|
+
"redux-logger": "^3.0.6",
|
|
28
|
+
"redux-observable": "^1.0.0",
|
|
29
|
+
"redux-thunk": "^2.3.0",
|
|
30
|
+
"rxjs": "^6.3.1",
|
|
31
|
+
"rxjs-compat": "^6.3.1",
|
|
32
|
+
"style-equal": "^1.0.0",
|
|
33
|
+
"tuya-panel-kit": "^4.9.4"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@babel/plugin-proposal-decorators": "^7.12.1",
|
|
37
|
+
"@commitlint/cli": "^11.0.0",
|
|
38
|
+
"@tuya/tuya-panel-patches": "^0.59.10",
|
|
39
|
+
"@types/lodash": "^4.14.137",
|
|
40
|
+
"@types/react": "^16.0.4",
|
|
41
|
+
"@types/react-native": "^0.60.0",
|
|
42
|
+
"@types/react-redux": "^7.1.2",
|
|
43
|
+
"@types/redux": "^3.6.0",
|
|
44
|
+
"@types/redux-actions": "^2.6.1",
|
|
45
|
+
"@types/redux-logger": "^3.0.7",
|
|
46
|
+
"@types/tuya-panel-kit": "^4.7.3",
|
|
47
|
+
"babel-jest": "^22.1.0",
|
|
48
|
+
"babel-plugin-import": "^1.11.0",
|
|
49
|
+
"babel-plugin-module-resolver": "^4.0.0",
|
|
50
|
+
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
|
51
|
+
"babel-plugin-transform-remove-console": "^6.9.4",
|
|
52
|
+
"commitizen": "^4.2.2",
|
|
53
|
+
"commitlint-config-cz": "^0.13.2",
|
|
54
|
+
"cz-customizable": "^6.3.0",
|
|
55
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
56
|
+
"eslint-config-tuya": "^1.0.0",
|
|
57
|
+
"eslint-import-resolver-alias": "^1.1.2",
|
|
58
|
+
"eslint-import-resolver-react-native": "^0.2.0",
|
|
59
|
+
"eslint-plugin-react-native": "^3.10.0",
|
|
60
|
+
"husky": "^4.3.0",
|
|
61
|
+
"jest": "^22.1.1",
|
|
62
|
+
"metro-react-native-babel-preset": "^0.63.0",
|
|
63
|
+
"react-native-typescript-transformer": "^1.2.13",
|
|
64
|
+
"react-test-renderer": "^16.2.0",
|
|
65
|
+
"standard-version": "^9.0.0",
|
|
66
|
+
"typescript": "^4.1.2"
|
|
67
|
+
},
|
|
68
|
+
"jest": {
|
|
69
|
+
"preset": "react-native"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/rn-cli.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NativeResult } from '../models/modules/Result';
|
|
2
|
+
export declare class NativeApi {
|
|
3
|
+
static back(): void;
|
|
4
|
+
static log(msg: string): void;
|
|
5
|
+
static logObj(msg: any): void;
|
|
6
|
+
static showObj(obj: any): void;
|
|
7
|
+
static timerList(deviceId: string): Promise<any>;
|
|
8
|
+
static addTimer(deviceId: string, value: any, callback?: (res: any) => void): void;
|
|
9
|
+
static editTimer(deviceId: string, value: any, callback?: (res: any) => void): void;
|
|
10
|
+
static deleteTimer(deviceId: string, value: any, callback?: (res: any) => void): void;
|
|
11
|
+
static setDp<T>(deviceId: string, key: string, value: any): Promise<NativeResult<T>>;
|
|
12
|
+
static setDps<T>(deviceId: string, dps: any): Promise<NativeResult<T>>;
|
|
13
|
+
static deleteDevice(deviceId: string, isReset: boolean): Promise<NativeResult<any>>;
|
|
14
|
+
static renameDevice(deviceId: string, name: string): Promise<NativeResult<any>>;
|
|
15
|
+
static toDeviceSettingsPage(deviceId: string): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {NativeModules} from 'react-native'
|
|
2
|
+
import {NativeResult} from '../models/modules/Result'
|
|
3
|
+
|
|
4
|
+
interface LDVDevicePanelManager {
|
|
5
|
+
back: () => void
|
|
6
|
+
control: (params: any, callback: (result: any) => void) => void
|
|
7
|
+
setTimer: (params: any, callback: (result: any) => void) => void
|
|
8
|
+
deleteDevice: (deviceId: string, isReset: boolean, callback: (result: any) => void) => void
|
|
9
|
+
rename: (deviceId: string, name: string, callback: (result: any) => void) => void
|
|
10
|
+
toDeviceSettingsPage: (deviceId: string) => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const devicePanel: LDVDevicePanelManager = NativeModules.LDVDevicePanelManager
|
|
14
|
+
const logManager = NativeModules.RNLogManager
|
|
15
|
+
|
|
16
|
+
const back = () => {
|
|
17
|
+
devicePanel.back()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const log = (str: string) => {
|
|
21
|
+
logManager.log(str)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const showObj = (objc) => {
|
|
25
|
+
if (!!objc) {
|
|
26
|
+
logManager.objc(objc)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const control = (devId, dps, callback) => {
|
|
31
|
+
devicePanel.control({devId, dps: JSON.stringify(dps)}, res => {
|
|
32
|
+
callback && callback(res)
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// timer
|
|
37
|
+
const TASK = 'LDV_TY'
|
|
38
|
+
|
|
39
|
+
const timerList = devId => {
|
|
40
|
+
return new Promise((resolve, _reject) => {
|
|
41
|
+
const params = {devId, task: TASK, action: 'list', bizType: 0}
|
|
42
|
+
devicePanel.setTimer(params, res => {
|
|
43
|
+
resolve(res)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const addTimer = (devId, value, callback: any = undefined) => {
|
|
49
|
+
const params = {devId, task: TASK, action: 'add', value, bizType: 0}
|
|
50
|
+
devicePanel.setTimer(params, res => {
|
|
51
|
+
callback && callback(res)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const editTimer = (devId, value, callback: any = undefined) => {
|
|
56
|
+
const params = {devId, task: TASK, action: 'update', value, bizType: 0}
|
|
57
|
+
devicePanel.setTimer(params, res => {
|
|
58
|
+
callback && callback(res)
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const deleteTimer = (devId, value, callback: any = undefined) => {
|
|
63
|
+
const params = {devId, task: TASK, action: 'delete', value, bizType: 0}
|
|
64
|
+
devicePanel.setTimer(params, res => {
|
|
65
|
+
callback && callback(res)
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const setDp = <T>(deviceId: string, key: string, value: any) => {
|
|
70
|
+
return new Promise<NativeResult<T>>((resolve, _reject) => {
|
|
71
|
+
control(deviceId, {[key]: value}, res => {
|
|
72
|
+
resolve(res)
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const setDps = <T>(deviceId: string, dps: any) => {
|
|
78
|
+
return new Promise<NativeResult<T>>((resolve, _reject) => {
|
|
79
|
+
control(deviceId, dps, res => {
|
|
80
|
+
resolve(res)
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type DeleteDeviceResultType = (deviceId: string, isReset: boolean) => Promise<NativeResult<any>>
|
|
86
|
+
|
|
87
|
+
const deleteDevice: DeleteDeviceResultType = (deviceId: string, isReset: boolean) => {
|
|
88
|
+
return new Promise((resolve, _reject) => {
|
|
89
|
+
devicePanel.deleteDevice(deviceId, isReset, res => {
|
|
90
|
+
resolve(res)
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type RenameResultType = (deviceId: string, name: string) => Promise<NativeResult<any>>
|
|
96
|
+
|
|
97
|
+
const rename: RenameResultType = (deviceId: string, name: string) => {
|
|
98
|
+
return new Promise((resolve, _reject) => {
|
|
99
|
+
devicePanel.rename(deviceId, name, res => {
|
|
100
|
+
resolve(res)
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function toDeviceSettingsPage(tuyaDeviceId: string) {
|
|
106
|
+
devicePanel.toDeviceSettingsPage(tuyaDeviceId)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export class NativeApi {
|
|
110
|
+
static back(): void {
|
|
111
|
+
back()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static log(msg: string): void {
|
|
115
|
+
log(msg)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static logObj(msg: any): void {
|
|
119
|
+
this.log(JSON.stringify(msg))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static showObj(obj: any): void {
|
|
123
|
+
showObj(obj)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static timerList(deviceId: string): Promise<any> {
|
|
127
|
+
return timerList(deviceId)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static addTimer(deviceId: string, value: any, callback?: (res: any) => void): void {
|
|
131
|
+
addTimer(deviceId, value, callback)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static editTimer(deviceId: string, value: any, callback?: (res: any) => void): void {
|
|
135
|
+
editTimer(deviceId, value, callback)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
static deleteTimer(deviceId: string, value: any, callback?: (res: any) => void): void {
|
|
139
|
+
deleteTimer(deviceId, value, callback)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static setDp<T>(deviceId: string, key: string, value: any): Promise<NativeResult<T>> {
|
|
143
|
+
return setDp<T>(deviceId, key, value)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static setDps<T>(deviceId: string, dps: any): Promise<NativeResult<T>> {
|
|
147
|
+
return setDps<T>(deviceId, dps)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static deleteDevice(deviceId: string, isReset: boolean): Promise<NativeResult<any>> {
|
|
151
|
+
return deleteDevice(deviceId, isReset)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static renameDevice(deviceId: string, name: string): Promise<NativeResult<any>> {
|
|
155
|
+
return rename(deviceId, name)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static toDeviceSettingsPage(deviceId: string): void {
|
|
159
|
+
toDeviceSettingsPage(deviceId)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {NativeEventEmitter, NativeModules} from 'react-native'
|
|
2
|
+
import {setNativeProps} from '../models/modules/NativePropsSlice'
|
|
3
|
+
|
|
4
|
+
const nativeModule = NativeModules.LDVDeviceEventEmitter
|
|
5
|
+
const nativeEventEmitter = new NativeEventEmitter(nativeModule)
|
|
6
|
+
|
|
7
|
+
let listener
|
|
8
|
+
|
|
9
|
+
export const addListener = (store) => {
|
|
10
|
+
listener = nativeEventEmitter.addListener('TYDataUpdate', (body: any) => {
|
|
11
|
+
// device info
|
|
12
|
+
if (body.dps && body.devId && body.devId === store.getState().ldvModules.devId) {
|
|
13
|
+
console.log('长链接刷新DP数据', body.devId, body.dps)
|
|
14
|
+
const data = body
|
|
15
|
+
data.dps = JSON.parse(body.dps)
|
|
16
|
+
store.dispatch(setNativeProps(data))
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const removeListener = () => {
|
|
22
|
+
listener && listener.remove()
|
|
23
|
+
listener = null
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
interface CardProps extends PropsWithChildren<ViewProps> {
|
|
4
|
+
shadowHeight?: number | undefined;
|
|
5
|
+
onPress?: () => void;
|
|
6
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
7
|
+
}
|
|
8
|
+
export default function Card(props: CardProps): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {Platform, StyleProp, TouchableOpacity, View, ViewProps, ViewStyle} from 'react-native'
|
|
2
|
+
import React, {PropsWithChildren} from 'react'
|
|
3
|
+
import {Utils} from 'tuya-panel-kit'
|
|
4
|
+
|
|
5
|
+
const cx = Utils.RatioUtils.convertX
|
|
6
|
+
|
|
7
|
+
interface CardProps extends PropsWithChildren<ViewProps> {
|
|
8
|
+
shadowHeight?: number | undefined
|
|
9
|
+
onPress?: () => void
|
|
10
|
+
containerStyle?: StyleProp<ViewStyle>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function Card(props: CardProps) {
|
|
14
|
+
const shadowHeight = props.shadowHeight || cx(7)
|
|
15
|
+
return (
|
|
16
|
+
<View
|
|
17
|
+
style={[{
|
|
18
|
+
overflow: Platform.OS === 'ios' ? undefined : 'hidden',
|
|
19
|
+
backgroundColor: 'white',
|
|
20
|
+
elevation: shadowHeight,
|
|
21
|
+
shadowColor: '#000000',
|
|
22
|
+
shadowOpacity: 0.2,
|
|
23
|
+
shadowRadius: shadowHeight,
|
|
24
|
+
shadowOffset: {
|
|
25
|
+
width: 0,
|
|
26
|
+
height: shadowHeight,
|
|
27
|
+
},
|
|
28
|
+
borderRadius: cx(10),
|
|
29
|
+
}, props.style]}>
|
|
30
|
+
<TouchableOpacity disabled={!(!!props.onPress)} onPress={props.onPress}>
|
|
31
|
+
<View style={props.containerStyle}>{props.children}</View>
|
|
32
|
+
</TouchableOpacity>
|
|
33
|
+
</View>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IconFont, Utils } from 'tuya-panel-kit'
|
|
2
|
+
import { StyleProp, Text, TouchableOpacity, View, ViewStyle } from 'react-native'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
const cx = Utils.RatioUtils.convertX
|
|
6
|
+
|
|
7
|
+
interface CellProps {
|
|
8
|
+
title: string,
|
|
9
|
+
value: string,
|
|
10
|
+
onPress: () => void,
|
|
11
|
+
style?: StyleProp<ViewStyle>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function Cell(props: CellProps) {
|
|
15
|
+
return (
|
|
16
|
+
<TouchableOpacity
|
|
17
|
+
style={[{
|
|
18
|
+
height: cx(50),
|
|
19
|
+
paddingHorizontal: cx(24),
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
}, props.style]}
|
|
22
|
+
onPress={props.onPress}>
|
|
23
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }}>
|
|
24
|
+
<Text style={{
|
|
25
|
+
fontSize: cx(14),
|
|
26
|
+
color: '#444',
|
|
27
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
28
|
+
}}>{props.title}</Text>
|
|
29
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
30
|
+
<Text style={{
|
|
31
|
+
fontSize: cx(14),
|
|
32
|
+
color: '#444',
|
|
33
|
+
fontFamily: 'helvetica_neue_lt_std_roman',
|
|
34
|
+
}}>{props.value}</Text>
|
|
35
|
+
<View style={{ width: cx(4) }} />
|
|
36
|
+
<IconFont color={'#444'} size={cx(11)} name="arrow" />
|
|
37
|
+
</View>
|
|
38
|
+
</View>
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ColorAdjustViewProps {
|
|
2
|
+
h: number;
|
|
3
|
+
s: number;
|
|
4
|
+
v: number;
|
|
5
|
+
onHSVChange?: (h: number, s: number, v: number) => void;
|
|
6
|
+
onHSVChangeComplete: (h: number, s: number, v: number) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const ColorAdjustView: (props: ColorAdjustViewProps) => JSX.Element;
|
|
9
|
+
export default ColorAdjustView;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {View} from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import LdvColorSlider from './ldvColorSlider'
|
|
4
|
+
import {hex2Hsv, hsv2Hex} from '../utils'
|
|
5
|
+
import Spacer from './Spacer'
|
|
6
|
+
import LdvPresetView from './ldvPresetView'
|
|
7
|
+
import {Utils} from 'tuya-panel-kit'
|
|
8
|
+
import LdvSaturation from './ldvSaturation'
|
|
9
|
+
import LdvColorBrightness from './ldvColorBrightness'
|
|
10
|
+
import I18n from '../i18n/index'
|
|
11
|
+
|
|
12
|
+
const {convertX: cx} = Utils.RatioUtils
|
|
13
|
+
|
|
14
|
+
export interface ColorAdjustViewProps {
|
|
15
|
+
h: number
|
|
16
|
+
s: number
|
|
17
|
+
v: number
|
|
18
|
+
onHSVChange?: (h: number, s: number, v: number) => void
|
|
19
|
+
onHSVChangeComplete: (h: number, s: number, v: number) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ColorAdjustView = (props: ColorAdjustViewProps) => {
|
|
23
|
+
return (
|
|
24
|
+
<View>
|
|
25
|
+
<LdvColorSlider
|
|
26
|
+
type={'color'}
|
|
27
|
+
title={I18n.getLang('light_sources_tile_sec_lighting_shade')}
|
|
28
|
+
thumbColor={hsv2Hex(props.h, 100, 100)}
|
|
29
|
+
value={props.h}
|
|
30
|
+
onValueChange={hue => {
|
|
31
|
+
props.onHSVChange && props.onHSVChange(hue, props.s, props.v)
|
|
32
|
+
}}
|
|
33
|
+
onSlidingComplete={hue => {
|
|
34
|
+
props.onHSVChangeComplete(hue, props.s, props.v)
|
|
35
|
+
}}/>
|
|
36
|
+
<Spacer height={cx(10)}/>
|
|
37
|
+
<LdvPresetView
|
|
38
|
+
type={'color'}
|
|
39
|
+
style={{height: cx(60)}}
|
|
40
|
+
onPress={(item) => {
|
|
41
|
+
const hsv = hex2Hsv(item.color)
|
|
42
|
+
if (hsv) {
|
|
43
|
+
props.onHSVChangeComplete(hsv.h, hsv.s, hsv.v)
|
|
44
|
+
}
|
|
45
|
+
}}/>
|
|
46
|
+
<LdvSaturation
|
|
47
|
+
value={props.s}
|
|
48
|
+
onValueChange={s => {
|
|
49
|
+
props.onHSVChange && props.onHSVChange(props.h, s, props.v)
|
|
50
|
+
}}
|
|
51
|
+
onSlidingComplete={s => {
|
|
52
|
+
props.onHSVChangeComplete(props.h, s, props.v)
|
|
53
|
+
}}/>
|
|
54
|
+
<LdvColorBrightness
|
|
55
|
+
value={props.v}
|
|
56
|
+
onValueChange={v => {
|
|
57
|
+
props.onHSVChange && props.onHSVChange(props.h, props.s, v)
|
|
58
|
+
}}
|
|
59
|
+
onSlidingComplete={v => {
|
|
60
|
+
props.onHSVChangeComplete(props.h, props.s, v)
|
|
61
|
+
}}/>
|
|
62
|
+
</View>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default ColorAdjustView
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ColorTempAdjustViewProps {
|
|
2
|
+
colorTemp: number;
|
|
3
|
+
brightness: number;
|
|
4
|
+
isSupportTemperature: boolean;
|
|
5
|
+
isSupportBrightness: boolean;
|
|
6
|
+
onCCTChange?: (cct: number) => void;
|
|
7
|
+
onCCTChangeComplete: (cct: number) => void;
|
|
8
|
+
onBrightnessChange?: (brightness: number) => void;
|
|
9
|
+
onBrightnessChangeComplete: (brightness: number) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const ColorTempAdjustView: (props: ColorTempAdjustViewProps) => JSX.Element;
|
|
12
|
+
export default ColorTempAdjustView;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {View} from 'react-native'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import LdvColorSlider from './ldvColorSlider'
|
|
4
|
+
import Spacer from './Spacer'
|
|
5
|
+
import LdvPresetView from './ldvPresetView'
|
|
6
|
+
import LdvSlider from './ldvSlider'
|
|
7
|
+
import {Utils} from 'tuya-panel-kit'
|
|
8
|
+
import I18n from '../i18n/index'
|
|
9
|
+
|
|
10
|
+
const {convertX: cx} = Utils.RatioUtils
|
|
11
|
+
|
|
12
|
+
export interface ColorTempAdjustViewProps {
|
|
13
|
+
colorTemp: number
|
|
14
|
+
brightness: number
|
|
15
|
+
isSupportTemperature: boolean
|
|
16
|
+
isSupportBrightness: boolean
|
|
17
|
+
onCCTChange?: (cct: number) => void
|
|
18
|
+
onCCTChangeComplete: (cct: number) => void
|
|
19
|
+
onBrightnessChange?: (brightness: number) => void
|
|
20
|
+
onBrightnessChangeComplete: (brightness: number) => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ColorTempAdjustView = (props: ColorTempAdjustViewProps) => {
|
|
24
|
+
return (
|
|
25
|
+
<View>
|
|
26
|
+
{props.isSupportTemperature &&
|
|
27
|
+
<>
|
|
28
|
+
<LdvColorSlider
|
|
29
|
+
type={'temperature'}
|
|
30
|
+
title={I18n.getLang('light_sources_tile_main_lighting_shade')}
|
|
31
|
+
thumbColor={'white'}
|
|
32
|
+
value={props.colorTemp}
|
|
33
|
+
onValueChange={props.onCCTChange}
|
|
34
|
+
onSlidingComplete={props.onCCTChangeComplete}/>
|
|
35
|
+
<Spacer height={cx(10)}/>
|
|
36
|
+
<LdvPresetView
|
|
37
|
+
type={'temperature'}
|
|
38
|
+
style={{height: cx(60)}}
|
|
39
|
+
onPress={item => {
|
|
40
|
+
props.onCCTChangeComplete(item.value)
|
|
41
|
+
}}/>
|
|
42
|
+
<Spacer height={cx(10)}/>
|
|
43
|
+
</>
|
|
44
|
+
}
|
|
45
|
+
{props.isSupportBrightness &&
|
|
46
|
+
<LdvSlider
|
|
47
|
+
title={I18n.getLang('light_sources_tile_rgb_lighting_brightness')}
|
|
48
|
+
value={props.brightness}
|
|
49
|
+
onValueChange={props.onBrightnessChange}
|
|
50
|
+
onSlidingComplete={props.onBrightnessChangeComplete}/>}
|
|
51
|
+
</View>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default ColorTempAdjustView
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { ViewProps } from 'react-native';
|
|
3
|
+
interface DialogProps extends PropsWithChildren<ViewProps> {
|
|
4
|
+
show: boolean;
|
|
5
|
+
hideMask: boolean;
|
|
6
|
+
animationType?: 'none' | 'slide' | 'fade';
|
|
7
|
+
onRequestClose: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const Dialog: (props: DialogProps) => JSX.Element;
|
|
10
|
+
export default Dialog;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react'
|
|
2
|
+
import { Modal, StyleSheet, TouchableOpacity, ViewProps } from 'react-native'
|
|
3
|
+
|
|
4
|
+
interface DialogProps extends PropsWithChildren<ViewProps> {
|
|
5
|
+
show: boolean
|
|
6
|
+
hideMask: boolean
|
|
7
|
+
animationType?: 'none' | 'slide' | 'fade'
|
|
8
|
+
onRequestClose: () => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Dialog = (props: DialogProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<Modal
|
|
14
|
+
transparent={true}
|
|
15
|
+
visible={props.show}
|
|
16
|
+
animationType={props.animationType || 'fade'}
|
|
17
|
+
onRequestClose={props.onRequestClose}>
|
|
18
|
+
<TouchableOpacity
|
|
19
|
+
style={[
|
|
20
|
+
styles.mask,
|
|
21
|
+
{
|
|
22
|
+
backgroundColor: props.hideMask ? 'rgba(0, 0, 0, 0)' : 'rgba(0, 0, 0, 0.7)',
|
|
23
|
+
},
|
|
24
|
+
]}
|
|
25
|
+
activeOpacity={1}
|
|
26
|
+
onPress={props.onRequestClose}>
|
|
27
|
+
{props.children}
|
|
28
|
+
</TouchableOpacity>
|
|
29
|
+
</Modal>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const styles = StyleSheet.create({
|
|
34
|
+
mask: {
|
|
35
|
+
flex: 1,
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
export default Dialog
|