@momo-kits/foundation 0.168.1-beta.39 → 0.168.1-beta.40

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.
Files changed (153) hide show
  1. package/Application/BottomSheet.tsx +398 -86
  2. package/Application/BottomTab/BottomTabBar.tsx +275 -215
  3. package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
  4. package/Application/BottomTab/DuoBarCompression.tsx +28 -14
  5. package/Application/BottomTab/DuoTabBar.tsx +540 -32
  6. package/Application/BottomTab/TabBarIcon.tsx +72 -146
  7. package/Application/BottomTab/index.tsx +353 -89
  8. package/Application/BottomTab/useLiquidSelection.ts +374 -0
  9. package/Application/Components/BackgroundImageView.tsx +0 -4
  10. package/Application/Components/DuoGlassBackground.tsx +5 -7
  11. package/Application/Components/HeaderAnimated.tsx +13 -41
  12. package/Application/Components/HeaderBackground.tsx +3 -20
  13. package/Application/Components/HeaderExtendHeader.tsx +46 -66
  14. package/Application/Components/HeaderLeft.tsx +18 -5
  15. package/Application/Components/HeaderRight.tsx +529 -8
  16. package/Application/Components/HeaderTitle.tsx +579 -16
  17. package/Application/Components/NavigationButton.tsx +11 -18
  18. package/Application/Components/SearchHeader.tsx +18 -38
  19. package/Application/Localize.ts +0 -7
  20. package/Application/ModalScreen.tsx +18 -41
  21. package/Application/Navigation.ts +17 -15
  22. package/Application/NavigationContainer.tsx +21 -23
  23. package/Application/Navigator.ts +48 -20
  24. package/Application/ScaleSizeProvider.tsx +6 -13
  25. package/Application/StackScreen.tsx +172 -27
  26. package/Application/TooltipPortal.tsx +5 -12
  27. package/Application/WidgetContainer.tsx +7 -20
  28. package/Application/device.ts +52 -0
  29. package/Application/index.ts +1 -23
  30. package/Application/types.ts +242 -17
  31. package/Application/utils.tsx +493 -0
  32. package/Badge/Badge.tsx +0 -5
  33. package/Badge/BadgeDot.tsx +0 -1
  34. package/Badge/BadgeDotAnimation.tsx +7 -15
  35. package/Badge/BadgeRibbon.tsx +39 -47
  36. package/Badge/Shape.tsx +0 -2
  37. package/Badge/styles.ts +0 -2
  38. package/Badge/types.ts +2 -2
  39. package/Button/index.tsx +152 -21
  40. package/Button/styles.ts +1 -1
  41. package/CheckBox/index.tsx +6 -5
  42. package/Consts/theme.ts +10 -10
  43. package/Context/index.ts +1 -5
  44. package/Divider/DashDivider.tsx +11 -11
  45. package/Divider/index.tsx +7 -21
  46. package/FoundationList/index.tsx +0 -4
  47. package/Icon/index.tsx +6 -6
  48. package/Icon/types.ts +1 -1
  49. package/IconButton/index.tsx +12 -4
  50. package/Image/index.tsx +7 -9
  51. package/Input/Input.tsx +12 -10
  52. package/Input/InputDropDown.tsx +13 -10
  53. package/Input/InputMoney.tsx +152 -45
  54. package/Input/InputOTP.tsx +34 -36
  55. package/Input/InputPhoneNumber.tsx +5 -8
  56. package/Input/InputSearch.tsx +111 -19
  57. package/Input/InputTextArea.tsx +5 -5
  58. package/Input/SystemTextInput.tsx +2 -7
  59. package/Input/TextTyping.tsx +0 -4
  60. package/Input/common.tsx +17 -31
  61. package/Input/index.tsx +21 -24
  62. package/Input/styles.ts +5 -25
  63. package/Input/utils.ts +12 -14
  64. package/Layout/Card.tsx +4 -7
  65. package/Layout/FloatingButton.tsx +21 -26
  66. package/Layout/Item.tsx +2 -6
  67. package/Layout/ItemList.tsx +7 -9
  68. package/Layout/ItemSectionList.tsx +1 -2
  69. package/Layout/ReservedRegions.tsx +17 -34
  70. package/Layout/Screen.tsx +696 -122
  71. package/Layout/Section.tsx +7 -9
  72. package/Layout/TrackingScope.tsx +0 -1
  73. package/Layout/index.ts +4 -10
  74. package/Layout/styles.ts +0 -2
  75. package/Layout/types.ts +4 -2
  76. package/Layout/utils.ts +181 -40
  77. package/Loader/DotLoader.tsx +3 -11
  78. package/Loader/Loader.tsx +0 -4
  79. package/Loader/ProgressBar.tsx +6 -3
  80. package/Loader/Spinner.tsx +3 -11
  81. package/Loader/styles.ts +0 -4
  82. package/Loader/utils.ts +7 -11
  83. package/Pagination/Dot.tsx +0 -4
  84. package/Pagination/PaginationDot.tsx +0 -1
  85. package/Pagination/PaginationNumber.tsx +3 -5
  86. package/Pagination/PaginationScroll.tsx +0 -5
  87. package/Pagination/PaginationWhiteDot.tsx +0 -1
  88. package/Pagination/index.tsx +0 -4
  89. package/Pagination/types.ts +2 -2
  90. package/Popup/PopupNotify.tsx +102 -94
  91. package/Popup/PopupPromotion.tsx +11 -9
  92. package/Popup/types.ts +4 -11
  93. package/Popup/utils.ts +18 -50
  94. package/Radio/index.tsx +10 -6
  95. package/Radio/styles.ts +0 -6
  96. package/Skeleton/index.tsx +9 -9
  97. package/Skeleton/styles.ts +0 -1
  98. package/Switch/index.tsx +0 -1
  99. package/Tag/index.tsx +4 -8
  100. package/Tag/types.ts +3 -3
  101. package/Text/index.tsx +5 -25
  102. package/Text/styles.ts +1 -1
  103. package/Text/types.ts +6 -1
  104. package/Text/utils.ts +4 -20
  105. package/Title/index.tsx +40 -42
  106. package/Title/styles.ts +0 -6
  107. package/ViewBoundary/index.tsx +2 -4
  108. package/index.ts +6 -0
  109. package/package.json +1 -2
  110. package/Application/BottomSheet.hooks.ts +0 -195
  111. package/Application/BottomSheet.parts.tsx +0 -157
  112. package/Application/BottomSheet.styles.ts +0 -43
  113. package/Application/BottomTab/ActiveIndicator.tsx +0 -91
  114. package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
  115. package/Application/BottomTab/BottomTabInset.tsx +0 -18
  116. package/Application/BottomTab/CurvedContainer.tsx +0 -155
  117. package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
  118. package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
  119. package/Application/BottomTab/TabScreen.tsx +0 -160
  120. package/Application/BottomTab/metrics.ts +0 -164
  121. package/Application/BottomTab/tabItems.ts +0 -46
  122. package/Application/BottomTab/usePressLift.ts +0 -32
  123. package/Application/Components/HeaderRight.styles.ts +0 -146
  124. package/Application/Components/HeaderTitle.shared.ts +0 -44
  125. package/Application/Components/HeaderTitle.styles.ts +0 -125
  126. package/Application/Components/HeaderToolkitAction.tsx +0 -180
  127. package/Application/Components/SwipeBackHaptic.tsx +0 -95
  128. package/Application/Components/TitleJourney.tsx +0 -110
  129. package/Application/Components/TitleLocation.tsx +0 -73
  130. package/Application/Components/TitleUser.tsx +0 -304
  131. package/Application/Components/useToolkitActions.tsx +0 -218
  132. package/Application/ModalIconButton.tsx +0 -66
  133. package/Application/StackScreen.tracking.ts +0 -143
  134. package/Application/headerLayout.ts +0 -158
  135. package/Application/hooks.ts +0 -137
  136. package/Application/modalLayout.ts +0 -176
  137. package/Application/navigationOptions.tsx +0 -212
  138. package/Application/types.header.ts +0 -121
  139. package/Application/types.tabs.ts +0 -48
  140. package/Application/types.theme.ts +0 -87
  141. package/Application/utils.ts +0 -107
  142. package/Button/utils.ts +0 -133
  143. package/Input/InputMoneyView.tsx +0 -194
  144. package/Input/SearchTextTyping.tsx +0 -108
  145. package/Input/moneyUtils.ts +0 -23
  146. package/Layout/layoutMetrics.ts +0 -58
  147. package/Layout/layoutTypes.ts +0 -86
  148. package/Layout/screenContent.tsx +0 -92
  149. package/Layout/screenFooter.tsx +0 -63
  150. package/Layout/screenHeader.tsx +0 -321
  151. package/Layout/screenQuickReturn.tsx +0 -64
  152. package/Layout/screenScroll.ts +0 -107
  153. package/Layout/screenTypes.ts +0 -143
