@ledvance/ui-biz-bundle 1.1.148 → 1.1.149
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 +1 -1
- package/src/newModules/energyConsumption/EnergyConsumptionChart/LandscapeView.tsx +4 -4
- package/src/newModules/energyConsumption/EnergyConsumptionChart/index.tsx +11 -1
- package/src/newModules/energyConsumption/EnergyConsumptionChart/styles.ts +1 -1
- package/src/newModules/energyConsumption/EnergyConsumptionChart/useScreenDimensions.ts +36 -0
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@ 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}>
|
|
12
|
+
export const LandscapeView = ({ state, actions, params, styles, theme, screenWidth, screenHeight }) => (
|
|
13
|
+
<View style={[styles.landscapeContainer, { width: screenWidth, height: screenHeight }]}>
|
|
14
14
|
<View style={styles.landscapeHeader}>
|
|
15
15
|
<Text style={styles.landscapeTitle}>
|
|
16
16
|
{I18n.getLang(state.chartType === ChartType.kWh ? 'chartdisplay_energy' : 'chartdisplay_power')}
|
|
@@ -29,7 +29,7 @@ export const LandscapeView = ({ state, actions, params, styles, theme }) => (
|
|
|
29
29
|
params={params}
|
|
30
30
|
styles={styles}
|
|
31
31
|
theme={theme}
|
|
32
|
-
chartHeight={
|
|
32
|
+
chartHeight={screenHeight - cx(110)}
|
|
33
33
|
/>
|
|
34
34
|
) : (
|
|
35
35
|
<PowerChartSection
|
|
@@ -38,7 +38,7 @@ export const LandscapeView = ({ state, actions, params, styles, theme }) => (
|
|
|
38
38
|
actions={actions}
|
|
39
39
|
styles={styles}
|
|
40
40
|
theme={theme}
|
|
41
|
-
chartHeight={
|
|
41
|
+
chartHeight={screenHeight - cx(110)}
|
|
42
42
|
/>
|
|
43
43
|
)}
|
|
44
44
|
</View>
|
|
@@ -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
|
|
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,7 +51,7 @@ 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
57
|
paddingHorizontal: cx(20),
|
|
@@ -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
|
+
}
|