@momo-kits/foundation 0.169.17-beta.10 → 0.169.17-beta.13

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 (60) hide show
  1. package/Application/BottomSheet.tsx +2 -2
  2. package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
  3. package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
  4. package/Application/BottomTab/TabBarIcon.tsx +1 -1
  5. package/Application/BottomTab/index.tsx +1 -15
  6. package/Application/Components/HeaderExtendHeader.tsx +1 -3
  7. package/Application/Components/HeaderRight.tsx +3 -24
  8. package/Application/Components/SearchHeader.tsx +2 -3
  9. package/Application/ModalScreen.tsx +2 -2
  10. package/Application/StackScreen.tsx +6 -2
  11. package/Application/TooltipPortal.tsx +3 -3
  12. package/Application/headerLayout.ts +3 -7
  13. package/Application/hooks.ts +1 -1
  14. package/Application/modalLayout.ts +4 -12
  15. package/Application/types.tabs.ts +0 -8
  16. package/Button/index.tsx +2 -2
  17. package/Divider/DashDivider.tsx +2 -2
  18. package/Divider/index.tsx +3 -3
  19. package/FoundationList/index.tsx +1 -1
  20. package/Icon/types.ts +1 -2
  21. package/Image/index.tsx +70 -7
  22. package/Image/styles.ts +2 -0
  23. package/Image/types.ts +9 -1
  24. package/Input/Input.tsx +2 -2
  25. package/Input/InputMoney.tsx +7 -2
  26. package/Input/InputMoneyView.tsx +2 -2
  27. package/Input/InputOTP.tsx +2 -2
  28. package/Input/InputPhoneNumber.tsx +40 -22
  29. package/Input/InputSearch.tsx +2 -2
  30. package/Input/InputTextArea.tsx +2 -2
  31. package/Input/SearchTextTyping.tsx +2 -2
  32. package/Input/SystemTextInput.tsx +2 -1
  33. package/Input/TextTyping.tsx +7 -2
  34. package/Input/index.tsx +1 -14
  35. package/Layout/Screen.tsx +5 -11
  36. package/Layout/Section.tsx +3 -14
  37. package/Layout/screenFooter.tsx +21 -181
  38. package/Layout/screenHeader.tsx +41 -56
  39. package/Layout/screenTypes.ts +1 -16
  40. package/Layout/styles.ts +0 -10
  41. package/Layout/types.ts +0 -6
  42. package/Pagination/types.ts +6 -2
  43. package/package.json +28 -26
  44. package/Application/BottomTab/Legacy/BottomTabBar.styles.ts +0 -60
  45. package/Application/BottomTab/Legacy/BottomTabBar.tsx +0 -270
  46. package/Application/BottomTab/Legacy/CustomBottomTabItem.tsx +0 -153
  47. package/Application/BottomTab/Legacy/DuoBarCompression.tsx +0 -135
  48. package/Application/BottomTab/Legacy/DuoRailTabBar.tsx +0 -149
  49. package/Application/BottomTab/Legacy/DuoTabBar.parts.tsx +0 -202
  50. package/Application/BottomTab/Legacy/DuoTabBar.styles.ts +0 -123
  51. package/Application/BottomTab/Legacy/DuoTabBar.tsx +0 -151
  52. package/Application/BottomTab/Legacy/TabBarIcon.tsx +0 -113
  53. package/Application/BottomTab/Legacy/TabScreen.tsx +0 -177
  54. package/Application/BottomTab/Legacy/badge.ts +0 -41
  55. package/Application/BottomTab/Legacy/hooks.ts +0 -358
  56. package/Application/BottomTab/Legacy/index.styles.ts +0 -30
  57. package/Application/BottomTab/Legacy/index.tsx +0 -230
  58. package/Application/Components/useHeaderRightWidth.ts +0 -46
  59. package/Input/CountryCodeView.tsx +0 -93
  60. package/Layout/__tests__/screenFooter.test.ts +0 -56
