@ledvance/group-ui-biz-bundle 1.0.137 → 1.0.138

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/group-ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.0.137",
7
+ "version": "1.0.138",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -7,8 +7,8 @@ import { ChartSection } from './ChartSection'
7
7
 
8
8
  const { convertX: cx, width } = Utils.RatioUtils
9
9
 
10
- export const LandscapeView = ({ state, actions, params, styles, theme }) => (
11
- <View style={styles.landscapeContainer}>
10
+ export const LandscapeView = ({ state, actions, params, styles, theme, screenWidth, screenHeight }) => (
11
+ <View style={[styles.landscapeContainer, { width: screenWidth, height: screenHeight }]}>
12
12
  <View style={styles.landscapeHeader}>
13
13
  <Text style={styles.landscapeTitle}>
14
14
  {I18n.getLang('chartdisplay_energy')}
@@ -25,7 +25,7 @@ export const LandscapeView = ({ state, actions, params, styles, theme }) => (
25
25
  params={params}
26
26
  styles={styles}
27
27
  theme={theme}
28
- chartHeight={cx(width - 120)}
28
+ chartHeight={screenHeight - cx(110)}
29
29
  />
30
30
  </View>
31
31
  </View>
@@ -8,6 +8,7 @@ import { PortraitView } from './PortraitView'
8
8
  import { getStyles } from './styles'
9
9
 
10
10
  import { useEnergyData } from './useEnergyData'
11
+ import { useScreenDimensions } from './useScreenDimensions'
11
12
 
12
13
  const { withTheme } = Utils.ThemeUtils;
13
14
 
@@ -16,9 +17,17 @@ const EnergyConsumptionGroupChartComponent = (props: { theme?: ThemeType }) => {
16
17
 
17
18
  const { state, actions } = useEnergyData(params);
18
19
  const styles = useMemo(() => getStyles(props.theme), [props.theme]);
19
-
20
+ const { width: screenWidth, height: screenHeight } = useScreenDimensions()
20
21
  if (state.isLandscape) {
21
- return <LandscapeView state={state} actions={actions} params={params} styles={styles} theme={props.theme} />;
22
+ return <LandscapeView
23
+ state={state}
24
+ actions={actions}
25
+ params={params}
26
+ styles={styles}
27
+ theme={props.theme}
28
+ screenWidth={screenWidth}
29
+ screenHeight={screenHeight}
30
+ />;
22
31
  }
23
32
 
24
33
  return <PortraitView state={state} actions={actions} params={params} styles={styles} theme={props.theme} />;
@@ -28,7 +28,7 @@ export const getStyles = (theme: ThemeType | undefined) => StyleSheet.create({
28
28
  landscapeContainer: {
29
29
  flex: 1,
30
30
  backgroundColor: theme?.global.background,
31
- width: cx(height + 20),
31
+ // width: cx(height + 20),
32
32
  paddingVertical: cx(30),
33
33
  paddingHorizontal: cx(20),
34
34
  },
@@ -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
+ }