@@ -1,25 +1,15 @@
1
1
  import { Colors, Radius, Spacing, Styles } from '../../Consts';
2
- import { InputRef, InputSearch, type InputSearchProps } from '../../Input';
2
+ import { InputRef, InputSearch } from '../../Input';
3
3
  import { StyleSheet, TouchableOpacity, View } from 'react-native';
4
4
  import Animated, { useAnimatedStyle } from 'react-native-reanimated';
5
5
  import React, { useContext } from 'react';
6
6
  import { SearchHeaderProps } from '../types';
7
7
  import { ApplicationContext, MiniAppContext } from '../../Context';
8
8
  import { Text } from '../../Text';
9
- import { useNormalizedSharedValue } from '../hooks';
9
+ import { useNormalizedSharedValue } from '../utils';
10
10
  import { useScreenLayout } from '../../Layout';
11
- import { HeaderBarMetrics } from '../headerLayout';
11
+ import { DuoMetrics } from '../../Layout/utils';
12
12
 
13
- const { buttonSize, pillWidth, sidePadding, titleGap } = HeaderBarMetrics;
14
- // help center | home pill and the bar padding right of it
15
- const TOOLKIT_WIDTH = pillWidth + sidePadding;
16
- // the iPhone Duo side bar keeps its right header width
17
- const DUO_TOOLKIT_WIDTH = 73;
18
-
19
- /**
20
- * Header search bar whose fill turns from surface to default once scrolled, with
21
- * a cancel button that goes back (or dismisses the mini app) unless `renderButtons`.
22
- */
23
13
  const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
