@momo-kits/foundation 0.169.7-beta.6 → 0.169.7-beta.8

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.
@@ -5,6 +5,7 @@ import Animated, {
5
5
  useSharedValue,
6
6
  withTiming,
7
7
  } from 'react-native-reanimated';
8
+ import { defaultTheme } from '../../Consts';
8
9
  import { ApplicationContext } from '../../Context';
9
10
  import { getIndicatorShadow, TabBarMotion } from './metrics';
10
11
 
@@ -70,7 +71,10 @@ const ActiveIndicator: React.FC<Props> = ({
70
71
  styles.indicator,
71
72
  {
72
73
  borderRadius: radius,
73
- backgroundColor: theme.colors.background.tonal,
74
+ // a mini app's own theme may lack `tonal`; without the fallback the indicator is transparent
75
+ backgroundColor:
76
+ theme.colors.background.tonal ??
77
+ defaultTheme.colors.background.tonal,
74
78
  boxShadow: getIndicatorShadow(theme.colors.primary),
75
79
  },
76
80
  style,
@@ -2,6 +2,20 @@ import { StyleSheet } from 'react-native';
2
2
  import { Colors, Spacing } from '../../Consts';
3
3
  import { CTA_SHADOW, TabBarMetrics } from './metrics';
4
4
 
5
+ const ITEM_HEIGHT =
6
+ TabBarMetrics.indicatorHeight +
7
+ TabBarMetrics.itemIconLabelGap +
8
+ TabBarMetrics.labelHeight;
9
+ const CONTENT_HEIGHT = TabBarMetrics.height - 2 * TabBarMetrics.paddingVertical;
10
+ // the items are centered in the content, so their label starts this far below the content top
11
+ const ITEM_LABEL_TOP =
12
+ (CONTENT_HEIGHT - ITEM_HEIGHT) / 2 +
13
+ TabBarMetrics.indicatorHeight +
14
+ TabBarMetrics.itemIconLabelGap;
15
+ // the center action column is placed so its label starts on the same line as the tab labels
16
+ const CTA_TOP =
17
+ ITEM_LABEL_TOP - TabBarMetrics.ctaLabelGap - TabBarMetrics.ctaSize;
18
+
5
19
  export const styles = StyleSheet.create({
6
20
  bar: {
7
21
  position: 'absolute',
@@ -37,7 +51,7 @@ export const styles = StyleSheet.create({
37
51
  position: 'absolute',
38
52
  left: 0,
39
53
  right: 0,
40
- top: -TabBarMetrics.ctaLift - TabBarMetrics.paddingVertical,
54
+ top: CTA_TOP,
41
55
  alignItems: 'center',
42
56
  gap: TabBarMetrics.ctaLabelGap,
43
57
  },
@@ -46,6 +60,9 @@ export const styles = StyleSheet.create({
46
60
  width: TabBarMetrics.ctaSize,
47
61
  height: TabBarMetrics.ctaSize,
48
62
  borderRadius: TabBarMetrics.ctaSize / 2,
63
+ // Figma Icon Button border: white 60% hairline
64
+ borderWidth: 1,
65
+ borderColor: `rgba(255, 255, 255, ${TabBarMetrics.ctaBorderOpacity})`,
49
66
  alignItems: 'center',
50
67
  justifyContent: 'center',
51
68
  },
@@ -181,21 +181,17 @@ const HorizontalTabBar: React.FC<{
181
181
  return renderItems(items);
182
182
  };
183
183
 
184
- const customContainer = withCta && floatingButton?.container;
185
-
186
184
  return (
187
185
  <View
188
186
  style={[styles.container, { width }]}
189
187
  accessibilityLabel={'bottom_tab_bar'}
190
188
  >
191
- {customContainer || (
192
- <CurvedContainer
193
- width={width}
194
- height={TabBarMetrics.height}
195
- radius={TabBarMetrics.height / 2}
196
- notchCenterX={withCta ? width / 2 : undefined}
197
- />
198
- )}
189
+ <CurvedContainer
190
+ width={width}
191
+ height={TabBarMetrics.height}
192
+ radius={TabBarMetrics.height / 2}
193
+ notchCenterX={withCta ? width / 2 : undefined}
194
+ />
199
195
  <View style={styles.content}>
200
196
  <ActiveIndicator
201
197
  axis={'x'}
@@ -228,6 +224,8 @@ export default function BottomTabBar(props: Props) {
228
224
  window.height,
229
225
  insets.left,
230
226
  insets.right,
227
+ state.routes.length,
228
+ withCta,
231
229
  );
232
230
 
233
231
  return (
@@ -3,7 +3,7 @@ import { StyleSheet } from 'react-native';
3
3
  import Svg, { Defs, FeGaussianBlur, Filter, Path } from 'react-native-svg';
4
4
  import { Colors } from '../../Consts';
5
5
  import { ApplicationContext } from '../../Context';
6
- import { NOTCH_CURVES, NOTCH_HALF_WIDTH } from './metrics';
6
+ import { NOTCH_CURVES, NOTCH_HALF_WIDTH, TabBarMetrics } from './metrics';
7
7
 
8
8
  type Props = {
9
9
  width: number;
@@ -139,7 +139,13 @@ const CurvedContainer: React.FC<Props> = ({
139
139
  filter={'url(#keyShadow)'}
140
140
  />
141
141
  )}
142
- <Path d={path} fill={theme.colors.background.surface} />
142
+ <Path
143
+ d={path}
144
+ fill={theme.colors.background.surface}
145
+ fillOpacity={TabBarMetrics.backgroundOpacity}
146
+ stroke={theme.colors.border.default}
147
+ strokeWidth={1}
148
+ />
143
149
  </Svg>
144
150
  );
145
151
  };
@@ -13,7 +13,7 @@ import Animated, {
13
13
  import { TabBarIcon } from './TabBarIcon';
14
14
  import { Text } from '../../Text';
15
15
  import { MiniAppContext } from '../../Context';
16
- import { Colors, Spacing } from '../../Consts';
16
+ import { Colors } from '../../Consts';
17
17
  import { TabBarMetrics, TabBarMotion } from './metrics';
18
18
 
19
19
  type IconRenderer = (props: {
@@ -143,7 +143,7 @@ const styles = StyleSheet.create({
143
143
  minWidth: 1,
144
144
  alignItems: 'center',
145
145
  justifyContent: 'center',
146
- gap: Spacing.XXS,
146
+ gap: TabBarMetrics.itemIconLabelGap,
147
147
  },
148
148
  slot: {
149
149
  height: TabBarMetrics.indicatorHeight,
@@ -3,7 +3,11 @@ import React from 'react';
3
3
  import { useWindowDimensions, View } from 'react-native';
4
4
  import { useScreenLayout } from '../../Layout/utils';
5
5
  import { FloatingButtonProps } from '../types';
6
- import { getSystemIndicatorHeight, HorizontalTabBar } from './BottomTabBar';
6
+ import {
7
+ getSystemIndicatorHeight,
8
+ hasCenterAction,
9
+ HorizontalTabBar,
10
+ } from './BottomTabBar';
7
11
  import { getHorizontalBarWidth, TabBarMetrics } from './metrics';
8
12
  import { getTabItems } from './tabItems';
9
13
  import { DuoRailTabBar } from './DuoRailTabBar';
@@ -34,6 +38,7 @@ const DuoFloatingTabBar: React.FC<DuoTabBarProps> = props => {
34
38
  const { insets } = useScreenLayout();
35
39
  const { width, height } = useWindowDimensions();
36
40
  const { floatingButton, activeTintColor, inactiveTintColor } = props;
41
+ const tabItems = getTabItems(props);
37
42
 
38
43
  return (
39
44
  <View
@@ -44,8 +49,15 @@ const DuoFloatingTabBar: React.FC<DuoTabBarProps> = props => {
44
49
  ]}
45
50
  >
46
51
  <HorizontalTabBar
47
- items={getTabItems(props)}
48
- width={getHorizontalBarWidth(width, height, insets.left, insets.right)}
52
+ items={tabItems}
53
+ width={getHorizontalBarWidth(
54
+ width,
55
+ height,
56
+ insets.left,
57
+ insets.right,
58
+ tabItems.length,
59
+ hasCenterAction(floatingButton, tabItems.length),
60
+ )}
49
61
  floatingButton={floatingButton}
50
62
  activeTintColor={activeTintColor}
51
63
  inactiveTintColor={inactiveTintColor}
@@ -8,11 +8,18 @@ import { Colors, Radius, Spacing } from '../../Consts';
8
8
  * iPhone Duo rail (center action under the container).
9
9
  */
10
10
  const TabBarMetrics = {
11
- height: 68,
11
+ height: 60,
12
12
  margin: Spacing.S,
13
- paddingVertical: Spacing.S,
13
+ paddingVertical: Spacing.XS,
14
14
  paddingHorizontal: Spacing.M,
15
- itemGap: Spacing.XS,
15
+ itemGap: 1,
16
+ // gap between the icon slot and the label inside a tab (Figma: none)
17
+ itemIconLabelGap: 0,
18
+ // .Nav/Background: no backdrop blur, so use the Figma Blur=Off spec (opacity 95%, no blur) plus the 1px
19
+ // border — nearly solid, matching the frosted sample; surface keeps dark-mode support
20
+ backgroundOpacity: 0.95,
21
+ // white 60% hairline around the center action button (Figma Icon Button border)
22
+ ctaBorderOpacity: 0.6,
16
23
  iconSize: 24,
17
24
  // active indicator behind the icon: 24 icon + XS·M padding
18
25
  indicatorPaddingVertical: Spacing.XS,
@@ -25,6 +32,9 @@ const TabBarMetrics = {
25
32
  systemIndicatorHeight: 24,
26
33
  foldableMinShortSide: 600,
27
34
  foldableWidthRatio: 0.65,
35
+ // a 2-tab bar doesn't stretch to the full width: each item is this fixed width and the bar is
36
+ // sized to its content, centered (Figma Navigation · 2 Tab: item 100, bar ~225)
37
+ twoTabItemWidth: 100,
28
38
  ctaSlotWidth: 92,
29
39
  ctaSize: 48,
30
40
  ctaIconSize: 28,
@@ -132,7 +142,17 @@ const getHorizontalBarWidth = (
132
142
  height: number,
133
143
  insetLeft: number,
134
144
  insetRight: number,
145
+ itemCount: number,
146
+ hasCta: boolean,
135
147
  ) => {
148
+ // 2 tabs (no center action) stay content-sized and centered instead of filling the window
149
+ if (itemCount === 2 && !hasCta) {
150
+ return (
151
+ TabBarMetrics.twoTabItemWidth * 2 +
152
+ TabBarMetrics.paddingHorizontal * 2 +
153
+ TabBarMetrics.itemGap
154
+ );
155
+ }
136
156
  const shortSide = Math.min(width, height);
137
157
  if (shortSide >= TabBarMetrics.foldableMinShortSide) {
138
158
  return shortSide * TabBarMetrics.foldableWidthRatio;
@@ -17,7 +17,7 @@ import BackgroundImageView from './BackgroundImageView';
17
17
  import { type AnimatedCompatValue } from '../utils';
18
18
  import { useNormalizedSharedValue } from '../hooks';
19
19
  import { useScreenLayout } from '../../Layout';
20
- import { DuoMetrics, HeaderMetrics } from '../../Layout/utils';
20
+ import { HeaderMetrics } from '../../Layout/utils';
21
21
  import {
22
22
  HeaderBarMetrics,
23
23
  type HeaderContentLayout,
@@ -66,17 +66,10 @@ const HeaderExtendHeader: React.FC<{
66
66
  // the stretch frame pulls the search in from both bar edges
67
67
  const frameShift = headerLayout.frameInset - sidePadding;
68
68
 
69
- let backWidth = buttonSize;
70
- let toolkitWidth = TOOLKIT_WIDTH;
71
- // the iPhone Duo status bar row keeps side bar sized back and toolkit
72
- if (layout.statusBarClearance) {
73
- backWidth = DuoMetrics.controlSize;
74
- toolkitWidth = DuoMetrics.itemPitch * 2 + SCREEN_PADDING;
75
- }
76
- const backLeft = backWidth + sidePadding + titleGap;
69
+ const backLeft = buttonSize + sidePadding + titleGap;
77
70
  const defaultLeft = layout.sideBar ? SCREEN_PADDING : backLeft;
78
71
  const leftPosition = inputSearchProps?.leftPosition || defaultLeft;
79
- const defaultRightWidth = layout.sideBar ? 0 : toolkitWidth;
72
+ const defaultRightWidth = layout.sideBar ? 0 : TOOLKIT_WIDTH;
80
73
  const headerRightWidth = customHeaderRightWidth ?? defaultRightWidth;
81
74
  const contentLeft = layout.insetLeft + SCREEN_PADDING + frameShift;
82
75
  const contentRight = layout.insetLeft + layout.contentWidth - frameShift;
@@ -92,9 +85,8 @@ const HeaderExtendHeader: React.FC<{
92
85
  const titleRowHeight = layout.headerHeight - layout.headerStatusBarHeight;
93
86
  const collapsedRaise = (titleRowHeight - HeaderMetrics.barHeight) / 2;
94
87
 
95
- // the iPhone Duo side bar and status bar row keep the content search size
96
- const isDuoRow = !!layout.sideBar || !!layout.statusBarClearance;
97
- const searchSize = isDuoRow ? 'default' : 'header';
88
+ // the iPhone Duo side bar keeps the content search size
89
+ const searchSize = layout.sideBar ? 'default' : 'header';
98
90
 
99
91
  let useShadowHeader = useShadowHeaderProp;
100
92
  if (inputSearchProps && Platform.OS === 'android') {
@@ -6,13 +6,13 @@ import { PopupNotify } from '../../Popup';
6
6
  import { NavigationButton } from './NavigationButton';
7
7
  import { SideBarButton } from './SideBarButton';
8
8
  import Animated from 'react-native-reanimated';
9
- import { useScreenLayout, useSideBarItemStyle } from '../../Layout/utils';
9
+ import { useSideBarItemStyle } from '../../Layout/utils';
10
10
  import { useSideBarCounterStyle } from './DuoQuickReturnHeader';
11
11
  import { HeaderBarMetrics } from '../headerLayout';
12
12
 
13
13
  /**
14
14
  * Header back button, also bound to the Android hardware back. `preventBack`
15
- * confirms in a popup first; the iPhone Duo layouts use the 48pt side bar button.
15
+ * confirms in a popup first; the iPhone Duo side bar uses the 48pt side bar button.
16
16
  */
17
17
  const HeaderLeft: React.FC<HeaderBackProps> = ({
18
18
  tintColor,
@@ -25,7 +25,6 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
25
25
  const { navigator } = useContext(ApplicationContext);
26
26
  const sideBarStyle = useSideBarItemStyle('left', 0);
27
27
  const counterStyle = useSideBarCounterStyle();
28
- const { statusBarClearance } = useScreenLayout();
29
28
 
30
29
  const goBack = useCallback(() => {
31
30
  const canGoBack = navigator?.ref?.current?.canGoBack?.();
@@ -98,20 +97,6 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
98
97
  );
99
98
  }
100
99
 
101
- // on the status bar row the controls keep the side bar size
102
- if (statusBarClearance) {
103
- return (
104
- <View style={styles.headerLeft}>
105
- <SideBarButton
106
- accessibilityLabel="btn_navigation_back"
107
- icon="arrow-back"
108
- tintColor={tintColor}
109
- onPress={goBackSafe}
110
- />
111
- </View>
112
- );
113
- }
114
-
115
100
  return (
116
101
  <View style={styles.headerLeft}>
117
102
  <NavigationButton
@@ -74,10 +74,6 @@ export const styles = StyleSheet.create({
74
74
  sideBarColumn: {
75
75
  gap: Spacing.M,
76
76
  },
77
- sideBarRow: {
78
- flexDirection: 'row',
79
- gap: Spacing.M,
80
- },
81
77
  headerLeft: {
82
78
  marginLeft: 12,
83
79
  },
@@ -23,28 +23,22 @@ const useHeaderFontFamily = (): string => {
23
23
  const HEADER_ACTIONS_WIDTH =
24
24
  sidePadding * 2 + buttonSize + titleGap * 2 + clusterWidth;
25
25
 
26
- /**
27
- * extra width the 48pt back and toolkit take on the iPhone Duo status bar row
28
- */
29
- const STATUS_BAR_ROW_ACTIONS_EXTRA = 43;
30
-
31
26
  /**
32
27
  * Max header title width. The iPhone Duo side bar takes back and toolkit out of
33
- * the bar, so the title gets the content width; otherwise it shares the bar with them.
28
+ * the bar, so the title gets the content width; otherwise it shares the bar with
29
+ * them, minus the status bar clusters on the iPhone Duo inner portrait row.
34
30
  */
35
31
  const useTitleMaxWidth = () => {
36
32
  const layout = useScreenLayout();
37
33
  const { width, contentWidth, sideBar, statusBarClearance } = layout;
38
34
  let clearance = 0;
39
- let rowActionsExtra = 0;
40
35
  if (statusBarClearance) {
41
36
  clearance = statusBarClearance.left + statusBarClearance.right;
42
- rowActionsExtra = STATUS_BAR_ROW_ACTIONS_EXTRA;
43
37
  }
44
38
  if (sideBar) {
45
39
  return contentWidth - Spacing.M * 2 - clearance;
46
40
  }
47
- return width - HEADER_ACTIONS_WIDTH - rowActionsExtra - clearance;
41
+ return width - HEADER_ACTIONS_WIDTH - clearance;
48
42
  };
49
43
 
50
44
  export { useHeaderFontFamily, HEADER_ACTIONS_WIDTH, useTitleMaxWidth };
@@ -4,7 +4,7 @@ import { NavigationButton } from './NavigationButton';
4
4
  import { MiniAppContext } from '../../Context';
5
5
  import { Colors, Spacing, Styles } from '../../Consts';
6
6
  import { Icon } from '../../Icon';
7
- import { DuoMetrics, useScreenLayout } from '../../Layout/utils';
7
+ import { DuoMetrics } from '../../Layout/utils';
8
8
  import { SideBarButton, SideBarGroup, SideBarGroupItem } from './SideBarButton';
9
9
  import { useDuoBarCompression } from '../BottomTab/DuoBarCompression';
10
10
  import { styles } from './HeaderRight.styles';
@@ -32,7 +32,6 @@ const HeaderToolkitAction: React.FC<any> = ({
32
32
  const compression = useDuoBarCompression();
33
33
  const { toolbarCompressed, toolbarHidden } = compression;
34
34
  const { expandToolbar, setToolbarHeight } = compression;
35
- const { statusBarClearance } = useScreenLayout();
36
35
  const {
37
36
  isLoading,
38
37
  iconShortcut,
@@ -132,39 +131,6 @@ const HeaderToolkitAction: React.FC<any> = ({
132
131
  );
133
132
  }
134
133
 
135
- // on the status bar row the controls keep the side bar size
136
- if (statusBarClearance) {
137
- return (
138
- <View style={styles.sideBarRow}>
139
- {useShortcut && (
140
- <SideBarButton
141
- disabled={isLoading}
142
- icon={iconShortcut}
143
- onPress={shortcutOnPress}
144
- tintColor={tintColor}
145
- showBadge={showBadge}
146
- />
147
- )}
148
- <SideBarGroup tintColor={tintColor} horizontal>
149
- {useHelpCenter && (
150
- <SideBarGroupItem
151
- accessibilityLabel={'btn_navigation_help_center'}
152
- icon={'help_center'}
153
- tintColor={tintColor}
154
- onPress={onPressHelpCenter}
155
- />
156
- )}
157
- <SideBarGroupItem
158
- accessibilityLabel={'btn_navigation_close'}
159
- icon={closeIcon}
160
- tintColor={tintColor}
161
- onPress={onClose}
162
- />
163
- </SideBarGroup>
164
- </View>
165
- );
166
- }
167
-
168
134
  return (
169
135
  <View style={Styles.row}>
170
136
  {useShortcut && (
@@ -8,13 +8,12 @@ import { ApplicationContext, MiniAppContext } from '../../Context';
8
8
  import { Text } from '../../Text';
9
9
  import { useNormalizedSharedValue } from '../hooks';
10
10
  import { useScreenLayout } from '../../Layout';
11
- import { DuoMetrics } from '../../Layout/utils';
12
11
  import { HeaderBarMetrics } from '../headerLayout';
13
12
 
14
13
  const { buttonSize, pillWidth, sidePadding, titleGap } = HeaderBarMetrics;
15
14
  // help center | home pill and the bar padding right of it
16
15
  const TOOLKIT_WIDTH = pillWidth + sidePadding;
17
- // the iPhone Duo side bar and status bar row keep their right header width
16
+ // the iPhone Duo side bar keeps its right header width
18
17
  const DUO_TOOLKIT_WIDTH = 73;
19
18
 
20
19
  /**
@@ -35,20 +34,15 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
35
34
  const { theme, navigator } = useContext(ApplicationContext);
36
35
  const context = useContext<any>(MiniAppContext);
37
36
  const layout = useScreenLayout();
38
- // the iPhone Duo status bar row keeps a side bar sized back button
39
- let backWidth = buttonSize;
40
- if (layout.statusBarClearance) {
41
- backWidth = DuoMetrics.controlSize;
42
- }
43
37
  let defaultRightWidth = TOOLKIT_WIDTH;
44
38
  let searchSize: InputSearchProps['size'] = 'header';
45
- if (layout.sideBar || layout.statusBarClearance) {
39
+ if (layout.sideBar) {
46
40
  defaultRightWidth = DUO_TOOLKIT_WIDTH;
47
41
  searchSize = 'default';
48
42
  }
49
43
 
50
44
  const sharedValue = useNormalizedSharedValue(animatedValue);
51
- const defaultLeft = backWidth + sidePadding + titleGap;
45
+ const defaultLeft = buttonSize + sidePadding + titleGap;
52
46
  const leftPosition = props?.leftPosition ?? defaultLeft;
53
47
  const headerRightWidth = props?.headerRightWidth ?? defaultRightWidth;
54
48
 
@@ -36,7 +36,6 @@ export type BottomTabProps = {
36
36
  };
37
37
 
38
38
  export type FloatingButtonProps = {
39
- container?: React.ReactNode;
40
39
  icon: string | React.ReactNode;
41
40
  label: string;
42
41
  onPress: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.169.7-beta.6",
3
+ "version": "0.169.7-beta.8",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},