@ledvance/base 1.3.82 → 1.3.84

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.82",
7
+ "version": "1.3.84",
8
8
  "scripts": {
9
9
  "prepublishOnly": "python update-localazy.py"
10
10
  },
@@ -1,17 +1,23 @@
1
- import {IconFont, Utils} from 'tuya-panel-kit'
2
- import {StyleProp, Text, TextStyle, TouchableOpacity, View, ViewStyle} from 'react-native'
1
+ import { IconFont, Utils } from 'tuya-panel-kit'
2
+ import { StyleProp, Text, TextStyle, TouchableOpacity, View, ViewStyle, Image, ImageSourcePropType, ImageStyle } from 'react-native'
3
3
  import React from 'react'
4
4
  import ThemeType from "../config/themeType";
5
5
 
6
6
  const cx = Utils.RatioUtils.convertX
7
- const {withTheme} = Utils.ThemeUtils
7
+ const { withTheme } = Utils.ThemeUtils
8
8
 
9
9
  interface CellProps {
10
10
  theme?: ThemeType
11
+ icon?: ImageSourcePropType
12
+ iconStyle?: StyleProp<ImageStyle>
11
13
  title: string,
12
14
  value: string,
13
15
  onPress: () => void,
16
+ needArrow?: boolean
14
17
  style?: StyleProp<ViewStyle>
18
+ contentStyle?: StyleProp<ViewStyle>
19
+ titleStyle?: StyleProp<TextStyle>
20
+ valueStyle?: StyleProp<TextStyle>
15
21
  }
16
22
 
17
23
  export default withTheme(function Cell(props: CellProps) {
@@ -26,38 +32,53 @@ export default withTheme(function Cell(props: CellProps) {
26
32
  backgroundColor: props.theme?.card.background,
27
33
  }, props.style]}
28
34
  onPress={props.onPress}>
29
- <CellContent title={props.title} value={props.value}/>
35
+ <CellContent
36
+ icon={props.icon}
37
+ iconStyle={props.iconStyle}
38
+ title={props.title}
39
+ titleStyle={props.titleStyle}
40
+ value={props.value}
41
+ valueStyle={props.valueStyle}
42
+ needArrow={props.needArrow ?? true}
43
+ style={props.contentStyle}
44
+ />
30
45
  </TouchableOpacity>
31
46
  )
32
47
  }) as React.ComponentType<CellProps>
33
48
 
34
49
  interface CellContentProps {
35
50
  theme?: ThemeType
51
+ icon?: ImageSourcePropType
52
+ iconStyle?: StyleProp<ImageStyle>
36
53
  title: string
37
54
  value: string
38
55
  style?: StyleProp<ViewStyle>
39
56
  titleStyle?: StyleProp<TextStyle>
40
57
  valueStyle?: StyleProp<TextStyle>
41
- iconStyle?: { color?: any, size?: number }
58
+ needArrow: boolean
59
+ arrowStyle?: { color?: any, size?: number }
42
60
  }
43
61
 
