@towsila/expo-ui-library 4.18.2 → 4.19.0
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/hooks/useScreenLayout.ts +26 -0
- package/src/index.ts +2 -1
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useWindowDimensions } from "react-native";
|
|
2
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
3
|
+
|
|
4
|
+
const MAX_CONTENT_WIDTH = 640;
|
|
5
|
+
|
|
6
|
+
export function useScreenLayout(hasBottomNav: boolean = false) {
|
|
7
|
+
const { width, height } = useWindowDimensions();
|
|
8
|
+
const insets = useSafeAreaInsets();
|
|
9
|
+
|
|
10
|
+
const horizontalPadding = width < 360 ? 16 : width >= 768 ? 32 : 20;
|
|
11
|
+
const topPadding = Math.max(insets.top, 12) + 12;
|
|
12
|
+
const bottomPadding = hasBottomNav
|
|
13
|
+
? 16
|
|
14
|
+
: Math.max(insets.bottom, 12) + 10;
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
insets,
|
|
20
|
+
horizontalPadding,
|
|
21
|
+
topPadding,
|
|
22
|
+
bottomPadding,
|
|
23
|
+
maxContentWidth: MAX_CONTENT_WIDTH,
|
|
24
|
+
isCompact: width < 360 || height < 700,
|
|
25
|
+
};
|
|
26
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -90,4 +90,5 @@ export {default as AppMap} from "./components/ui/appMap";
|
|
|
90
90
|
export {default as CustomMarker} from "./components/ui/customMarker";
|
|
91
91
|
export {default as PositionMarker} from "./components/ui/positionMarker";
|
|
92
92
|
export {default as MovingMarker} from "./components/ui/movingMarker";
|
|
93
|
-
export {default as MapHeader} from "./components/ui/mapHeader";
|
|
93
|
+
export {default as MapHeader} from "./components/ui/mapHeader";
|
|
94
|
+
export {useScreenLayout} from "./hooks/useScreenLayout";
|