@ledvance/base 1.3.2 → 1.3.4

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.3.2",
7
+ "version": "1.3.4",
8
8
  "scripts": {
9
9
  "prepublishOnly": "python update-localazy.py"
10
10
  },
package/src/api/native.ts CHANGED
@@ -24,6 +24,7 @@ interface LDVDevicePanelManager {
24
24
  getGroupDevices: (tyGroupId: number) => Promise<NativeResult<string>>
25
25
  getSystemTimeFormat: () => Promise<number>
26
26
  getMicrophoneAccess: (res:any) => Promise<Result<any>>
27
+ firebaseEvent: (dimensions:Record<any, any>) => Promise<NativeResult<any>>
27
28
  }
28
29
 
29
30
  export enum UADeviceCategory {
@@ -351,6 +352,16 @@ export class NativeApi {
351
352
  }
352
353
  }
353
354
 
355
+ static async putFlagFirebase(dimensions: Record<any, any>){
356
+ const nativeResult = await devicePanel.firebaseEvent({
357
+ eventName: 'select_country_flag',
358
+ dimensions
359
+ })
360
+ return {
361
+ success: nativeResult.result,
362
+ msg: nativeResult.msg,
363
+ }
364
+ }
354
365
  }
355
366
 
356
367
  // 打开下载文件
@@ -6,12 +6,63 @@ import Spacer from './Spacer'
6
6
  import res from '../res'
7
7
 
8
8
  const cx = Utils.RatioUtils.convertX
9
+ const { withTheme } = Utils.ThemeUtils
9
10
 
10
11
  export interface ApplyForDeviceItemProps {
12
+ theme?: any
11
13
  deviceInfo: DeviceInfo
12
14
  }
13
15
 
