@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,138 +1,136 @@
|
|
|
1
|
-
import React, { useContext
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { TouchableOpacity, StyleSheet } from 'react-native';
|
|
2
3
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from 'react-native';
|
|
8
|
-
import Animated, {
|
|
9
|
-
useAnimatedStyle,
|
|
10
|
-
useSharedValue,
|
|
11
|
-
withTiming,
|
|
12
|
-
} from 'react-native-reanimated';
|
|
4
|
+
BottomTabBarButtonProps,
|
|
5
|
+
BottomTabNavigationOptions,
|
|
6
|
+
} from '@react-navigation/bottom-tabs';
|
|
7
|
+
import { Route } from '@react-navigation/native';
|
|
13
8
|
import { TabBarIcon } from './TabBarIcon';
|
|
14
9
|
import { Text } from '../../Text';
|
|
15
10
|
import { MiniAppContext } from '../../Context';
|
|
16
|
-
import { Colors
|
|
17
|
-
import { TabBarMetrics, TabBarMotion } from './metrics';
|
|
11
|
+
import { Colors } from '../../Consts';
|
|
18
12
|
|
|
19
|
-
type
|
|
20
|
-
focused: boolean;
|
|
21
|
-
color: string;
|
|
22
|
-
size: number;
|
|
23
|
-
}) => React.ReactNode;
|
|
13
|
+
type LabelType = NonNullable<BottomTabNavigationOptions['tabBarLabel']>;
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
interface CustomBottomTabItemProps {
|
|
16
|
+
route: Route<string>;
|
|
27
17
|
focused: boolean;
|
|
18
|
+
label: LabelType;
|
|
19
|
+
onPress: () => void;
|
|
20
|
+
onLongPress: () => void;
|
|
28
21
|
activeTintColor: string;
|
|
29
22
|
inactiveTintColor: string;
|
|
30
|
-
|
|
23
|
+
activeBackgroundColor?: string;
|
|
24
|
+
inactiveBackgroundColor?: string;
|
|
25
|
+
icon: any;
|
|
31
26
|
badge?: string | number;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
}
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* scaled label grows down. The bar slides one shared active indicator behind the icon slots.
|
|
40
|
-
*/
|
|
41
|
-
const TabItemContent: React.FC<TabItemContentProps> = ({
|
|
42
|
-
label,
|
|
44
|
+
const CustomBottomTabItem: React.FC<CustomBottomTabItemProps> = ({
|
|
45
|
+
route,
|
|
43
46
|
focused,
|
|
47
|
+
label,
|
|
48
|
+
onPress,
|
|
49
|
+
onLongPress,
|
|
44
50
|
activeTintColor,
|
|
45
51
|
inactiveTintColor,
|
|
52
|
+
activeBackgroundColor,
|
|
53
|
+
inactiveBackgroundColor,
|
|
46
54
|
icon,
|
|
47
55
|
badge,
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
showLabel,
|
|
57
|
+
labelStyle,
|
|
58
|
+
iconStyle,
|
|
59
|
+
style,
|
|
60
|
+
badgeStyle,
|
|
61
|
+
allowFontScaling,
|
|
50
62
|
}) => {
|
|
51
|
-
const
|
|
63
|
+
const context = useContext<any>(MiniAppContext);
|
|
64
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
const renderIcon = () => {
|
|
67
|
+
if (icon === undefined) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
56
70
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}));
|
|
71
|
+
const activeOpacity = focused ? 1 : 0;
|
|
72
|
+
const inactiveOpacity = focused ? 0 : 1;
|
|
60
73
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
};
|
|
71
89
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<Animated.View
|
|
77
|
-
pointerEvents={'none'}
|
|
78
|
-
style={[StyleSheet.absoluteFill, activeLabelStyle]}
|
|
79
|
-
>
|
|
80
|
-
{renderText(activeTintColor)}
|
|
81
|
-
</Animated.View>
|
|
82
|
-
</View>
|
|
83
|
-
);
|
|
90
|
+
const renderLabel = ({ focused }: { focused: boolean }) => {
|
|
91
|
+
if (showLabel === false) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
84
94
|
|
|
85
|
-
|
|
86
|
-
<>
|
|
87
|
-
<View style={vertical ? styles.railSlot : styles.slot}>
|
|
88
|
-
<TabBarIcon
|
|
89
|
-
focused={focused}
|
|
90
|
-
badge={badge}
|
|
91
|
-
vertical={vertical}
|
|
92
|
-
activeTintColor={activeTintColor}
|
|
93
|
-
inactiveTintColor={inactiveTintColor}
|
|
94
|
-
renderIcon={icon}
|
|
95
|
-
/>
|
|
96
|
-
</View>
|
|
97
|
-
{!hideLabel && labelNode}
|
|
98
|
-
</>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
95
|
+
const color = focused ? activeTintColor : inactiveTintColor;
|
|
101
96
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
97
|
+
if (typeof label === 'string') {
|
|
98
|
+
return (
|
|
99
|
+
<Text
|
|
100
|
+
numberOfLines={1}
|
|
101
|
+
style={[styles.label, labelStyle]}
|
|
102
|
+
color={focused ? activeTintColor : inactiveTintColor}
|
|
103
|
+
typography={focused ? 'label_xs_medium' : 'description_xs_regular'}
|
|
104
|
+
allowFontScaling={allowFontScaling}
|
|
105
|
+
>
|
|
106
|
+
{label}
|
|
107
|
+
</Text>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
...content
|
|
120
|
-
}) => {
|
|
121
|
-
const context = useContext<any>(MiniAppContext);
|
|
122
|
-
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
111
|
+
return label({
|
|
112
|
+
focused,
|
|
113
|
+
color,
|
|
114
|
+
children: route.name,
|
|
115
|
+
position: 'below-icon',
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const background = focused ? activeBackgroundColor : inactiveBackgroundColor;
|
|
123
120
|
|
|
124
121
|
return (
|
|
125
122
|
<TouchableOpacity
|
|
126
|
-
accessibilityRole={'tab'}
|
|
127
|
-
accessibilityLabel={accessibilityLabel ?? content.label}
|
|
128
|
-
accessibilityState={{ selected: content.focused }}
|
|
129
|
-
testID={testID}
|
|
130
123
|
onPress={onPress}
|
|
131
124
|
onLongPress={onLongPress}
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
style={[
|
|
126
|
+
styles.container,
|
|
127
|
+
{ backgroundColor: background },
|
|
128
|
+
style,
|
|
129
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
130
|
+
]}
|
|
134
131
|
>
|
|
135
|
-
|
|
132
|
+
{renderIcon()}
|
|
133
|
+
{renderLabel({ focused })}
|
|
136
134
|
</TouchableOpacity>
|
|
137
135
|
);
|
|
138
136
|
};
|
|
@@ -140,38 +138,16 @@ const CustomBottomTabItem: React.FC<CustomBottomTabItemProps> = ({
|
|
|
140
138
|
const styles = StyleSheet.create({
|
|
141
139
|
container: {
|
|
142
140
|
flex: 1,
|
|
143
|
-
minWidth: 1,
|
|
144
141
|
alignItems: 'center',
|
|
145
142
|
justifyContent: 'center',
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
slot: {
|
|
149
|
-
height: TabBarMetrics.indicatorHeight,
|
|
150
|
-
alignSelf: 'stretch',
|
|
151
|
-
alignItems: 'center',
|
|
152
|
-
justifyContent: 'center',
|
|
153
|
-
paddingVertical: TabBarMetrics.indicatorPaddingVertical,
|
|
154
|
-
paddingHorizontal: TabBarMetrics.indicatorPaddingHorizontal,
|
|
155
|
-
},
|
|
156
|
-
railSlot: {
|
|
157
|
-
height: TabBarMetrics.railIndicatorHeight,
|
|
158
|
-
alignItems: 'center',
|
|
159
|
-
justifyContent: 'center',
|
|
160
|
-
paddingVertical: TabBarMetrics.railIndicatorPaddingVertical,
|
|
161
|
-
paddingHorizontal: TabBarMetrics.indicatorPaddingHorizontal,
|
|
162
|
-
},
|
|
163
|
-
labelSlot: {
|
|
164
|
-
height: TabBarMetrics.labelHeight,
|
|
165
|
-
alignSelf: 'stretch',
|
|
166
|
-
},
|
|
167
|
-
railLabelSlot: {
|
|
168
|
-
height: TabBarMetrics.railLabelHeight,
|
|
143
|
+
paddingVertical: 8,
|
|
144
|
+
bottom: -2,
|
|
169
145
|
},
|
|
170
146
|
label: {
|
|
171
|
-
|
|
147
|
+
fontSize: 12,
|
|
148
|
+
fontWeight: '600',
|
|
172
149
|
},
|
|
173
150
|
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
174
151
|
});
|
|
175
152
|
|
|
176
|
-
export { TabItemContent };
|
|
177
153
|
export default CustomBottomTabItem;
|
|
@@ -8,7 +8,6 @@ import React, {
|
|
|
8
8
|
import { Spacing } from '../../Consts';
|
|
9
9
|
import { useScreenLayout } from '../../Layout';
|
|
10
10
|
import { DuoMetrics } from '../../Layout/utils';
|
|
11
|
-
import { getRailHeight, TabBarMetrics } from './metrics';
|
|
12
11
|
|
|
13
12
|
export type DuoBarCompressionBehavior = 'toolbar' | 'tabBar';
|
|
14
13
|
|
|
@@ -26,11 +25,13 @@ type DuoBarCompression = {
|
|
|
26
25
|
setToolbarHeight?: (height: number) => void;
|
|
27
26
|
};
|
|
28
27
|
|
|
28
|
+
const RAIL_PADDING = 6;
|
|
29
|
+
const RAIL_GAP = Spacing.XXS;
|
|
29
30
|
// space kept between the top and the bottom groups (HIG Vertical controls)
|
|
30
31
|
const GROUP_GAP = Spacing.M;
|
|
31
|
-
const BACK_SLOT_HEIGHT = DuoMetrics.controlSize + Spacing.M;
|
|
32
32
|
// Back, then the right toolkit: help + home capsule
|
|
33
|
-
const DEFAULT_TOOLBAR_HEIGHT =
|
|
33
|
+
const DEFAULT_TOOLBAR_HEIGHT =
|
|
34
|
+
DuoMetrics.controlSize + Spacing.M + 2 * DuoMetrics.itemPitch;
|
|
34
35
|
// Back, then the single button the toolbar folds into
|
|
35
36
|
const COMPRESSED_TOOLBAR_HEIGHT = 2 * DuoMetrics.controlSize + Spacing.M;
|
|
36
37
|
|
|
@@ -39,12 +40,25 @@ const NO_COMPRESSION: DuoBarCompression = {
|
|
|
39
40
|
tabBarCompressed: false,
|
|
40
41
|
};
|
|
41
42
|
|
|
42
|
-
const DuoBarCompressionContext =
|
|
43
|
+
const DuoBarCompressionContext =
|
|
44
|
+
createContext<DuoBarCompression>(NO_COMPRESSION);
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
|
-
*
|
|
46
|
-
|
|
47
|
-
|
|
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)
|
|
48
62
|
*/
|
|
49
63
|
const DuoBarCompressionProvider: React.FC<{
|
|
50
64
|
behavior?: DuoBarCompressionBehavior;
|
|
@@ -67,16 +81,16 @@ const DuoBarCompressionProvider: React.FC<{
|
|
|
67
81
|
}
|
|
68
82
|
const room = height - sideBar.bottom - sideBar.top - GROUP_GAP;
|
|
69
83
|
const tabBar = getRailHeight(tabCount, hasQr);
|
|
70
|
-
const
|
|
71
|
-
const compressedTabBar = DuoMetrics.controlSize + (hasQr ? qrHeight : 0);
|
|
84
|
+
const compressedTabBar = getRailHeight(1, hasQr) - 2 * RAIL_PADDING;
|
|
72
85
|
const fits = (toolbar: number, tabs: number) => toolbar + tabs <= room;
|
|
73
86
|
|
|
74
87
|
if (fits(toolbarHeight, tabBar)) {
|
|
75
88
|
return { ...NO_COMPRESSION, setToolbarHeight };
|
|
76
89
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
const canSwap =
|
|
91
|
+
fits(COMPRESSED_TOOLBAR_HEIGHT, tabBar) &&
|
|
92
|
+
fits(toolbarHeight, compressedTabBar);
|
|
93
|
+
if (canSwap) {
|
|
80
94
|
return {
|
|
81
95
|
toolbarCompressed: expanded === 'tabBar',
|
|
82
96
|
tabBarCompressed: expanded === 'toolbar',
|
|
@@ -91,7 +105,8 @@ const DuoBarCompressionProvider: React.FC<{
|
|
|
91
105
|
expandTabBar: () => setOpened('tabBar'),
|
|
92
106
|
setToolbarHeight,
|
|
93
107
|
};
|
|
94
|
-
//
|
|
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
|
|
95
110
|
if (opened === 'tabBar') {
|
|
96
111
|
return {
|
|
97
112
|
...open,
|
|
@@ -115,7 +130,6 @@ const DuoBarCompressionProvider: React.FC<{
|
|
|
115
130
|
);
|
|
116
131
|
};
|
|
117
132
|
|
|
118
|
-
/** Compression state of the Duo side bars; no compression outside the provider. */
|
|
119
133
|
const useDuoBarCompression = () => useContext(DuoBarCompressionContext);
|
|
120
134
|
|
|
121
135
|
export { DuoBarCompressionProvider, useDuoBarCompression };
|