@tactics/toddle-styleguide 5.4.48 → 5.4.49

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "5.4.48",
3
+ "version": "5.4.49",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -14,6 +14,7 @@ type PopoverModalProps = {
14
14
  isVisible: boolean;
15
15
  children: React.ReactNode;
16
16
  windowHeight: number;
17
+ bottomInset?: number;
17
18
  disableScrollContent?: boolean;
18
19
  };
19
20
 
@@ -24,6 +25,7 @@ const Modal = ({
24
25
  onClose,
25
26
  children,
26
27
  windowHeight,
28
+ bottomInset = 0,
27
29
  disableScrollContent,
28
30
  }: PopoverModalProps) => {
29
31
  // Keep element and window size in local state.
@@ -36,7 +38,11 @@ const Modal = ({
36
38
  const elementHeight = Math.round(elementSize.height);
37
39
 
38
40
  const maxHeight = Math.round(windowHeight / 100) * 90;
39
- const translateYStartingPoint = windowHeight;
41
+ // windowHeight already reflects the full edge-to-edge screen height on
42
+ // Android, but it excludes the space behind the navigation bar, so the
43
+ // sheet's rest/closed position needs bottomInset added or its top edge
44
+ // peeks out from behind the nav bar when closed (see PopoverAction).
45
+ const translateYStartingPoint = windowHeight + bottomInset;
40
46
 
41
47
  const saveHeight = elementHeight > maxHeight ? maxHeight : elementHeight;
42
48
 
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import {useEffect, useState} from 'react';
3
- import {Dimensions, Platform, StatusBar, View} from 'react-native';
3
+ import {Dimensions, Platform, View} from 'react-native';
4
+ import {useSafeAreaInsets} from 'react-native-safe-area-context';
4
5
  import {Stylesheet} from './popover.styles';
5
6
  import {Backdrop} from '../../atoms/backdrop/backdrop.component';
6
7
  import {Modal, Foreground} from './components';
@@ -23,17 +24,14 @@ const Popover = ({
23
24
  disableScrollContent,
24
25
  }: PopoverProps) => {
25
26
  const styles = Stylesheet();
27
+ const insets = useSafeAreaInsets();
26
28
  const [windowHeight, setWindowHeight] = useState(
27
29
  Dimensions.get('window').height
28
30
  );
29
31
 
30
32
  useEffect(() => {
31
33
  const updateWindowHeight = () => {
32
- let availableHeight = Dimensions.get('window').height;
33
- if (Platform.OS === 'android') {
34
- availableHeight += StatusBar.currentHeight ?? 0;
35
- }
36
- setWindowHeight(availableHeight);
34
+ setWindowHeight(Dimensions.get('window').height);
37
35
  };
38
36
 
39
37
  updateWindowHeight();
@@ -52,6 +50,7 @@ const Popover = ({
52
50
  <Foreground>
53
51
  <Modal
54
52
  windowHeight={windowHeight}
53
+ bottomInset={Platform.OS === 'android' ? insets.bottom : 0}
55
54
  isVisible={isVisible}
56
55
  onClose={onClose}
57
56
  title={title}
@@ -12,7 +12,6 @@ import {
12
12
  Dimensions,
13
13
  LayoutChangeEvent,
14
14
  Platform,
15
- StatusBar,
16
15
  View,
17
16
  ViewProps,
18
17
  } from 'react-native';
@@ -114,11 +113,7 @@ export const PopOverAction = ({
114
113
 
115
114
  useEffect(() => {
116
115
  const updateWindowHeight = () => {
117
- let availableHeight = Dimensions.get('window').height;
118
- if (Platform.OS === 'android') {
119
- availableHeight += StatusBar.currentHeight ?? 0;
120
- }
121
- setWindowHeight(availableHeight);
116
+ setWindowHeight(Dimensions.get('window').height);
122
117
  };
123
118
 
124
119
  updateWindowHeight();