14
16
  const ApplyForDeviceItem = (props: ApplyForDeviceItemProps) => {
17
+
18
+ const styles = StyleSheet.create({
19
+ root: {
20
+ marginHorizontal: cx(8),
21
+ backgroundColor: props.theme.global.background,
22
+ flexDirection: 'row',
23
+ alignItems: 'center'
24
+ },
25
+ deviceInfo: {
26
+ flex: 1,
27
+ flexDirection: 'row',
28
+ alignItems: 'center',
29
+ marginTop: cx(4),
30
+ },
31
+ deviceIcon: {
32
+ width: cx(24),
33
+ height: cx(24),
34
+ marginStart: cx(6),
35
+ },
36
+ deviceName: {
37
+ flex: 1,
38
+ marginStart: cx(8),
39
+ color: props.theme.global.fontColor,
40
+ fontSize: cx(16),
41
+ fontFamily: 'helvetica_neue_lt_std_roman',
42
+ },
43
+ deviceRoomInfo: {
44
+ marginStart: cx(38),
45
+ flexDirection: 'row',
46
+ },
47
+ roomNameTag: {
48
+ height: cx(16),
49
+ display: 'flex',
50
+ justifyContent: 'center',
51
+ backgroundColor: props.theme.tag.background,
52
+ borderRadius: cx(8),
53
+ },
54
+ roomName: {
55
+ marginHorizontal: cx(12),
56
+ color: props.theme.tag.fontColor,
57
+ fontSize: cx(10),
58
+ fontFamily: 'helvetica_neue_lt_std_roman',
59
+ },
60
+ offlineIcon: {
61
+ width: cx(24),
62
+ height: cx(24)
63
+ }
64
+ })
65
+
15
66
  return (
16
67
  <View style={styles.root}>
17
68
  <View style={{ flex: 1 }}>
@@ -33,52 +84,4 @@ const ApplyForDeviceItem = (props: ApplyForDeviceItemProps) => {
33
84
  )
34
85
  }
35
86
 
36
- const styles = StyleSheet.create({
37
- root: {
38
- marginHorizontal: cx(8),
39
- backgroundColor: '#fff',
40
- flexDirection: 'row',
41
- alignItems: 'center'
42
- },
43
- deviceInfo: {
44
- flex: 1,
45
- flexDirection: 'row',
46
- alignItems: 'center',
47
- marginTop: cx(4),
48
- },
49
- deviceIcon: {
50
- width: cx(24),
51
- height: cx(24),
52
- marginStart: cx(6),
53
- },
54
- deviceName: {
55
- flex: 1,
56
- marginStart: cx(8),
57
- color: '#666',
58
- fontSize: cx(16),
59
- fontFamily: 'helvetica_neue_lt_std_roman',
60
- },
61
- deviceRoomInfo: {
62
- marginStart: cx(38),
63
- flexDirection: 'row',
64
- },
65
- roomNameTag: {
66
- height: cx(16),
67
- display: 'flex',
68
- justifyContent: 'center',
69
- backgroundColor: '#cbcbcb',
70
- borderRadius: cx(8),
71
- },
72
- roomName: {
73
- marginHorizontal: cx(12),
74
- color: '#000',
75
- fontSize: cx(10),
76
- fontFamily: 'helvetica_neue_lt_std_roman',
77
- },
78
- offlineIcon: {
79
- width: cx(24),
80
- height: cx(24)
81
- }
82
- })
83
-
84
- export default ApplyForDeviceItem
87
+ export default withTheme(ApplyForDeviceItem)
@@ -8,14 +8,16 @@ import { Utils } from 'tuya-panel-kit'
8
8
  import { useReactive, useUpdateEffect } from 'ahooks'
9
9
 
10
10
  const cx = Utils.RatioUtils.convertX
11
+ const { withTheme } = Utils.ThemeUtils
11
12
 
12
13
  export interface ApplyForDeviceListProps {
14
+ theme?: any
13
15
  devices: DeviceInfo[]
14
16
  expand?: boolean
15
17
  onExpandChange?: (expand: boolean) => void
16
18
  }
17
19
 
18
- export default function ApplyForDeviceList(props: ApplyForDeviceListProps) {
20
+ const ApplyForDeviceList = (props: ApplyForDeviceListProps) => {
19
21
  const state = useReactive({
20
22
  expand: props.expand || false
21
23
  })
@@ -24,6 +26,17 @@ export default function ApplyForDeviceList(props: ApplyForDeviceListProps) {
24
26
  state.expand = props.expand || false
25
27
  }, [props.expand])
26
28
 
29
+ const styles = StyleSheet.create({
30
+ deviceList: {
31
+ marginHorizontal: cx(16),
32
+ paddingVertical: cx(8),
33
+ backgroundColor: props.theme.container.background,
34
+ },
35
+ spacer: {
36
+ backgroundColor: props.theme.container.background,
37
+ }
38
+ })
39
+
27
40
  return <View>
28
41
  <ApplyForText
29
42
  expand={state.expand}
@@ -36,27 +49,19 @@ export default function ApplyForDeviceList(props: ApplyForDeviceListProps) {
36
49
  }}/>
37
50
  <Spacer height={cx(2)}/>
38
51
  {state.expand &&
39
- <FlatList
40
- style={styles.deviceList}
41
- data={props.devices}
42
- renderItem={({ item }) => <ApplyForDeviceItem deviceInfo={item}/>}
43
- keyExtractor={item => item.deviceId}
44
- ItemSeparatorComponent={() => {
45
- return (
46
- <Spacer
47
- style={{
48
- backgroundColor: 'rgb(241,241,241)',
49
- }}
50
- height={cx(8)}/>
51
- )
52
- }}/>}
52
+ <FlatList
53
+ style={styles.deviceList}
54
+ data={props.devices}
55
+ renderItem={({ item }) => <ApplyForDeviceItem deviceInfo={item}/>}
56
+ keyExtractor={item => item.deviceId}
57
+ ItemSeparatorComponent={() => {
58
+ return (
59
+ <Spacer
60
+ style={styles.spacer}
61
+ height={cx(8)}/>
62
+ )
63
+ }}/>}
53
64
  </View>
54
65
  }
55
66
 
