@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.
- package/Application/BottomSheet.tsx +398 -86
- package/Application/BottomTab/BottomTabBar.tsx +275 -215
- package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
- package/Application/BottomTab/DuoBarCompression.tsx +28 -14
- package/Application/BottomTab/DuoTabBar.tsx +540 -32
- package/Application/BottomTab/TabBarIcon.tsx +72 -146
- package/Application/BottomTab/index.tsx +353 -89
- package/Application/BottomTab/useLiquidSelection.ts +374 -0
- package/Application/Components/BackgroundImageView.tsx +0 -4
- package/Application/Components/DuoGlassBackground.tsx +5 -7
- package/Application/Components/HeaderAnimated.tsx +13 -41
- package/Application/Components/HeaderBackground.tsx +3 -20
- package/Application/Components/HeaderExtendHeader.tsx +46 -66
- package/Application/Components/HeaderLeft.tsx +18 -5
- package/Application/Components/HeaderRight.tsx +529 -8
- package/Application/Components/HeaderTitle.tsx +579 -16
- package/Application/Components/NavigationButton.tsx +11 -18
- package/Application/Components/SearchHeader.tsx +18 -38
- package/Application/Localize.ts +0 -7
- package/Application/ModalScreen.tsx +18 -41
- package/Application/Navigation.ts +17 -15
- package/Application/NavigationContainer.tsx +21 -23
- package/Application/Navigator.ts +48 -20
- package/Application/ScaleSizeProvider.tsx +6 -13
- package/Application/StackScreen.tsx +172 -27
- package/Application/TooltipPortal.tsx +5 -12
- package/Application/WidgetContainer.tsx +7 -20
- package/Application/device.ts +52 -0
- package/Application/index.ts +1 -23
- package/Application/types.ts +242 -17
- package/Application/utils.tsx +493 -0
- package/Badge/Badge.tsx +0 -5
- package/Badge/BadgeDot.tsx +0 -1
- package/Badge/BadgeDotAnimation.tsx +7 -15
- package/Badge/BadgeRibbon.tsx +39 -47
- package/Badge/Shape.tsx +0 -2
- package/Badge/styles.ts +0 -2
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +152 -21
- package/Button/styles.ts +1 -1
- package/CheckBox/index.tsx +6 -5
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +1 -5
- package/Divider/DashDivider.tsx +11 -11
- package/Divider/index.tsx +7 -21
- package/FoundationList/index.tsx +0 -4
- package/Icon/index.tsx +6 -6
- package/Icon/types.ts +1 -1
- package/IconButton/index.tsx +12 -4
- package/Image/index.tsx +7 -9
- package/Input/Input.tsx +12 -10
- package/Input/InputDropDown.tsx +13 -10
- package/Input/InputMoney.tsx +152 -45
- package/Input/InputOTP.tsx +34 -36
- package/Input/InputPhoneNumber.tsx +5 -8
- package/Input/InputSearch.tsx +111 -19
- package/Input/InputTextArea.tsx +5 -5
- package/Input/SystemTextInput.tsx +2 -7
- package/Input/TextTyping.tsx +0 -4
- package/Input/common.tsx +17 -31
- package/Input/index.tsx +21 -24
- package/Input/styles.ts +5 -25
- package/Input/utils.ts +12 -14
- package/Layout/Card.tsx +4 -7
- package/Layout/FloatingButton.tsx +21 -26
- package/Layout/Item.tsx +2 -6
- package/Layout/ItemList.tsx +7 -9
- package/Layout/ItemSectionList.tsx +1 -2
- package/Layout/ReservedRegions.tsx +17 -34
- package/Layout/Screen.tsx +696 -122
- package/Layout/Section.tsx +7 -9
- package/Layout/TrackingScope.tsx +0 -1
- package/Layout/index.ts +4 -10
- package/Layout/styles.ts +0 -2
- package/Layout/types.ts +4 -2
- package/Layout/utils.ts +181 -40
- package/Loader/DotLoader.tsx +3 -11
- package/Loader/Loader.tsx +0 -4
- package/Loader/ProgressBar.tsx +6 -3
- package/Loader/Spinner.tsx +3 -11
- package/Loader/styles.ts +0 -4
- package/Loader/utils.ts +7 -11
- package/Pagination/Dot.tsx +0 -4
- package/Pagination/PaginationDot.tsx +0 -1
- package/Pagination/PaginationNumber.tsx +3 -5
- package/Pagination/PaginationScroll.tsx +0 -5
- package/Pagination/PaginationWhiteDot.tsx +0 -1
- package/Pagination/index.tsx +0 -4
- package/Pagination/types.ts +2 -2
- package/Popup/PopupNotify.tsx +102 -94
- package/Popup/PopupPromotion.tsx +11 -9
- package/Popup/types.ts +4 -11
- package/Popup/utils.ts +18 -50
- package/Radio/index.tsx +10 -6
- package/Radio/styles.ts +0 -6
- package/Skeleton/index.tsx +9 -9
- package/Skeleton/styles.ts +0 -1
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +4 -8
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +5 -25
- package/Text/styles.ts +1 -1
- package/Text/types.ts +6 -1
- package/Text/utils.ts +4 -20
- package/Title/index.tsx +40 -42
- package/Title/styles.ts +0 -6
- package/ViewBoundary/index.tsx +2 -4
- package/index.ts +6 -0
- package/package.json +1 -2
- package/Application/BottomSheet.hooks.ts +0 -195
- package/Application/BottomSheet.parts.tsx +0 -157
- package/Application/BottomSheet.styles.ts +0 -43
- package/Application/BottomTab/ActiveIndicator.tsx +0 -91
- package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
- package/Application/BottomTab/BottomTabInset.tsx +0 -18
- package/Application/BottomTab/CurvedContainer.tsx +0 -155
- package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
- package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
- package/Application/BottomTab/TabScreen.tsx +0 -160
- package/Application/BottomTab/metrics.ts +0 -164
- package/Application/BottomTab/tabItems.ts +0 -46
- package/Application/BottomTab/usePressLift.ts +0 -32
- package/Application/Components/HeaderRight.styles.ts +0 -146
- package/Application/Components/HeaderTitle.shared.ts +0 -44
- package/Application/Components/HeaderTitle.styles.ts +0 -125
- package/Application/Components/HeaderToolkitAction.tsx +0 -180
- package/Application/Components/SwipeBackHaptic.tsx +0 -95
- package/Application/Components/TitleJourney.tsx +0 -110
- package/Application/Components/TitleLocation.tsx +0 -73
- package/Application/Components/TitleUser.tsx +0 -304
- package/Application/Components/useToolkitActions.tsx +0 -218
- package/Application/ModalIconButton.tsx +0 -66
- package/Application/StackScreen.tracking.ts +0 -143
- package/Application/headerLayout.ts +0 -158
- package/Application/hooks.ts +0 -137
- package/Application/modalLayout.ts +0 -176
- package/Application/navigationOptions.tsx +0 -212
- package/Application/types.header.ts +0 -121
- package/Application/types.tabs.ts +0 -48
- package/Application/types.theme.ts +0 -87
- package/Application/utils.ts +0 -107
- package/Button/utils.ts +0 -133
- package/Input/InputMoneyView.tsx +0 -194
- package/Input/SearchTextTyping.tsx +0 -108
- package/Input/moneyUtils.ts +0 -23
- package/Layout/layoutMetrics.ts +0 -58
- package/Layout/layoutTypes.ts +0 -86
- package/Layout/screenContent.tsx +0 -92
- package/Layout/screenFooter.tsx +0 -63
- package/Layout/screenHeader.tsx +0 -321
- package/Layout/screenQuickReturn.tsx +0 -64
- package/Layout/screenScroll.ts +0 -107
- package/Layout/screenTypes.ts +0 -143
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors, Radius, Spacing } from '../Consts';
|
|
3
|
-
import { MODAL_ICON_BUTTON_SIZE } from './ModalIconButton';
|
|
4
|
-
|
|
5
|
-
export const INDICATOR_HEIGHT = 16;
|
|
6
|
-
export const HEADER_HEIGHT = 56;
|
|
7
|
-
export const DUO_ORIENTATIONS = ['portrait', 'landscape'];
|
|
8
|
-
|
|
9
|
-
export const styles = StyleSheet.create({
|
|
10
|
-
container: {
|
|
11
|
-
flex: 1,
|
|
12
|
-
justifyContent: 'flex-end',
|
|
13
|
-
},
|
|
14
|
-
overlay: {
|
|
15
|
-
flex: 1,
|
|
16
|
-
backgroundColor: Colors.black_20,
|
|
17
|
-
},
|
|
18
|
-
indicator: {
|
|
19
|
-
width: 40,
|
|
20
|
-
height: 4,
|
|
21
|
-
borderRadius: Radius.S,
|
|
22
|
-
backgroundColor: Colors.black_06,
|
|
23
|
-
position: 'absolute',
|
|
24
|
-
alignSelf: 'center',
|
|
25
|
-
top: Spacing.S,
|
|
26
|
-
},
|
|
27
|
-
header: {
|
|
28
|
-
height: HEADER_HEIGHT,
|
|
29
|
-
flexDirection: 'row',
|
|
30
|
-
alignItems: 'center',
|
|
31
|
-
paddingHorizontal: Spacing.M,
|
|
32
|
-
gap: Spacing.S,
|
|
33
|
-
},
|
|
34
|
-
title: { textAlign: 'center' },
|
|
35
|
-
iconButtonSpace: {
|
|
36
|
-
width: MODAL_ICON_BUTTON_SIZE,
|
|
37
|
-
height: MODAL_ICON_BUTTON_SIZE,
|
|
38
|
-
},
|
|
39
|
-
shrink: { flexShrink: 1 },
|
|
40
|
-
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
41
|
-
headerDivider: { borderBottomWidth: 1 },
|
|
42
|
-
sheetContainer: { overflow: 'hidden' },
|
|
43
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useRef } from 'react';
|
|
2
|
-
import { StyleProp, StyleSheet, ViewStyle } from 'react-native';
|
|
3
|
-
import Animated, {
|
|
4
|
-
useAnimatedStyle,
|
|
5
|
-
useSharedValue,
|
|
6
|
-
withTiming,
|
|
7
|
-
} from 'react-native-reanimated';
|
|
8
|
-
import { ApplicationContext } from '../../Context';
|
|
9
|
-
import { getIndicatorShadow, TabBarMotion } from './metrics';
|
|
10
|
-
|
|
11
|
-
type Props = {
|
|
12
|
-
axis: 'x' | 'y';
|
|
13
|
-
// position of the selected item along the axis, undefined until it is measured
|
|
14
|
-
offset?: number;
|
|
15
|
-
// horizontal bar: width of the selected item
|
|
16
|
-
extent?: number;
|
|
17
|
-
radius: number;
|
|
18
|
-
style: StyleProp<ViewStyle>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The single active indicator of a bar (Background/tonal with inner shadows) that slides
|
|
23
|
-
* to the selected item. It lands in place on the first measure and slides from then on.
|
|
24
|
-
*/
|
|
25
|
-
const ActiveIndicator: React.FC<Props> = ({
|
|
26
|
-
axis,
|
|
27
|
-
offset,
|
|
28
|
-
extent,
|
|
29
|
-
radius,
|
|
30
|
-
style,
|
|
31
|
-
}) => {
|
|
32
|
-
const { theme } = useContext(ApplicationContext);
|
|
33
|
-
const position = useSharedValue(offset ?? 0);
|
|
34
|
-
const size = useSharedValue(extent ?? 0);
|
|
35
|
-
const visible = useSharedValue(offset === undefined ? 0 : 1);
|
|
36
|
-
const placed = useRef(offset !== undefined);
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (offset === undefined) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
size.value = extent ?? 0;
|
|
43
|
-
if (!placed.current) {
|
|
44
|
-
placed.current = true;
|
|
45
|
-
position.value = offset;
|
|
46
|
-
visible.value = 1;
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
position.value = withTiming(offset, TabBarMotion.indicator);
|
|
50
|
-
}, [offset, extent, position, size, visible]);
|
|
51
|
-
|
|
52
|
-
const animatedStyle = useAnimatedStyle(() => {
|
|
53
|
-
if (axis === 'x') {
|
|
54
|
-
return {
|
|
55
|
-
opacity: visible.value,
|
|
56
|
-
width: size.value,
|
|
57
|
-
transform: [{ translateX: position.value }],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
opacity: visible.value,
|
|
62
|
-
transform: [{ translateY: position.value }],
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<Animated.View
|
|
68
|
-
pointerEvents={'none'}
|
|
69
|
-
style={[
|
|
70
|
-
styles.indicator,
|
|
71
|
-
{
|
|
72
|
-
borderRadius: radius,
|
|
73
|
-
backgroundColor: theme.colors.background.tonal,
|
|
74
|
-
boxShadow: getIndicatorShadow(theme.colors.primary),
|
|
75
|
-
},
|
|
76
|
-
style,
|
|
77
|
-
animatedStyle,
|
|
78
|
-
]}
|
|
79
|
-
/>
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const styles = StyleSheet.create({
|
|
84
|
-
indicator: {
|
|
85
|
-
position: 'absolute',
|
|
86
|
-
left: 0,
|
|
87
|
-
top: 0,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
export { ActiveIndicator };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors, Spacing } from '../../Consts';
|
|
3
|
-
import { CTA_SHADOW, TabBarMetrics } from './metrics';
|
|
4
|
-
|
|
5
|
-
export const styles = StyleSheet.create({
|
|
6
|
-
bar: {
|
|
7
|
-
position: 'absolute',
|
|
8
|
-
left: 0,
|
|
9
|
-
right: 0,
|
|
10
|
-
bottom: 0,
|
|
11
|
-
alignItems: 'center',
|
|
12
|
-
},
|
|
13
|
-
// transparent strip that keeps the rising center action touchable
|
|
14
|
-
barCtaRise: {
|
|
15
|
-
paddingTop: TabBarMetrics.ctaLift,
|
|
16
|
-
},
|
|
17
|
-
container: {
|
|
18
|
-
height: TabBarMetrics.height,
|
|
19
|
-
},
|
|
20
|
-
content: {
|
|
21
|
-
flex: 1,
|
|
22
|
-
flexDirection: 'row',
|
|
23
|
-
alignItems: 'center',
|
|
24
|
-
gap: TabBarMetrics.itemGap,
|
|
25
|
-
paddingVertical: TabBarMetrics.paddingVertical,
|
|
26
|
-
paddingHorizontal: TabBarMetrics.paddingHorizontal,
|
|
27
|
-
},
|
|
28
|
-
indicator: {
|
|
29
|
-
height: TabBarMetrics.indicatorHeight,
|
|
30
|
-
},
|
|
31
|
-
ctaSlot: {
|
|
32
|
-
width: TabBarMetrics.ctaSlotWidth,
|
|
33
|
-
alignSelf: 'stretch',
|
|
34
|
-
},
|
|
35
|
-
// the button rises ctaLift above the container top, the label ends on the item baseline
|
|
36
|
-
cta: {
|
|
37
|
-
position: 'absolute',
|
|
38
|
-
left: 0,
|
|
39
|
-
right: 0,
|
|
40
|
-
top: -TabBarMetrics.ctaLift - TabBarMetrics.paddingVertical,
|
|
41
|
-
alignItems: 'center',
|
|
42
|
-
gap: TabBarMetrics.ctaLabelGap,
|
|
43
|
-
},
|
|
44
|
-
ctaButton: {
|
|
45
|
-
boxShadow: CTA_SHADOW,
|
|
46
|
-
width: TabBarMetrics.ctaSize,
|
|
47
|
-
height: TabBarMetrics.ctaSize,
|
|
48
|
-
borderRadius: TabBarMetrics.ctaSize / 2,
|
|
49
|
-
alignItems: 'center',
|
|
50
|
-
justifyContent: 'center',
|
|
51
|
-
},
|
|
52
|
-
// custom label content over the label text, centered and unclipped
|
|
53
|
-
ctaLabelOverlay: {
|
|
54
|
-
...StyleSheet.absoluteFillObject,
|
|
55
|
-
alignItems: 'center',
|
|
56
|
-
justifyContent: 'center',
|
|
57
|
-
},
|
|
58
|
-
ctaLabel: {
|
|
59
|
-
maxWidth: TabBarMetrics.ctaSlotWidth,
|
|
60
|
-
minHeight: TabBarMetrics.ctaLabelHeight,
|
|
61
|
-
paddingHorizontal: Spacing.XXS,
|
|
62
|
-
justifyContent: 'center',
|
|
63
|
-
},
|
|
64
|
-
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
65
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
2
|
-
|
|
3
|
-
type BottomTabInset = {
|
|
4
|
-
/**
|
|
5
|
-
* Space the floating tab bar takes over the bottom of a tab's content (bar + home
|
|
6
|
-
* indicator area, plus the rising center action when shown); 0 on the iPhone Duo rail.
|
|
7
|
-
*/
|
|
8
|
-
inset: number;
|
|
9
|
-
/**
|
|
10
|
-
* Called by a Screen in the tab that keeps its content clear of the bar itself (inside
|
|
11
|
-
* its scroll view, or above the bar when static), so the tab stops padding its content.
|
|
12
|
-
*/
|
|
13
|
-
claim?: () => void;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const BottomTabInsetContext = createContext<BottomTabInset>({ inset: 0 });
|
|
17
|
-
|
|
18
|
-
export { BottomTabInsetContext };
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import { StyleSheet } from 'react-native';
|
|
3
|
-
import Svg, { Defs, FeGaussianBlur, Filter, Path } from 'react-native-svg';
|
|
4
|
-
import { Colors } from '../../Consts';
|
|
5
|
-
import { ApplicationContext } from '../../Context';
|
|
6
|
-
import { NOTCH_CURVES, NOTCH_HALF_WIDTH } from './metrics';
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
radius: number;
|
|
12
|
-
// x of the center action, the top edge is cut around it
|
|
13
|
-
notchCenterX?: number;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// room for the floating shadow around the shape: the key shadow reaches 12 + 3 × 16 below it
|
|
17
|
-
const SHADOW_PADDING = 64;
|
|
18
|
-
/**
|
|
19
|
-
* Figma Shadow/floating: 12% blur 24, plus 4% blur 32 spread -16 offset 12. SVG blur takes
|
|
20
|
-
* half the CSS blur radius; the spread shrinks the shape the key shadow is cast from.
|
|
21
|
-
*/
|
|
22
|
-
const AMBIENT_BLUR = 12;
|
|
23
|
-
const KEY_BLUR = 16;
|
|
24
|
-
const KEY_SPREAD = 16;
|
|
25
|
-
const KEY_OFFSET_Y = 12;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* SVG path of the rounded container placed at (`x`, `y`) on the canvas, with the notch
|
|
29
|
-
* dipped into the top edge around `notchCenterX`.
|
|
30
|
-
*/
|
|
31
|
-
const getContainerPath = (
|
|
32
|
-
width: number,
|
|
33
|
-
height: number,
|
|
34
|
-
radius: number,
|
|
35
|
-
x: number,
|
|
36
|
-
y: number,
|
|
37
|
-
notchCenterX?: number,
|
|
38
|
-
) => {
|
|
39
|
-
const r = Math.max(Math.min(radius, height / 2, width / 2), 0);
|
|
40
|
-
const left = x;
|
|
41
|
-
const top = y;
|
|
42
|
-
const right = x + width;
|
|
43
|
-
const bottom = y + height;
|
|
44
|
-
let notch = '';
|
|
45
|
-
if (notchCenterX !== undefined) {
|
|
46
|
-
const cx = x + notchCenterX;
|
|
47
|
-
const point = ([dx, dy]: [number, number]) => `${cx + dx} ${top + dy}`;
|
|
48
|
-
const curves = NOTCH_CURVES.map(([c1, c2, end]) => {
|
|
49
|
-
return ` C ${point(c1)} ${point(c2)} ${point(end)}`;
|
|
50
|
-
});
|
|
51
|
-
notch = ` L ${cx - NOTCH_HALF_WIDTH} ${top}${curves.join('')}`;
|
|
52
|
-
}
|
|
53
|
-
return (
|
|
54
|
-
`M ${left + r} ${top}` +
|
|
55
|
-
notch +
|
|
56
|
-
` L ${right - r} ${top}` +
|
|
57
|
-
` A ${r} ${r} 0 0 1 ${right} ${top + r}` +
|
|
58
|
-
` L ${right} ${bottom - r}` +
|
|
59
|
-
` A ${r} ${r} 0 0 1 ${right - r} ${bottom}` +
|
|
60
|
-
` L ${left + r} ${bottom}` +
|
|
61
|
-
` A ${r} ${r} 0 0 1 ${left} ${bottom - r}` +
|
|
62
|
-
` L ${left} ${top + r}` +
|
|
63
|
-
` A ${r} ${r} 0 0 1 ${left + r} ${top} Z`
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Navigation bar container: surface fill with the floating shadow, drawn as an SVG shape
|
|
69
|
-
* so the shadow follows the notch.
|
|
70
|
-
*/
|
|
71
|
-
const CurvedContainer: React.FC<Props> = ({
|
|
72
|
-
width,
|
|
73
|
-
height,
|
|
74
|
-
radius,
|
|
75
|
-
notchCenterX,
|
|
76
|
-
}) => {
|
|
77
|
-
const { theme } = useContext(ApplicationContext);
|
|
78
|
-
if (width <= 0 || height <= 0) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
const canvasWidth = width + 2 * SHADOW_PADDING;
|
|
82
|
-
const canvasHeight = height + 2 * SHADOW_PADDING;
|
|
83
|
-
const path = getContainerPath(
|
|
84
|
-
width,
|
|
85
|
-
height,
|
|
86
|
-
radius,
|
|
87
|
-
SHADOW_PADDING,
|
|
88
|
-
SHADOW_PADDING,
|
|
89
|
-
notchCenterX,
|
|
90
|
-
);
|
|
91
|
-
const hasKeyShadow = width > 2 * KEY_SPREAD && height > 2 * KEY_SPREAD;
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<Svg
|
|
95
|
-
pointerEvents={'none'}
|
|
96
|
-
width={canvasWidth}
|
|
97
|
-
height={canvasHeight}
|
|
98
|
-
style={styles.canvas}
|
|
99
|
-
>
|
|
100
|
-
<Defs>
|
|
101
|
-
<Filter
|
|
102
|
-
id={'ambientShadow'}
|
|
103
|
-
filterUnits={'userSpaceOnUse'}
|
|
104
|
-
x={0}
|
|
105
|
-
y={0}
|
|
106
|
-
width={canvasWidth}
|
|
107
|
-
height={canvasHeight}
|
|
108
|
-
>
|
|
109
|
-
<FeGaussianBlur in={'SourceAlpha'} stdDeviation={AMBIENT_BLUR} />
|
|
110
|
-
</Filter>
|
|
111
|
-
<Filter
|
|
112
|
-
id={'keyShadow'}
|
|
113
|
-
filterUnits={'userSpaceOnUse'}
|
|
114
|
-
x={0}
|
|
115
|
-
y={0}
|
|
116
|
-
width={canvasWidth}
|
|
117
|
-
height={canvasHeight}
|
|
118
|
-
>
|
|
119
|
-
<FeGaussianBlur in={'SourceAlpha'} stdDeviation={KEY_BLUR} />
|
|
120
|
-
</Filter>
|
|
121
|
-
</Defs>
|
|
122
|
-
<Path
|
|
123
|
-
d={path}
|
|
124
|
-
fill={Colors.black_20}
|
|
125
|
-
fillOpacity={0.12}
|
|
126
|
-
filter={'url(#ambientShadow)'}
|
|
127
|
-
/>
|
|
128
|
-
{hasKeyShadow && (
|
|
129
|
-
<Path
|
|
130
|
-
d={getContainerPath(
|
|
131
|
-
width - 2 * KEY_SPREAD,
|
|
132
|
-
height - 2 * KEY_SPREAD,
|
|
133
|
-
radius - KEY_SPREAD,
|
|
134
|
-
SHADOW_PADDING + KEY_SPREAD,
|
|
135
|
-
SHADOW_PADDING + KEY_SPREAD + KEY_OFFSET_Y,
|
|
136
|
-
)}
|
|
137
|
-
fill={Colors.black_20}
|
|
138
|
-
fillOpacity={0.04}
|
|
139
|
-
filter={'url(#keyShadow)'}
|
|
140
|
-
/>
|
|
141
|
-
)}
|
|
142
|
-
<Path d={path} fill={theme.colors.background.surface} />
|
|
143
|
-
</Svg>
|
|
144
|
-
);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const styles = StyleSheet.create({
|
|
148
|
-
canvas: {
|
|
149
|
-
position: 'absolute',
|
|
150
|
-
left: -SHADOW_PADDING,
|
|
151
|
-
top: -SHADOW_PADDING,
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
export { CurvedContainer };
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import { Pressable, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import Animated from 'react-native-reanimated';
|
|
4
|
-
import { Colors, Radius } from '../../Consts';
|
|
5
|
-
import { ApplicationContext } from '../../Context';
|
|
6
|
-
import { Icon } from '../../Icon';
|
|
7
|
-
import { useScreenLayout } from '../../Layout/utils';
|
|
8
|
-
import { Text } from '../../Text';
|
|
9
|
-
import { FloatingButtonProps } from '../types';
|
|
10
|
-
import { useDuoBarCompression } from './DuoBarCompression';
|
|
11
|
-
import { useCenterActionPress } from './BottomTabBar';
|
|
12
|
-
import { TabItemContent } from './CustomBottomTabItem';
|
|
13
|
-
import { CurvedContainer } from './CurvedContainer';
|
|
14
|
-
import { TabBarMetrics } from './metrics';
|
|
15
|
-
import { getTabItems, TabItem } from './tabItems';
|
|
16
|
-
import { usePressLift } from './usePressLift';
|
|
17
|
-
import { ActiveIndicator } from './ActiveIndicator';
|
|
18
|
-
import {
|
|
19
|
-
RAIL_COMPACT_SIZE,
|
|
20
|
-
RAIL_ITEM_HEIGHT,
|
|
21
|
-
styles,
|
|
22
|
-
} from './DuoTabBar.styles';
|
|
23
|
-
import type { DuoTabBarProps } from './DuoTabBar';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Center action icon: an icon name drawn at the CTA size, or a custom node.
|
|
27
|
-
*/
|
|
28
|
-
const CtaIcon: React.FC<{ icon: FloatingButtonProps['icon'] }> = ({ icon }) => {
|
|
29
|
-
if (typeof icon === 'string') {
|
|
30
|
-
return (
|
|
31
|
-
<Icon
|
|
32
|
-
source={icon}
|
|
33
|
-
size={TabBarMetrics.ctaIconSize}
|
|
34
|
-
color={Colors.black_01}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
return <>{icon}</>;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Vertical container (.Nav/Duo/Item column) with the sliding active indicator.
|
|
43
|
-
*/
|
|
44
|
-
const Rail: React.FC<{
|
|
45
|
-
items: TabItem[];
|
|
46
|
-
index: number;
|
|
47
|
-
activeTintColor: string;
|
|
48
|
-
inactiveTintColor: string;
|
|
49
|
-
onItemPress?: () => void;
|
|
50
|
-
}> = ({ items, index, activeTintColor, inactiveTintColor, onItemPress }) => (
|
|
51
|
-
<View style={styles.rail} accessibilityLabel={'bottom_tab_bar'}>
|
|
52
|
-
<CurvedContainer
|
|
53
|
-
width={TabBarMetrics.railContainerWidth}
|
|
54
|
-
height={items.length * RAIL_ITEM_HEIGHT + TabBarMetrics.railPaddingBottom}
|
|
55
|
-
radius={Radius.XL}
|
|
56
|
-
/>
|
|
57
|
-
<ActiveIndicator
|
|
58
|
-
axis={'y'}
|
|
59
|
-
offset={index * RAIL_ITEM_HEIGHT}
|
|
60
|
-
radius={TabBarMetrics.railIndicatorRadius}
|
|
61
|
-
style={styles.railIndicator}
|
|
62
|
-
/>
|
|
63
|
-
{items.map(item => (
|
|
64
|
-
<TouchableOpacity
|
|
65
|
-
key={item.route.key}
|
|
66
|
-
accessibilityRole={'tab'}
|
|
67
|
-
accessibilityLabel={item.label}
|
|
68
|
-
accessibilityState={{ selected: item.focused }}
|
|
69
|
-
onPress={() => {
|
|
70
|
-
item.onPress();
|
|
71
|
-
onItemPress?.();
|
|
72
|
-
}}
|
|
73
|
-
onLongPress={item.onLongPress}
|
|
74
|
-
style={styles.railItem}
|
|
75
|
-
>
|
|
76
|
-
<TabItemContent
|
|
77
|
-
vertical
|
|
78
|
-
label={item.label}
|
|
79
|
-
focused={item.focused}
|
|
80
|
-
icon={item.icon}
|
|
81
|
-
badge={item.badge}
|
|
82
|
-
activeTintColor={activeTintColor}
|
|
83
|
-
inactiveTintColor={inactiveTintColor}
|
|
84
|
-
/>
|
|
85
|
-
</TouchableOpacity>
|
|
86
|
-
))}
|
|
87
|
-
</View>
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Center action of the rail: a round button with its label, under the container.
|
|
92
|
-
*/
|
|
93
|
-
const RailCenterAction: React.FC<{ floatingButton: FloatingButtonProps }> = ({
|
|
94
|
-
floatingButton,
|
|
95
|
-
}) => {
|
|
96
|
-
const { theme } = useContext(ApplicationContext);
|
|
97
|
-
const { buttonStyle, onPressIn, onPressOut } = useCenterActionPress();
|
|
98
|
-
return (
|
|
99
|
-
<Pressable
|
|
100
|
-
accessibilityRole={'button'}
|
|
101
|
-
accessibilityLabel={floatingButton.label}
|
|
102
|
-
onPress={floatingButton.onPress}
|
|
103
|
-
onPressIn={onPressIn}
|
|
104
|
-
onPressOut={onPressOut}
|
|
105
|
-
style={styles.railCta}
|
|
106
|
-
>
|
|
107
|
-
<Animated.View
|
|
108
|
-
style={[
|
|
109
|
-
styles.railCtaButton,
|
|
110
|
-
{ backgroundColor: theme.colors.primary },
|
|
111
|
-
buttonStyle,
|
|
112
|
-
]}
|
|
113
|
-
>
|
|
114
|
-
<CtaIcon icon={floatingButton.icon} />
|
|
115
|
-
</Animated.View>
|
|
116
|
-
<View style={styles.railCtaLabel}>
|
|
117
|
-
<Text
|
|
118
|
-
numberOfLines={1}
|
|
119
|
-
typography={'label_xs_medium'}
|
|
120
|
-
color={theme.colors.text.secondary}
|
|
121
|
-
>
|
|
122
|
-
{floatingButton.label}
|
|
123
|
-
</Text>
|
|
124
|
-
{floatingButton.labelContent && (
|
|
125
|
-
<View pointerEvents={'none'} style={styles.railCtaLabelOverlay}>
|
|
126
|
-
{floatingButton.labelContent}
|
|
127
|
-
</View>
|
|
128
|
-
)}
|
|
129
|
-
</View>
|
|
130
|
-
</Pressable>
|
|
131
|
-
);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Vertical bar anchored to the bottom of the Duo side bar, center action below it. When the
|
|
136
|
-
* side bar is short it can shrink to one button showing the current tab (HIG "Tab bar
|
|
137
|
-
* compressed"); tapping it expands the rail and compresses the toolbar.
|
|
138
|
-
*/
|
|
139
|
-
const DuoRailTabBar: React.FC<DuoTabBarProps> = props => {
|
|
140
|
-
const { sideBar } = useScreenLayout();
|
|
141
|
-
const compression = useDuoBarCompression();
|
|
142
|
-
const { tabBarCompressed, expandTabBar, onTabSelected } = compression;
|
|
143
|
-
const compactLift = usePressLift();
|
|
144
|
-
const { state, floatingButton, activeTintColor, inactiveTintColor } = props;
|
|
145
|
-
const items = getTabItems(props);
|
|
146
|
-
const current = items[state.index];
|
|
147
|
-
|
|
148
|
-
if (!sideBar) {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Lines up with the side bar header buttons: a 48 lane kept 12 from the inner edge.
|
|
153
|
-
const columnStyle = [
|
|
154
|
-
styles.railColumn,
|
|
155
|
-
{
|
|
156
|
-
[sideBar.edge]: 0,
|
|
157
|
-
width: sideBar.width,
|
|
158
|
-
bottom: sideBar.bottom,
|
|
159
|
-
},
|
|
160
|
-
sideBar.edge === 'right' ? styles.railColumnRight : styles.railColumnLeft,
|
|
161
|
-
];
|
|
162
|
-
let cta: React.ReactNode;
|
|
163
|
-
if (floatingButton) {
|
|
164
|
-
cta = <RailCenterAction floatingButton={floatingButton} />;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (!tabBarCompressed) {
|
|
168
|
-
return (
|
|
169
|
-
<View pointerEvents={'box-none'} style={columnStyle}>
|
|
170
|
-
<View pointerEvents={'box-none'} style={styles.railLane}>
|
|
171
|
-
<Rail
|
|
172
|
-
items={items}
|
|
173
|
-
index={state.index}
|
|
174
|
-
activeTintColor={activeTintColor}
|
|
175
|
-
inactiveTintColor={inactiveTintColor}
|
|
176
|
-
onItemPress={onTabSelected}
|
|
177
|
-
/>
|
|
178
|
-
{cta}
|
|
179
|
-
</View>
|
|
180
|
-
</View>
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<View pointerEvents={'box-none'} style={columnStyle}>
|
|
186
|
-
<View pointerEvents={'box-none'} style={styles.railLane}>
|
|
187
|
-
<Animated.View style={compactLift.style}>
|
|
188
|
-
<TouchableOpacity
|
|
189
|
-
accessibilityRole={'button'}
|
|
190
|
-
accessibilityLabel={current?.label}
|
|
191
|
-
accessibilityHint={'bottom_tab_bar'}
|
|
192
|
-
activeOpacity={1}
|
|
193
|
-
onPressIn={compactLift.onPressIn}
|
|
194
|
-
onPressOut={compactLift.onPressOut}
|
|
195
|
-
onPress={expandTabBar}
|
|
196
|
-
style={styles.railCompact}
|
|
197
|
-
>
|
|
198
|
-
<CurvedContainer
|
|
199
|
-
width={RAIL_COMPACT_SIZE}
|
|
200
|
-
height={RAIL_COMPACT_SIZE}
|
|
201
|
-
radius={RAIL_COMPACT_SIZE / 2}
|
|
202
|
-
/>
|
|
203
|
-
{current && (
|
|
204
|
-
<TabItemContent
|
|
205
|
-
vertical
|
|
206
|
-
hideLabel
|
|
207
|
-
focused
|
|
208
|
-
label={current.label}
|
|
209
|
-
icon={current.icon}
|
|
210
|
-
badge={current.badge}
|
|
211
|
-
activeTintColor={activeTintColor}
|
|
212
|
-
inactiveTintColor={inactiveTintColor}
|
|
213
|
-
/>
|
|
214
|
-
)}
|
|
215
|
-
</TouchableOpacity>
|
|
216
|
-
</Animated.View>
|
|
217
|
-
{cta}
|
|
218
|
-
</View>
|
|
219
|
-
</View>
|
|
220
|
-
);
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
export { DuoRailTabBar };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Spacing } from '../../Consts';
|
|
3
|
-
import { DuoMetrics } from '../../Layout/utils';
|
|
4
|
-
import { CTA_SHADOW, TabBarMetrics } from './metrics';
|
|
5
|
-
|
|
6
|
-
export const RAIL_ITEM_WIDTH = TabBarMetrics.railItemWidth;
|
|
7
|
-
export const RAIL_ITEM_HEIGHT = TabBarMetrics.railItemHeight;
|
|
8
|
-
export const RAIL_COMPACT_SIZE = DuoMetrics.controlSize;
|
|
9
|
-
|
|
10
|
-
export const styles = StyleSheet.create({
|
|
11
|
-
railColumn: {
|
|
12
|
-
position: 'absolute',
|
|
13
|
-
},
|
|
14
|
-
railColumnRight: {
|
|
15
|
-
alignItems: 'flex-start',
|
|
16
|
-
paddingLeft: Spacing.M,
|
|
17
|
-
},
|
|
18
|
-
railColumnLeft: {
|
|
19
|
-
alignItems: 'flex-end',
|
|
20
|
-
paddingRight: Spacing.M,
|
|
21
|
-
},
|
|
22
|
-
// as wide as the header buttons; the wider rail and center action overflow it evenly
|
|
23
|
-
railLane: {
|
|
24
|
-
width: DuoMetrics.controlSize,
|
|
25
|
-
alignItems: 'center',
|
|
26
|
-
gap: TabBarMetrics.railCtaGap,
|
|
27
|
-
},
|
|
28
|
-
railCompact: {
|
|
29
|
-
width: RAIL_COMPACT_SIZE,
|
|
30
|
-
height: RAIL_COMPACT_SIZE,
|
|
31
|
-
alignItems: 'center',
|
|
32
|
-
justifyContent: 'center',
|
|
33
|
-
},
|
|
34
|
-
rail: {
|
|
35
|
-
width: TabBarMetrics.railContainerWidth,
|
|
36
|
-
paddingHorizontal: TabBarMetrics.railPaddingHorizontal,
|
|
37
|
-
paddingBottom: TabBarMetrics.railPaddingBottom,
|
|
38
|
-
},
|
|
39
|
-
railIndicator: {
|
|
40
|
-
top: Spacing.XS,
|
|
41
|
-
left: TabBarMetrics.railPaddingHorizontal,
|
|
42
|
-
width: RAIL_ITEM_WIDTH,
|
|
43
|
-
height: TabBarMetrics.railIndicatorHeight,
|
|
44
|
-
},
|
|
45
|
-
railItem: {
|
|
46
|
-
width: RAIL_ITEM_WIDTH,
|
|
47
|
-
height: RAIL_ITEM_HEIGHT,
|
|
48
|
-
alignItems: 'center',
|
|
49
|
-
justifyContent: 'center',
|
|
50
|
-
},
|
|
51
|
-
railCta: {
|
|
52
|
-
width: TabBarMetrics.railCtaWidth,
|
|
53
|
-
height: TabBarMetrics.railCtaHeight,
|
|
54
|
-
alignItems: 'center',
|
|
55
|
-
justifyContent: 'center',
|
|
56
|
-
gap: TabBarMetrics.railCtaLabelGap,
|
|
57
|
-
},
|
|
58
|
-
// custom label content over the label text, centered and unclipped
|
|
59
|
-
railCtaLabelOverlay: {
|
|
60
|
-
...StyleSheet.absoluteFillObject,
|
|
61
|
-
alignItems: 'center',
|
|
62
|
-
justifyContent: 'center',
|
|
63
|
-
},
|
|
64
|
-
railCtaLabel: {
|
|
65
|
-
paddingHorizontal: Spacing.XS,
|
|
66
|
-
},
|
|
67
|
-
railCtaButton: {
|
|
68
|
-
boxShadow: CTA_SHADOW,
|
|
69
|
-
width: TabBarMetrics.railCtaSize,
|
|
70
|
-
height: TabBarMetrics.railCtaSize,
|
|
71
|
-
borderRadius: TabBarMetrics.railCtaSize / 2,
|
|
72
|
-
alignItems: 'center',
|
|
73
|
-
justifyContent: 'center',
|
|
74
|
-
},
|
|
75
|
-
floating: {
|
|
76
|
-
position: 'absolute',
|
|
77
|
-
left: 0,
|
|
78
|
-
right: 0,
|
|
79
|
-
alignItems: 'center',
|
|
80
|
-
},
|
|
81
|
-
});
|