@ledvance/base 1.1.88 → 1.1.90

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
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/base",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.88",
7
+ "version": "1.1.90",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@reduxjs/toolkit": "^1.8.6",
@@ -65,4 +65,5 @@ export declare const queryDpIds: (dpIds: string, deviceId: string) => Promise<un
65
65
  export declare const formatNumber: (num: number, fixed: number, shoGroup?: boolean) => string;
66
66
  export declare const getTimeZone: () => string;
67
67
  export declare const getSystemTimeFormat: () => Promise<number>;
68
+ export declare const getMicrophoneAccess: () => Promise<boolean>;
68
69
  export {};
package/src/api/native.ts CHANGED
@@ -21,6 +21,7 @@ interface LDVDevicePanelManager {
21
21
  putFeature: (deviceId: string, featureId: string, value: any, callback: (res: NativeResult<string>) => void) => void
22
22
  getGroupDevices: (tyGroupId: number) => Promise<NativeResult<string>>
23
23
  getSystemTimeFormat: () => Promise<number>
24
+ getMicrophoneAccess: (res:any) => Promise<Result<any>>
24
25
  }
25
26
 
26
27
  export enum UADeviceCategory {
@@ -350,3 +351,15 @@ export const getSystemTimeFormat = async (): Promise<number> => {
350
351
  return 24
351
352
  }
352
353
  }
354
+
355
+ export const getMicrophoneAccess: () => Promise<boolean> = () => {
356
+ return new Promise((resolve, _reject) => {
357
+ devicePanel.getMicrophoneAccess(res => {
358
+ const haveAuthority = (typeof res?.data === 'string') ? !!res?.data && JSON.parse(res?.data)?.haveAuthority : res?.data?.haveAuthority
359
+ if(!res.result || (res.result && haveAuthority !== 'granted')){
360
+ resolve(false)
361
+ }
362
+ resolve(true)
363
+ })
364
+ })
365
+ }
@@ -1,16 +1,19 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { ViewProps } from 'react-native';
1
3
  export declare type Node = {
2
4
  color: string;
3
5
  backgroundColor?: string;
4
6
  };
