@momo-kits/foundation 0.169.19-beta.3 → 0.169.19-beta.4
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/Components/HeaderExtendHeader.tsx +6 -2
- package/Application/Components/HeaderLeft.tsx +9 -5
- package/Application/Components/HeaderRight.styles.ts +5 -1
- package/Application/Components/HeaderRight.tsx +7 -21
- package/Application/Components/SearchHeader.tsx +5 -3
- package/Application/Components/useHeaderRightWidth.ts +2 -2
- package/Application/__tests__/headerLayout.test.ts +2 -1
- package/Application/headerLayout.ts +10 -13
- package/Application/navigationOptions.tsx +5 -12
- package/Layout/FloatingButton.tsx +19 -7
- package/Layout/screenHeader.tsx +16 -20
- package/package.json +1 -1
|
@@ -17,6 +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 { getHeaderMargin } from '../../Layout/utils';
|
|
20
21
|
import {
|
|
21
22
|
HeaderBarMetrics,
|
|
22
23
|
type HeaderContentLayout,
|
|
@@ -70,8 +71,11 @@ const HeaderExtendHeader: React.FC<{
|
|
|
70
71
|
const layout = useScreenLayout();
|
|
71
72
|
const headerLayout = useHeaderLayout(contentLayout);
|
|
72
73
|
// collapsed into the bar, the search follows back and the right cluster into the
|
|
73
|
-
// frame
|
|
74
|
-
|
|
74
|
+
// frame, or the side margin React Navigation adds on large iOS windows (the larger)
|
|
75
|
+
let frameShift = headerLayout.frameInset - sidePadding;
|
|
76
|
+
if (!layout.sideBar) {
|
|
77
|
+
frameShift = Math.max(frameShift, getHeaderMargin(layout.width));
|
|
78
|
+
}
|
|
75
79
|
|
|
76
80
|
const backLeft = buttonSize + sidePadding + titleGap;
|
|
77
81
|
const defaultLeft = layout.sideBar ? SCREEN_PADDING : backLeft;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackHandler,
|
|
1
|
+
import { BackHandler, StyleSheet, View } from 'react-native';
|
|
2
2
|
import type { HeaderBackProps } from '../types';
|
|
3
3
|
import React, { useCallback, useContext, useEffect } from 'react';
|
|
4
4
|
import { ApplicationContext, MiniAppContext } from '../../Context';
|
|
@@ -8,12 +8,11 @@ import { SideBarButton } from './SideBarButton';
|
|
|
8
8
|
import Animated from 'react-native-reanimated';
|
|
9
9
|
import { useSideBarItemStyle } from '../../Layout/utils';
|
|
10
10
|
import { useSideBarCounterStyle } from './DuoQuickReturnHeader';
|
|
11
|
-
import {
|
|
11
|
+
import { HeaderBarMetrics } from '../headerLayout';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Header back button, also bound to the Android hardware back. `preventBack`
|
|
15
15
|
* confirms in a popup first; the iPhone Duo side bar uses the 48pt side bar button.
|
|
16
|
-
* In the bar it sits `sidePadding` from the window edge on every iPhone width.
|
|
17
16
|
*/
|
|
18
17
|
const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
19
18
|
tintColor,
|
|
@@ -26,7 +25,6 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
26
25
|
const { navigator } = useContext(ApplicationContext);
|
|
27
26
|
const sideBarStyle = useSideBarItemStyle('left', 0);
|
|
28
27
|
const counterStyle = useSideBarCounterStyle();
|
|
29
|
-
const { width } = useWindowDimensions();
|
|
30
28
|
|
|
31
29
|
const goBack = useCallback(() => {
|
|
32
30
|
const canGoBack = navigator?.ref?.current?.canGoBack?.();
|
|
@@ -100,7 +98,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
return (
|
|
103
|
-
<View style={
|
|
101
|
+
<View style={styles.headerLeft}>
|
|
104
102
|
<NavigationButton
|
|
105
103
|
accessibilityLabel="btn_navigation_back"
|
|
106
104
|
icon="arrow-back"
|
|
@@ -111,4 +109,10 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
111
109
|
);
|
|
112
110
|
};
|
|
113
111
|
|
|
112
|
+
const styles = StyleSheet.create({
|
|
113
|
+
headerLeft: {
|
|
114
|
+
marginLeft: HeaderBarMetrics.sidePadding,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
114
118
|
export { HeaderLeft };
|
|
@@ -2,7 +2,7 @@ import { Platform, StyleSheet } from 'react-native';
|
|
|
2
2
|
import { Colors, Spacing } from '../../Consts';
|
|
3
3
|
import { HeaderBarMetrics } from '../headerLayout';
|
|
4
4
|
|
|
5
|
-
const { buttonSize, pillWidth, pillHeight } = HeaderBarMetrics;
|
|
5
|
+
const { buttonSize, pillWidth, pillHeight, sidePadding } = HeaderBarMetrics;
|
|
6
6
|
|
|
7
7
|
export const styles = StyleSheet.create({
|
|
8
8
|
navigationButton: {
|
|
@@ -48,6 +48,7 @@ export const styles = StyleSheet.create({
|
|
|
48
48
|
flexDirection: 'row',
|
|
49
49
|
justifyContent: 'center',
|
|
50
50
|
alignItems: 'center',
|
|
51
|
+
paddingRight: sidePadding,
|
|
51
52
|
},
|
|
52
53
|
toolkitContainer: {
|
|
53
54
|
height: pillHeight,
|
|
@@ -133,6 +134,9 @@ export const styles = StyleSheet.create({
|
|
|
133
134
|
},
|
|
134
135
|
}),
|
|
135
136
|
},
|
|
137
|
+
onBoarding: {
|
|
138
|
+
marginRight: Spacing.M,
|
|
139
|
+
},
|
|
136
140
|
toolkitWide: {
|
|
137
141
|
width: pillWidth,
|
|
138
142
|
},
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
type LayoutChangeEvent,
|
|
4
|
-
TouchableOpacity,
|
|
5
|
-
useWindowDimensions,
|
|
6
|
-
View,
|
|
7
|
-
} from 'react-native';
|
|
2
|
+
import { type LayoutChangeEvent, TouchableOpacity, View } from 'react-native';
|
|
8
3
|
import { NavigationRouteContext } from '@react-navigation/native';
|
|
9
4
|
import { ApplicationContext } from '../../Context';
|
|
10
5
|
import { Text } from '../../Text';
|
|
11
6
|
import Animated from 'react-native-reanimated';
|
|
12
|
-
import {
|
|
13
|
-
import { getHeaderRowInset } from '../headerLayout';
|
|
7
|
+
import { useSideBarItemStyle } from '../../Layout/utils';
|
|
14
8
|
import { useSideBarCounterStyle } from './DuoQuickReturnHeader';
|
|
15
9
|
import { HeaderToolkitAction } from './HeaderToolkitAction';
|
|
16
10
|
import { styles } from './HeaderRight.styles';
|
|
@@ -19,8 +13,7 @@ import { setHeaderRightWidth } from './useHeaderRightWidth';
|
|
|
19
13
|
/**
|
|
20
14
|
* Header right slot: a custom `headerRight` render function, the onboarding skip
|
|
21
15
|
* button, or the toolkit (stacked vertically in the floating iPhone Duo side bar).
|
|
22
|
-
* The bar toolkit
|
|
23
|
-
* from that edge so header searches stop short of it.
|
|
16
|
+
* The bar toolkit reports its width so header searches stop short of it.
|
|
24
17
|
*/
|
|
25
18
|
const HeaderRight: React.FC<any> = props => {
|
|
26
19
|
const { translate } = useContext(ApplicationContext);
|
|
@@ -29,18 +22,14 @@ const HeaderRight: React.FC<any> = props => {
|
|
|
29
22
|
const sideBarStyle = useSideBarItemStyle('right', 1);
|
|
30
23
|
const counterStyle = useSideBarCounterStyle();
|
|
31
24
|
const routeKey = useContext(NavigationRouteContext)?.key;
|
|
32
|
-
const { width } = useWindowDimensions();
|
|
33
|
-
const rowMargin = getHeaderMargin(width);
|
|
34
|
-
const rowInset = getHeaderRowInset(width);
|
|
35
25
|
|
|
36
26
|
const handleToolkitLayout = useCallback(
|
|
37
27
|
(event: LayoutChangeEvent) => {
|
|
38
28
|
if (routeKey) {
|
|
39
|
-
|
|
40
|
-
setHeaderRightWidth(routeKey, toolkitWidth);
|
|
29
|
+
setHeaderRightWidth(routeKey, event.nativeEvent.layout.width);
|
|
41
30
|
}
|
|
42
31
|
},
|
|
43
|
-
[routeKey
|
|
32
|
+
[routeKey],
|
|
44
33
|
);
|
|
45
34
|
|
|
46
35
|
useEffect(() => {
|
|
@@ -57,7 +46,7 @@ const HeaderRight: React.FC<any> = props => {
|
|
|
57
46
|
|
|
58
47
|
if (useOnBoarding && onPress) {
|
|
59
48
|
return (
|
|
60
|
-
<TouchableOpacity onPress={onPress} style={
|
|
49
|
+
<TouchableOpacity onPress={onPress} style={styles.onBoarding}>
|
|
61
50
|
<Text typography={'action_s_bold'}>
|
|
62
51
|
{buttonOnBoarding || translate?.('skip')}
|
|
63
52
|
</Text>
|
|
@@ -81,10 +70,7 @@ const HeaderRight: React.FC<any> = props => {
|
|
|
81
70
|
}
|
|
82
71
|
|
|
83
72
|
return (
|
|
84
|
-
<View
|
|
85
|
-
style={[styles.headerRightButton, { paddingRight: rowInset }]}
|
|
86
|
-
onLayout={handleToolkitLayout}
|
|
87
|
-
>
|
|
73
|
+
<View style={styles.headerRightButton} onLayout={handleToolkitLayout}>
|
|
88
74
|
<HeaderToolkitAction {...props.headerRight} tintColor={props.tintColor} />
|
|
89
75
|
</View>
|
|
90
76
|
);
|
|
@@ -8,6 +8,7 @@ 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 { getHeaderMargin } from '../../Layout/utils';
|
|
11
12
|
import { HeaderBarMetrics } from '../headerLayout';
|
|
12
13
|
import { useHeaderRightWidth } from './useHeaderRightWidth';
|
|
13
14
|
|
|
@@ -46,9 +47,10 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
|
|
|
46
47
|
const headerRightWidth = props?.headerRightWidth ?? defaultRightWidth;
|
|
47
48
|
|
|
48
49
|
// iPhone Duo side bar holds back: the search shares the content width with the buttons only
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
const rowWidth =
|
|
50
|
+
// large iOS windows: React Navigation narrows the header row by a margin each side
|
|
51
|
+
const headerMargin = getHeaderMargin(layout.width);
|
|
52
|
+
const rowWidth =
|
|
53
|
+
layout.width - leftPosition - sidePadding - headerMargin * 2;
|
|
52
54
|
let searchMaxWidth = rowWidth - headerRightWidth;
|
|
53
55
|
if (layout.sideBar) {
|
|
54
56
|
searchMaxWidth = layout.contentWidth - Spacing.M * 2 - headerRightWidth;
|
|
@@ -16,8 +16,8 @@ const subscribe = (listener: () => void) => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Records
|
|
20
|
-
*
|
|
19
|
+
* Records the laid out width of a route's header right, side padding included;
|
|
20
|
+
* `undefined` clears it when the header right unmounts.
|
|
21
21
|
*/
|
|
22
22
|
const setHeaderRightWidth = (routeKey: string, width?: number) => {
|
|
23
23
|
if (widths.get(routeKey) === width) {
|
|
@@ -69,7 +69,7 @@ describe('getHeaderFrameOptions', () => {
|
|
|
69
69
|
isDuo: false,
|
|
70
70
|
contentLayout,
|
|
71
71
|
});
|
|
72
|
-
return { layout, isDuo: false, edgePadding: NO_EDGE };
|
|
72
|
+
return { layout, isDuo: false, headerMargin: 0, edgePadding: NO_EDGE };
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
it('leaves the options alone when contentLayout is unset', () => {
|
|
@@ -103,6 +103,7 @@ describe('getHeaderFrameOptions', () => {
|
|
|
103
103
|
const options = getHeaderFrameOptions({
|
|
104
104
|
layout,
|
|
105
105
|
isDuo: true,
|
|
106
|
+
headerMargin: 0,
|
|
106
107
|
edgePadding: DUO_EDGE,
|
|
107
108
|
contentLayout: 'stretch',
|
|
108
109
|
});
|
|
@@ -85,6 +85,8 @@ type EdgePadding = { left: number; right: number };
|
|
|
85
85
|
type HeaderFrameInput = {
|
|
86
86
|
layout: HeaderLayout;
|
|
87
87
|
isDuo: boolean;
|
|
88
|
+
// side margin @react-navigation/elements already adds to the row
|
|
89
|
+
headerMargin: number;
|
|
88
90
|
// padding of the plain row containers: the iPhone Duo status bar clearance, else 0
|
|
89
91
|
edgePadding: EdgePadding;
|
|
90
92
|
contentLayout?: HeaderContentLayout;
|
|
@@ -121,14 +123,6 @@ const getHeaderLayout = ({
|
|
|
121
123
|
};
|
|
122
124
|
};
|
|
123
125
|
|
|
124
|
-
/**
|
|
125
|
-
* Inset from the React Navigation header row that puts an item `sidePadding` from
|
|
126
|
-
* the window edge: large iOS windows already inset that row by `getHeaderMargin`.
|
|
127
|
-
*/
|
|
128
|
-
const getHeaderRowInset = (width: number) => {
|
|
129
|
-
return HeaderBarMetrics.sidePadding - getHeaderMargin(width);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
126
|
/**
|
|
133
127
|
* Widest a title can be between back and the right cluster of the header row.
|
|
134
128
|
*/
|
|
@@ -195,6 +189,7 @@ const getEdgeFrameOptions = (
|
|
|
195
189
|
const getHeaderFrameOptions = ({
|
|
196
190
|
layout,
|
|
197
191
|
isDuo,
|
|
192
|
+
headerMargin,
|
|
198
193
|
edgePadding,
|
|
199
194
|
contentLayout,
|
|
200
195
|
}: HeaderFrameInput): StackNavigationOptions | undefined => {
|
|
@@ -204,11 +199,12 @@ const getHeaderFrameOptions = ({
|
|
|
204
199
|
if (contentLayout !== 'stretch' || isDuo) {
|
|
205
200
|
return getEdgeFrameOptions(edgePadding);
|
|
206
201
|
}
|
|
207
|
-
//
|
|
202
|
+
// the header content row already sits this far in on large iOS windows
|
|
208
203
|
const shift = layout.frameInset - layout.sidePadding;
|
|
204
|
+
const containerShift = Math.max(0, shift - headerMargin);
|
|
209
205
|
return {
|
|
210
|
-
headerLeftContainerStyle: { paddingLeft:
|
|
211
|
-
headerRightContainerStyle: { paddingRight:
|
|
206
|
+
headerLeftContainerStyle: { paddingLeft: containerShift },
|
|
207
|
+
headerRightContainerStyle: { paddingRight: containerShift },
|
|
212
208
|
headerTitleContainerStyle: {
|
|
213
209
|
...TITLE_CONTAINER_RESET,
|
|
214
210
|
left: layout.titleGap,
|
|
@@ -229,15 +225,17 @@ const useHeaderFrameOptions = (
|
|
|
229
225
|
const rowOptions = getHeaderRowOptions(screenLayout);
|
|
230
226
|
const edgeLeft = rowOptions.headerLeftContainerStyle?.paddingLeft ?? 0;
|
|
231
227
|
const edgeRight = rowOptions.headerRightContainerStyle?.paddingRight ?? 0;
|
|
228
|
+
const headerMargin = getHeaderMargin(screenLayout.width);
|
|
232
229
|
const isDuo = isIPhoneDuo();
|
|
233
230
|
return useMemo(() => {
|
|
234
231
|
return getHeaderFrameOptions({
|
|
235
232
|
layout,
|
|
236
233
|
isDuo,
|
|
234
|
+
headerMargin,
|
|
237
235
|
edgePadding: { left: edgeLeft, right: edgeRight },
|
|
238
236
|
contentLayout,
|
|
239
237
|
});
|
|
240
|
-
}, [contentLayout, isDuo, layout, edgeLeft, edgeRight]);
|
|
238
|
+
}, [contentLayout, isDuo, layout, headerMargin, edgeLeft, edgeRight]);
|
|
241
239
|
};
|
|
242
240
|
|
|
243
241
|
export type { HeaderContentLayout, HeaderLayout };
|
|
@@ -249,7 +247,6 @@ export {
|
|
|
249
247
|
getHeaderFrameOptions,
|
|
250
248
|
getHeaderLayout,
|
|
251
249
|
getSearchHeaderHeight,
|
|
252
|
-
getHeaderRowInset,
|
|
253
250
|
getTitleBudget,
|
|
254
251
|
useHeaderLayout,
|
|
255
252
|
useHeaderFrameOptions,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
3
|
import {
|
|
4
4
|
CardStyleInterpolators,
|
|
5
5
|
type StackCardInterpolatedStyle,
|
|
@@ -13,11 +13,7 @@ import { HeaderBackground } from './Components/HeaderBackground';
|
|
|
13
13
|
import { HeaderLeft } from './Components/HeaderLeft';
|
|
14
14
|
import { HeaderRight } from './Components/HeaderRight';
|
|
15
15
|
import { HeaderTitle, TitleCustom } from './Components/HeaderTitle';
|
|
16
|
-
import {
|
|
17
|
-
getHeaderRowInset,
|
|
18
|
-
HeaderBarMetrics,
|
|
19
|
-
TITLE_CONTAINER_RESET,
|
|
20
|
-
} from './headerLayout';
|
|
16
|
+
import { HeaderBarMetrics, TITLE_CONTAINER_RESET } from './headerLayout';
|
|
21
17
|
import type { HeaderTitleProps, NavigationOptions } from './types';
|
|
22
18
|
|
|
23
19
|
const CARD_SHADOW_OPACITY = 0.3;
|
|
@@ -148,9 +144,8 @@ const exportHeaderTitle = (
|
|
|
148
144
|
};
|
|
149
145
|
|
|
150
146
|
/**
|
|
151
|
-
* React Navigation options from screen params: design system header left,
|
|
152
|
-
*
|
|
153
|
-
* off for screens that own their back flow.
|
|
147
|
+
* React Navigation options from screen params: design system header left,
|
|
148
|
+
* title and right, and swipe back off for screens that own their back flow.
|
|
154
149
|
*/
|
|
155
150
|
const getOptions = (
|
|
156
151
|
params: NavigationOptions,
|
|
@@ -172,11 +167,9 @@ const getOptions = (
|
|
|
172
167
|
};
|
|
173
168
|
if (params.hiddenBack) {
|
|
174
169
|
headerLeft = null;
|
|
175
|
-
// options are static, so the window width is read once when they are built
|
|
176
|
-
const { width } = Dimensions.get('window');
|
|
177
170
|
options.headerTitleContainerStyle = {
|
|
178
171
|
...TITLE_CONTAINER_RESET,
|
|
179
|
-
left:
|
|
172
|
+
left: HeaderBarMetrics.sidePadding,
|
|
180
173
|
};
|
|
181
174
|
}
|
|
182
175
|
options = {
|
|
@@ -64,8 +64,11 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
64
64
|
const labelFontFamily = exportFontFamily('bold');
|
|
65
65
|
const maxWidth = useSharedValue(0);
|
|
66
66
|
const minWidth = size === 'small' ? SMALL_SIZE : LARGE_SIZE;
|
|
67
|
+
const iconSize = size === 'small' ? SMALL_ICON_SIZE : LARGE_ICON_SIZE;
|
|
67
68
|
const opacityAnimated = useSharedValue(0);
|
|
68
69
|
const widthAnimated = useSharedValue<number | null>(null);
|
|
70
|
+
const paddingLeftAnimated = useSharedValue(Spacing.M);
|
|
71
|
+
const collapsedPaddingLeft = useSharedValue(Spacing.M);
|
|
69
72
|
const lastOffset = useSharedValue(0);
|
|
70
73
|
const lastDirection = useSharedValue<string | null>(null);
|
|
71
74
|
const [isLabelShown, setIsLabelShown] = useState(true);
|
|
@@ -89,6 +92,9 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
89
92
|
opacityAnimated.value = withTiming(0, {
|
|
90
93
|
duration: ANIMATION_DURATION,
|
|
91
94
|
});
|
|
95
|
+
paddingLeftAnimated.value = withTiming(collapsedPaddingLeft.value, {
|
|
96
|
+
duration: ANIMATION_DURATION,
|
|
97
|
+
});
|
|
92
98
|
widthAnimated.value = withTiming(
|
|
93
99
|
minWidth,
|
|
94
100
|
{ duration: ANIMATION_DURATION },
|
|
@@ -100,6 +106,9 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
100
106
|
opacityAnimated.value = withTiming(1, {
|
|
101
107
|
duration: ANIMATION_DURATION,
|
|
102
108
|
});
|
|
109
|
+
paddingLeftAnimated.value = withTiming(Spacing.M, {
|
|
110
|
+
duration: ANIMATION_DURATION,
|
|
111
|
+
});
|
|
103
112
|
widthAnimated.value = withTiming(
|
|
104
113
|
maxWidth.value,
|
|
105
114
|
{ duration: ANIMATION_DURATION },
|
|
@@ -116,6 +125,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
116
125
|
|
|
117
126
|
const containerStyle = useAnimatedStyle(() => ({
|
|
118
127
|
width: widthAnimated.value ?? undefined,
|
|
128
|
+
paddingLeft: paddingLeftAnimated.value,
|
|
119
129
|
}));
|
|
120
130
|
|
|
121
131
|
const labelStyle = useAnimatedStyle(() => ({
|
|
@@ -125,8 +135,14 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
125
135
|
const handleLayout = (event: LayoutChangeEvent) => {
|
|
126
136
|
const layout = event.nativeEvent.layout;
|
|
127
137
|
if (widthAnimated.value != null) return;
|
|
128
|
-
|
|
129
|
-
|
|
138
|
+
// layout is already scaled: rescale by height/minWidth so `width` isn't scaled twice
|
|
139
|
+
const expandedWidth = (layout.width * minWidth) / layout.height;
|
|
140
|
+
maxWidth.value = expandedWidth;
|
|
141
|
+
widthAnimated.value = expandedWidth;
|
|
142
|
+
// collapsed it is a circle as wide as it is tall: center the icon from the
|
|
143
|
+
// rendered height so it stays centered when sizes are scaled but padding is not
|
|
144
|
+
collapsedPaddingLeft.value =
|
|
145
|
+
(layout.height - (layout.height * iconSize) / minWidth) / 2;
|
|
130
146
|
};
|
|
131
147
|
|
|
132
148
|
if (renderComponent) {
|
|
@@ -158,11 +174,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
158
174
|
]}
|
|
159
175
|
>
|
|
160
176
|
<TouchableOpacity style={styles.content} onPress={onPress}>
|
|
161
|
-
<Icon
|
|
162
|
-
source={icon}
|
|
163
|
-
size={size === 'small' ? SMALL_ICON_SIZE : LARGE_ICON_SIZE}
|
|
164
|
-
color={iconColor}
|
|
165
|
-
/>
|
|
177
|
+
<Icon source={icon} size={iconSize} color={iconColor} />
|
|
166
178
|
{isLabelShown && !!label && (
|
|
167
179
|
<Animated.Text
|
|
168
180
|
allowFontScaling={false}
|
package/Layout/screenHeader.tsx
CHANGED
|
@@ -13,11 +13,8 @@ import {
|
|
|
13
13
|
SearchHeader,
|
|
14
14
|
} from '../Application';
|
|
15
15
|
import { DuoGlassBackground } from '../Application/Components/DuoGlassBackground';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
type HeaderContentLayout,
|
|
19
|
-
TITLE_CONTAINER_RESET,
|
|
20
|
-
} from '../Application/headerLayout';
|
|
16
|
+
import { type HeaderContentLayout } from '../Application/headerLayout';
|
|
17
|
+
import { getHeaderMargin } from './utils';
|
|
21
18
|
import { useHeaderBarOptions } from './useHeaderBarOptions';
|
|
22
19
|
import { HeaderType } from './types';
|
|
23
20
|
|
|
@@ -245,11 +242,10 @@ export const useScreenHeader = ({
|
|
|
245
242
|
// the search field spans the content, clear of the side bar and status bar
|
|
246
243
|
// clusters; kept as numbers so the setter below stays stable
|
|
247
244
|
let searchWidth = layout.width - Spacing.M * 2;
|
|
248
|
-
|
|
249
|
-
const rowStartLeft = getHeaderRowInset(layout.width);
|
|
250
|
-
const searchLeft = layout.sideBar ? rowStartLeft : Spacing.M;
|
|
245
|
+
let searchLeft = Spacing.M;
|
|
251
246
|
if (layout.sideBar) {
|
|
252
247
|
searchWidth = layout.contentWidth - Spacing.M * 2;
|
|
248
|
+
searchLeft = Spacing.M - getHeaderMargin(layout.width);
|
|
253
249
|
}
|
|
254
250
|
const clearance = layout.statusBarClearance;
|
|
255
251
|
if (clearance) {
|
|
@@ -263,18 +259,25 @@ export const useScreenHeader = ({
|
|
|
263
259
|
const setSearchHeader = useCallback(
|
|
264
260
|
(params: SearchHeaderProps) => {
|
|
265
261
|
searchHeaderParams.current = params;
|
|
266
|
-
const hasBack = !params?.hiddenBack;
|
|
267
262
|
const options: StackNavigationOptions = {
|
|
268
263
|
...searchOptions,
|
|
269
264
|
headerRight: undefined,
|
|
270
265
|
headerTitleContainerStyle: {
|
|
271
|
-
...TITLE_CONTAINER_RESET,
|
|
272
266
|
width: searchWidth,
|
|
273
267
|
maxWidth: searchWidth,
|
|
274
|
-
|
|
268
|
+
marginLeft: 0,
|
|
269
|
+
marginEnd: 0,
|
|
270
|
+
marginStart: 0,
|
|
271
|
+
marginHorizontal: 0,
|
|
272
|
+
marginVertical: 0,
|
|
273
|
+
margin: 0,
|
|
274
|
+
left: searchLeft,
|
|
275
275
|
},
|
|
276
276
|
headerLeft: (props: any) => {
|
|
277
|
-
|
|
277
|
+
if (params?.hiddenBack) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
return <HeaderLeft {...props} floating />;
|
|
278
281
|
},
|
|
279
282
|
headerTitle: () => (
|
|
280
283
|
<SearchHeader {...params} animatedValue={sharedValue} />
|
|
@@ -283,14 +286,7 @@ export const useScreenHeader = ({
|
|
|
283
286
|
|
|
284
287
|
navigation?.instance?.setOptions(options);
|
|
285
288
|
},
|
|
286
|
-
[
|
|
287
|
-
navigation?.instance,
|
|
288
|
-
sharedValue,
|
|
289
|
-
searchOptions,
|
|
290
|
-
searchWidth,
|
|
291
|
-
searchLeft,
|
|
292
|
-
rowStartLeft,
|
|
293
|
-
],
|
|
289
|
+
[navigation?.instance, sharedValue, searchOptions, searchWidth, searchLeft],
|
|
294
290
|
);
|
|
295
291
|
|
|
296
292
|
useEffect(() => {
|