@@ -1,153 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import { TouchableOpacity, StyleSheet } from 'react-native';
3
- import {
4
- BottomTabBarButtonProps,
5
- BottomTabNavigationOptions,
6
- } from '@react-navigation/bottom-tabs';
7
- import { Route } from '@react-navigation/native';
8
- import { TabBarIcon } from './TabBarIcon';
9
- import { Text } from '../../../Text';
10
- import { MiniAppContext } from '../../../Context';
11
- import { Colors } from '../../../Consts';
12
-
13
- type LabelType = NonNullable<BottomTabNavigationOptions['tabBarLabel']>;
14
-
15
- interface CustomBottomTabItemProps {
16
- route: Route<string>;
17
- focused: boolean;
18
- label: LabelType;
19
- onPress: () => void;
20
- onLongPress: () => void;
21
- activeTintColor: string;
22
- inactiveTintColor: string;
23
- activeBackgroundColor?: string;
24
- inactiveBackgroundColor?: string;
25
- icon: any;
26
- badge?: string | number;
27
- showLabel?: boolean;
28
- labelStyle?: any;
29
- iconStyle?: any;
30
- style?: any;
31
- badgeStyle?: any;
32
- allowFontScaling?: boolean;
33
- button?: (props: BottomTabBarButtonProps) => React.ReactNode;
34
- /**
35
- * The accessibility label for the tab.
36
- */
37
- accessibilityLabel?: string;
38
- /**
39
- * An unique ID for testing for the tab.
40
- */
41
- testID?: string;
42
- }
43
-
44
- const CustomBottomTabItem: React.FC<CustomBottomTabItemProps> = ({
45
- route,
46
- focused,
47
- label,
48
- onPress,
49
- onLongPress,
50
- activeTintColor,
51
- inactiveTintColor,
52
- activeBackgroundColor,
53
- inactiveBackgroundColor,
54
- icon,
55
- badge,
56
- showLabel,
57
- labelStyle,
58
- iconStyle,
59
- style,
60
- badgeStyle,
61
- allowFontScaling,
62
- }) => {
63
- const context = useContext<any>(MiniAppContext);
64
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
65
-
66
- const renderIcon = () => {
67
- if (icon === undefined) {
68
- return null;
69
- }
70
-
71
- const activeOpacity = focused ? 1 : 0;
72
- const inactiveOpacity = focused ? 0 : 1;
73
-
74
- return (
75
- <TabBarIcon
76
- route={route}
77
- badge={badge}
78
- badgeStyle={badgeStyle}
79
- activeOpacity={activeOpacity}
80
- allowFontScaling={allowFontScaling}
81
- inactiveOpacity={inactiveOpacity}
82
- activeTintColor={activeTintColor}
83
- inactiveTintColor={inactiveTintColor}
84
- renderIcon={icon}
85
- style={iconStyle}
86
- />
87
- );
88
- };
89
-
90
- const renderLabel = ({ focused: isFocused }: { focused: boolean }) => {
91
- if (showLabel === false) {
92
- return null;
93
- }
94
-
95
- const color = isFocused ? activeTintColor : inactiveTintColor;
96
-
97
- if (typeof label === 'string') {
98
- return (
99
- <Text
100
- numberOfLines={1}
101
- style={[styles.label, labelStyle]}
102
- color={isFocused ? activeTintColor : inactiveTintColor}
103
- typography={isFocused ? 'label_xs_medium' : 'description_xs_regular'}
104
- allowFontScaling={allowFontScaling}
105
- >
106
- {label}
107
- </Text>
108
- );
109
- }
110
-
111
- return label({
112
- focused: isFocused,
113
- color,
114
- children: route.name,
115
- position: 'below-icon',
116
- });
117
- };
118
-
119
- const background = focused ? activeBackgroundColor : inactiveBackgroundColor;
120
-
121
- return (
122
- <TouchableOpacity
123
- onPress={onPress}
124
- onLongPress={onLongPress}
125
- style={[
126
- styles.container,
127
- { backgroundColor: background },
128
- style,
129
- showBaseLineDebug && styles.debugBaseLine,
130
- ]}
131
- >
132
- {renderIcon()}
133
- {renderLabel({ focused })}
134
- </TouchableOpacity>
135
- );
136
- };
137
-
138
- const styles = StyleSheet.create({
139
- container: {
140
- flex: 1,
141
- alignItems: 'center',
142
- justifyContent: 'center',
143
- paddingVertical: 8,
144
- bottom: -2,
145
- },
146
- label: {
147
- fontSize: 12,
148
- fontWeight: '600',
149
- },
150
- debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
151
- });
152
-
153
- export default CustomBottomTabItem;
@@ -1,135 +0,0 @@
1
- import React, {
2
- createContext,
3
- ReactNode,
4
- useContext,
5
- useMemo,
6
- useState,
7
- } from 'react';
8
- import { Spacing } from '../../../Consts';
9
- import { useScreenLayout } from '../../../Layout';
10
- import { DuoMetrics } from '../../../Layout/utils';
11
-
12
- export type DuoBarCompressionBehavior = 'toolbar' | 'tabBar';
13
-
14
- type DuoBarCompression = {
15
- toolbarCompressed: boolean;
16
- tabBarCompressed: boolean;
17
- // the open rail needs the toolbar button slot too: only Back stays
18
- toolbarHidden?: boolean;
19
- // tapping the compressed bar expands it and compresses the other one
20
- expandToolbar?: () => void;
21
- expandTabBar?: () => void;
22
- // a rail opened from the compressed state closes once a tab is picked
23
- onTabSelected?: () => void;
24
- // header buttons report their full height so the tab bar knows what is left
25
- setToolbarHeight?: (height: number) => void;
26
- };
27
-
28
- const RAIL_PADDING = 6;
29
- const RAIL_GAP = Spacing.XXS;
30
- // space kept between the top and the bottom groups (HIG Vertical controls)
31
- const GROUP_GAP = Spacing.M;
32
- // Back, then the right toolkit: help + home capsule
33
- const DEFAULT_TOOLBAR_HEIGHT =
34
- DuoMetrics.controlSize + Spacing.M + 2 * DuoMetrics.itemPitch;
35
- // Back, then the single button the toolbar folds into
36
- const COMPRESSED_TOOLBAR_HEIGHT = 2 * DuoMetrics.controlSize + Spacing.M;
37
-
38
- const NO_COMPRESSION: DuoBarCompression = {
39
- toolbarCompressed: false,
40
- tabBarCompressed: false,
41
- };
42
-
43
- const DuoBarCompressionContext =
44
- createContext<DuoBarCompression>(NO_COMPRESSION);
45
-
46
- /**
47
- * height of the vertical tab rail, plus the QR button under it
48
- */
49
- const getRailHeight = (tabCount: number, hasQr: boolean) =>
50
- 2 * RAIL_PADDING +
51
- tabCount * DuoMetrics.controlSize +
52
- Math.max(tabCount - 1, 0) * RAIL_GAP +
53
- (hasQr ? Spacing.M + DuoMetrics.controlSize : 0);
54
-
55
- /**
56
- * keeps the side bar's toolbar and tab bar clear of each other (HIG, Designing for
57
- * iPhone Duo: Vertical controls):
58
- * - both fit: both stay whole
59
- * - one fits whole beside the other compressed: one is compressed, tapping it swaps them
60
- * - otherwise both rest compressed; tapping one opens it for a moment (the rail closes
61
- * again once a tab is picked)
62
- */
63
- const DuoBarCompressionProvider: React.FC<{
64
- behavior?: DuoBarCompressionBehavior;
65
- tabCount: number;
66
- hasQr: boolean;
67
- children: ReactNode;
68
- }> = ({ behavior = 'toolbar', tabCount, hasQr, children }) => {
69
- const { height, sideBar } = useScreenLayout();
70
- const [toolbarHeight, setToolbarHeight] = useState(DEFAULT_TOOLBAR_HEIGHT);
71
- // 'toolbar' compression keeps the tab bar whole until the toolbar is tapped
72
- const [expanded, setExpanded] = useState<'toolbar' | 'tabBar'>(
73
- behavior === 'toolbar' ? 'tabBar' : 'toolbar',
74
- );
75
- // bar opened for a moment while both rest compressed
76
- const [opened, setOpened] = useState<'toolbar' | 'tabBar'>();
77
-
78
- const value = useMemo(() => {
79
- if (!sideBar) {
80
- return NO_COMPRESSION;
81
- }
82
- const room = height - sideBar.bottom - sideBar.top - GROUP_GAP;
83
- const tabBar = getRailHeight(tabCount, hasQr);
84
- const compressedTabBar = getRailHeight(1, hasQr) - 2 * RAIL_PADDING;
85
- const fits = (toolbar: number, tabs: number) => toolbar + tabs <= room;
86
-
87
- if (fits(toolbarHeight, tabBar)) {
88
- return { ...NO_COMPRESSION, setToolbarHeight };
89
- }
90
- const canSwap =
91
- fits(COMPRESSED_TOOLBAR_HEIGHT, tabBar) &&
92
- fits(toolbarHeight, compressedTabBar);
93
- if (canSwap) {
94
- return {
95
- toolbarCompressed: expanded === 'tabBar',
96
- tabBarCompressed: expanded === 'toolbar',
97
- expandToolbar: () => setExpanded('toolbar'),
98
- expandTabBar: () => setExpanded('tabBar'),
99
- setToolbarHeight,
100
- };
101
- }
102
-
103
- const open = {
104
- expandToolbar: () => setOpened('toolbar'),
105
- expandTabBar: () => setOpened('tabBar'),
106
- setToolbarHeight,
107
- };
108
- // an opened rail always shows, even when only the gap between the groups is short:
109
- // it closes again once a tab is picked
110
- if (opened === 'tabBar') {
111
- return {
112
- ...open,
113
- toolbarCompressed: true,
114
- toolbarHidden: true,
115
- tabBarCompressed: false,
116
- onTabSelected: () => setOpened(undefined),
117
- };
118
- }
119
- return {
120
- ...open,
121
- toolbarCompressed: opened !== 'toolbar',
122
- tabBarCompressed: true,
123
- };
124
- }, [expanded, opened, hasQr, height, sideBar, tabCount, toolbarHeight]);
125
-
126
- return (
127
- <DuoBarCompressionContext.Provider value={value}>
128
- {children}
129
- </DuoBarCompressionContext.Provider>
130
- );
131
- };
132
-
133
- const useDuoBarCompression = () => useContext(DuoBarCompressionContext);
134
-
135
- export { DuoBarCompressionProvider, useDuoBarCompression };
@@ -1,149 +0,0 @@
1
- import React, { useContext, useMemo } from 'react';
2
- import { TouchableOpacity, View } from 'react-native';
3
- import { GestureDetector } from 'react-native-gesture-handler';
4
- import Animated from 'react-native-reanimated';
5
- import { Radius } from '../../../Consts';
6
- import { ApplicationContext } from '../../../Context';
7
- import { useScreenLayout } from '../../../Layout/utils';
8
- import { useDuoBarCompression } from './DuoBarCompression';
9
- import { useLiquidSelection, usePressLift } from './hooks';
10
- import {
11
- BarMaterial,
12
- getTabItems,
13
- LiquidTabItem,
14
- Props,
15
- QrIcon,
16
- SelectionMaterial,
17
- TabItem,
18
- } from './DuoTabBar.parts';
19
- import {
20
- ITEM_SIZE,
21
- QR_ICON_SIZE,
22
- RAIL_BUBBLE_WIDTH,
23
- RAIL_PADDING,
24
- RAIL_PITCH,
25
- styles,
26
- } from './DuoTabBar.styles';
27
-
28
- /**
29
- * column of icon-only tab items with the sliding selection bubble
30
- */
31
- const Rail: React.FC<{
32
- items: TabItem[];
33
- index: number;
34
- onItemPress?: () => void;
35
- }> = ({ items, index, onItemPress }) => {
36
- const onSelect = (itemIndex: number) => {
37
- items[itemIndex]?.onPress();
38
- onItemPress?.();
39
- };
40
- const selection = useLiquidSelection({
41
- count: items.length,
42
- pitch: RAIL_PITCH,
43
- firstCenter: RAIL_PADDING + ITEM_SIZE / 2,
44
- axis: 'y',
45
- index,
46
- onSelect,
47
- });
48
- const { barStyle, bubbleStyle } = selection;
49
- // stable style arrays: the tab switch re-renders the rail while the lens is still
50
- // springing back, a new array would re-attach the animated style mid animation
51
- const railStyle = useMemo(() => [styles.rail, barStyle], [barStyle]);
52
- const railBubbleStyle = useMemo(
53
- () => [styles.railBubble, bubbleStyle],
54
- [bubbleStyle],
55
- );
56
-
57
- return (
58
- <GestureDetector gesture={selection.gesture}>
59
- <Animated.View style={railStyle} accessibilityLabel={'bottom_tab_bar'}>
60
- <BarMaterial radius={ITEM_SIZE / 2} />
61
- <Animated.View pointerEvents={'none'} style={railBubbleStyle}>
62
- <SelectionMaterial radius={RAIL_BUBBLE_WIDTH / 2} />
63
- </Animated.View>
64
- {items.map((item, itemIndex) => (
65
- <LiquidTabItem
66
- key={item.route.key}
67
- item={item}
68
- itemIndex={itemIndex}
69
- selection={selection}
70
- onSelect={() => onSelect(itemIndex)}
71
- renderContent={item.renderIcon}
72
- style={styles.railItem}
73
- />
74
- ))}
75
- </Animated.View>
76
- </GestureDetector>
77
- );
78
- };
79
-
80
- /**
81
- * vertical bar anchored to the bottom of the Duo side bar, QR button below it (Figma MT1-C/E).
82
- * When the side bar is short, it can shrink to one button showing the current tab
83
- * (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar
84
- */
85
- export const DuoRailTabBar: React.FC<Props> = props => {
86
- const { theme } = useContext(ApplicationContext);
87
- const { sideBar } = useScreenLayout();
88
- const { tabBarCompressed, expandTabBar, onTabSelected } =
89
- useDuoBarCompression();
90
- const compactLift = usePressLift();
91
- const { state, floatingButton } = props;
92
- const items = getTabItems(props);
93
- const current = items[state.index];
94
-
95
- const columnStyle = sideBar && [
96
- styles.railColumn,
97
- {
98
- [sideBar.edge]: 0,
99
- width: sideBar.width,
100
- bottom: sideBar.bottom,
101
- },
102
- sideBar.edge === 'right' ? styles.railColumnRight : styles.railColumnLeft,
103
- ];
104
-
105
- const qr = floatingButton && (
106
- <TouchableOpacity
107
- accessibilityRole={'button'}
108
- accessibilityLabel={floatingButton.label}
109
- onPress={floatingButton.onPress}
110
- style={[styles.railQr, { backgroundColor: theme.colors.primary }]}
111
- >
112
- <QrIcon icon={floatingButton.icon} size={QR_ICON_SIZE} />
113
- </TouchableOpacity>
114
- );
115
-
116
- if (!sideBar) {
117
- return null;
118
- }
119
-
120
- if (!tabBarCompressed) {
121
- return (
122
- <View pointerEvents={'box-none'} style={columnStyle}>
123
- <Rail items={items} index={state.index} onItemPress={onTabSelected} />
124
- {qr}
125
- </View>
126
- );
127
- }
128
-
129
- return (
130
- <View pointerEvents={'box-none'} style={columnStyle}>
131
- <Animated.View style={compactLift.style}>
132
- <TouchableOpacity
133
- accessibilityRole={'button'}
134
- accessibilityLabel={current?.label}
135
- accessibilityHint={'bottom_tab_bar'}
136
- activeOpacity={1}
137
- onPressIn={compactLift.onPressIn}
138
- onPressOut={compactLift.onPressOut}
139
- onPress={expandTabBar}
140
- style={styles.railCompact}
141
- >
142
- <BarMaterial radius={Radius.XL} />
143
- {current?.renderIcon(true)}
144
- </TouchableOpacity>
145
- </Animated.View>
146
- {qr}
147
- </View>
148
- );
149
- };
@@ -1,202 +0,0 @@
1
- import { CommonActions, Route } from '@react-navigation/native';
2
- import { BottomTabBarProps } from '@react-navigation/bottom-tabs';
3
- import React, { ReactNode, useContext, useMemo, useRef } from 'react';
4
- import {
5
- StyleProp,
6
- StyleSheet,
7
- TouchableOpacity,
8
- View,
9
- ViewStyle,
10
- } from 'react-native';
11
- import Animated from 'react-native-reanimated';
12
- import { Colors } from '../../../Consts';
13
- import { ApplicationContext, MiniAppContext } from '../../../Context';
14
- import { Icon } from '../../../Icon';
15
- import { Text } from '../../../Text';
16
- import { FloatingButtonProps } from '../../types';
17
- import { TabBarIcon } from './TabBarIcon';
18
- import { LiquidSelection, useLiquidItem } from './hooks';
19
- import { styles } from './DuoTabBar.styles';
20
-
21
- export type Props = BottomTabBarProps & {
22
- activeTintColor: string;
23
- inactiveTintColor: string;
24
- floatingButton?: FloatingButtonProps;
25
- };
26
-
27
- export const BarMaterial: React.FC<{ radius: number }> = ({ radius }) => {
28
- const { theme } = useContext(ApplicationContext);
29
- return (
30
- <View
31
- pointerEvents={'none'}
32
- style={[
33
- StyleSheet.absoluteFill,
34
- styles.barMaterial,
35
- {
36
- borderRadius: radius,
37
- backgroundColor: theme.colors.background.surface,
38
- borderColor: theme.colors.border.default,
39
- },
40
- ]}
41
- />
42
- );
43
- };
44
-
45
- // Figma Home-2026 tab bar "Selection": brand pink at 8%
46
- const SELECTION_TINT_ALPHA = '14';
47
-
48
- /**
49
- * pink tinted capsule under the selected tab
50
- */
51
- export const SelectionMaterial: React.FC<{ radius: number }> = ({ radius }) => {
52
- const { theme } = useContext(ApplicationContext);
53
- return (
54
- <View
55
- pointerEvents={'none'}
56
- style={[
57
- StyleSheet.absoluteFill,
58
- {
59
- borderRadius: radius,
60
- backgroundColor: theme.colors.primary + SELECTION_TINT_ALPHA,
61
- },
62
- ]}
63
- />
64
- );
65
- };
66
-
67
- /**
68
- * tab label at its design size: like the system tab bar it doesn't grow with the wide
69
- * Duo displays, which Text otherwise scales up to 5pt
70
- */
71
- export const TabLabel: React.FC<{
72
- label: string;
73
- color: string;
74
- typography: 'label_xs_medium';
75
- }> = ({ label, color, typography }) => {
76
- const context = useContext<any>(MiniAppContext);
77
- return (
78
- <MiniAppContext.Provider
79
- value={{
80
- ...context,
81
- fontScale: { useOSScaleRate: false, userScaleRate: 1 },
82
- }}
83
- >
84
- <Text numberOfLines={1} typography={typography} color={color}>
85
- {label}
86
- </Text>
87
- </MiniAppContext.Provider>
88
- );
89
- };
90
-
91
- export const getTabItems = ({
92
- state,
93
- descriptors,
94
- navigation,
95
- activeTintColor,
96
- inactiveTintColor,
97
- }: Props) => {
98
- return state.routes.map((route: Route<string>, index: number) => {
99
- const { options } = descriptors[route.key];
100
- const focused = index === state.index;
101
- const label = options.title ?? route.name;
102
-
103
- const onPress = () => {
104
- const event = navigation.emit({
105
- type: 'tabPress',
106
- target: route.key,
107
- canPreventDefault: true,
108
- });
109
- if (!focused && !event.defaultPrevented) {
110
- navigation.dispatch({
111
- ...CommonActions.navigate(route.name),
112
- target: state.key,
113
- });
114
- }
115
- };
116
-
117
- const onLongPress = () => {
118
- navigation.emit({ type: 'tabLongPress', target: route.key });
119
- };
120
-
121
- const renderIcon = (active: boolean) =>
122
- options.tabBarIcon && (
123
- <TabBarIcon
124
- route={route}
125
- badge={options.tabBarBadge}
126
- badgeStyle={options.tabBarBadgeStyle}
127
- activeOpacity={active ? 1 : 0}
128
- inactiveOpacity={active ? 0 : 1}
129
- activeTintColor={activeTintColor}
130
- inactiveTintColor={inactiveTintColor}
131
- renderIcon={options.tabBarIcon}
132
- style={styles.icon}
133
- />
134
- );
135
-
136
- return { route, focused, label, onPress, onLongPress, renderIcon };
137
- });
138
- };
139
-
140
- export const QrIcon: React.FC<{
141
- icon: FloatingButtonProps['icon'];
142
- size: number;
143
- }> = ({ icon, size }) => {
144
- if (typeof icon === 'string') {
145
- return <Icon source={icon} size={size} color={Colors.black_01} />;
146
- }
147
- return <>{icon}</>;
148
- };
149
-
150
- export type TabItem = ReturnType<typeof getTabItems>[number];
151
-
152
- /**
153
- * tab item: a tap is handled here as before, a drag over the bar is handled by the bar's
154
- * gesture. The active layer fades in as the lens passes over it
155
- */
156
- export const LiquidTabItem: React.FC<{
157
- item: TabItem;
158
- itemIndex: number;
159
- selection: LiquidSelection;
160
- onSelect: () => void;
161
- renderContent: (active: boolean) => ReactNode;
162
- style: StyleProp<ViewStyle>;
163
- }> = ({ item, itemIndex, selection, onSelect, renderContent, style }) => {
164
- const { activeStyle, popStyle } = useLiquidItem(selection, itemIndex);
165
- const activeLayerStyle = useMemo(
166
- () => [StyleSheet.absoluteFill, styles.itemLayer, activeStyle],
167
- [activeStyle],
168
- );
169
- // like the system tab bar, a held tab is still picked when released
170
- const longPressed = useRef(false);
171
-
172
- return (
173
- <TouchableOpacity
174
- accessibilityRole={'tab'}
175
- accessibilityLabel={item.label}
176
- accessibilityState={{ selected: item.focused }}
177
- activeOpacity={1}
178
- onPressIn={() => {
179
- longPressed.current = false;
180
- selection.handlePressIn(itemIndex);
181
- }}
182
- onPressOut={() => {
183
- if (selection.handlePressOut() && longPressed.current) {
184
- onSelect();
185
- }
186
- }}
187
- onPress={onSelect}
188
- onLongPress={() => {
189
- longPressed.current = true;
190
- item.onLongPress();
191
- }}
192
- style={style}
193
- >
194
- <Animated.View style={popStyle}>
195
- <View style={styles.itemLayer}>{renderContent(false)}</View>
196
- <Animated.View style={activeLayerStyle}>
197
- {renderContent(true)}
198
- </Animated.View>
199
- </Animated.View>
200
- </TouchableOpacity>
201
- );
202
- };