44
62
  const CellContentBase = (props: CellContentProps) => {
45
63
  return (
46
64
  <View
47
65
  style={[
48
- {flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center'},
66
+ { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' },
49
67
  props.style,
50
68
  ]}>
51
- <Text
52
- style={[
53
- {
54
- fontSize: cx(14),
55
- color: props.theme?.global.secondFontColor,
56
- fontFamily: 'helvetica_neue_lt_std_roman',
57
- },
58
- props.titleStyle,
59
- ]}>{props.title}</Text>
60
- <View style={{flexDirection: 'row', alignItems: 'center'}}>
69
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
70
+ {props.icon && (<Image source={props.icon} style={[{ width: cx(24), height: cx(24), marginRight: cx(10) }, props.iconStyle]} />)}
71
+ <Text
72
+ style={[
73
+ {
74
+ fontSize: cx(14),
75
+ color: props.theme?.global.secondFontColor,
76
+ fontFamily: 'helvetica_neue_lt_std_roman',
77
+ },
78
+ props.titleStyle,
79
+ ]}>{props.title}</Text>
80
+ </View>
81
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
61
82
  <Text style={[
62
83
  {
63
84
  fontSize: cx(14),
@@ -66,11 +87,15 @@ const CellContentBase = (props: CellContentProps) => {
66
87
  },
67
88
  props.valueStyle,
68
89
  ]}>{props.value}</Text>
69
- <View style={{width: cx(4)}}/>
70
- <IconFont
71
- name="arrow"
72
- color={props.iconStyle?.color || props.theme?.global.secondFontColor}
73
- size={props.iconStyle?.size || cx(11)}/>
90
+ <View style={{ width: cx(4) }} />
91
+ {
92
+ props.needArrow && (
93
+ <IconFont
94
+ name="arrow"
95
+ color={props.arrowStyle?.color || props.theme?.global.secondFontColor}
96
+ size={props.arrowStyle?.size || cx(11)} />
97
+ )
98
+ }
74
99
  </View>
75
100
  </View>
76
101
  )
@@ -35,6 +35,7 @@ const NewColorTempPicker = React.memo((props: ColorTempAdjustViewProps) => {
35
35
  brightness = 100,
36
36
  minBrightness,
37
37
  isSupportTemperature,
38
+ isSupportBrightness,
38
39
  onCCTChange,
39
40
  onCCTChangeComplete,
40
41
  onBrightnessChange,
@@ -78,15 +79,16 @@ const NewColorTempPicker = React.memo((props: ColorTempAdjustViewProps) => {
78
79
  const { temperature, brightness: stateBrightness } = state
79
80
  const white = { temperature, brightness: stateBrightness }
80
81
  const minBrightnessValue = minBrightness ?? 1
81
-
82
+ const height = cx(isSupportTemperature? 200 : (isSupportBrightness ? 45 : 0))
83
+ const borderWidth = (isSupportTemperature || isSupportBrightness) ? 1 : 0
82
84
  return (
83
85
  <View style={{justifyContent: 'center', alignItems: 'center'}}>
84
86
  <View style={{
85
87
  width: width,
86
- height: cx(isSupportTemperature? 200 : 45),
88
+ height: height,
87
89
  borderRadius: cx(10),
88
90
  borderColor: '#eeeeef',
89
- borderWidth: 1,
91
+ borderWidth: borderWidth,
90
92
  overflow: 'hidden'
91
93
  }}>
92
94
  {
@@ -97,7 +99,7 @@ const NewColorTempPicker = React.memo((props: ColorTempAdjustViewProps) => {
97
99
  onMove={handleMove}
98
100
  onRelease={handleComplete}
99
101
  onPress={handleComplete}
100
- /> : <RectColorAndBrightPicker.BrightnessSlider
102
+ /> : isSupportBrightness ? <RectColorAndBrightPicker.BrightnessSlider
101
103
  value={stateBrightness}
102
104
  min={scaleUp(minBrightnessValue)}
103
105
  minPercent={minBrightnessValue ? minBrightnessValue : 0}
@@ -106,7 +108,7 @@ const NewColorTempPicker = React.memo((props: ColorTempAdjustViewProps) => {
106
108
  onMove={handleBrightnessMove}
107
109
  onRelease={handleBrightnessComplete}
108
110
  onPress={handleBrightnessComplete}
109
- />
111
+ /> : <></>
110
112
  }
111
113
 
112
114
  </View>
@@ -1,5 +1,5 @@
1
1
  import React, {ReactNode} from 'react'
2
- import {StyleSheet, Text, TouchableOpacity, View, ViewStyle} from 'react-native'
2
+ import {ScrollView, StyleSheet, Text, TouchableOpacity, View, ViewStyle} from 'react-native'
3
3
  import {Utils} from 'tuya-panel-kit'
4
4
  import ThemeType from '../config/themeType'
5
5
 
@@ -27,6 +27,7 @@ const Segmented = (props: SegmentedProps) => {
27
27
  backgroundColor: props.theme?.segment.background,
28
28
  padding: cx(2),
29
29
  borderRadius: cx(8),
30
+ flexGrow: 1,
30
31
  },
31
32
  segmented_item: {
32
33
  flex: 1,
@@ -45,6 +46,9 @@ const Segmented = (props: SegmentedProps) => {
45
46
  segmented_item_check: {
46
47
  backgroundColor: props.theme?.button.primary,
47
48
  },
49
+ segmented_item_min_width: {
50
+ minWidth: cx(120),
51
+ },
48
52
  segmented_text: {
49
53
  fontSize: cx(16),
50
54
  color: props.theme?.global.secondFontColor,
@@ -54,7 +58,11 @@ const Segmented = (props: SegmentedProps) => {
54
58
  },
55
59
  })
56
60
  return (
57
- <View style={[styles.wrap_container, props.style]}>
61
+ <ScrollView
62
+ horizontal
63
+ showsHorizontalScrollIndicator={false}
64
+ contentContainerStyle={[styles.wrap_container]}
65
+ style={[props.style, {flex: 1 }]}>
58
66
  {props.options && props.options.map((item, idx) => (
59
67
  <TouchableOpacity
60
68
  accessibilityLabel={"Segmented"}
@@ -62,6 +70,7 @@ const Segmented = (props: SegmentedProps) => {
62
70
  accessibilityState={{checked: item.value === props.value}}
63
71
  style={[
64
72
  styles.segmented_item,
73
+ (props.options?.length || 0) > 2 ? styles.segmented_item_min_width : {},
65
74
  idx === 0 && styles.segmented_item_first,
66
75
  idx + 1 === props.options?.length && styles.segmented_item_last,
67
76
  item.value === props.value && styles.segmented_item_check,
@@ -75,7 +84,7 @@ const Segmented = (props: SegmentedProps) => {
75
84
  ]}>{item.label}</Text>
76
85
  </TouchableOpacity>
77
86
  ))}
78
- </View>
87
+ </ScrollView>
79
88
  )
80
89
  }
81
90
 
@@ -63,6 +63,12 @@ const darkTheme = {
63
63
  border: '#888888',
64
64
  fontColor: '#ffffff',
65
65
  },
66
+ tabBar: {
67
+ background: '#2a2a2a',
68
+ active: '#ffffff',
69
+ inactive: '#4a4a4a',
70
+ divider: '#e0e0e0',
71
+ },
66
72
  dialog: {
67
73
  width: cx(315), // 弹窗容器宽度
68
74
  bg: "#2a2a2a", // 弹窗背景色
@@ -63,6 +63,12 @@ const lightTheme = {
63
63
  border: '#666666',
64
64
  fontColor: '#000000',
65
65
  },
66
+ tabBar: {
67
+ background: '#ffffff',
68
+ active: '#ff6600',
69
+ inactive: '#666666',
70
+ divider: '#e0e0e0'
71
+ },
66
72
  dialog: {
67
73
  width: cx(315), // 弹窗容器宽度
68
74
  bg: "#ffffff", // 弹窗背景色
@@ -1,4 +1,5 @@
1
1
  import { useRoute, useNavigation } from '@react-navigation/core'
2
+ import { Result } from 'models/modules/Result'
2
3
  import { useCallback, useEffect, useRef } from 'react'
3
4
 
4
5
  export function createParams<T>(params: T): T {
@@ -59,3 +60,54 @@ export function useDpResponseValidator(timeoutMs: number = 1000) {
59
60
  onDpResponse,
60
61
  };
61
62
  }
63
+
64
+ interface IControlData {
65
+ colorMode: boolean
66
+ hue: number
67
+ saturation: number
68
+ value: number
69
+ brightness: number
70
+ temperature: number
71
+ }
72
+
73
+ interface IControlDataOptions {
74
+ mode?: 0 | 1 // 0: 跳变, 1: 渐变
75
+ saturationConvert?: (v: number) => number
76
+ valueConvert?: (v: number) => number
77
+ temperatureConvert?: (v: number) => number
78
+ brightnessConvert?: (v: number) => number
79
+ }
80
+
81
+ /**
82
+ * 通用控制支持device和group
83
+ * @param control Tuya Control Formatter
84
+ * @param sendValueFunc send tuya control function
85
+ * @returns
86
+ */
87
+ export function useControlData(control: any, sendValueFunc: (value: any) => Promise<Result<any>>): (
88
+ controlValue: IControlData,
89
+ options?: IControlDataOptions
90
+ ) => Promise<any> {
91
+ const setControlData = useCallback(
92
+ async (controlValue: IControlData, options: IControlDataOptions = {}) => {
93
+ const {
94
+ mode = 1,
95
+ saturationConvert = (v: number) => Math.round(v * 10),
96
+ valueConvert = (v: number) => Math.round(v * 10),
97
+ temperatureConvert = (v: number) => Math.round(v * 10),
98
+ brightnessConvert = (v: number) => Math.round(v * 10),
99
+ } = options
100
+ const value = control.format({
101
+ mode: mode,
102
+ hue: controlValue.colorMode ? controlValue.hue : 0,
103
+ saturation: controlValue.colorMode ? saturationConvert(controlValue.saturation) : 0,
104
+ value: controlValue.colorMode ? valueConvert(controlValue.value) : 0,
105
+ temperature: !controlValue.colorMode ? temperatureConvert(controlValue.temperature) : 0,
106
+ brightness: !controlValue.colorMode ? brightnessConvert(controlValue.brightness) : 0,
107
+ });
108
+ return await sendValueFunc(value)
109
+ },
110
+ []
111
+ );
112
+ return setControlData
113
+ }
@@ -6093,7 +6093,7 @@ export default {
6093
6093
  "camera_settings_onvif_set_password_tips": "Das Gerätekennwort unterstützt 8-32 Zeichen und muss Groß- und Kleinbuchstaben sowie Ziffern enthalten.",
6094
6094
  "camera_settings_onvif_switch_topic": "Onvif-Schalter",
6095
6095
  "camera_settings_onvif_topic": "Onvif",
6096
- "camera_settings_power_management_settings_topic": "Energieverwaltungseinstellungen",
6096
+ "camera_settings_power_management_settings_topic": "Energieverwaltung",
6097
6097
  "camera_settings_recording_mode_firstbox_topic1": "Bewegungsauslöser",
6098
6098
  "camera_settings_recording_mode_firstbox_topic1_description": "Nimmt nur auf, wenn eine Bewegung erkannt wird",
6099
6099
  "camera_settings_recording_mode_firstbox_topic2": "Fortlaufend",
@@ -6116,7 +6116,7 @@ export default {
6116
6116
  "camera_site_overview_empty_button_add_text": "Standort hinzufügen",
6117
6117
  "camera_site_overview_empty_information_text": "Du hast noch keinen Ort hinzugefügt",
6118
6118
  "camera_site_overview_warning_max_number_text": "Die maximale Anzahl an Orte wurde erreicht.",
6119
- "camera_status_indicator": "LED-Anzeige",
6119
+ "camera_status_indicator": "LED-Indikator",
6120
6120
  "camera_tile_camera_button_label_photo": "Foto aufnehmen",
6121
6121
  "camera_tile_camera_button_label_video": "Video aufzeichnen",
6122
6122
  "camera_tile_camera_headline": "Kamera",
@@ -6604,7 +6604,7 @@ export default {
6604
6604
  "matter_gradient_light_on_description_text": "Stelle eine Zeit im Bereich von 0 bis 60 Sekunden ein, um die Helligkeit beim Einschalten der Lampe schrittweise zu erhöhen",
6605
6605
  "matter_gradient_light_on_title": "Einblenden (s)",
6606
6606
  "matter_gradient_overview_headline_text": "Ein-/Ausblenden",
6607
- "matterplug_LED": "LED-Anzeige",
6607
+ "matterplug_LED": "LED-Indikator",
6608
6608
  "matterplug_description": "Konfiguration der Status-LED nach dem Ein-/Ausschalten",
6609
6609
  "matterplug_heading": "Status-LED",
6610
6610
  "matterplug_option1description": "Der Status des Schalters entspricht der Status-LED: Die Steckdose ist eingeschaltet, wenn die LED an ist, und ausgeschaltet, wenn die LED aus ist.",