24
14
  (
25
15
  {
@@ -34,27 +24,21 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
34
24
  const { theme, navigator } = useContext(ApplicationContext);
35
25
  const context = useContext<any>(MiniAppContext);
36
26
  const layout = useScreenLayout();
37
- let defaultRightWidth = TOOLKIT_WIDTH;
38
- let searchSize: InputSearchProps['size'] = 'header';
39
- if (layout.sideBar) {
40
- defaultRightWidth = DUO_TOOLKIT_WIDTH;
41
- searchSize = 'default';
42
- }
27
+ // the iPhone Duo status bar row keeps a side bar sized back button
28
+ const BACK_WIDTH = layout.statusBarClearance ? DuoMetrics.controlSize : 28;
43
29
 
44
30
  const sharedValue = useNormalizedSharedValue(animatedValue);
45
- const defaultLeft = buttonSize + sidePadding + titleGap;
46
- const leftPosition = props?.leftPosition ?? defaultLeft;
47
- const headerRightWidth = props?.headerRightWidth ?? defaultRightWidth;
31
+ const leftPosition = props?.leftPosition ?? BACK_WIDTH + 20;
32
+ const headerRightWidth = props?.headerRightWidth ?? 73;
48
33
 
49
34
  // iPhone Duo side bar holds back: the search shares the content width with the buttons only
50
- const rowWidth = layout.width - leftPosition - sidePadding;
51
- let searchMaxWidth = rowWidth - headerRightWidth;
35
+ let searchMaxWidth = layout.width - leftPosition - 12 - headerRightWidth;
52
36
  if (layout.sideBar) {
53
37
  searchMaxWidth = layout.contentWidth - Spacing.M * 2 - headerRightWidth;
54
38
  }
55
- const clearance = layout.statusBarClearance;
56
- if (clearance) {
57
- searchMaxWidth -= clearance.left + clearance.right;
39
+ if (layout.statusBarClearance) {
40
+ searchMaxWidth -=
41
+ layout.statusBarClearance.left + layout.statusBarClearance.right;
58
42
  }
59
43
 
60
44
  const backgroundStyle = useAnimatedStyle(() => {
@@ -92,15 +76,6 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
92
76
 
93
77
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
94
78
 
95
- let buttons: React.ReactNode = (
96
- <TouchableOpacity onPress={goBackSafe} style={styles.searchAction}>
97
- <Text typography={'action_default_bold'}>{buttonText}</Text>
98
- </TouchableOpacity>
99
- );
100
- if (typeof renderButtons === 'function') {
101
- buttons = renderButtons();
102
- }
103
-
104
79
  return (
105
80
  <View
106
81
  style={[styles.container, showBaseLineDebug && styles.debugBaseLine]}
@@ -117,13 +92,18 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
117
92
  <InputSearch
118
93
  ref={ref}
119
94
  {...props}
120
- size={searchSize}
121
95
  backgroundColor={'transparent'}
122
96
  showButtonText={false}
123
97
  />
124
98
  </Animated.View>
125
99
  </View>
126
- {buttons}
100
+ {renderButtons && typeof renderButtons === 'function' ? (
101
+ renderButtons()
102
+ ) : (
103
+ <TouchableOpacity onPress={goBackSafe} style={styles.searchAction}>
104
+ <Text typography={'action_default_bold'}>{buttonText}</Text>
105
+ </TouchableOpacity>
106
+ )}
127
107
  </View>
128
108
  );
129
109
  },
@@ -2,10 +2,6 @@ import { NativeModules } from 'react-native';
2
2
  import { LocalizationObject } from './types';
3
3
  import defaultLanguage from '../Assets/language.json';
4
4
 
5
- /**
6
- * String table for kit and feature copy. The language is read once from the
7
- * native `RNResource` module at construction; Vietnamese is the default.
8
- */
9
5
  class Localize {
10
6
  private assets: LocalizationObject;
11
7
  private readonly currentLanguage: 'en' | 'vi';
@@ -29,17 +25,14 @@ class Localize {
29
25
  return this.assets;
30
26
  }
31
27
 
32
- /** Text for `key` in the current language, or the key itself if missing. */
33
28
  translate(key: string) {
34
29
  return this.assets[this.currentLanguage]?.[key] || key;
35
30
  }
36
31
 
37
- /** Picks the current-language text of a `{ vi, en }` pair, else its JSON. */
38
32
  translateData(data: { vi: string; en: string }) {
39
33
  return data[this.currentLanguage] ?? JSON.stringify(data);
40
34
  }
41
35
 
42
- /** Merges extra translations; keys that already exist keep their text. */
43
36
  addTranslations(translations: LocalizationObject) {
44
37
  this.assets = {
45
38
  vi: { ...translations?.vi, ...this.assets.vi },
@@ -1,10 +1,4 @@
1
- import React, {
2
- useCallback,
3
- useContext,
4
- useEffect,
5
- useMemo,
6
- useRef,
7
- } from 'react';
1
+ import React, { useCallback, useContext, useEffect, useRef } from 'react';
8
2
  import {
9
3
  Animated,
10
4
  BackHandler,
@@ -17,20 +11,16 @@ import {
17
11
  useWindowDimensions,
18
12
  View,
19
13
  } from 'react-native';
14
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
20
15
 
21
16
  import { ApplicationContext, MiniAppContext } from '../Context';
22
- import { Colors, Styles } from '../Consts';
17
+ import { Styles } from '../Consts';
23
18
  import Navigation from './Navigation';
24
19
  import { ModalParams } from './types';
25
20
  import BottomSheet from './BottomSheet';
26
- import { isIPhoneDuo } from './utils';
27
- import { useModalLayout } from './modalLayout';
21
+ import { getDuoModalBounds, isIPhoneDuo } from './device';
28
22
  import { scheduleOnRN } from 'react-native-worklets';
29
23
 
30
- /**
31
- * Screen of the `Modal` route: a bottom sheet when pushed by
32
- * `showBottomSheet`, otherwise a centered popup.
33
- */
34
24
  const ModalScreen: React.FC<any> = props => {
35
25
  if (props.route?.params?.isBottomSheet) {
36
26
  return <BottomSheet {...props} />;
@@ -38,10 +28,6 @@ const ModalScreen: React.FC<any> = props => {
38
28
  return <Modal {...props} />;
39
29
  };
40
30
 
41
- /**
42
- * Centered popup that fades and scales in over a scrim. On foldables it is
43
- * centered in the modal placement area, at most a popup wide.
44
- */
45
31
  const Modal: React.FC<ModalParams> = props => {
46
32
  const { navigator } = useContext(ApplicationContext);
47
33
  const context = useContext<any>(MiniAppContext);
@@ -54,11 +40,13 @@ const Modal: React.FC<ModalParams> = props => {
54
40
  title,
55
41
  } = props.route.params;
56
42
  const Component = useRef(screen).current;
57
- const { width, height } = useWindowDimensions();
43
+ const insets = useSafeAreaInsets();
44
+ const windowSize = useWindowDimensions();
58
45
  const isDuo = isIPhoneDuo();
59
- const { isFoldable, placement, popup, scrimOpacity } = useModalLayout();
60
46
 
61
- // Auto-tracks the popup as displayed on the current screen.
47
+ /**
48
+ * Fire auto_popup_displayed tracking event on mount
49
+ */
62
50
  useEffect(() => {
63
51
  navigator?.maxApi?.getDataObserver?.('current_screen', (curScreen: any) => {
64
52
  context.autoTracking({
@@ -73,15 +61,6 @@ const Modal: React.FC<ModalParams> = props => {
73
61
 
74
62
  const opacity = useRef(new Animated.Value(0)).current;
75
63
  const scale = useRef(new Animated.Value(0.8)).current;
76
- const scrimStyle = useMemo(
77
- () => ({
78
- opacity: opacity.interpolate({
79
- inputRange: [0, 1],
80
- outputRange: [0, scrimOpacity],
81
- }),
82
- }),
83
- [opacity, scrimOpacity],
84
- );
85
64
 
86
65
  const navigation = new Navigation(props.navigation);
87
66
  const params = {
@@ -167,7 +146,7 @@ const Modal: React.FC<ModalParams> = props => {
167
146
  style={StyleSheet.absoluteFillObject}
168
147
  onPress={() => onDismiss(undefined, barrierDismissible)}
169
148
  >
170
- <Animated.View style={[styles.overlayContent, scrimStyle]} />
149
+ <Animated.View style={[styles.overlayContent, { opacity }]} />
171
150
  </Pressable>
172
151
  <Animated.View
173
152
  style={[
@@ -175,15 +154,13 @@ const Modal: React.FC<ModalParams> = props => {
175
154
  opacity,
176
155
  transform: [{ scale }],
177
156
  },
178
- // centered in the placement area, at most a popup wide
179
- isFoldable && styles.shrink,
180
- isFoldable && {
181
- marginTop: placement.y,
182
- marginBottom: height - placement.y - placement.height,
183
- marginLeft: placement.x,
184
- marginRight: width - placement.x - placement.width,
185
- maxWidth: popup.width,
186
- maxHeight: popup.maxHeight,
157
+ isDuo && styles.shrink,
158
+ isDuo && {
159
+ marginTop: insets.top,
160
+ marginBottom: insets.bottom,
161
+ marginLeft: insets.left,
162
+ marginRight: insets.right,
163
+ ...getDuoModalBounds(insets, windowSize.width, windowSize.height),
187
164
  },
188
165
  modalStyle,
189
166
  ]}
@@ -200,7 +177,7 @@ const DUO_ORIENTATIONS = ['portrait', 'landscape'];
200
177
  const styles = StyleSheet.create({
201
178
  overlayContent: {
202
179
  flex: 1,
203
- backgroundColor: Colors.black_20,
180
+ backgroundColor: 'rgba(0, 0, 0, 0.6)',
204
181
  },
205
182
  shrink: { flexShrink: 1 },
206
183
  });
@@ -1,6 +1,6 @@
1
1
  import {NavigationProp} from '@react-navigation/native';
2
2
  import {NavigationOptions} from './types';
3
- import {getOptions} from './navigationOptions';
3
+ import {getOptions} from './utils';
4
4
  import {StackNavigationOptions} from '@react-navigation/stack';
5
5
 
6
6
  export const WHITE_LIST = [
@@ -11,10 +11,6 @@ export const WHITE_LIST = [
11
11
  'vn.momo.ekyc',
12
12
  ];
13
13
 
14
- /**
15
- * Screen-level navigation handle given to features; `setOptions` enforces the
16
- * design system's header rules before applying React Navigation options.
17
- */
18
14
  class Navigation {
19
15
  instance: NavigationProp<any>;
20
16
  context: any;
@@ -25,33 +21,39 @@ class Navigation {
25
21
  }
26
22
 
27
23
  /**
28
- * Drops header overrides the design system forbids: any `headerLeft`, and
29
- * render-function `headerRight`/`headerTitle` outside `WHITE_LIST` apps.
24
+ * navigation options filter by design system rule
25
+ * @param params
30
26
  */
31
27
  private filterParams = (params: NavigationOptions) => {
32
- const isWhiteListed = WHITE_LIST.includes(this.context?.appId);
33
- const rightType = typeof params.headerRight;
34
- const titleType = typeof params.headerTitle;
35
- const isTitleRenderer = titleType !== 'string' && titleType !== 'object';
36
-
37
28
  if (params.headerLeft) {
38
29
  console.warn('headerLeft not allow override render by design system!');
39
30
  delete params.headerLeft;
40
31
  }
41
32
 
42
- if (params.headerRight && rightType !== 'object' && !isWhiteListed) {
33
+ if (
34
+ params.headerRight &&
35
+ typeof params.headerRight !== 'object' &&
36
+ !WHITE_LIST.includes(this.context?.appId)
37
+ ) {
43
38
  console.warn('headerRight not allow type func render by design system!');
44
39
  delete params.headerRight;
45
40
  }
46
41
 
47
- if (params.headerTitle && isTitleRenderer && !isWhiteListed) {
42
+ if (
43
+ params.headerTitle &&
44
+ !['string', 'object'].includes(typeof params.headerTitle) &&
45
+ !WHITE_LIST.includes(this.context?.appId)
46
+ ) {
48
47
  console.warn('headerTitle not allow type func render by design system!');
49
48
  delete params.headerTitle;
50
49
  }
51
50
  return params;
52
51
  };
53
52
 
54
- /** Applies kit `NavigationOptions` to the screen after `filterParams`. */
53
+ /**
54
+ * navigation setOptions support props NavigationOptions base on react-navigation options
55
+ * @param params
56
+ */
55
57
  setOptions = (params: NavigationOptions) => {
56
58
  const options = getOptions(this.filterParams(params));
57
59
  this.instance.setOptions(options as StackNavigationOptions);
@@ -2,7 +2,6 @@ import React, { useContext, useEffect, useRef, useState } from 'react';
2
2
  import {
3
3
  SafeAreaInsetsContext,
4
4
  SafeAreaProvider,
5
- type EdgeInsets,
6
5
  } from 'react-native-safe-area-context';
7
6
  import {
8
7
  NavigationContainer as ReactNavigationContainer,
@@ -16,9 +15,12 @@ import {
16
15
  import StackScreen from './StackScreen';
17
16
  import ModalScreen from './ModalScreen';
18
17
  import Navigator from './Navigator';
19
- import { getModalOptions, getStackOptions } from './navigationOptions';
20
- import { isWhiteListDesignSystem } from './utils';
21
- import { useNativeCanGoBack } from './hooks';
18
+ import {
19
+ getModalOptions,
20
+ getStackOptions,
21
+ isWhiteListDesignSystem,
22
+ useNativeCanGoBack,
23
+ } from './utils';
22
24
  import { NavigationContainerProps } from './types';
23
25
  import { ApplicationContext, MiniAppContext } from '../Context';
24
26
  import Localize from './Localize';
@@ -27,16 +29,13 @@ import { HeaderLeft } from './Components/HeaderLeft';
27
29
  import { HeaderRight } from './Components/HeaderRight';
28
30
  import { HeaderTitle } from './Components/HeaderTitle';
29
31
  import { HeaderBackground } from './Components/HeaderBackground';
32
+ import { type EdgeInsets } from 'react-native-safe-area-context';
30
33
  import { useScreenLayout } from '../Layout';
31
34
  import { getHeaderRowOptions } from '../Layout/utils';
32
35
  import { ReservedRegionsProvider } from '../Layout/ReservedRegions';
33
36
 
34
37
  const Stack = createStackNavigator();
35
38
 
36
- /**
37
- * Root of a mini app: safe area, reserved regions and the merged mini app
38
- * context around the kit's navigator.
39
- */
40
39
  const NavigationContainer: React.FC<NavigationContainerProps> = ({
41
40
  screen,
42
41
  theme = defaultTheme,
@@ -96,10 +95,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
96
95
  );
97
96
  };
98
97
 
99
- /**
100
- * Stack navigator with its `Stack`, `Dialog` and `Modal` routes, under an
101
- * `ApplicationContext` carrying the navigator, themed fonts and `translate`.
102
- */
103
98
  const Navigation: React.FC<any> = ({
104
99
  screen,
105
100
  theme = defaultTheme,
@@ -117,10 +112,7 @@ const Navigation: React.FC<any> = ({
117
112
  const syncCanGoBack = useNativeCanGoBack();
118
113
  const isWhiteList = isWhiteListDesignSystem(context);
119
114
  const fontFamily = isWhiteList ? 'MomoTrustSans' : 'SFProText';
120
- let navigationFontFamily = 'SFProText';
121
- if (isWhiteList) {
122
- navigationFontFamily = 'MomoTrustSans-Regular';
123
- }
115
+ const navigationFontFamily = isWhiteList ? 'MomoTrustSans-Regular' : 'SFProText';
124
116
  let headerBackground = context?.designSystemConfig?.config?.headerBar;
125
117
  let headerGradient = theme.colors?.gradient;
126
118
 
@@ -131,9 +123,15 @@ const Navigation: React.FC<any> = ({
131
123
  headerGradient = context?.designSystemConfig?.config?.headerGradient;
132
124
  }
133
125
 
126
+ /**
127
+ * inject data for navigator
128
+ */
134
129
  navigator.current.maxApi = maxApi;
135
130
 
136
- /** Text for a localization key, or the current-language side of `{ vi, en }`. */
131
+ /**
132
+ * translate context method
133
+ * @param data
134
+ */
137
135
  const translate = (data?: string | { vi: string; en: string }) => {
138
136
  if (data && typeof data !== 'string') {
139
137
  return localize?.translateData(data);
@@ -231,12 +229,12 @@ const Navigation: React.FC<any> = ({
231
229
  backgroundColor: theme.colors.background.default,
232
230
  },
233
231
  headerLeft: (props: any) => <HeaderLeft {...props} floating />,
234
- headerBackground: (props: any) => {
235
- return <HeaderBackground {...props} />;
236
- },
237
- headerRight: (props: any) => {
238
- return <HeaderRight {...props} floating />;
239
- },
232
+ headerBackground: (props: any) => (
233
+ <HeaderBackground {...props} />
234
+ ),
235
+ headerRight: (props: any) => (
236
+ <HeaderRight {...props} floating />
237
+ ),
240
238
  headerTintColor: Colors.black_17,
241
239
  ...TransitionPresets.ModalTransition,
242
240
  }}
@@ -1,10 +1,6 @@
1
1
  import {CommonActions, StackActions} from '@react-navigation/native';
2
2
  import {BottomSheetParams, ModalParams, ScreenParams} from './types';
3
3
 
4
- /**
5
- * Imperative navigation API exposed to features through `ApplicationContext`.
6
- * Every action is a no-op until the container reports ready.
7
- */
8
4
  class Navigator {
9
5
  ref?: any;
10
6
  isReady?: any;
@@ -18,28 +14,40 @@ class Navigator {
18
14
  this.isWidget = isWidget;
19
15
  }
20
16
 
21
- /** Pushes a new stack screen. */
17
+ /**
18
+ * push new stack screen
19
+ * @param params
20
+ */
22
21
  push = (params: ScreenParams) => {
23
22
  if (this.isReady.current) {
24
23
  this.ref.current?.dispatch?.(StackActions.push('Stack', params));
25
24
  }
26
25
  };
27
26
 
28
- /** Replaces the current screen with a new stack screen. */
27
+ /**
28
+ * replace current screen with new screen
29
+ * @param params
30
+ */
29
31
  replace = (params: ScreenParams) => {
30
32
  if (this.isReady.current) {
31
33
  this.ref.current?.dispatch?.(StackActions.replace('Stack', params));
32
34
  }
33
35
  };
34
36
 
35
- /** Pops `count` screens, 1 by default. */
37
+ /**
38
+ * pop to dismiss a screen
39
+ * @param count
40
+ */
36
41
  pop = (count?: number) => {
37
42
  if (this.isReady.current) {
38
43
  this.ref.current?.dispatch?.(StackActions.pop(count ?? 1));
39
44
  }
40
45
  };
41
46
 
42
- /** Presents a screen as a dialog (slides up from the bottom on iOS). */
47
+ /**
48
+ * present a new screen, show from bottom iOS
49
+ * @param params
50
+ */
43
51
  present = (params: ScreenParams) => {
44
52
  if (this.isReady.current) {
45
53
  this.ref.current?.dispatch?.(StackActions.push('Dialog', params));
@@ -47,8 +55,9 @@ class Navigator {
47
55
  };
48
56
 
49
57
  /**
50
- * Shows a modal popup; inside a widget it always uses the native modal.
51
- * Failures are reported through `onError` instead of throwing.
58
+ * show a modal popup
59
+ * @param params
60
+ * @param onError
52
61
  */
53
62
  showModal = (params: ModalParams, onError?: (error: string) => void) => {
54
63
  try {
@@ -67,7 +76,11 @@ class Navigator {
67
76
  }
68
77
  };
69
78
 
70
- /** Shows a bottom sheet through the modal route; failures go to `onError`. */
79
+ /**
80
+ * show a bottom sheet
81
+ * @param params
82
+ * @param onError
83
+ */
71
84
  showBottomSheet = (
72
85
  params: BottomSheetParams,
73
86
  onError?: (error: string) => void
@@ -89,21 +102,31 @@ class Navigator {
89
102
  }
90
103
  };
91
104
 
92
- /** Pops back to the first screen of the stack. */
105
+ /**
106
+ * pop all screen route
107
+ */
93
108
  popToTop = () => {
94
109
  if (this.isReady.current) {
95
110
  this.ref.current?.dispatch?.(StackActions.popToTop());
96
111
  }
97
112
  };
98
113
 
99
- /** Navigates to a route by name; meant for bottom tab routes only. */
114
+ /**
115
+ * navigate route name bottom tab only
116
+ * @param name
117
+ */
100
118
  navigate = (name: string) => {
101
119
  if (this.isReady.current) {
102
- this.ref.current?.dispatch?.(CommonActions.navigate(name));
120
+ this.ref.current?.dispatch?.(
121
+ CommonActions.navigate(name)
122
+ );
103
123
  }
104
124
  };
105
125
 
106
- /** Resets the flow to a single new stack screen. */
126
+ /**
127
+ * reset a navigation flow with new screen
128
+ * @param params
129
+ */
107
130
  reset = (params: ScreenParams) => {
108
131
  if (this.isReady.current) {
109
132
  this.ref.current?.dispatch?.(
@@ -121,21 +144,26 @@ class Navigator {
121
144
  }
122
145
  };
123
146
 
124
- /** Sets the payload the header passes to `maxApi.dismiss` on close. */
147
+ /**
148
+ * dismiss a feature data
149
+ * @param data
150
+ */
125
151
  setDismissData = (data: any) => {
126
152
  this.dismissData = data;
127
153
  };
128
154
 
129
155
  /**
130
- * No-op placeholder; `NavigationContainer` and `WidgetContainer` replace it
131
- * with their context state setter.
156
+ * set app context using for features of kit
157
+ * @param context
132
158
  */
133
- setCurrentContext = (_context: {
159
+ setCurrentContext = (context: {
134
160
  code?: string;
135
161
  name?: {vi: string; en: string};
136
162
  description?: {vi: string; en: string};
137
163
  icon?: string;
138
- }) => {};
164
+ }) => {
165
+ console.log(context);
166
+ };
139
167
  }
140
168
 
141
169
  export default Navigator;
@@ -1,23 +1,16 @@
1
- import React, { FC, useContext, useMemo } from 'react';
2
- import { MiniAppContext } from '../Context';
1
+ import React, { FC } from 'react';
2
+ import { ScaleSizeContext } from '../Context';
3
3
  import { ScaleSizeProviderProps } from './types';
4
4
 
5
- /**
6
- * Caps the font scale of its subtree at `scaleSizeMaxRate` × the design size
7
- * (`useScaleSize`), passed down in MiniAppContext. The nearest provider wins;
8
- * an undefined rate lifts an outer cap.
9
- */
5
+ /** @deprecated Max font scale is fixed at 1.5; this provider no longer affects scaling. */
10
6
  const ScaleSizeProvider: FC<ScaleSizeProviderProps> = ({
11
7
  scaleSizeMaxRate,
12
8
  children,
13
9
  }) => {
14
- const context = useContext<object | undefined>(MiniAppContext);
15
- const value = useMemo(() => {
16
- return { ...context, scaleSizeMaxRate };
17
- }, [context, scaleSizeMaxRate]);
18
-
19
10
  return (
20
- <MiniAppContext.Provider value={value}>{children}</MiniAppContext.Provider>
11
+ <ScaleSizeContext.Provider value={{ scaleSizeMaxRate }}>
12
+ {children}
13
+ </ScaleSizeContext.Provider>
21
14
  );
22
15
  };
23
16