@ledvance/base 1.2.4 → 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
|
@@ -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)
|
package/src/components/Page.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, {PropsWithChildren, useCallback, useEffect} from 'react'
|
|
2
|
-
import {BackHandler, View, ViewProps} from 'react-native'
|
|
1
|
+
import React, { PropsWithChildren, useCallback, useEffect } from 'react'
|
|
2
|
+
import { BackHandler, View, ViewProps } from 'react-native'
|
|
3
3
|
import LDVTopBar from './ldvTopBar'
|
|
4
|
-
import {useNavigation} from '@react-navigation/native'
|
|
5
|
-
import {Dialog, Toast} from 'tuya-panel-kit'
|
|
4
|
+
import { useNavigation } from '@react-navigation/native'
|
|
5
|
+
import { Dialog, Toast } from 'tuya-panel-kit'
|
|
6
6
|
import I18n from '@i18n'
|
|
7
7
|
import LdvTopName from './ldvTopName'
|
|
8
8
|
|
|
@@ -38,14 +38,14 @@ const Page = (props: PageProps) => {
|
|
|
38
38
|
subTitle: props.backDialogContent || '',
|
|
39
39
|
cancelText: I18n.getLang('cancel_dialog_delete_item_sleepschedule_answer_no_text'),
|
|
40
40
|
confirmText: I18n.getLang('cancel_dialog_delete_item_sleepschedule_answer_yes_text'),
|
|
41
|
-
onConfirm: (_, {close}) => {
|
|
41
|
+
onConfirm: (_, { close }) => {
|
|
42
42
|
close()
|
|
43
43
|
navigation.goBack()
|
|
44
44
|
},
|
|
45
|
-
motionConfig:{
|
|
45
|
+
motionConfig: {
|
|
46
46
|
hideDuration: 0,
|
|
47
|
-
showDuration: 100
|
|
48
|
-
}
|
|
47
|
+
showDuration: 100,
|
|
48
|
+
},
|
|
49
49
|
})
|
|
50
50
|
return true
|
|
51
51
|
},
|
|
@@ -63,7 +63,7 @@ const Page = (props: PageProps) => {
|
|
|
63
63
|
|
|
64
64
|
return (
|
|
65
65
|
<>
|
|
66
|
-
<View style={[{flex: 1, position: 'relative'}, props.style]}>
|
|
66
|
+
<View style={[{ flex: 1, position: 'relative' }, props.style]}>
|
|
67
67
|
<LDVTopBar
|
|
68
68
|
title={props.backText}
|
|
69
69
|
onBackPress={
|
|
@@ -77,16 +77,17 @@ const Page = (props: PageProps) => {
|
|
|
77
77
|
onRightButtonPress={props.rightButtonIconClick}
|
|
78
78
|
rightButtonDisabled={disabled}/>
|
|
79
79
|
{(!!props.headlineText) &&
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
<LdvTopName
|
|
81
|
+
title={props.headlineText}
|
|
82
|
+
rightIcon={props.headlineIcon}
|
|
83
|
+
rightIconClick={props.onHeadlineIconClick}
|
|
84
|
+
showGreenery={props.showGreenery}
|
|
85
|
+
greeneryIcon={props.greeneryIcon}/>}
|
|
86
86
|
{props.children}
|
|
87
87
|
</View>
|
|
88
88
|
{!!props.loading && <Toast.Loading
|
|
89
|
-
|
|
89
|
+
style={{ zIndex: 999, elevation: 10 }}
|
|
90
|
+
show={props.loading}
|
|
90
91
|
onFinish={() => {
|
|
91
92
|
|
|
92
93
|
}}/>}
|