@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,187 +1,113 @@
1
- import React, { useContext, useEffect } from 'react';
2
- import { StyleSheet, View } from 'react-native';
3
- import Animated, {
4
- useAnimatedStyle,
5
- useSharedValue,
6
- withTiming,
7
- } from 'react-native-reanimated';
1
+ import type { Route } from '@react-navigation/native';
2
+ import React from 'react';
3
+ import {
4
+ type StyleProp,
5
+ StyleSheet,
6
+ type TextStyle,
7
+ View,
8
+ type ViewStyle,
9
+ } from 'react-native';
8
10
 
9
- import { Colors, Spacing } from '../../Consts';
10
- import { ApplicationContext } from '../../Context';
11
- import { BadgeDot } from '../../Badge';
12
- import { Text } from '../../Text';
13
- import ScaleSizeProvider from '../ScaleSizeProvider';
14
- import { TabBarMetrics, TabBarMotion } from './metrics';
11
+ import { Colors } from '../../Consts';
12
+ import { Badge, BadgeDot } from '../../Badge';
15
13
 
16
14
  type Props = {
17
- focused: boolean;
18
- // '' shows a dot, anything else a label badge
15
+ route: Route<string>;
19
16
  badge?: string | number;
20
- // rail items center the label badge over the icon
21
- vertical?: boolean;
22
- activeTintColor: string;
23
- inactiveTintColor: string;
24
- renderIcon?: (props: {
17
+ badgeStyle?: StyleProp<TextStyle> | any;
18
+ activeOpacity: number;
19
+ inactiveOpacity: number;
20
+ activeTintColor?: string;
21
+ inactiveTintColor?: string;
22
+ renderIcon: (props: {
25
23
  focused: boolean;
26
24
  color: string;
27
25
  size: number;
28
26
  }) => React.ReactNode;
27
+ allowFontScaling?: boolean;
28
+ style: StyleProp<ViewStyle>;
29
29
  };
30
30
 
31
31
  /**
32
- * Badge value of a tab: undefined hides it, '' is a dot (also 0 when `showDot`), numbers
33
- * cap at 99+.
32
+ * Icon sizes taken from Apple HIG
33
+ * https://developer.apple.com/design/human-interface-guidelines/tab-bars
34
34
  */
35
- export const getTabBadge = (
36
- badgeLabel?: string | number,
37
- showDot?: boolean,
38
- ) => {
39
- if (badgeLabel === undefined || badgeLabel === null) {
40
- return showDot ? '' : undefined;
41
- }
42
- const text = `${badgeLabel}`;
43
- if (text === '') {
44
- return '';
45
- }
46
- if (/^\d+$/.test(text)) {
47
- const value = Number(text);
48
- if (value === 0) {
49
- return showDot ? '' : undefined;
50
- }
51
- return value > 99 ? '99+' : text;
52
- }
53
- return text;
54
- };
55
-
56
- /**
57
- * Label badge of a tab: numbers use the error color, text the warning color (Figma Badge
58
- * round numeric / text). The text keeps its design size to fit the 16 height.
59
- */
60
- const TabBadge: React.FC<{ label: string; vertical?: boolean }> = ({
61
- label,
62
- vertical,
63
- }) => {
64
- const { theme } = useContext(ApplicationContext);
65
- const isNumber = /^\d+\+?$/.test(label);
66
- let backgroundColor = theme.colors.warning.primary;
67
- if (isNumber) {
68
- backgroundColor = theme.colors.error.primary;
69
- }
70
- const badge = (
71
- <View
72
- style={[
73
- styles.badge,
74
- {
75
- backgroundColor,
76
- borderColor: theme.colors.background.surface,
77
- },
78
- ]}
79
- >
80
- <ScaleSizeProvider scaleSizeMaxRate={1}>
81
- <Text
82
- numberOfLines={1}
83
- typography={'action_xxs_bold'}
84
- color={Colors.black_01}
85
- >
86
- {label}
87
- </Text>
88
- </ScaleSizeProvider>
89
- </View>
90
- );
91
- if (vertical) {
92
- return <View style={styles.badgeCentered}>{badge}</View>;
93
- }
94
- return <View style={styles.badgeLeading}>{badge}</View>;
95
- };
35
+ const ICON_SIZE_WIDE = 35;
96
36
 
97
- /**
98
- * Tab icon (24) with its badge; active and inactive icons are stacked and cross-fade on
99
- * focus.
100
- */
101
37
  export function TabBarIcon({
102
- focused,
38
+ route: _,
103
39
  badge,
104
- vertical,
40
+ badgeStyle,
41
+ activeOpacity,
42
+ inactiveOpacity,
105
43
  activeTintColor,
106
44
  inactiveTintColor,
107
45
  renderIcon,
46
+ style,
108
47
  }: Props) {
109
- const size = TabBarMetrics.iconSize;
110
- const progress = useSharedValue(focused ? 1 : 0);
111
-
112
- useEffect(() => {
113
- progress.value = withTiming(focused ? 1 : 0, TabBarMotion.tint);
114
- }, [focused, progress]);
115
-
116
- const activeStyle = useAnimatedStyle(() => ({ opacity: progress.value }));
117
- const inactiveStyle = useAnimatedStyle(() => ({
118
- opacity: 1 - progress.value,
119
- }));
48
+ const iconSize = 25;
120
49
 
121
50
  const renderBadge = () => {
122
- if (badge === undefined || badge === null) {
123
- return null;
51
+ if (badge == null) {
52
+ return;
124
53
  }
125
54
  if (badge === '') {
126
- return <BadgeDot size={'small'} style={styles.dot} />;
55
+ return <BadgeDot size={'small'} style={[styles.badge, badgeStyle]} />;
127
56
  }
128
- return <TabBadge label={`${badge}`} vertical={vertical} />;
57
+ return <Badge style={[styles.badge, badgeStyle]} label={badge} />;
129
58
  };
130
59
 
60
+ // We render the icon twice at the same position on top of each other:
61
+ // active and inactive one, so we can fade between them.
131
62
  return (
132
- <View style={styles.icon}>
133
- <Animated.View style={[styles.layer, activeStyle]}>
134
- {renderIcon?.({ focused: true, size, color: activeTintColor })}
135
- </Animated.View>
136
- <Animated.View style={[styles.layer, inactiveStyle]}>
137
- {renderIcon?.({ focused: false, size, color: inactiveTintColor })}
138
- </Animated.View>
63
+ <View style={[styles.wrapperUikit, style]}>
64
+ <View
65
+ style={[
66
+ styles.icon,
67
+ {
68
+ opacity: activeOpacity,
69
+ // Workaround for react-native >= 0.54 layout bug
70
+ minWidth: iconSize,
71
+ },
72
+ ]}
73
+ >
74
+ {renderIcon({
75
+ focused: true,
76
+ size: iconSize,
77
+ color: activeTintColor ?? Colors.black_20,
78
+ })}
79
+ </View>
80
+ <View style={[styles.icon, { opacity: inactiveOpacity }]}>
81
+ {renderIcon({
82
+ focused: false,
83
+ size: iconSize,
84
+ color: inactiveTintColor ?? Colors.black_04,
85
+ })}
86
+ </View>
139
87
  {renderBadge()}
140
88
  </View>
141
89
  );
142
90
  }
143
91
 
144
- const BADGE_HEIGHT = 16;
145
- const BADGE_BORDER = 1;
146
-
147
92
  const styles = StyleSheet.create({
148
93
  icon: {
149
- width: TabBarMetrics.iconSize,
150
- height: TabBarMetrics.iconSize,
151
- },
152
- layer: {
153
- ...StyleSheet.absoluteFillObject,
94
+ // We render the icon twice at the same position on top of each other:
95
+ // active and inactive one, so we can fade between them:
96
+ // Cover the whole iconContainer:
97
+ position: 'absolute',
98
+ alignSelf: 'center',
154
99
  alignItems: 'center',
155
100
  justifyContent: 'center',
101
+ height: '100%',
102
+ width: '100%',
156
103
  },
157
- dot: {
158
- position: 'absolute',
159
- left: 16,
160
- top: -Spacing.XXS,
161
- },
162
- badgeLeading: {
163
- position: 'absolute',
164
- left: Spacing.M,
165
- top: -7,
166
- width: TabBarMetrics.badgeMaxWidth,
167
- alignItems: 'flex-start',
168
- },
169
- badgeCentered: {
170
- position: 'absolute',
171
- left: (TabBarMetrics.iconSize - TabBarMetrics.badgeMaxWidth) / 2,
172
- top: -10,
173
- width: TabBarMetrics.badgeMaxWidth,
174
- alignItems: 'center',
104
+ wrapperUikit: {
105
+ width: ICON_SIZE_WIDE,
106
+ height: ICON_SIZE_WIDE,
175
107
  },
176
108
  badge: {
177
- height: BADGE_HEIGHT,
178
- minWidth: BADGE_HEIGHT,
179
- maxWidth: TabBarMetrics.badgeMaxWidth,
180
- // the border is drawn inside the 4 padding, like the Figma inside stroke
181
- paddingHorizontal: Spacing.XS - BADGE_BORDER,
182
- borderRadius: BADGE_HEIGHT / 2,
183
- borderWidth: BADGE_BORDER,
184
- alignItems: 'center',
185
- justifyContent: 'center',
109
+ position: 'absolute',
110
+ end: -3,
111
+ top: -3,
186
112
  },
187
113
  });