56
- const styles = StyleSheet.create({
57
- deviceList: {
58
- marginHorizontal: cx(16),
59
- paddingVertical: cx(8),
60
- backgroundColor: 'rgb(241,241,241)',
61
- },
62
- })
67
+ export default withTheme(ApplyForDeviceList)
@@ -5,13 +5,33 @@ import res from '../res/index'
5
5
  import I18n from '../i18n/index'
6
6
 
7
7
  const cx = Utils.RatioUtils.convertX
8
+ const { withTheme } = Utils.ThemeUtils
8
9
 
9
10
  export interface ApplyForTextProps {
11
+ theme?: any
10
12
  expand: boolean
11
13
  onExpandChange: (expand: boolean) => void
12
14
  }
13
15
 
14
16
  const ApplyForText = (props: ApplyForTextProps) => {
17
+ const styles = StyleSheet.create({
18
+ root: {
19
+ flexDirection: 'row',
20
+ alignItems: 'center',
21
+ marginStart: cx(16),
22
+ },
23
+ text: {
24
+ color: props.theme.global.secondFontColor,
25
+ fontSize: cx(16),
26
+ letterSpacing: cx(0.12),
27
+ fontFamily: 'helvetica_neue_lt_std_bd',
28
+ },
29
+ icon: {
30
+ tintColor: props.theme.global.secondFontColor,
31
+ width: cx(24),
32
+ height: cx(24),
33
+ },
34
+ })
15
35
  return (
16
36
  <TouchableOpacity
17
37
  onPress={() => {
@@ -32,22 +52,5 @@ const ApplyForText = (props: ApplyForTextProps) => {
32
52
  )
33
53
  }
34
54
 
35
- const styles = StyleSheet.create({
36
- root: {
37
- flexDirection: 'row',
38
- alignItems: 'center',
39
- marginStart: cx(16),
40
- },
41
- text: {
42
- color: '#666',
43
- fontSize: cx(16),
44
- letterSpacing: cx(0.12),
45
- fontFamily: 'helvetica_neue_lt_std_bd',
46
- },
47
- icon: {
48
- width: cx(24),
49
- height: cx(24),
50
- },
51
- })
52
55
 
53
- export default ApplyForText
56
+ export default withTheme(ApplyForText)
@@ -9,8 +9,10 @@ import I18n from '../i18n/index'
9
9
  import {cctToColor} from '../utils/cctUtils'
10
10
 
11
11
  const {convertX: cx} = Utils.RatioUtils
12
+ const { withTheme } = Utils.ThemeUtils
12
13
 
13
14
  export interface ColorTempAdjustViewProps {
15
+ theme?: any
14
16
  colorTemp: number
15
17
  brightness: number
16
18
  minBrightness?: number
@@ -55,4 +57,4 @@ const ColorTempAdjustView = (props: ColorTempAdjustViewProps) => {
55
57
  )
56
58
  }
57
59
 
58
- export default ColorTempAdjustView
60
+ export default withTheme(ColorTempAdjustView)
@@ -23,7 +23,7 @@ const DeleteButton = (props: DeleteButtonProps) => {
23
23
  style={[{
24
24
  width: '100%',
25
25
  height: cx(50),
26
- backgroundColor: props.theme.button.disabled,
26
+ backgroundColor: props.theme.button.delete,
27
27
  alignItems: 'center',
28
28
  justifyContent: 'center',
29
29
  borderRadius: cx(8),
@@ -4,8 +4,10 @@ import {Utils} from 'tuya-panel-kit'
4
4
  import Spacer from './Spacer'
5
5
 
6
6
  const cx = Utils.RatioUtils.convertX
7
+ const { withTheme } = Utils.ThemeUtils
7
8
 
8
9
  interface InfoTextProps extends ViewProps {
10
+ theme?: any
9
11
  icon: string | number
10
12
  text: string
11
13
  contentColor?: string
@@ -15,7 +17,7 @@ interface InfoTextProps extends ViewProps {
15
17
  }
16
18
 
17
19
  const InfoText = (props: InfoTextProps) => {
18
- const contentColor = props.contentColor || '#666666'
20
+ const contentColor = props.contentColor || props.theme.global.secondFontColor
19
21
  const source = typeof props.icon === 'string' ? {uri: props.icon} : props.icon
20
22
  return (
21
23
  <View style={[styles.root, props.style]}>
@@ -43,4 +45,4 @@ const styles = StyleSheet.create({
43
45
  },
44
46
  })
45
47
 
46
- export default InfoText
48
+ export default withTheme(InfoText)
@@ -22,8 +22,9 @@ interface PageProps extends PropsWithChildren<ViewProps> {
22
22
  headlineText?: string
23
23
  headlineIcon?: string | number
24
24
  onHeadlineIconClick?: () => void
25
- headlineContent?: React.ReactNode
25
+ headlineIconContent?: React.ReactNode
26
26
  headlineTopContent?: React.ReactNode
27
+ headlineContent?: React.ReactNode
27
28
  showGreenery?: boolean
28
29
  greeneryIcon?: string | undefined | number
29
30
  loading?: boolean
@@ -81,15 +82,16 @@ const Page = (props: PageProps) => {
81
82
  rightButtonStyle={props.rightButtonStyle}
82
83
  onRightButtonPress={props.rightButtonIconClick}
83
84
  rightButtonDisabled={disabled}/>
84
- {(!!props.headlineText) &&
85
+ {(!!props.headlineText || !!props.headlineContent) &&
85
86
  <LdvTopName
86
87
  title={props.headlineText}
87
88
  rightIcon={props.headlineIcon}
88
89
  rightIconClick={props.onHeadlineIconClick}
89
90
  showGreenery={props.showGreenery}
90
91
  greeneryIcon={props.greeneryIcon}
91
- headlineContent={props.headlineContent}
92
+ headlineIconContent={props.headlineIconContent}
92
93
  headlineTopContent={props.headlineTopContent}
94
+ headlineContent={props.headlineContent}
93
95
  />}
94
96
  {props.children}
95
97
  </View>
@@ -1,13 +1,15 @@
1
1
  import React, { PropsWithChildren } from "react";
2
2
  import { View, Image, StyleSheet, Text, TouchableOpacity, ViewProps } from "react-native";
3
- import Card from "@ledvance/base/src/components/Card";
4
- import Spacer from "@ledvance/base/src/components/Spacer";
3
+ import Card from "components/Card";
4
+ import Spacer from "components/Spacer";
5
5
  import { Dialog, SwitchButton, Utils } from "tuya-panel-kit";
6
- import I18n from "@ledvance/base/src/i18n";
6
+ import I18n from "../i18n";
7
7
 
8
8
  const cx = Utils.RatioUtils.convertX
9
+ const { withTheme } = Utils.ThemeUtils
9
10
 
10
11
  interface SocketItemProps extends PropsWithChildren<ViewProps>{
12
+ theme?: any
11
13
  title: string
12
14
  name: string
13
15
  icon: any
@@ -18,6 +20,34 @@ interface SocketItemProps extends PropsWithChildren<ViewProps>{
18
20
  }
19
21
 
20
22
  function SocketItem(props: SocketItemProps) {
23
+
24
+ const styles = StyleSheet.create({
25
+ switchLine: {
26
+ flexDirection: 'row',
27
+ alignItems: 'center',
28
+ marginHorizontal: cx(16),
29
+ },
30
+ title: {
31
+ fontSize: cx(16),
32
+ color: props.theme.global.fontColor,
33
+ fontFamily: 'helvetica_neue_lt_std_bd',
34
+ fontWeight: 'bold',
35
+ },
36
+ icon: {
37
+ width: cx(60),
38
+ height: cx(20),
39
+ },
40
+ nameLine: {
41
+ flex: 1,
42
+ marginHorizontal: cx(16),
43
+ },
44
+ name: {
45
+ fontSize: cx(14),
46
+ color: props.theme.global.fontColor,
47
+ fontFamily: 'helvetica_neue_lt_std_roman',
48
+ },
49
+ })
50
+
21
51
  return (
22
52
  <Card style={{ marginHorizontal: cx(24) }}>
23
53
  <View>
@@ -58,31 +88,4 @@ function SocketItem(props: SocketItemProps) {
58
88
  )
59
89
  }
60
90
 
61
- const styles = StyleSheet.create({
62
- switchLine: {
63
- flexDirection: 'row',
64
- alignItems: 'center',
65
- marginHorizontal: cx(16),
66
- },
67
- title: {
68
- fontSize: cx(16),
69
- color: '#000',
70
- fontFamily: 'helvetica_neue_lt_std_bd',
71
- fontWeight: 'bold',
72
- },
73
- icon: {
74
- width: cx(60),
75
- height: cx(20),
76
- },
77
- nameLine: {
78
- flex: 1,
79
- marginHorizontal: cx(16),
80
- },
81
- name: {
82
- fontSize: cx(14),
83
- color: '#000',
84
- fontFamily: 'helvetica_neue_lt_std_roman',
85
- },
86
- })
87
-
88
- export default SocketItem
91
+ export default withTheme(SocketItem)
@@ -4,20 +4,47 @@ import {Utils} from 'tuya-panel-kit'
4
4
  import res from '../res'
5
5
 
6
6
  const cx = Utils.RatioUtils.convertX
7
+ const { withTheme } = Utils.ThemeUtils
7
8
 
8
9
  interface TagProps extends ViewProps {
10
+ theme?: any
9
11
  checked: boolean
10
12
  text: string
11
13
  onCheckedChange: (boolean) => void
12
14
  }
13
15
 
14
16
  const Tag = (props: TagProps) => {
17
+
18
+ const styles = StyleSheet.create({
19
+ root: {
20
+ height: cx(24),
21
+ flexDirection: 'row',
22
+ justifyContent: 'center',
23
+ alignItems: 'center',
24
+ borderWidth: cx(1),
25
+ borderColor: props.theme.global.brand,
26
+ borderRadius: cx(12),
27
+ },
28
+ text: {
29
+ marginStart: cx(12),
30
+ color: props.theme.global.brand,
31
+ fontSize: cx(14),
32
+ fontFamily: 'helvetica_neue_lt_std_roman',
33
+ },
34
+ icon: {
35
+ width: cx(12),
36
+ height: cx(12),
37
+ marginEnd: cx(6),
38
+ tintColor: props.theme.global.brand,
39
+ },
40
+ })
41
+
15
42
  return (
16
43
  <TouchableOpacity
17
44
  onPress={() => {
18
45
  props.onCheckedChange(!props.checked)
19
46
  }}>
20
- <View style={[styles.root, props.checked ? {backgroundColor: '#ffe0d4'} : {}, props.style]}>
47
+ <View style={[styles.root, props.checked ? {backgroundColor: props.theme.global.thirdBrand} : {}, props.style]}>
21
48
  <Text style={[styles.text, {marginEnd: cx(props.checked ? 4 : 12)}]}>{props.text}</Text>
22
49
  {
23
50
  props.checked &&
@@ -30,28 +57,4 @@ const Tag = (props: TagProps) => {
30
57
  )
31
58
  }
32
59
 
33
- const styles = StyleSheet.create({
34
- root: {
35
- height: cx(24),
36
- flexDirection: 'row',
37
- justifyContent: 'center',
38
- alignItems: 'center',
39
- borderWidth: cx(1),
40
- borderColor: '#ff6600',
41
- borderRadius: cx(12),
42
- },
43
- text: {
44
- marginStart: cx(12),
45
- color: '#ff6600',
46
- fontSize: cx(14),
47
- fontFamily: 'helvetica_neue_lt_std_roman',
48
- },
49
- icon: {
50
- width: cx(12),
51
- height: cx(12),
52
- marginEnd: cx(6),
53
- tintColor: '#F60',
54
- },
55
- })
56
-
57
- export default Tag
60
+ export default withTheme(Tag)
@@ -4,6 +4,7 @@ import {LinearGradient, Slider, Utils} from 'tuya-panel-kit'
4
4
  import {Rect} from 'react-native-svg'
5
5
 
6
6
  const cx = Utils.RatioUtils.convertX
7
+ const { withTheme } = Utils.ThemeUtils
7
8
 
8
9
  const temperatures = {
9
10
  '0%': 'rgb(254, 172, 90)',
@@ -27,6 +28,7 @@ const colors = {
27
28
  export const TEMP_KEY = 'temperature'
28
29
 
29
30
  interface LdvColorSliderProps {
31
+ theme?: any
30
32
  title: string,
31
33
  type: string,
32
34
  onValueChange?: (number) => void | undefined,
@@ -43,6 +45,54 @@ const LdvColorSlider = (props: LdvColorSliderProps) => {
43
45
  let max = type === TEMP_KEY ? 100 : 359
44
46
  let min = type === TEMP_KEY ? 0 : 0
45
47
  const width = props.width || (Utils.RatioUtils.width - cx(80))
48
+
49
+ const styles = StyleSheet.create({
50
+ container: {
51
+ height: cx(57),
52
+ flexDirection: 'column',
53
+ paddingStart: cx(16),
54
+ },
55
+ title: {
56
+ marginTop: cx(4),
57
+ fontSize: cx(14),
58
+ color: props.theme.global.fontColor,
59
+ fontFamily: 'helvetica_neue_lt_std_roman',
60
+ },
61
+ shadeSlider: {
62
+ marginTop: cx(8),
63
+ height: cx(28),
64
+ justifyContent: 'center',
65
+ },
66
+ sliderTrack: {
67
+ marginTop: cx(9),
68
+ marginBottom: cx(9),
69
+ flex: 1,
70
+ borderRadius: cx(15),
71
+ },
72
+ shadeThumb: {
73
+ backgroundColor: 'rgb(0, 249, 255)',
74
+ width: cx(28),
75
+ height: cx(28),
76
+ borderRadius: cx(14),
77
+ borderColor: 'white',
78
+ borderWidth: 1,
79
+ shadowColor: '#000000',
80
+ shadowOpacity: 0.2,
81
+ shadowRadius: cx(8),
82
+ elevation: cx(8),
83
+ shadowOffset: {
84
+ width: 0,
85
+ height: cx(4),
86
+ },
87
+ },
88
+ sliderLinearGradient: {
89
+ height: cx(12),
90
+ },
91
+ presetView: {
92
+ height: cx(60),
93
+ },
94
+ })
95
+
46
96
  return (
47
97
  <View style={[styles.container, props.style]}>
48
98
  <Text style={styles.title}>
@@ -82,51 +132,4 @@ const LdvColorSlider = (props: LdvColorSliderProps) => {
82
132
  )
83
133
  }
84
134
 
85
- const styles = StyleSheet.create({
86
- container: {
87
- height: cx(57),
88
- flexDirection: 'column',
89
- paddingStart: cx(16),
90
- },
91
- title: {
92
- marginTop: cx(4),
93
- fontSize: cx(14),
94
- color: '#000',
95
- fontFamily: 'helvetica_neue_lt_std_roman',
96
- },
97
- shadeSlider: {
98
- marginTop: cx(8),
99
- height: cx(28),
100
- justifyContent: 'center',
101
- },
102
- sliderTrack: {
103
- marginTop: cx(9),
104
- marginBottom: cx(9),
105
- flex: 1,
106
- borderRadius: cx(15),
107
- },
108
- shadeThumb: {
109
- backgroundColor: 'rgb(0, 249, 255)',
110
- width: cx(28),
111
- height: cx(28),
112
- borderRadius: cx(14),
113
- borderColor: 'white',
114
- borderWidth: 1,
115
- shadowColor: '#000000',
116
- shadowOpacity: 0.2,
117
- shadowRadius: cx(8),
118
- elevation: cx(8),
119
- shadowOffset: {
120
- width: 0,
121
- height: cx(4),
122
- },
123
- },
124
- sliderLinearGradient: {
125
- height: cx(12),
126
- },
127
- presetView: {
128
- height: cx(60),
129
- },
130
- })
131
-
132
- export default LdvColorSlider
135
+ export default withTheme(LdvColorSlider)