@ledvance/base 1.2.5 → 1.2.6

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.2.5",
7
+ "version": "1.2.6",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@reduxjs/toolkit": "^1.8.6",
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ export interface HSV {
3
+ h: number;
4
+ s: number;
5
+ v: number;
6
+ }
7
+ interface LampConfigViewProps {
8
+ isSupportColor: boolean;
9
+ isSupportCCT: boolean;
10
+ isSupportBrightness: boolean;
11
+ isColorMode: boolean;
12
+ setIsColorMode: (isColorMode: boolean) => void;
13
+ minBrightness?: number;
14
+ minSaturation?: number;
15
+ reserveSV?: boolean;
16
+ hsv: HSV;
17
+ onHSVChange: (hsv: HSV, isComplete: boolean) => void;
18
+ cct: number;
19
+ onCCTChange: (cct: number, isComplete: boolean) => void;
20
+ brightness: number;
21
+ onBrightnessChange: (brightness: number, isComplete: boolean) => void;
22
+ }
23
+ declare const _default: React.MemoExoticComponent<(props: LampConfigViewProps) => JSX.Element>;
24
+ export default _default;
@@ -0,0 +1,105 @@
1
+ import { StyleSheet, View } from 'react-native'
2
+ import React, { memo } from 'react'
3
+ import { Utils } from 'tuya-panel-kit'
4
+ import { useReactive } from 'ahooks'
5
+ import Spacer from './Spacer'
6
+ import ColorAdjustView from './ColorAdjustView'
7
+ import ColorTempAdjustView from './ColorTempAdjustView'
8
+ import SegmentControl from './segmentControl'
9
+ import I18n from '../i18n/index'
10
+
11
+ const { convertX: cx } = Utils.RatioUtils
12
+
13
+ export interface HSV {
14
+ h: number
15
+ s: number
16
+ v: number
17
+ }
18
+
19
+ interface LampConfigViewProps {
20
+ isSupportColor: boolean
21
+ isSupportCCT: boolean
22
+ isSupportBrightness: boolean
23
+ isColorMode: boolean
24
+ setIsColorMode: (isColorMode: boolean) => void
25
+ minBrightness?: number // 最小亮度
26
+ minSaturation?: number // 最小Saturation
27
+ reserveSV?: boolean // 保留 s v
28
+ hsv: HSV
29
+ onHSVChange: (hsv: HSV, isComplete: boolean) => void
30
+ cct: number
31
+ onCCTChange: (cct: number, isComplete: boolean) => void
32
+ brightness: number
33
+ onBrightnessChange: (brightness: number, isComplete: boolean) => void
34
+ }
35
+
36
+ const LampAdjustView2 = (props: LampConfigViewProps) => {
37
+
38
+ const state = useReactive({
39
+ hasSegmentControl: props.isSupportColor && (props.isSupportBrightness || props.isSupportCCT),
40
+ })
41
+
42
+ return (
43
+ <View>
44
+ {state.hasSegmentControl &&
45
+ <SegmentControl
46
+ style={styles.segmentControl}
47
+ title1={I18n.getLang('light_sources_tile_rgb_lighting_tab_color')}
48
+ title2={I18n.getLang('light_sources_tile_rgb_lighting_tab_white')}
49
+ isFirst={props.isColorMode}
50
+ setIsFirst={props.setIsColorMode}/>
51
+ }
52
+ {((state.hasSegmentControl && props.isColorMode) || (!state.hasSegmentControl && props.isSupportColor)) &&
53
+ <>
54
+ {state.hasSegmentControl && <Spacer height={cx(10)}/>}
55
+ <ColorAdjustView
56
+ h={props.hsv.h}
57
+ s={props.hsv.s}
58
+ v={props.hsv.v}
59
+ minBrightness={props.minBrightness}
60
+ minSaturation={props.minSaturation}
61
+ reserveSV={props.reserveSV}
62
+ onHSVChange={(h, s, v) => {
63
+ props.onHSVChange({ h, s, v }, false)
64
+ }}
65
+ onHSVChangeComplete={(h, s, v) => {
66
+ props.onHSVChange({ h, s, v }, true)
67
+ }}/>
68
+ <Spacer/>
69
+ </>
70
+ }
71
+ {((state.hasSegmentControl && !props.isColorMode) || (!state.hasSegmentControl && (props.isSupportBrightness || props.isSupportCCT))) &&
72
+ <>
73
+ {state.hasSegmentControl && <Spacer height={cx(10)}/>}
74
+ <ColorTempAdjustView
75
+ minBrightness={props.minBrightness}
76
+ isSupportTemperature={props.isSupportCCT}
77
+ isSupportBrightness={props.isSupportBrightness}
78
+ colorTemp={props.cct}
79
+ brightness={props.brightness}
80
+ onCCTChange={cct => {
81
+ props.onCCTChange(cct, false)
82
+ }}
83
+ onCCTChangeComplete={cct => {
84
+ props.onCCTChange(cct, true)
85
+ }}
86
+ onBrightnessChange={brightness => {
87
+ props.onBrightnessChange(brightness, false)
88
+ }}
89
+ onBrightnessChangeComplete={brightness => {
90
+ props.onBrightnessChange(brightness, true)
91
+ }}/>
92
+ <Spacer/>
93
+ </>
94
+ }
95
+ </View>
96
+ )
97
+ }
98
+
99
+ const styles = StyleSheet.create({
100
+ segmentControl: {
101
+ marginHorizontal: cx(16),
102
+ },
103
+ })
104
+
105
+ export default memo(LampAdjustView2)