5
- interface DrawToolViewProps {
7
+ interface DrawToolViewProps extends PropsWithChildren<ViewProps> {
6
8
  switchLed?: boolean;
7
9
  showEnable?: boolean;
8
10
  setEnable: (enable: boolean) => void;
9
- adjustType?: number;
11
+ adjustType?: 1 | 2 | 3;
10
12
  setAdjustType: (type: number) => void;
11
13
  stripStyle?: 'ONLY_LINE' | 'WITH_BEAD';
12
14
  nodes: Node[];
13
15
  fixCount?: number;
16
+ touchingMode?: 'CLICK' | 'TOUCH';
14
17
  nodeTouch: (idx: number) => void;
15
18
  fingerUp: (idxList: string) => void;
16
19
  hideLightView?: boolean;
@@ -1,34 +1,36 @@
1
- import React, { useMemo, useEffect, useCallback } from 'react'
2
- import { View, Text, StyleSheet, TouchableOpacity, Image } from 'react-native'
3
- import { Utils, Modal } from 'tuya-panel-kit'
4
- import { useReactive } from "ahooks"
5
- import Card from "@ledvance/base/src/components/Card"
6
- import res from '@ledvance/base/src/res'
7
- import I18n from '@ledvance/base/src/i18n'
8
- import LdvSwitch from '@ledvance/base/src/components/ldvSwitch'
9
- import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
10
- import { hsv2Hex, mapFloatToRange } from '@ledvance/base/src/utils'
11
- import Spacer from "@ledvance/base/src/components/Spacer"
12
- import DeleteButton from "@ledvance/base/src/components/DeleteButton"
13
- import Stepper from '@ledvance/base/src/components/Stepper'
14
- const { convertX: cx } = Utils.RatioUtils
1
+ import React, { PropsWithChildren, useCallback, useEffect, useMemo } from 'react'
2
+ import { Image, StyleSheet, Text, TouchableOpacity, View, ViewProps } from 'react-native'
3
+ import { Modal, Utils } from 'tuya-panel-kit'
4
+ import { useReactive } from 'ahooks'
5
+ import Card from './Card'
6
+ import res from '@res'
7
+ import I18n from '@i18n'
8
+ import LdvSwitch from './ldvSwitch'
9
+ import LampAdjustView from './LampAdjustView'
10
+ import { hsv2Hex, mapFloatToRange } from '@utils'
11
+ import Spacer from './Spacer'
12
+ import DeleteButton from './DeleteButton'
13
+ import Stepper from './Stepper'
15
14
  import StripLightView from './StripLightView'
16
- import { nativeEventEmitter} from '@ledvance/base/src/api/nativeEventEmitter'
15
+ import { nativeEventEmitter } from '../api/nativeEventEmitter'
16
+
17
+ const { convertX: cx } = Utils.RatioUtils
17
18
 
18
19
  export type Node = {
19
20
  color: string,
20
21
  backgroundColor?: string
21
22
  }
22
23
 
23
- interface DrawToolViewProps {
24
+ interface DrawToolViewProps extends PropsWithChildren<ViewProps> {
24
25
  switchLed?: boolean
25
26
  showEnable?: boolean
26
27
  setEnable: (enable: boolean) => void
27
- adjustType?: number // 1 全选, 2 单选, 3 擦除
28
+ adjustType?: 1 | 2 | 3 // 1 全选, 2 单选, 3 擦除
28
29
  setAdjustType: (type: number) => void
29
30
  stripStyle?: 'ONLY_LINE' | 'WITH_BEAD'
30
31
  nodes: Node[]
31
32
  fixCount?: number
33
+ touchingMode?: 'CLICK' | 'TOUCH'
32
34
  nodeTouch: (idx: number) => void
33
35
  fingerUp: (idxList: string) => void
34
36
  hideLightView?: boolean
@@ -52,11 +54,12 @@ interface DrawToolViewProps {
52
54
  ledNum?: number
53
55
  setLedNum: (num: number) => void
54
56
  }
57
+
55
58
  const DrawToolView = (props: DrawToolViewProps) => {
56
59
  const state = useReactive({
57
60
  visible: false,
58
61
  ledNum: props.ledNum || 5,
59
- width: 0
62
+ width: 0,
60
63
  })
61
64
 
62
65
  useEffect(() => {
@@ -69,7 +72,7 @@ const DrawToolView = (props: DrawToolViewProps) => {
69
72
  }
70
73
  }, [])
71
74
 
72
- const onLayout = (event) => {
75
+ const onLayout = (event: any) => {
73
76
  const { width } = event.nativeEvent.layout
74
77
  state.width = width
75
78
  }
@@ -86,125 +89,129 @@ const DrawToolView = (props: DrawToolViewProps) => {
86
89
  return '#ffffff'
87
90
  }, [props.isColorMode, props.h, props.s])
88
91
 
89
- return <Card style={{ marginHorizontal: cx(24) }}>
90
- <LdvSwitch
91
- title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
92
- color={'#fff'}
93
- colorAlpha={1}
94
- enable={!!props.switchLed}
95
- showSwitch={!!props.showEnable}
96
- setEnable={props.setEnable}
97
- />
98
- {(props.showEnable && props.switchLed || !props.showEnable) && <>
99
- <View style={styles.container}>
100
- <View style={styles.adjustButtons}>
101
- <TouchableOpacity
102
- onPress={() => {
103
- props.setAdjustType(1)
104
- }}>
105
- <Image
106
- style={[styles.adjustButton, { tintColor: props.adjustType === 1 ? '#f60' : '#666' }]}
107
- source={res.ic_paint_bucket} />
108
- </TouchableOpacity>
109
- <TouchableOpacity
110
- onPress={() => {
111
- props.setAdjustType(3)
112
- }}>
113
- <Image
114
- style={[styles.adjustButton, { tintColor: props.adjustType === 3 ? '#f60' : '#666' }]}
115
- source={res.ic_disabled_light} />
116
- </TouchableOpacity>
117
- <TouchableOpacity
118
- onPress={() => {
119
- props.setAdjustType(2)
120
- }}>
121
- <Image
122
- style={[styles.adjustButton, { tintColor: props.adjustType === 2 ? '#f60' : '#666' }]}
123
- source={res.ic_colorize} />
124
- </TouchableOpacity>
125
- {!props.hideLedNum && <TouchableOpacity
126
- onPress={() => {
127
- state.visible = true
128
- }}
129
- style={[styles.adjustButton, { alignItems: 'center', justifyContent: 'center', backgroundColor: '#f60', borderRadius: cx(5) }]}>
130
- <Text style={{ color: '#fff', fontSize: cx(18), fontWeight: 'bold' }}>{props.ledNum || 5}</Text>
131
- </TouchableOpacity>}
132
- </View>
133
- <StripLightView
134
- style={{ height, flex: 1 }}
135
- nodes={JSON.stringify(props.nodes)}
136
- fixCount={props.fixCount || 5}
137
- stripStyle={props.stripStyle || 'WITH_BEAD'}
138
- width={state.width}
139
- onLayout={onLayout}
140
- />
141
- </View>
92
+ return (
93
+ <Card style={{ marginHorizontal: cx(24) }}>
142
94
  <LdvSwitch
143
- title={I18n.getLang('add_new_dynamic_mood_lights_field_headline2_text')}
144
- color={getBlockColor()}
95
+ title={I18n.getLang('light_sources_tile_tw_lighting_headline')}
96
+ color={'#fff'}
145
97
  colorAlpha={1}
146
- enable={false}
147
- showSwitch={false}
148
- setEnable={() => { }}
149
- />
150
- <LampAdjustView
151
- isSupportColor={!!props.isSupportColor}
152
- isSupportTemperature={!!props.isSupportTemperature}
153
- isSupportBrightness={!!props.isSupportBrightness}
154
- isColorMode={!!props.isColorMode}
155
- reserveSV={true}
156
- setIsColorMode={props.setIsColorMode}
157
- h={props.h} s={props.s} v={props.v}
158
- onHSVChange={props.onHSVChange}
159
- onHSVChangeComplete={props.onHSVChangeComplete}
160
- colorTemp={props.temperature}
161
- brightness={props.brightness}
162
- onCCTChange={props.onCCTChange}
163
- onCCTChangeComplete={props.onCCTChangeComplete}
164
- onBrightnessChange={props.onBrightnessChange}
165
- onBrightnessChangeComplete={props.onBrightnessChangeComplete} />
166
- {!props.hideLedNum && <Modal
167
- visible={state.visible}
168
- onMaskPress={() => {
169
- state.visible = false
170
- }}
171
- alignContainer='center'
172
- style={{ width: '100%', height: cx(100) }}
173
- >
174
- <Card style={{ marginHorizontal: cx(24), marginTop: cx(50), alignItems: 'center' }}>
175
- <Spacer />
176
- <Stepper
177
- min={5}
178
- max={48}
179
- stepValue={1}
180
- editable={true}
181
- value={state.ledNum}
182
- onValueChange={(v) => {
183
- state.ledNum = v
184
- }}
185
- />
186
- <Spacer />
187
- <DeleteButton
188
- text={I18n.getLang('auto_scan_system_wifi_confirm')}
189
- style={{ width: cx(150), height: cx(40), backgroundColor: '#f60' }}
190
- textStyle={{ fontSize: cx(14) }}
191
- onPress={() => {
192
- props.setLedNum(state.ledNum)
98
+ enable={!!props.switchLed}
99
+ showSwitch={!!props.showEnable}
100
+ setEnable={props.setEnable}/>
101
+ {(props.showEnable && props.switchLed || !props.showEnable) && <>
102
+ <View style={styles.container}>
103
+ <View style={styles.adjustButtons}>
104
+ <TouchableOpacity
105
+ onPress={() => {
106
+ props.setAdjustType(1)
107
+ }}>
108
+ <Image
109
+ style={[styles.adjustButton, { tintColor: props.adjustType === 1 ? '#f60' : '#666' }]}
110
+ source={res.ic_paint_bucket}/>
111
+ </TouchableOpacity>
112
+ <TouchableOpacity
113
+ onPress={() => {
114
+ props.setAdjustType(3)
115
+ }}>
116
+ <Image
117
+ style={[styles.adjustButton, { tintColor: props.adjustType === 3 ? '#f60' : '#666' }]}
118
+ source={res.ic_disabled_light}/>
119
+ </TouchableOpacity>
120
+ <TouchableOpacity
121
+ onPress={() => {
122
+ props.setAdjustType(2)
123
+ }}>
124
+ <Image
125
+ style={[styles.adjustButton, { tintColor: props.adjustType === 2 ? '#f60' : '#666' }]}
126
+ source={res.ic_colorize}/>
127
+ </TouchableOpacity>
128
+ {!props.hideLedNum && <TouchableOpacity
129
+ onPress={() => {
130
+ state.visible = true
131
+ }}
132
+ style={[styles.adjustButton, {
133
+ alignItems: 'center',
134
+ justifyContent: 'center',
135
+ backgroundColor: '#f60',
136
+ borderRadius: cx(5),
137
+ }]}>
138
+ <Text style={{ color: '#fff', fontSize: cx(18), fontWeight: 'bold' }}>{props.ledNum || 5}</Text>
139
+ </TouchableOpacity>}
140
+ </View>
141
+ <StripLightView
142
+ style={{ height, flex: 1 }}
143
+ nodes={props.nodes}
144
+ fixCount={props.fixCount || 5}
145
+ stripStyle={props.stripStyle || 'WITH_BEAD'}
146
+ touchingMode={props.touchingMode || 'TOUCH'}
147
+ width={state.width}
148
+ onLayout={onLayout}/>
149
+ </View>
150
+ <LdvSwitch
151
+ title={I18n.getLang('add_new_dynamic_mood_lights_field_headline2_text')}
152
+ color={getBlockColor()}
153
+ colorAlpha={1}
154
+ enable={false}
155
+ showSwitch={false}
156
+ setEnable={() => {
157
+ }}/>
158
+ <LampAdjustView
159
+ isSupportColor={!!props.isSupportColor}
160
+ isSupportTemperature={!!props.isSupportTemperature}
161
+ isSupportBrightness={!!props.isSupportBrightness}
162
+ isColorMode={!!props.isColorMode}
163
+ reserveSV={true}
164
+ setIsColorMode={props.setIsColorMode}
165
+ h={props.h} s={props.s} v={props.v}
166
+ onHSVChange={props.onHSVChange}
167
+ onHSVChangeComplete={props.onHSVChangeComplete}
168
+ colorTemp={props.temperature}
169
+ brightness={props.brightness}
170
+ onCCTChange={props.onCCTChange}
171
+ onCCTChangeComplete={props.onCCTChangeComplete}
172
+ onBrightnessChange={props.onBrightnessChange}
173
+ onBrightnessChangeComplete={props.onBrightnessChangeComplete}/>
174
+ {!props.hideLedNum && <Modal
175
+ visible={state.visible}
176
+ onMaskPress={() => {
193
177
  state.visible = false
194
178
  }}
195
- />
196
- <Spacer />
197
- </Card>
198
- </Modal>}
199
- </>}
200
- </Card>
179
+ alignContainer="center"
180
+ style={{ width: '100%', height: cx(100) }}>
181
+ <Card style={{ marginHorizontal: cx(24), marginTop: cx(50), alignItems: 'center' }}>
182
+ <Spacer/>
183
+ <Stepper
184
+ min={5}
185
+ max={48}
186
+ stepValue={1}
187
+ editable={true}
188
+ value={state.ledNum}
189
+ onValueChange={(v) => {
190
+ state.ledNum = v
191
+ }}/>
192
+ <Spacer/>
193
+ <DeleteButton
194
+ text={I18n.getLang('auto_scan_system_wifi_confirm')}
195
+ style={{ width: cx(150), height: cx(40), backgroundColor: '#f60' }}
196
+ textStyle={{ fontSize: cx(14) }}
197
+ onPress={() => {
198
+ props.setLedNum(state.ledNum)
199
+ state.visible = false
200
+ }}/>
201
+ <Spacer/>
202
+ </Card>
203
+ </Modal>}
204
+ {props.children}
205
+ </>}
206
+ </Card>
207
+ )
201
208
  }
202
209
 
203
210
  const styles = StyleSheet.create({
204
211
  container: {
205
212
  paddingLeft: cx(10),
206
213
  flexDirection: 'row',
207
- alignItems: 'center'
214
+ alignItems: 'center',
208
215
  },
209
216
  title: {
210
217
  color: '#000',
@@ -214,12 +221,12 @@ const styles = StyleSheet.create({
214
221
  fontWeight: 'bold',
215
222
  },
216
223
  adjustButtons: {
217
- width: cx(50)
224
+ width: cx(50),
218
225
  },
219
226
  adjustButton: {
220
227
  width: cx(44),
221
- height: cx(44)
222
- }
228
+ height: cx(44),
229
+ },
223
230
  })
224
231
 
225
232
  export default DrawToolView
@@ -1,2 +1,14 @@
1
- declare const StripLightView: any;
1
+ import { ViewProps } from 'react-native';
2
+ export interface LightNode {
3
+ color: string;
4
+ backgroundColor?: string;
5
+ }
6
+ export interface StripLightViewProps extends ViewProps {
7
+ nodes: LightNode[];
8
+ fixCount: number;
9
+ stripStyle: 'ONLY_LINE' | 'WITH_BEAD';
10
+ touchingMode?: 'CLICK' | 'TOUCH';
11
+ width: number;
12
+ }
13
+ declare const StripLightView: (props: StripLightViewProps) => JSX.Element;
2
14
  export default StripLightView;
@@ -0,0 +1,25 @@
1
+ import { requireNativeComponent, ViewProps } from 'react-native'
2
+ import React from 'react-redux/node_modules/@types/react'
3
+
4
+ const NativeStripLightView = requireNativeComponent('StripLightView')
5
+
6
+ export interface LightNode {
7
+ color: string
8
+ backgroundColor?: string
9
+ }
10
+
11
+ export interface StripLightViewProps extends ViewProps {
12
+ nodes: LightNode[]
13
+ fixCount: number
14
+ stripStyle: 'ONLY_LINE' | 'WITH_BEAD'
15
+ touchingMode?: 'CLICK' | 'TOUCH'
16
+ width: number
17
+ }
18
+
19
+ const StripLightView = (props: StripLightViewProps) => {
20
+ return (
21
+ <NativeStripLightView {...props} nodes={JSON.stringify(props.nodes)}/>
22
+ )
23
+ }
24
+
25
+ export default StripLightView
@@ -1,4 +0,0 @@
1
- import { requireNativeComponent } from 'react-native'
2
- const StripLightView = requireNativeComponent('StripLightView');
3
-
4
- export default StripLightView