@ledvance/base 1.2.17 → 1.2.18

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.17",
7
+ "version": "1.2.18",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@reduxjs/toolkit": "^1.8.6",
@@ -0,0 +1,131 @@
1
+ import React from "react";
2
+ import { FlatList, TouchableOpacity, View, Image } from "react-native";
3
+ import ColorAdjustView, { ColorAdjustViewProps } from "@ledvance/base/src/components/ColorAdjustView";
4
+ import ColorTempAdjustView, { ColorTempAdjustViewProps } from "@ledvance/base/src/components/ColorTempAdjustView";
5
+ import Spacer from "@ledvance/base/src/components/Spacer";
6
+ import { TabBar, Utils } from "tuya-panel-kit";
7
+ import { ColorDisk } from "@tuya/tuya-panel-lamp-sdk";
8
+ import res from "@ledvance/base/src/res";
9
+ const { convertX: cx } = Utils.RatioUtils
10
+
11
+ type TabsNode = {
12
+ key: number | string
13
+ title: string
14
+ }
15
+ interface StripAdjustViewProps extends ColorAdjustViewProps, ColorTempAdjustViewProps {
16
+ lampTabs: TabsNode[]
17
+ activeKey: number | string
18
+ onActiveKeyChange: (key: number | string) => void
19
+ colorDiskActiveKey? : number | undefined
20
+ onColorDiskChange?: (color: string[], idx: number) => void
21
+ }
22
+
23
+ const StripAdjustView = (props: StripAdjustViewProps) => {
24
+ return (
25
+ <View>
26
+ <TabBar
27
+ type='radio'
28
+ tabs={props.lampTabs}
29
+ style={{ borderRadius: cx(8), backgroundColor: '#f6f6f6', height: cx(40), marginHorizontal: cx(16) }}
30
+ tabTextStyle={{ color: '#000' }}
31
+ tabActiveTextStyle={{ color: '#000', fontWeight: 'bold' }}
32
+ activeKey={props.activeKey}
33
+ onChange={props.onActiveKeyChange}
34
+ />
35
+ {
36
+ props.activeKey === 1 &&
37
+ <>
38
+ <Spacer height={cx(10)} />
39
+ <ColorAdjustView
40
+ h={props.h}
41
+ s={props.s}
42
+ v={props.v}
43
+ minBrightness={0}
44
+ minSaturation={1}
45
+ reserveSV={true}
46
+ onHSVChange={props.onHSVChange}
47
+ onHSVChangeComplete={props.onHSVChangeComplete} />
48
+ <Spacer />
49
+ </>
50
+ }
51
+ {
52
+ props.activeKey === 0 &&
53
+ <>
54
+ <Spacer height={cx(10)} />
55
+ <ColorTempAdjustView
56
+ minBrightness={1}
57
+ isSupportTemperature={props.isSupportTemperature}
58
+ isSupportBrightness={props.isSupportBrightness}
59
+ colorTemp={props.colorTemp}
60
+ brightness={props.brightness}
61
+ onCCTChange={props.onCCTChange}
62
+ onCCTChangeComplete={props.onCCTChangeComplete}
63
+ onBrightnessChange={props.onBrightnessChange}
64
+ onBrightnessChangeComplete={props.onBrightnessChangeComplete} />
65
+ <Spacer />
66
+ </>
67
+ }
68
+ {
69
+ props.activeKey === 3 &&
70
+ <FlatList
71
+ numColumns={6}
72
+ style={{
73
+ marginHorizontal: cx(16),
74
+ }}
75
+ data={ColorList}
76
+ renderItem={({ item, index }) => {
77
+ return (
78
+ <TouchableOpacity
79
+ onPress={() => {
80
+ props.onColorDiskChange && props.onColorDiskChange(item, index)
81
+ }}
82
+ style={{
83
+ width: '16.66%', alignItems: 'center',
84
+ justifyContent: 'center',
85
+ }}>
86
+ <ColorDisk
87
+ radius={cx(20)}
88
+ colors={item}
89
+ />
90
+ {props.colorDiskActiveKey === index && <View style={{ width: cx(44), height: cx(44), borderRadius: cx(44), borderColor: '#f60', borderWidth: cx(2), alignItems: 'center', justifyContent: 'center', position: 'absolute' }}>
91
+ <Image source={{ uri: res.ic_check }} style={{ width: cx(40), height: cx(40), tintColor: '#fff' }} />
92
+ </View>}
93
+ </TouchableOpacity>
94
+ )
95
+ }}
96
+ ListHeaderComponent={() => <Spacer height={cx(10)} />}
97
+ ItemSeparatorComponent={() => <Spacer height={cx(10)} />}
98
+ ListFooterComponent={() => <Spacer height={cx(10)} />}
99
+ keyExtractor={(_, idx) => idx.toString()}
100
+ />
101
+ }
102
+ </View>
103
+ )
104
+ }
105
+
106
+ export default StripAdjustView
107
+
108
+ export const ColorList = [
109
+ ['#F4A4BF', '#F65997','#F5075A','#F52071'],
110
+ ['#E393FE','#E294FE','#94E3FC','#A7C5FF'],
111
+ ['#2661FC', '#4D21B2','#F5085A','#FDFB42'],
112
+ ['#F66252','#F9B241', '#41C6FC','#E5EF66'],
113
+ ['#CBF0FF','#94E3FC','#41C6FC','#52D6FB'],
114
+ ['#76BC41','#95D35F','#F1F6B6','#B2DD8D'],
115
+ ['#76BC41','#D9EC39','#F66B05','#F9AB03'],
116
+ ['#F54019','#F66B05','#76BC41','#F9AA04'],
117
+ ['#4D21B2','#2661FC','#FDF76C','#BD39F4'],
118
+ ['#B18DFD','#8550FB','#4D21B2','#5E30E9'],
119
+ ['#F9AB03','#F9B241','#FCD9A7','#FAC678'],
120
+ ['#F9AC02','#41C6FC','#F54019','#5E30E9'],
121
+ ['#B2DD8D','#52D6FB','#8550FB','#41C6FC'],
122
+ ['#9A2ABD','#F65997','#F5085A','#F66B05','#FDFB42'],
123
+ ['#4D21B2','#5E30E9','#8550FB','#B18DFD','#D9C9FF'],
124
+ ['#F77370','#F65250','#F53B3C','#F52929','#F50204'],
125
+ ['#2660FC','#76A7FE','#FAC678','#F9AB03','#F66B05'],
126
+ ['#E294FE','#FDF76C','#95D35F','#52D6FB','#B18DFD'],
127
+ ['#3B88FD','#5E30E9','#F50821','#F66B05','#F9AB03'],
128
+ ['#76BC41','#95D35F','#B2DD8D','#D9EC39','#E8F291'],
129
+ ['#52D6FB','#F9B241','#F66B05','#D356FC','#9A2ABD'],
130
+ ['#F9AEC7','#F88ABA','#F65590','#F65C79','#F64A49', '#F50803'],
131
+ ]