@ledvance/base 1.2.77 → 1.2.79

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.
@@ -3,8 +3,10 @@ import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native'
3
3
  import {Utils} from 'tuya-panel-kit'
4
4
 
5
5
  const cx = Utils.RatioUtils.convertX
6
+ const { withTheme } = Utils.ThemeUtils
6
7
 
7
8
  interface LdvTopNameProps {
9
+ theme?: any
8
10
  title: string,
9
11
  rightIcon?: string | undefined | number,
10
12
  rightIconClick?: () => void
@@ -16,6 +18,17 @@ interface LdvTopNameProps {
16
18
  const LdvTopName = (props: LdvTopNameProps) => {
17
19
  const rightIcon = typeof props.rightIcon === 'number' ? props.rightIcon : {uri: props.rightIcon}
18
20
  const greeneryIcon = typeof props.greeneryIcon === 'number' ? props.greeneryIcon : {uri: props.greeneryIcon}
21
+
22
+ const styles = StyleSheet.create({
23
+ container: {
24
+ marginHorizontal: cx(24),
25
+ marginBottom: cx(12),
26
+ },
27
+ title: {
28
+ color: props.theme.global.brand,
29
+ fontSize: cx(24),
30
+ },
31
+ })
19
32
  return (
20
33
  <View style={styles.container}>
21
34
  <View
@@ -38,7 +51,7 @@ const LdvTopName = (props: LdvTopNameProps) => {
38
51
  {props.rightIcon && <TouchableOpacity
39
52
  onPress={props.rightIconClick}>
40
53
  <Image
41
- style={{width: cx(24), height: cx(24), tintColor: '#ff6600'}}
54
+ style={{width: cx(24), height: cx(24), tintColor: props.theme.global.brand}}
42
55
  source={rightIcon}/>
43
56
  </TouchableOpacity>}
44
57
  {props.headlineContent && props.headlineContent}
@@ -47,15 +60,4 @@ const LdvTopName = (props: LdvTopNameProps) => {
47
60
  )
48
61
  }
49
62
 
50
- const styles = StyleSheet.create({
51
- container: {
52
- marginHorizontal: cx(24),
53
- marginBottom: cx(12),
54
- },
55
- title: {
56
- color: '#f60',
57
- fontSize: cx(24),
58
- },
59
- })
60
-
61
- export default LdvTopName
63
+ export default withTheme(LdvTopName)
@@ -4,6 +4,7 @@ import {Utils} from 'tuya-panel-kit'
4
4
  import I18n from '../i18n/index'
5
5
 
6
6
  const cx = Utils.RatioUtils.convertX
7
+ const { withTheme } = Utils.ThemeUtils
7
8
 
8
9
  const repeatPeriod = [
9
10
  {
@@ -46,7 +47,7 @@ export const setDataSource = (loop) => {
46
47
  })
47
48
  }
48
49
 
49
- export default (props) => {
50
+ const WeekSelect = (props) => {
50
51
 
51
52
  const {value, onSelect, style} = props
52
53
  const dataSource = setDataSource(value)
@@ -74,15 +75,15 @@ export default (props) => {
74
75
  justifyContent: 'center',
75
76
  alignItems: 'center',
76
77
  borderRadius: cx(20),
77
- backgroundColor: period.enabled ? '#ffe0d4' : '#fff',
78
+ backgroundColor: period.enabled ? props.theme.global.thirdBrand : props.theme.global.background,
78
79
  borderWidth: cx(1),
79
80
  // borderColor: period.enabled ? "#fff" : 'rgba(120, 120, 128, 0.2)'
80
- borderColor: '#f60',
81
+ borderColor: props.theme.global.brand,
81
82
  }}>
82
83
 
83
84
  <Text
84
85
  style={{
85
- color: '#f60',
86
+ color: props.theme.global.brand,
86
87
  textAlign: 'center',
87
88
  }}>{period.title}</Text>
88
89
  </View>
@@ -92,4 +93,6 @@ export default (props) => {
92
93
  </View>
93
94
 
94
95
  </View>)
95
- }
96
+ }
97
+
98
+ export default withTheme(WeekSelect)
@@ -3,7 +3,7 @@ import React, { Component } from 'react'
3
3
  import { Provider } from 'react-redux'
4
4
  import { DevInfo, DpValue, Theme, TYSdk } from 'tuya-panel-kit'
5
5
  import { actions, store } from './models'
6
- import { addListener, removeListener } from 'api/nativeEventEmitter'
6
+ import {addListener, nativeEventEmitter, removeListener} from 'api/nativeEventEmitter'
7
7
  import {getSystemTimeFormat, getTimeZone, NativeApi} from 'api/native'
8
8
  import {
9
9
  DeviceInfo,
@@ -17,12 +17,15 @@ import {
17
17
  } from './models/modules/NativePropsSlice'
18
18
  import { DpSchema, GlobalParams } from './models/GlobalParams'
19
19
  import Connect from './components/connect'
20
+ import darkTheme from "./config/dark-theme";
21
+ import lightTheme from "./config/light-theme";
20
22
 
21
23
  interface Props {
22
24
  devInfo: DevInfo
23
25
  preload?: boolean
24
26
  ldvDevInfo: LdvDevInfo
25
27
  uaGroupInfo: UAGroupInfoProps
28
+ colorScheme?: string
26
29
  }
27
30
 
28
31
  interface LdvDevInfo extends DeviceInfo {
@@ -40,14 +43,6 @@ interface UAGroupInfoProps extends UAGroupInfo {
40
43
  const TYEvent = TYSdk.event
41
44
  const TYDevice = TYSdk.device
42
45
 
43
- const theme = {
44
- global: {
45
- background: '#fff',
46
- },
47
- ldvMainBgColor: '#f60',
48
- 'slider.trackRadius': 15,
49
- }
50
-
51
46
  /**
52
47
  *
53
48
  * @param {} component - 需要连接到redux store的组件,通常为即为main
@@ -93,6 +88,9 @@ const composeLayout = (component: React.ComponentType) => {
93
88
  * 如果面板进入时,`devInfo`不存在,
94
89
  * 那么会调用 getDeviceInfo 异步获取处理好的`devInfo`,并置入`redux`
95
90
  */
91
+ state = {
92
+ colorScheme: 'light'
93
+ }
96
94
  constructor(props: Props) {
97
95
  super(props)
98
96
  if (props && props.devInfo && props.devInfo.devId) {
@@ -119,6 +117,12 @@ const composeLayout = (component: React.ComponentType) => {
119
117
  this.initReduxGroupNativeProps(props.uaGroupInfo)
120
118
  this.initGroupDevices(props.uaGroupInfo?.tyGroupId)
121
119
  }
120
+
121
+ if (!!props.colorScheme) {
122
+ this.state = {
123
+ colorScheme: props.colorScheme || 'light'
124
+ }
125
+ }
122
126
  getSystemTimeFormat().then(time => {
123
127
  dispatch(setSystemTimeFormat(time === 24))
124
128
  })
@@ -213,10 +217,32 @@ const composeLayout = (component: React.ComponentType) => {
213
217
  return dps
214
218
  }
215
219
 
220
+ componentDidMount() {
221
+ nativeEventEmitter.addListener('ColorSchemeUpdate', this.handleColorSchemeUpdate)
222
+ }
223
+
224
+ componentWillUnmount() {
225
+ removeListener()
226
+ nativeEventEmitter.removeListener('ColorSchemeUpdate', this.handleColorSchemeUpdate)
227
+ }
228
+
229
+ handleColorSchemeUpdate = (event: { colorScheme: string }) => {
230
+ this.updateColorScheme(event.colorScheme)
231
+ }
232
+
233
+ updateColorScheme(colorScheme: string) {
234
+ this.setState({
235
+ colorScheme: colorScheme
236
+ })
237
+ }
238
+
216
239
  render() {
240
+ // const { colorScheme } = this.state
241
+ const colorScheme = 'light'
242
+ console.log('colorScheme', colorScheme)
217
243
  return (
218
244
  <Provider store={store}>
219
- <Theme theme={theme}>
245
+ <Theme theme={colorScheme === 'dark' ? darkTheme : lightTheme}>
220
246
  <Connect mapStateToProps={_.identity}>
221
247
  {({ mapStateToProps, ...props }: { mapStateToProps: any; [_: string]: any }) => {
222
248
  return <NavigatorLayout {...props} />
@@ -226,10 +252,6 @@ const composeLayout = (component: React.ComponentType) => {
226
252
  </Provider>
227
253
  )
228
254
  }
229
-
230
- componentWillUnmount() {
231
- removeListener()
232
- }
233
255
  }
234
256
 
235
257
  return PanelComponent
@@ -0,0 +1,60 @@
1
+ import {Utils} from "tuya-panel-kit";
2
+
3
+ const { convertX: cx } = Utils.RatioUtils
4
+
5
+ export default {
6
+ type: 'dark',
7
+ global: {
8
+ brand: '#fff',
9
+ secondBrand: '#fff',
10
+ thirdBrand: '#FFE0D4',
11
+ background: '#000',
12
+ fontColor: '#fff',
13
+ secondFontColor: '#cccccc',
14
+ disabledFontColor: '#555555',
15
+ success: '#00C931',
16
+ warning: '#ff9500',
17
+ error: '#ff0015',
18
+ },
19
+ card: {
20
+ head: '#666',
21
+ background: '#2a2a2a',
22
+ fontColor: '#ffffff',
23
+ shadowColor: '#444444'
24
+ },
25
+ button: {
26
+ active: '#f60',
27
+ disabled: '#f60',
28
+ fontColor: '#fff'
29
+ },
30
+ textInput: {
31
+ background: '#737373',
32
+ fontColor: '#fff',
33
+ line: '#fff'
34
+ },
35
+ tag: {
36
+ background: '#737373',
37
+ fontColor: '#fff'
38
+ },
39
+ dialog: {
40
+ width: cx(315), // 弹窗容器宽度
41
+ bg: "#2a2a2a", // 弹窗背景色
42
+ radius: cx(8), // 弹窗容器圆角
43
+ cellHeight: 56, // 列表高度(头部、底部)
44
+ lineColor: "#e5e5e5", // 分隔线颜色
45
+ titleFontSize: 18, // 标题字体大小
46
+ titleFontColor: "#fff", // 头部栏标题颜色
47
+ subTitleFontSize: 16, // 副标题字体大小
48
+ subTitleFontColor: "#cccccc", // 头部栏副标题颜色
49
+ cancelFontSize: 16, // 底部栏取消字体大小
50
+ cancelFontColor: "#cccccc", // 底部栏取消字体颜色
51
+ confirmFontSize: 16, // 底部栏确认字体大小
52
+ confirmFontColor: "#f60", // 底部栏确认字体颜色
53
+ prompt: {
54
+ bg: "#737373", // 输入框背景色
55
+ radius: cx(4), // 输入框圆角
56
+ padding: "12px 16px", // 输入框边距
57
+ placeholder: "#fff", // 占位符字体颜色
58
+ },
59
+ },
60
+ }
@@ -0,0 +1,60 @@
1
+ import {Utils} from "tuya-panel-kit";
2
+
3
+ const { convertX: cx } = Utils.RatioUtils
4
+
5
+ export default {
6
+ type: 'light',
7
+ global: {
8
+ brand: '#f60',
9
+ secondBrand: '#ff8555',
10
+ thirdBrand: '#FFE0D4',
11
+ background: '#fff',
12
+ fontColor: '#000',
13
+ secondFontColor: '#666666',
14
+ disabledFontColor: '#CBCBCB',
15
+ success: '#00C931',
16
+ warning: '#ff9500',
17
+ error: '#ff0015',
18
+ },
19
+ card: {
20
+ head: '#DFDEDE',
21
+ background: '#fff',
22
+ fontColor: '#000',
23
+ shadowColor: '#000'
24
+ },
25
+ button: {
26
+ active: '#f60',
27
+ disabled: '#666666',
28
+ fontColor: '#fff'
29
+ },
30
+ textInput: {
31
+ background: '#F6F6F6',
32
+ fontColor: '#000',
33
+ line: '#cbcbcb'
34
+ },
35
+ tag: {
36
+ background: '#E6E7E8',
37
+ fontColor: '#000'
38
+ },
39
+ dialog: {
40
+ width: cx(315), // 弹窗容器宽度
41
+ bg: "#fff", // 弹窗背景色
42
+ radius: cx(8), // 弹窗容器圆角
43
+ cellHeight: 56, // 列表高度(头部、底部)
44
+ lineColor: "#e5e5e5", // 分隔线颜色
45
+ titleFontSize: 18, // 标题字体大小
46
+ titleFontColor: "#333", // 头部栏标题颜色
47
+ subTitleFontSize: 16, // 副标题字体大小
48
+ subTitleFontColor: "#999", // 头部栏副标题颜色
49
+ cancelFontSize: 16, // 底部栏取消字体大小
50
+ cancelFontColor: "#666", // 底部栏取消字体颜色
51
+ confirmFontSize: 16, // 底部栏确认字体大小
52
+ confirmFontColor: "#f60", // 底部栏确认字体颜色
53
+ prompt: {
54
+ bg: "#f8f8f8", // 输入框背景色
55
+ radius: cx(4), // 输入框圆角
56
+ padding: "12px 16px", // 输入框边距
57
+ placeholder: "#d6d6de", // 占位符字体颜色
58
+ },
59
+ },
60
+ }