@ledvance/ui-biz-bundle 1.1.148 → 1.1.150

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/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.148",
7
+ "version": "1.1.150",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -1,3 +1,4 @@
1
+ import FeatureInfo from '@ledvance/base/src/components/FeatureInfo'
1
2
  import Page from '@ledvance/base/src/components/Page'
2
3
  import { useDeviceInfo } from '@ledvance/base/src/models/modules/NativePropsSlice'
3
4
  import React, { useCallback, useEffect } from 'react'
@@ -187,6 +188,7 @@ const SwitchHistoryPage = (props: { theme?: ThemeType }) => {
187
188
  headlineText={headlineText || I18n.getLang('history_socket_headline_text')}
188
189
  headlineIcon={res.download_icon}
189
190
  onHeadlineIconClick={downFile}
191
+ info={<FeatureInfo title={I18n.getLang('history_socket_headline_text')} content={I18n.getLang('infobutton_history')} />}
190
192
  >
191
193
  <View style={styles.content}>
192
194
  <Text style={styles.titleText}>{I18n.getLang('history_contact_sensor_description_text')}</Text>
@@ -1,3 +1,4 @@
1
+ import FeatureInfo from '@ledvance/base/src/components/FeatureInfo'
1
2
  import React, { useCallback, useEffect } from "react";
2
3
  import { View, Text, ScrollView, TouchableOpacity, StyleSheet, Image } from "react-native"
3
4
  import { useNavigation } from '@react-navigation/native'
@@ -216,6 +217,7 @@ const TimerPage = (props: {theme?: ThemeType}) => {
216
217
  backText={devInfo.name}
217
218
  headlineText={I18n.getLang('timer_nightplug_headline_text')}
218
219
  onBackClick={navigation.goBack}
220
+ info={<FeatureInfo title={I18n.getLang('timer_nightplug_headline_text')} content={I18n.getLang('infobutton_timer')} />}
219
221
  >
220
222
  <ScrollView
221
223
  nestedScrollEnabled={true}
@@ -1,7 +1,7 @@
1
1
  import I18n from '@ledvance/base/src/i18n'
2
2
  import res from '@ledvance/base/src/res'
3
- import React from 'react'
4
- import { Image, Text, TouchableOpacity, View } from 'react-native'
3
+ import React, { useEffect } from 'react'
4
+ import { BackHandler, Image, Text, TouchableOpacity, View } from 'react-native'
5
5
  import { Utils } from 'tuya-panel-kit'
6
6
  import { ChartType } from '../co2Data'
7
7
  import { EnergyChartSection } from './EnergyChartSection'
@@ -9,38 +9,50 @@ import { PowerChartSection } from './PowerChartSection'
9
9
 
10
10
  const { convertX: cx, width } = Utils.RatioUtils
11
11
 
12
- export const LandscapeView = ({ state, actions, params, styles, theme }) => (
13
- <View style={styles.landscapeContainer}>
14
- <View style={styles.landscapeHeader}>
15
- <Text style={styles.landscapeTitle}>
16
- {I18n.getLang(state.chartType === ChartType.kWh ? 'chartdisplay_energy' : 'chartdisplay_power')}
17
- </Text>
18
- <TouchableOpacity onPress={actions.toggleLandscape}>
19
- <Image source={{ uri: res.screen_normal }} style={styles.normalScreenIcon}/>
20
- </TouchableOpacity>
21
- </View>
12
+ export const LandscapeView = ({ state, actions, params, styles, theme, screenWidth, screenHeight }) => {
13
+ useEffect(() => {
14
+ const onBack = () => {
15
+ actions.toggleLandscape()
16
+ return true
17
+ }
18
+ BackHandler.addEventListener('hardwareBackPress', onBack)
19
+ return () => {
20
+ BackHandler.removeEventListener('hardwareBackPress', onBack)
21
+ }
22
+ }, [])
23
+ return (
24
+ <View style={[styles.landscapeContainer, { width: screenWidth, height: screenHeight }]}>
25
+ <View style={styles.landscapeHeader}>
26
+ <Text style={styles.landscapeTitle}>
27
+ {I18n.getLang(state.chartType === ChartType.kWh ? 'chartdisplay_energy' : 'chartdisplay_power')}
28
+ </Text>
29
+ <TouchableOpacity onPress={actions.toggleLandscape}>
30
+ <Image source={{ uri: res.screen_normal }} style={styles.normalScreenIcon}/>
31
+ </TouchableOpacity>
32
+ </View>
22
33
 
23
- <View style={styles.landscapeContent}>
24
- {state.chartType === ChartType.kWh ? (
25
- <EnergyChartSection
26
- isLandscape={true}
27
- state={state}
28
- actions={actions}
29
- params={params}
30
- styles={styles}
31
- theme={theme}
32
- chartHeight={cx(width - 110)}
33
- />
34
- ) : (
35
- <PowerChartSection
36
- isLandscape={true}
37
- state={state}
38
- actions={actions}
39
- styles={styles}
40
- theme={theme}
41
- chartHeight={cx(width - 110)}
42
- />
43
- )}
34
+ <View style={styles.landscapeContent}>
35
+ {state.chartType === ChartType.kWh ? (
36
+ <EnergyChartSection
37
+ isLandscape={true}
38
+ state={state}
39
+ actions={actions}
40
+ params={params}
41
+ styles={styles}
42
+ theme={theme}
43
+ chartHeight={screenHeight - cx(110)}
44
+ />
45
+ ) : (
46
+ <PowerChartSection
47
+ isLandscape={true}
48
+ state={state}
49
+ actions={actions}
50
+ styles={styles}
51
+ theme={theme}
52
+ chartHeight={screenHeight - cx(110)}
53
+ />
54
+ )}
55
+ </View>
44
56
  </View>
45
- </View>
46
- )
57
+ )
58
+ }
@@ -9,6 +9,7 @@ import { PortraitView } from './PortraitView'
9
9
  import { getStyles } from './styles'
10
10
 
11
11
  import { useEnergyData } from './useEnergyData'
12
+ import { useScreenDimensions } from './useScreenDimensions'
12
13
 
13
14
  const { withTheme } = Utils.ThemeUtils
14
15
 
@@ -22,9 +23,18 @@ const EnergyConsumptionChartComponent = (props: { theme?: ThemeType }) => {
22
23
  // Use useMemo to prevent re-creating styles on every render
23
24
  const styles = useMemo(() => getStyles(props.theme), [props.theme])
24
25
 
26
+ const { width: screenWidth, height: screenHeight } = useScreenDimensions()
25
27
  // Conditionally render the correct view based on orientation state
26
28
  if (state.isLandscape) {
27
- return <LandscapeView state={state} actions={actions} params={params} styles={styles} theme={props.theme}/>
29
+ return <LandscapeView
30
+ state={state}
31
+ actions={actions}
32
+ params={params}
33
+ styles={styles}
34
+ theme={props.theme}
35
+ screenWidth={screenWidth}
36
+ screenHeight={screenHeight}
37
+ />
28
38
  }
29
39
 
30
40
  return <PortraitView state={state} actions={actions} params={params} styles={styles} theme={props.theme}/>
@@ -51,10 +51,10 @@ export const getStyles = (theme: ThemeType | undefined) => StyleSheet.create({
51
51
  },
52
52
  landscapeContainer: {
53
53
  backgroundColor: theme?.global.background,
54
- width: cx(height + 20), // In landscape, width is screen height
54
+ // width: cx(height + 20), // In landscape, width is screen height
55
55
  // height: width, // In landscape, height is screen width
56
56
  paddingVertical: cx(30),
57
- paddingHorizontal: cx(20),
57
+ paddingHorizontal: cx(50),
58
58
  },
59
59
  landscapeHeader: {
60
60
  flexDirection: 'row',
@@ -128,8 +128,10 @@ export const useEnergyData = (params: EnergyConsumptionChartProps, devId: string
128
128
  state.dateType = type
129
129
  }, []),
130
130
  setInterval: useCallback((newInterval: number) => {
131
- state.interval = newInterval
132
- state.powerData = []
131
+ if (newInterval !== state.interval) {
132
+ state.interval = newInterval
133
+ state.powerData = []
134
+ }
133
135
  }, []),
134
136
  toggleLandscape: useCallback(() => {
135
137
  if (!state.isSupportLandscape) return
@@ -0,0 +1,36 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { Dimensions, ScaledSize, Platform } from 'react-native'
3
+ import { Utils } from 'tuya-panel-kit'
4
+
5
+ const { width, height, statusBarHeight } = Utils.RatioUtils
6
+
7
+ export const useScreenDimensions = () => {
8
+ const { width: screenWidth, height: screenHeight } = Dimensions.get('window')
9
+ const [screenData, setScreenData] = useState({
10
+ width: screenWidth,
11
+ height: screenHeight,
12
+ })
13
+ useEffect(() => {
14
+ if (Platform.OS === 'android') {
15
+ setScreenData({
16
+ width: height,
17
+ height: width - statusBarHeight,
18
+ })
19
+ }
20
+ const onChange = (result: { window: ScaledSize }) => {
21
+ if (Platform.OS === 'ios') {
22
+ setScreenData(result.window)
23
+ }
24
+ }
25
+ // Subscribe to dimension changes
26
+ Dimensions.addEventListener('change', onChange)
27
+ // Don't forget to unsubscribe on cleanup
28
+ return () => {
29
+ Dimensions.removeEventListener('change', onChange)
30
+ }
31
+ }, [])
32
+ return {
33
+ ...screenData,
34
+ isLandscape: screenData.width > screenData.height,
35
+ }
36
+ }
@@ -1,3 +1,4 @@
1
+ import FeatureInfo from '@ledvance/base/src/components/FeatureInfo'
1
2
  import React, { memo, useCallback, useMemo } from "react";
2
3
  import { FlatList, Image, ScrollView, StyleSheet, Text, View } from 'react-native'
3
4
  import Page from "@ledvance/base/src/components/Page";
@@ -210,6 +211,7 @@ const FixedTimePage = (props: { theme?: ThemeType }) => {
210
211
  onHeadlineIconClick={() => {
211
212
  navigateToEdit('add', newFixedTime(!!params.isPlug))
212
213
  }}
214
+ info={<FeatureInfo title={I18n.getLang('fixedTimeCycle_socket_headline')} content={I18n.getLang('infobutton_fixedtimecycle')} />}
213
215
  >
214
216
  <ScrollView nestedScrollEnabled={true}>
215
217
  <Text style={{
@@ -1,3 +1,4 @@
1
+ import FeatureInfo from '@ledvance/base/src/components/FeatureInfo'
1
2
  import React from 'react'
2
3
  import {ScrollView, StyleSheet, Text, View} from 'react-native'
3
4
  import {useReactive, useUpdateEffect} from 'ahooks'
@@ -67,6 +68,7 @@ const LightBehaviorPage = (props: { theme?: ThemeType }) => {
67
68
  <Page
68
69
  backText={deviceInfo.name}
69
70
  headlineText={I18n.getLang('light_sources_specific_settings_power_off')}
71
+ info={<FeatureInfo title={I18n.getLang('light_sources_specific_settings_power_off')} content={I18n.getLang('infobutton_poweronbehavior')} />}
70
72
  loading={state.loading}>
71
73
  <ScrollView style={styles.root} nestedScrollEnabled={true}>
72
74
  <View>
@@ -1,3 +1,4 @@
1
+ import FeatureInfo from '@ledvance/base/src/components/FeatureInfo'
1
2
  import React from 'react'
2
3
  import {ScrollView, StyleSheet} from 'react-native'
3
4
  import Page from '@ledvance/base/src/components/Page'
@@ -44,6 +45,7 @@ const PlugBehaviorPage = () => {
44
45
  <Page
45
46
  backText={deviceInfo.name}
46
47
  headlineText={I18n.getLang('light_sources_specific_settings_power_off')}
48
+ info={<FeatureInfo title={I18n.getLang('light_sources_specific_settings_power_off')} content={I18n.getLang('infobutton_poweronbehavior')} />}
47
49
  loading={state.loading}>
48
50
  <ScrollView style={styles.root} nestedScrollEnabled={true}>
49
51
  {params.powerBehaviorKeys.length > 1 && <>
@@ -1,3 +1,4 @@
1
+ import FeatureInfo from '@ledvance/base/src/components/FeatureInfo'
1
2
  import React, { useCallback, useMemo } from 'react'
2
3
  import { FlatList, Image, ScrollView, StyleSheet, Text, View } from 'react-native'
3
4
  import Page from '@ledvance/base/src/components/Page'
@@ -213,6 +214,7 @@ const RandomTimePage = (props: { theme?: ThemeType }) => {
213
214
  onHeadlineIconClick={() => {
214
215
  navigateToEdit('add', newRandomTime(!!params.isPlug))
215
216
  }}
217
+ info={<FeatureInfo title={I18n.getLang('randomtimecycle_sockets_headline_text')} content={I18n.getLang('infobutton_randomtimecycle')} />}
216
218
  >
217
219
  <ScrollView nestedScrollEnabled={true}>
218
220
  <Text style={{
@@ -24,6 +24,7 @@ import { cloneDeep } from 'lodash';
24
24
  import ThemeType from '@ledvance/base/src/config/themeType'
25
25
  import { showDialog } from '@ledvance/base/src/utils/common';
26
26
  import { ApplyForItem } from '@ledvance/base/src/utils/interface';
27
+ import FeatureInfo from "@ledvance/base/src/components/FeatureInfo"
27
28
 
28
29
  const { convertX: cx } = Utils.RatioUtils;
29
30
  const { withTheme } = Utils.ThemeUtils
@@ -187,6 +188,7 @@ const TimeSchedulePage = (props: { theme?: ThemeType }) => {
187
188
  onHeadlineIconClick={() => {
188
189
  navigateToEdit('add');
189
190
  }}
191
+ info={<FeatureInfo title={I18n.getLang('timeschedule_overview_headline_text')} content={I18n.getLang('infobutton_timeschedule')} />}
190
192
  loading={state.loading}
191
193
  >
192
194
  <ScrollView nestedScrollEnabled={true}>