@momo-kits/foundation 0.168.1-beta.3 → 0.168.1-beta.30

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.
@@ -8,6 +8,9 @@ import React, {
8
8
  useState,
9
9
  } from 'react';
10
10
  import {
11
+ Platform,
12
+ Pressable,
13
+ Text,
11
14
  TextInput,
12
15
  TextInputFocusEvent,
13
16
  TouchableOpacity,
@@ -21,7 +24,6 @@ import {
21
24
  } from '../Context';
22
25
  import { Icon } from '../Icon';
23
26
  import { useScaleSize, exportFontFamily } from '../Text';
24
- import { Spacing } from '../Consts';
25
27
  import {
26
28
  ErrorView,
27
29
  FloatingView,
@@ -31,9 +33,26 @@ import {
31
33
  } from './common';
32
34
  import { InputMoneyProps } from './index';
33
35
  import styles from './styles';
34
- import { formatNumberToMoney } from './utils';
35
36
  import SystemTextInput from './SystemTextInput';
36
37
 
38
+ const moneyFormatter = new Intl.NumberFormat('vi-VN');
39
+
40
+ const findEdit = (old: string, text: string) => {
41
+ let start = 0;
42
+ while (start < text.length && old[start] === text[start]) {
43
+ start += 1;
44
+ }
45
+ let suffix = 0;
46
+ while (
47
+ suffix < Math.min(text.length, old.length) - start &&
48
+ old[old.length - 1 - suffix] === text[text.length - 1 - suffix]
49
+ ) {
50
+ suffix += 1;
51
+ }
52
+ const size = old.length + text.length - 2 * (start + suffix);
53
+ return { old, start, suffix, size };
54
+ };
55
+
37
56
  const InputMoney = forwardRef(
38
57
  (
39
58
  {
@@ -74,6 +93,12 @@ const InputMoney = forwardRef(
74
93
  const [numericValue, setNumericValue] = useState('');
75
94
  const [lastDisplayValue, setLastDisplayValue] = useState('');
76
95
  const inputRef = useRef<TextInput>(null);
96
+ const caretDigitsAfter = useRef<number | undefined>(undefined);
97
+ const lastRawText = useRef('');
98
+ const [caretSelection, setCaretSelection] = useState<{
99
+ start: number;
100
+ end: number;
101
+ }>();
77
102
  const componentName = 'InputMoney';
78
103
 
79
104
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
@@ -91,6 +116,7 @@ const InputMoney = forwardRef(
91
116
  if (value !== undefined && typeof value === 'string') {
92
117
  const cleanValue = value.replace(/\D/g, '').replace(/^0+(?=\d)/, '');
93
118
  if (cleanValue !== numericValue) {
119
+ caretDigitsAfter.current = undefined;
94
120
  setNumericValue(cleanValue);
95
121
  updateDisplayValue(cleanValue);
96
122
  }
@@ -101,21 +127,30 @@ const InputMoney = forwardRef(
101
127
  setLastDisplayValue(displayValue);
102
128
  }, [displayValue]);
103
129
 
130
+ useEffect(() => {
131
+ if (!caretSelection) return;
132
+ setCaretSelection(current =>
133
+ current === caretSelection ? undefined : current,
134
+ );
135
+ }, [caretSelection]);
136
+
104
137
  const updateDisplayValue = (numeric: string) => {
105
- if (!numeric) {
106
- setDisplayValue('');
107
- return;
138
+ const next = numeric ? moneyFormatter.format(Number(numeric)) : '';
139
+ setDisplayValue(next);
140
+
141
+ const digitsAfter = caretDigitsAfter.current;
142
+ caretDigitsAfter.current = undefined;
143
+ if (Platform.OS !== 'android' || digitsAfter === undefined) return;
144
+ let before = parseInputText(next).length - digitsAfter;
145
+ let caret = 0;
146
+ while (before > 0 && caret < next.length) {
147
+ if (/\d/.test(next[caret])) before -= 1;
148
+ caret += 1;
108
149
  }
109
- const formatted = formatNumberToMoney(Number(numeric));
110
- setDisplayValue(formatted ? `${formatted}${currency}` : '');
150
+ setCaretSelection({ start: caret, end: caret });
111
151
  };
112
152
 
113
- const parseInputText = (text: string): string => {
114
- if (!text) return '';
115
- const currencyRegex = new RegExp(` ?${currency}$`, 'g');
116
- const textWithoutCurrency = text.replace(currencyRegex, '').trim();
117
- return textWithoutCurrency.replace(/[^\d]/g, '');
118
- };
153
+ const parseInputText = (text: string): string => text.replace(/\D/g, '');
119
154
 
120
155
  const updateNumericValue = (val: string) => {
121
156
  let next = val.replace(/[^\d]/g, '').replace(/^0+(?=\d)/, '');
@@ -137,39 +172,35 @@ const InputMoney = forwardRef(
137
172
 
138
173
  const _onChangeText = (text: string) => {
139
174
  if (!text) {
175
+ lastRawText.current = '';
140
176
  setDisplayValue('');
141
177
  setNumericValue('');
142
178
  onChangeText?.('');
143
179
  return;
144
180
  }
145
- if (text.length < lastDisplayValue.length) {
146
- const old = lastDisplayValue;
147
- let start = 0;
148
- while (start < text.length && old[start] === text[start]) {
149
- start += 1;
150
- }
151
- let suffix = 0;
152
- while (
153
- suffix < text.length - start &&
154
- old[old.length - 1 - suffix] === text[text.length - 1 - suffix]
155
- ) {
156
- suffix += 1;
157
- }
158
- const removed = old.slice(start, old.length - suffix);
159
- if (!/\d/.test(removed)) {
160
- const index = removed.includes('.')
161
- ? parseInputText(old.slice(0, start)).length - 1
162
- : numericValue.length - 1;
163
- if (index >= 0) {
164
- updateNumericValue(
165
- numericValue.slice(0, index) + numericValue.slice(index + 1),
166
- );
167
- }
181
+ const digits = parseInputText(text);
182
+ const raw = lastRawText.current;
183
+ lastRawText.current = text;
184
+ const formattedEdit = findEdit(lastDisplayValue, text);
185
+ const rawEdit = findEdit(raw, text);
186
+ const { old, start, suffix } =
187
+ raw && rawEdit.size < formattedEdit.size ? rawEdit : formattedEdit;
188
+ caretDigitsAfter.current = parseInputText(
189
+ text.slice(text.length - suffix),
190
+ ).length;
191
+ if (text.length < old.length && digits === numericValue) {
192
+ const index = parseInputText(text.slice(0, start)).length - 1;
193
+ if (index >= 0) {
194
+ updateNumericValue(digits.slice(0, index) + digits.slice(index + 1));
168
195
  return;
169
196
  }
170
197
  }
171
- const newNumericValue = parseInputText(text);
172
- updateNumericValue(newNumericValue);
198
+ updateNumericValue(digits);
199
+ };
200
+
201
+ const focusAtEnd = () => {
202
+ inputRef.current?.focus();
203
+ inputRef.current?.setSelection(displayValue.length, displayValue.length);
173
204
  };
174
205
 
175
206
  const _onFocus = (e: TextInputFocusEvent) => {
@@ -183,6 +214,7 @@ const InputMoney = forwardRef(
183
214
  };
184
215
 
185
216
  const _setText = (text: string) => {
217
+ caretDigitsAfter.current = undefined;
186
218
  if (!text) {
187
219
  setDisplayValue('');
188
220
  setNumericValue('');
@@ -212,6 +244,14 @@ const InputMoney = forwardRef(
212
244
  placeholderColor = disabledColor;
213
245
  iconTintColor = disabledColor;
214
246
  }
247
+ const textStyle = {
248
+ fontSize: scaledFontSize,
249
+ fontFamily: inputFontFamily,
250
+ };
251
+ const placeholderHasCurrency = placeholder.endsWith(currency);
252
+ const inputPlaceholder = placeholderHasCurrency
253
+ ? placeholder.slice(0, -currency.length)
254
+ : placeholder;
215
255
  return (
216
256
  <View
217
257
  style={[
@@ -230,7 +270,11 @@ const InputMoney = forwardRef(
230
270
  onPress={onPressFloatingIcon}
231
271
  componentId={componentId}
232
272
  />
233
- <View style={styles.inputView}>
273
+ <Pressable
274
+ style={[styles.inputView, styles.moneyInputView]}
275
+ onPress={focusAtEnd}
276
+ disabled={disabled}
277
+ >
234
278
  <SystemTextInput
235
279
  {...props}
236
280
  accessibilityLabel={`${componentId}`}
@@ -240,32 +284,32 @@ const InputMoney = forwardRef(
240
284
  disabled: disabled,
241
285
  ...props.accessibilityState,
242
286
  }}
243
- style={[
244
- {
245
- width: '100%',
246
- paddingLeft: Spacing.M,
247
- height: '100%',
248
- fontSize: scaledFontSize,
249
- paddingVertical: Spacing.S,
250
- fontFamily: inputFontFamily,
251
- },
252
- {
253
- color: textColor,
254
- },
255
- ]}
287
+ style={[textStyle, styles.moneyTextInput, { color: textColor }]}
256
288
  allowFontScaling={false}
257
289
  textBreakStrategy="highQuality"
258
290
  value={displayValue}
291
+ selection={caretSelection ?? props.selection}
259
292
  onChangeText={_onChangeText}
260
293
  onFocus={_onFocus}
261
294
  onBlur={_onBlur}
262
- placeholder={placeholder}
295
+ placeholder={inputPlaceholder}
263
296
  selectionColor={theme.colors.primary}
264
297
  placeholderTextColor={placeholderColor}
265
298
  keyboardType={'numeric'}
266
299
  maxLength={undefined}
267
300
  />
268
- </View>
301
+ {displayValue || placeholderHasCurrency ? (
302
+ <Text
303
+ style={[
304
+ textStyle,
305
+ { color: displayValue ? textColor : placeholderColor },
306
+ ]}
307
+ allowFontScaling={false}
308
+ >
309
+ {currency}
310
+ </Text>
311
+ ) : null}
312
+ </Pressable>
269
313
  <View style={styles.iconView}>
270
314
  {showClearIcon && focused && displayValue ? (
271
315
  <TouchableOpacity
package/Input/styles.ts CHANGED
@@ -218,4 +218,13 @@ export default StyleSheet.create({
218
218
  marginLeft: Spacing.M,
219
219
  },
220
220
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
221
+ moneyInputView: {
222
+ paddingLeft: Spacing.M,
223
+ },
224
+ moneyTextInput: {
225
+ flexShrink: 1,
226
+ paddingLeft: 0,
227
+ paddingRight: Spacing.XXS,
228
+ paddingVertical: 0,
229
+ },
221
230
  });
package/Layout/Screen.tsx CHANGED
@@ -64,6 +64,8 @@ import {
64
64
  import { DuoQuickReturnHeader } from '../Application/Components/DuoQuickReturnHeader';
65
65
  import { useDuoTabBarInset } from '../Application/BottomTab/DuoTabBar';
66
66
 
67
+ const ANIMATED_BANNER_HEIGHT = 210;
68
+
67
69
  export interface ScreenProps extends ViewProps {
68
70
  /**
69
71
  * ReactNode representing the content of the screen.
@@ -222,19 +224,6 @@ const Screen = forwardRef(
222
224
  const frame = useSafeAreaFrame();
223
225
  const heightHeader = useHeaderHeight();
224
226
 
225
- /**
226
- * Dual animation source:
227
- * - `animatedValue` is a react-native `Animated.Value` driven natively by the
228
- * scroll event. It is what legacy consumers receive (`animatedValue`).
229
- * - `sharedValue` is a reanimated `SharedValue` consumed by every internal
230
- * foundation component (and offered to modern consumers). It is kept in
231
- * sync from the scroll `listener` (see below), which fires on the JS
232
- * thread even when the scroll uses the native driver.
233
- * If a legacy value is driven outside of Screen, its listener also
234
- * mirrors JS-driven updates into the shared value.
235
- * Consumers pass only `Animated.Value`; the reanimated shared value stays
236
- * an internal implementation detail.
237
- */
238
227
  const animatedValue = useRef<Animated.Value>(
239
228
  customAnimatedValue ?? new Animated.Value(0),
240
229
  );
@@ -258,7 +247,6 @@ const Screen = forwardRef(
258
247
  const currentTint = useRef<string | undefined>(undefined);
259
248
 
260
249
  const isTab = !!screen?.bottomTab;
261
- // Duo floating tab bar overlays the tab content instead of taking layout space
262
250
  const duoTabInset = useDuoTabBarInset();
263
251
 
264
252
  let handleScroll;
@@ -267,14 +255,12 @@ const Screen = forwardRef(
267
255
  const isIOS = Platform.OS === 'ios';
268
256
  const bottomInset = isIOS ? Math.min(insets.bottom, 21) : insets.bottom;
269
257
  const hasSideBar = !!layout.sideBar;
270
- // iPhone Duo: content scrolls under a glass header instead of starting below it
271
258
  const useDuoGlass =
272
259
  hasSideBar &&
273
260
  (headerType === 'default' || headerType === 'extended') &&
274
261
  !animatedHeader &&
275
262
  !inputSearchProps;
276
263
 
277
- // iPhone Duo: the header leaves with the content and returns on a reverse scroll
278
264
  const useQuickReturn =
279
265
  hasSideBar && scrollable && (useDuoGlass || !!animatedHeader);
280
266
  const headerHide = useSharedValue(0);
@@ -324,12 +310,14 @@ const Screen = forwardRef(
324
310
  */
325
311
  screen?.onSetParams?.(trackingParams);
326
312
 
313
+ const appliedHeaderMode = useRef<string | undefined>(undefined);
314
+
327
315
  /**
328
316
  * export options for screen
329
317
  * @param headerType
330
318
  */
331
319
  const setHeaderType = useCallback(
332
- (headerType: HeaderType) => {
320
+ (headerType: HeaderType, keepTitle = false) => {
333
321
  let options: StackNavigationOptions;
334
322
  switch (headerType) {
335
323
  case 'none':
@@ -418,6 +406,10 @@ const Screen = forwardRef(
418
406
  }
419
407
  }
420
408
 
409
+ if (keepTitle) {
410
+ delete options.headerTitle;
411
+ }
412
+
421
413
  navigation?.instance?.setOptions({ header: undefined, ...options });
422
414
  },
423
415
  [
@@ -449,10 +441,9 @@ const Screen = forwardRef(
449
441
  headerTransparent: true,
450
442
  headerBackground: (props: any) =>
451
443
  hasSideBar ? (
452
- // glass shows once the banner has scrolled under the header
453
444
  <DuoGlassBackground
454
445
  animatedValue={sharedValue}
455
- fadeStart={Math.max(210 + layoutOffset - heightHeader, 0)}
446
+ bannerBottom={ANIMATED_BANNER_HEIGHT + layoutOffset}
456
447
  />
457
448
  ) : (
458
449
  <HeaderBackground
@@ -486,7 +477,6 @@ const Screen = forwardRef(
486
477
  useShadowHeader,
487
478
  hasSideBar,
488
479
  layoutOffset,
489
- heightHeader,
490
480
  quickReturnOptions,
491
481
  ],
492
482
  );
@@ -521,7 +511,6 @@ const Screen = forwardRef(
521
511
  let searchWidth = layout.width - 24;
522
512
  let searchLeft = Spacing.M;
523
513
  if (layout.sideBar) {
524
- // back floats in the side bar: the search spans the content width
525
514
  searchWidth = layout.contentWidth - Spacing.M * 2;
526
515
  searchLeft = Spacing.M - getHeaderMargin(layout.width);
527
516
  }
@@ -563,10 +552,13 @@ const Screen = forwardRef(
563
552
 
564
553
  if (animatedHeader) {
565
554
  setAnimatedHeader(animatedHeader);
555
+ appliedHeaderMode.current = 'animated';
566
556
  } else if (inputSearchProps) {
567
557
  setAnimatedSearch();
558
+ appliedHeaderMode.current = 'search';
568
559
  } else {
569
- setHeaderType(headerType);
560
+ setHeaderType(headerType, appliedHeaderMode.current === headerType);
561
+ appliedHeaderMode.current = headerType;
570
562
  }
571
563
 
572
564
  return () => {
@@ -613,7 +605,6 @@ const Screen = forwardRef(
613
605
  useNativeDriver: true,
614
606
  listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
615
607
  const offsetY = e.nativeEvent.contentOffset.y;
616
- // keep the reanimated source in sync for the internal components.
617
608
  sharedValue.value = offsetY;
618
609
  scrollViewProps?.onScroll?.(e);
619
610
  if (animatedHeader) {
@@ -648,7 +639,6 @@ const Screen = forwardRef(
648
639
  */
649
640
  const snapQuickReturnHeader = (offsetY: number) => {
650
641
  const hide = headerHide.value;
651
- // above heightHeader the header still sits on the content
652
642
  if (
653
643
  !useQuickReturn ||
654
644
  offsetY < heightHeader ||
@@ -692,11 +682,12 @@ const Screen = forwardRef(
692
682
  if (typeof animatedHeader?.component === 'function') {
693
683
  return (
694
684
  <View
695
- style={[styles.screenBanner, { maxHeight: 210 + layoutOffset }]}
685
+ style={[
686
+ styles.screenBanner,
687
+ { maxHeight: ANIMATED_BANNER_HEIGHT + layoutOffset },
688
+ ]}
696
689
  >
697
690
  {animatedHeader?.component({
698
- // legacy consumers read `animatedValue` (Animated.Value),
699
- // modern consumers read `sharedValue` (SharedValue).
700
691
  animatedValue: animatedValue.current,
701
692
  sharedValue: sharedValue,
702
693
  })}
@@ -756,11 +747,6 @@ const Screen = forwardRef(
756
747
  }
757
748
  };
758
749
 
759
- // Cap the screen container height so a scrollable body with a sticky footer
760
- // can't push the footer past the visible frame (web previews measure the
761
- // safe-area frame from the seeded SafeAreaProvider metrics). Subtract the
762
- // bottom tab bar when present and the header unless it's an animated/extended
763
- // header (those overlay rather than offset the body).
764
750
  const getHeight = () => {
765
751
  let newHeight = frame.height;
766
752
  if (isTab) {
@@ -772,8 +758,6 @@ const Screen = forwardRef(
772
758
  return newHeight;
773
759
  };
774
760
 
775
- // without the grid, the content container keeps clear of the horizontal insets.
776
- // Only set when there are insets, so a caller's paddingHorizontal is never overridden.
777
761
  const hasContentInset = layout.insetLeft > 0 || layout.insetRight > 0;
778
762
  const needsContentInset = !useGridLayout && hasContentInset;
779
763
  const contentInsetStyle = needsContentInset && {
@@ -796,8 +780,6 @@ const Screen = forwardRef(
796
780
  Styles.flex,
797
781
  {
798
782
  backgroundColor: backgroundColor ?? theme.colors.background.default,
799
- // Web-only cap so a scrollable body with a sticky footer can't push
800
- // the footer past the frame. Native handles this without a cap.
801
783
  maxHeight: Platform.OS === 'web' ? getHeight() : undefined,
802
784
  },
803
785
  ]}
@@ -882,7 +864,6 @@ const Screen = forwardRef(
882
864
  )}
883
865
 
884
866
  {Footer && (
885
- // with side insets, the clip keeps the shadow off the side bar, only the top one shows
886
867
  <View
887
868
  pointerEvents={'box-none'}
888
869
  style={[
@@ -904,8 +885,6 @@ const Screen = forwardRef(
904
885
  },
905
886
  ]}
906
887
  >
907
- {/* The footer inset is a caller decision, not a platform one — a footer
908
- that carries its own horizontal padding passes `marginFooter={false}`. */}
909
888
  <Section useMargin={marginFooter}>{Footer}</Section>
910
889
  </View>
911
890
  </View>
package/Layout/utils.ts CHANGED
@@ -510,6 +510,7 @@ const useGridSystem = () => {
510
510
  export {
511
511
  DuoMetrics,
512
512
  HeaderMetrics,
513
+ InnerEdgeStyles,
513
514
  getHeaderMargin,
514
515
  getHeaderRowOptions,
515
516
  useGridSystem,
@@ -8,7 +8,7 @@ import { Image } from '../Image';
8
8
  import { Text, useScaleSize } from '../Text';
9
9
  import { PopupNotifyProps } from './types';
10
10
  import { scheduleOnRN } from 'react-native-worklets';
11
- import { usePopupMaxHeight, usePopupWidth } from './utils';
11
+ import { getPopupRadius, usePopupMaxHeight, usePopupWidth } from './utils';
12
12
 
13
13
  const PopupNotify: React.FC<PopupNotifyProps> = ({
14
14
  image,
@@ -26,6 +26,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
26
26
  const [scrollContent, setScrollContent] = useState(false);
27
27
  const popupWidth = usePopupWidth();
28
28
  const maxHeight = usePopupMaxHeight();
29
+ const radius = getPopupRadius();
29
30
  const scaledMaxHeight = useScaleSize(172);
30
31
 
31
32
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
@@ -170,7 +171,15 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
170
171
 
171
172
  const body = (
172
173
  <>
173
- {!!image && <Image source={{ uri: image }} style={styles.image} />}
174
+ {!!image && (
175
+ <Image
176
+ source={{ uri: image }}
177
+ style={[
178
+ styles.image,
179
+ { borderTopLeftRadius: radius, borderTopRightRadius: radius },
180
+ ]}
181
+ />
182
+ )}
174
183
  <View style={styles.content}>
175
184
  <Text
176
185
  typography={'header_default_bold'}
@@ -218,9 +227,9 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
218
227
  <View
219
228
  accessibilityLabel={'popup_notify'}
220
229
  style={[
221
- styles.container,
222
230
  {
223
231
  backgroundColor: theme.colors.background.surface,
232
+ borderRadius: radius,
224
233
  width: popupWidth,
225
234
  maxHeight,
226
235
  },
@@ -231,7 +240,13 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
231
240
  body
232
241
  ) : (
233
242
  // scrolls when iPhone Duo landscape is too short; actions stay visible
234
- <ScrollView style={styles.body} bounces={false}>
243
+ <ScrollView
244
+ style={[
245
+ styles.body,
246
+ { borderTopLeftRadius: radius, borderTopRightRadius: radius },
247
+ ]}
248
+ bounces={false}
249
+ >
235
250
  {body}
236
251
  </ScrollView>
237
252
  )}
@@ -242,17 +257,12 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
242
257
  };
243
258
 
244
259
  const styles = StyleSheet.create({
245
- container: {
246
- borderRadius: Radius.L,
247
- },
248
260
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
249
261
  image: {
250
- borderTopLeftRadius: Radius.L,
251
- borderTopRightRadius: Radius.L,
252
262
  aspectRatio: 1.7777,
253
263
  overflow: 'hidden',
254
264
  },
255
- body: { flexShrink: 1 },
265
+ body: { flexShrink: 1, overflow: 'hidden' },
256
266
  content: { padding: Spacing.XL },
257
267
  description: {
258
268
  marginTop: Spacing.S,
package/Popup/utils.ts CHANGED
@@ -1,32 +1,26 @@
1
1
  import { Dimensions, useWindowDimensions } from 'react-native';
2
2
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
3
- import { Spacing } from '../Consts';
4
- import { getDuoTopInset, isIPhoneDuo } from '../Application/device';
5
-
6
- // width of a system alert on the iPhone Duo inner display, in both orientations
7
- const DUO_POPUP_MAX_WIDTH = 440;
3
+ import { Radius, Spacing } from '../Consts';
4
+ import { getDuoModalBounds, isFoldableDevice } from '../Application/device';
8
5
 
9
6
  const usePopupWidth = () => {
10
- const windowSize = useWindowDimensions();
11
- if (!isIPhoneDuo()) {
7
+ const insets = useSafeAreaInsets();
8
+ const { width, height } = useWindowDimensions();
9
+ if (!isFoldableDevice()) {
12
10
  return Dimensions.get('window').width - Spacing.XL * 2;
13
11
  }
14
- return Math.min(windowSize.width - Spacing.XL * 2, DUO_POPUP_MAX_WIDTH);
12
+ return getDuoModalBounds(insets, width, height).maxWidth;
15
13
  };
16
14
 
17
- // room left for a popup on iPhone Duo, where landscape is too short for it
18
15
  const usePopupMaxHeight = () => {
19
16
  const insets = useSafeAreaInsets();
20
17
  const { width, height } = useWindowDimensions();
21
- if (!isIPhoneDuo()) {
18
+ if (!isFoldableDevice()) {
22
19
  return undefined;
23
20
  }
24
- return (
25
- height -
26
- getDuoTopInset(insets, width, height) -
27
- insets.bottom -
28
- Spacing.XL * 2
29
- );
21
+ return getDuoModalBounds(insets, width, height).maxHeight;
30
22
  };
31
23
 
32
- export { usePopupWidth, usePopupMaxHeight };
24
+ const getPopupRadius = () => (isFoldableDevice() ? Radius.XL : Radius.L);
25
+
26
+ export { usePopupWidth, usePopupMaxHeight, getPopupRadius };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.168.1-beta.3",
3
+ "version": "0.168.1-beta.30",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
@@ -8,21 +8,21 @@
8
8
  "@momo-kits/foundation"
9
9
  ],
10
10
  "dependencies": {
11
- "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
12
11
  "@react-navigation/bottom-tabs": "7.4.2",
13
12
  "@react-navigation/core": "7.12.1",
14
13
  "@react-navigation/elements": "2.5.2",
15
14
  "@react-navigation/native": "7.1.14",
16
15
  "@react-navigation/routers": "7.4.1",
17
16
  "@react-navigation/stack": "7.4.2",
17
+ "@shopify/flash-list": "2.1.0",
18
+ "lottie-react-native": "7.2.4",
19
+ "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
18
20
  "react-native-gesture-handler": "2.27.1",
19
21
  "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
20
22
  "react-native-reanimated": "4.2.2",
21
- "react-native-worklets": "0.6.1",
22
- "react-native-safe-area-context": "5.5.2",
23
23
  "react-native-reserved-regions": "0.2.0",
24
- "@shopify/flash-list": "2.1.0",
25
- "lottie-react-native": "7.2.4"
24
+ "react-native-safe-area-context": "5.5.2",
25
+ "react-native-worklets": "0.6.1"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react-native": "*",
@@ -35,4 +35,4 @@
35
35
  "registry": "https://registry.npmjs.org/"
36
36
  },
37
37
  "license": "MoMo"
38
- }
38
+ }