@momo-kits/foundation 0.169.17-beta.2 → 0.169.17-beta.4

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.
@@ -120,9 +120,9 @@ type SheetStyleParams = {
120
120
  };
121
121
 
122
122
  /**
123
- * Sheet container style. On foldables the sheet sits at `sheet.x`: centered on
124
- * the window, clear of the iPhone Duo control column, and on the right half when
125
- * half folded; the keyboard lift comes off its max height.
123
+ * Sheet container style. On foldables the sheet is centered in the placement
124
+ * area, clear of the iPhone Duo control column and on the right half when half
125
+ * folded; the keyboard lift comes off its max height.
126
126
  */
127
127
  export const getSheetStyle = ({
128
128
  backgroundColor,
@@ -138,7 +138,7 @@ export const getSheetStyle = ({
138
138
  if (isFoldable && width !== undefined && maxHeight !== undefined) {
139
139
  foldableStyle = {
140
140
  width,
141
- marginLeft: sheet.x ?? placement.x + (placement.width - width) / 2,
141
+ marginLeft: placement.x + (placement.width - width) / 2,
142
142
  maxHeight: maxHeight - keyboardLift,
143
143
  minHeight: sheet.minHeight,
144
144
  };
@@ -7,7 +7,6 @@ import {
7
7
  Pressable,
8
8
  StyleSheet,
9
9
  View,
10
- ViewStyle,
11
10
  } from 'react-native';
12
11
  import { ApplicationContext, MiniAppContext } from '../Context';
13
12
  import { BottomSheetParams } from './types';
@@ -191,10 +190,22 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
191
190
  />
192
191
  );
193
192
 
194
- // same tree on every layout so fold / unfold keeps the screen mounted (state, scroll)
195
- let contentStyle: ViewStyle | undefined;
193
+ let content: React.ReactNode;
196
194
  if (isFoldable) {
197
- contentStyle = styles.shrink;
195
+ // Content shrinks so a tall sheet keeps its header and footer.
196
+ content = (
197
+ <View style={styles.shrink}>
198
+ {renderSheetHeader(headerParams)}
199
+ <View style={styles.shrink}>{screen}</View>
200
+ </View>
201
+ );
202
+ } else {
203
+ content = (
204
+ <>
205
+ {renderSheetHeader(headerParams)}
206
+ {screen}
207
+ </>
208
+ );
198
209
  }
199
210
 
200
211
  return (
@@ -242,8 +253,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
242
253
  }),
243
254
  ]}
244
255
  >
245
- {renderSheetHeader(headerParams)}
246
- <View style={contentStyle}>{screen}</View>
256
+ {content}
247
257
  {renderSheetFooter({ footerComponent, theme })}
248
258
  {useBottomInset && (
249
259
  <View
@@ -6,14 +6,12 @@ import {
6
6
  ViewStyle,
7
7
  } from 'react-native';
8
8
  import { ApplicationContext } from '../Context';
9
- import { Colors } from '../Consts';
9
+ import { Radius, Spacing } from '../Consts';
10
10
  import { Icon } from '../Icon';
11
- import { HeaderBarMetrics } from './headerLayout';
12
11
 
13
- // same round button as the Top nav (NavigationButton), shared with the Compose / SwiftUI kits
14
- const MODAL_ICON_BUTTON_SIZE = HeaderBarMetrics.buttonSize;
15
- const MODAL_ICON_SIZE = HeaderBarMetrics.iconSize;
16
- const MODAL_ICON_BUTTON_BORDER_WIDTH = 0.2;
12
+ // modal spec: icon button 32, icon 20, shared with the Compose / SwiftUI kits
13
+ const MODAL_ICON_BUTTON_SIZE = Spacing.XXL;
14
+ const MODAL_ICON_SIZE = 20;
17
15
 
18
16
  type ModalIconButtonProps = {
19
17
  icon: string;
@@ -23,8 +21,7 @@ type ModalIconButtonProps = {
23
21
  };
24
22
 
25
23
  /**
26
- * Close / back button of popups and bottom sheet headers, drawn like the round
27
- * Top nav icon button so modals and headers share one look.
24
+ * Close / back button of popups and bottom sheet headers
28
25
  */
29
26
  const ModalIconButton: React.FC<ModalIconButtonProps> = ({
30
27
  icon,
@@ -37,7 +34,14 @@ const ModalIconButton: React.FC<ModalIconButtonProps> = ({
37
34
  <TouchableOpacity
38
35
  accessibilityLabel={accessibilityLabel}
39
36
  onPress={onPress}
40
- style={[styles.button, style]}
37
+ style={[
38
+ styles.button,
39
+ {
40
+ backgroundColor: theme.colors.background.surface,
41
+ borderColor: theme.colors.border.default,
42
+ },
43
+ style,
44
+ ]}
41
45
  >
42
46
  <Icon
43
47
  source={icon}
@@ -52,12 +56,10 @@ const styles = StyleSheet.create({
52
56
  button: {
53
57
  width: MODAL_ICON_BUTTON_SIZE,
54
58
  height: MODAL_ICON_BUTTON_SIZE,
55
- borderRadius: MODAL_ICON_BUTTON_SIZE / 2,
56
- borderWidth: MODAL_ICON_BUTTON_BORDER_WIDTH,
59
+ borderRadius: Radius.L,
60
+ borderWidth: 1,
57
61
  alignItems: 'center',
58
62
  justifyContent: 'center',
59
- backgroundColor: Colors.black_01 + '99',
60
- borderColor: Colors.black_20 + '33',
61
63
  },
62
64
  });
63
65
 
@@ -41,9 +41,47 @@ const ModalScreen: React.FC<any> = props => {
41
41
  if (props.route?.params?.isBottomSheet) {
42
42
  return <BottomSheet {...props} />;
43
43
  }
44
+ if (props.route?.params?.fullScreen) {
45
+ return <FullScreenModal {...props} />;
46
+ }
44
47
  return <Modal {...props} />;
45
48
  };
46
49
 
50
+ /**
51
+ * Edge to edge layer for overlays that draw their own scrim (e.g. Coachmark):
52
+ * no scrim, no animation, Android back is swallowed; the screen closes itself.
53
+ */
54
+ const FullScreenModal: React.FC<ModalParams> = props => {
55
+ const { screen, onDismiss } = props.route.params;
56
+ const Component = useRef(screen).current;
57
+ const params = { ...props.route.params };
58
+ delete params.screen;
59
+
60
+ useEffect(() => {
61
+ return () => {
62
+ onDismiss?.();
63
+ };
64
+ }, [onDismiss]);
65
+
66
+ useEffect(() => {
67
+ const backHandler = BackHandler.addEventListener(
68
+ 'hardwareBackPress',
69
+ () => true,
70
+ );
71
+ return () => backHandler.remove();
72
+ }, []);
73
+
74
+ const handleClose = useCallback(() => {
75
+ props.navigation.goBack();
76
+ }, [props.navigation]);
77
+
78
+ return (
79
+ <View style={StyleSheet.absoluteFillObject}>
80
+ <Component {...params} onRequestClose={handleClose} />
81
+ </View>
82
+ );
83
+ };
84
+
47
85
  /**
48
86
  * Centered popup that fades and scales in over a scrim. On foldables it is
49
87
  * centered in the modal placement area, at most a popup wide.
@@ -8,7 +8,7 @@ import { isIPhoneDuo } from './utils';
8
8
  const POPUP_MAX_WIDTH = 450;
9
9
  const POPUP_MIN_WIDTH = 280;
10
10
  const POPUP_MAX_HEIGHT = 600;
11
- const SHEET_MAX_WIDTH = 600;
11
+ const SHEET_MAX_WIDTH = 653;
12
12
  const SHEET_MIN_WIDTH = 296;
13
13
  const SHEET_MIN_HEIGHT = 230;
14
14
  const FOLDABLE_MIN_WIDTH = 600;
@@ -53,12 +53,6 @@ export type ModalLayout = {
53
53
  * `undefined` on phones, the sheet spans the window.
54
54
  */
55
55
  width?: number;
56
- /**
57
- * Window x of the sheet's left edge, `undefined` on phones. Centered on the
58
- * window, but kept a margin clear of the iPhone Duo control column / system
59
- * insets; half folded it is centered in the right half.
60
- */
61
- x?: number;
62
56
  maxHeight?: number;
63
57
  minHeight?: number;
64
58
  margin: number;
@@ -136,19 +130,6 @@ const getModalLayout = ({
136
130
  const sheetSpace = placement.width - sheetMargin * 2;
137
131
  const sheetMinWidth = Math.min(SHEET_MIN_WIDTH, sheetSpace);
138
132
  const sheetMaxHeight = height - insets.top - Spacing.M;
139
- const sheetWidth = clamp(sheetSpace, sheetMinWidth, SHEET_MAX_WIDTH);
140
- // the window center, not the placement's, so an inset on one side (control column) does not push it off center
141
- let sheetCenter = width / 2;
142
- if (isHalfFolded) {
143
- sheetCenter = placement.x + placement.width / 2;
144
- }
145
- const sheetX = Math.max(
146
- placement.x + sheetMargin,
147
- Math.min(
148
- sheetCenter - sheetWidth / 2,
149
- placement.x + placement.width - sheetMargin - sheetWidth,
150
- ),
151
- );
152
133
 
153
134
  return {
154
135
  isFoldable,
@@ -162,8 +143,7 @@ const getModalLayout = ({
162
143
  radius: Radius.XL,
163
144
  },
164
145
  sheet: {
165
- width: sheetWidth,
166
- x: sheetX,
146
+ width: clamp(sheetSpace, sheetMinWidth, SHEET_MAX_WIDTH),
167
147
  maxHeight: sheetMaxHeight,
168
148
  minHeight: Math.min(SHEET_MIN_HEIGHT, sheetMaxHeight),
169
149
  margin: sheetMargin,
@@ -96,6 +96,8 @@ export type ModalParams = {
96
96
  barrierDismissible?: boolean;
97
97
  modalStyle?: ViewStyle;
98
98
  useNativeModal?: boolean;
99
+ /** Edge to edge screen with no scrim or animation; it closes itself. */
100
+ fullScreen?: boolean;
99
101
  };
100
102
 
101
103
  export type BottomSheetParams = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.169.17-beta.2",
3
+ "version": "0.169.17-beta.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},