@momo-kits/foundation 0.169.8 → 0.169.9-beta.1
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/BottomTab/ActiveIndicator.tsx +1 -5
- package/Application/BottomTab/BottomTabBar.styles.ts +1 -18
- package/Application/BottomTab/BottomTabBar.tsx +10 -8
- package/Application/BottomTab/CurvedContainer.tsx +2 -8
- package/Application/BottomTab/CustomBottomTabItem.tsx +2 -2
- package/Application/BottomTab/DuoTabBar.tsx +3 -15
- package/Application/BottomTab/metrics.ts +3 -23
- package/Application/Components/HeaderAnimated.tsx +38 -13
- package/Application/Components/HeaderBackground.tsx +16 -3
- package/Application/Components/HeaderExtendHeader.tsx +41 -28
- package/Application/Components/HeaderLeft.tsx +4 -18
- package/Application/Components/HeaderRight.styles.ts +15 -13
- package/Application/Components/HeaderTitle.shared.ts +10 -11
- package/Application/Components/HeaderToolkitAction.tsx +12 -37
- package/Application/Components/NavigationButton.tsx +9 -6
- package/Application/Components/SearchHeader.tsx +20 -7
- package/Application/StackScreen.tsx +9 -0
- package/Application/headerLayout.ts +165 -0
- package/Application/index.ts +11 -1
- package/Application/modalLayout.ts +0 -3
- package/Application/navigationOptions.tsx +6 -15
- package/Application/types.header.ts +7 -2
- package/Application/types.tabs.ts +1 -0
- package/Application/types.ts +7 -0
- package/Input/InputSearch.tsx +18 -2
- package/Input/index.tsx +7 -1
- package/Layout/Screen.tsx +3 -0
- package/Layout/screenHeader.tsx +55 -52
- package/Layout/screenTypes.ts +10 -2
- package/Popup/PopupNotify.tsx +1 -1
- package/Popup/utils.ts +4 -7
- package/package.json +1 -1
package/Layout/screenHeader.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { StatusBar, StatusBarStyle } from 'react-native';
|
|
3
3
|
import { StackNavigationOptions } from '@react-navigation/stack';
|
|
4
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
4
5
|
import Navigation from '../Application/Navigation';
|
|
5
6
|
import { AnimatedHeader, SearchHeaderProps } from '../Application/types';
|
|
6
7
|
import { exportHeaderTitle } from '../Application/navigationOptions';
|
|
@@ -12,6 +13,11 @@ import {
|
|
|
12
13
|
SearchHeader,
|
|
13
14
|
} from '../Application';
|
|
14
15
|
import { DuoGlassBackground } from '../Application/Components/DuoGlassBackground';
|
|
16
|
+
import {
|
|
17
|
+
type HeaderContentLayout,
|
|
18
|
+
useHeaderFrameOptions,
|
|
19
|
+
useHeaderLayout,
|
|
20
|
+
} from '../Application/headerLayout';
|
|
15
21
|
import { getHeaderMargin } from './utils';
|
|
16
22
|
import { ANIMATED_BANNER_HEIGHT } from './screenTypes';
|
|
17
23
|
import { HeaderType } from './types';
|
|
@@ -29,6 +35,31 @@ type ScreenHeaderParams = {
|
|
|
29
35
|
gradientColor?: string;
|
|
30
36
|
headerBackground?: string;
|
|
31
37
|
layoutOffset: number;
|
|
38
|
+
contentLayout?: HeaderContentLayout;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Transparent header for an `inputSearchProps` Screen: its title fades out over the
|
|
43
|
+
* first 50pt of scroll while the search collapses into the bar.
|
|
44
|
+
*/
|
|
45
|
+
const getSearchTitleOptions = (
|
|
46
|
+
sharedValue: SharedValue<number>,
|
|
47
|
+
): StackNavigationOptions => {
|
|
48
|
+
return {
|
|
49
|
+
headerShown: true,
|
|
50
|
+
headerTransparent: true,
|
|
51
|
+
headerBackground: () => null,
|
|
52
|
+
headerTitle: (props: any) => (
|
|
53
|
+
<HeaderTitle
|
|
54
|
+
{...props}
|
|
55
|
+
interpolate={{
|
|
56
|
+
inputRange: [0, 50],
|
|
57
|
+
outputRange: [1, 0],
|
|
58
|
+
}}
|
|
59
|
+
animatedValue={sharedValue}
|
|
60
|
+
/>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
32
63
|
};
|
|
33
64
|
|
|
34
65
|
/**
|
|
@@ -48,9 +79,12 @@ export const useScreenHeader = ({
|
|
|
48
79
|
gradientColor,
|
|
49
80
|
headerBackground,
|
|
50
81
|
layoutOffset,
|
|
82
|
+
contentLayout,
|
|
51
83
|
}: ScreenHeaderParams) => {
|
|
52
84
|
const currentTint = useRef<string | undefined>(undefined);
|
|
53
85
|
const appliedHeaderMode = useRef<string | undefined>(undefined);
|
|
86
|
+
const headerLayout = useHeaderLayout(contentLayout);
|
|
87
|
+
const frameOptions = useHeaderFrameOptions(contentLayout);
|
|
54
88
|
|
|
55
89
|
// keepTitle leaves a title the screen set itself when the same type is re-applied
|
|
56
90
|
const setHeaderType = useCallback(
|
|
@@ -79,21 +113,7 @@ export const useScreenHeader = ({
|
|
|
79
113
|
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
80
114
|
};
|
|
81
115
|
if (inputSearchProps) {
|
|
82
|
-
options =
|
|
83
|
-
headerShown: true,
|
|
84
|
-
headerTransparent: true,
|
|
85
|
-
headerBackground: () => null,
|
|
86
|
-
headerTitle: (props: any) => (
|
|
87
|
-
<HeaderTitle
|
|
88
|
-
{...props}
|
|
89
|
-
interpolate={{
|
|
90
|
-
inputRange: [0, 50],
|
|
91
|
-
outputRange: [1, 0],
|
|
92
|
-
}}
|
|
93
|
-
animatedValue={sharedValue}
|
|
94
|
-
/>
|
|
95
|
-
),
|
|
96
|
-
};
|
|
116
|
+
options = getSearchTitleOptions(sharedValue);
|
|
97
117
|
}
|
|
98
118
|
break;
|
|
99
119
|
|
|
@@ -127,21 +147,7 @@ export const useScreenHeader = ({
|
|
|
127
147
|
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
128
148
|
};
|
|
129
149
|
if (inputSearchProps) {
|
|
130
|
-
options =
|
|
131
|
-
headerShown: true,
|
|
132
|
-
headerTransparent: true,
|
|
133
|
-
headerBackground: () => null,
|
|
134
|
-
headerTitle: (props: any) => (
|
|
135
|
-
<HeaderTitle
|
|
136
|
-
{...props}
|
|
137
|
-
interpolate={{
|
|
138
|
-
inputRange: [0, 50],
|
|
139
|
-
outputRange: [1, 0],
|
|
140
|
-
}}
|
|
141
|
-
animatedValue={sharedValue}
|
|
142
|
-
/>
|
|
143
|
-
),
|
|
144
|
-
};
|
|
150
|
+
options = getSearchTitleOptions(sharedValue);
|
|
145
151
|
}
|
|
146
152
|
}
|
|
147
153
|
|
|
@@ -149,7 +155,11 @@ export const useScreenHeader = ({
|
|
|
149
155
|
delete options.headerTitle;
|
|
150
156
|
}
|
|
151
157
|
|
|
152
|
-
navigation?.instance?.setOptions({
|
|
158
|
+
navigation?.instance?.setOptions({
|
|
159
|
+
header: undefined,
|
|
160
|
+
...frameOptions,
|
|
161
|
+
...options,
|
|
162
|
+
});
|
|
153
163
|
},
|
|
154
164
|
[
|
|
155
165
|
gradientColor,
|
|
@@ -160,6 +170,7 @@ export const useScreenHeader = ({
|
|
|
160
170
|
useShadowHeader,
|
|
161
171
|
hasSideBar,
|
|
162
172
|
quickReturnOptions,
|
|
173
|
+
frameOptions,
|
|
163
174
|
],
|
|
164
175
|
);
|
|
165
176
|
|
|
@@ -207,7 +218,7 @@ export const useScreenHeader = ({
|
|
|
207
218
|
};
|
|
208
219
|
}
|
|
209
220
|
|
|
210
|
-
navigation?.instance?.setOptions(options);
|
|
221
|
+
navigation?.instance?.setOptions({ ...frameOptions, ...options });
|
|
211
222
|
},
|
|
212
223
|
[
|
|
213
224
|
gradientColor,
|
|
@@ -218,32 +229,23 @@ export const useScreenHeader = ({
|
|
|
218
229
|
hasSideBar,
|
|
219
230
|
layoutOffset,
|
|
220
231
|
quickReturnOptions,
|
|
232
|
+
frameOptions,
|
|
221
233
|
],
|
|
222
234
|
);
|
|
223
235
|
|
|
224
236
|
const setAnimatedSearch = useCallback(() => {
|
|
225
|
-
const options
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
interpolate={{
|
|
233
|
-
inputRange: [0, 50],
|
|
234
|
-
outputRange: [1, 0],
|
|
235
|
-
}}
|
|
236
|
-
animatedValue={sharedValue}
|
|
237
|
-
/>
|
|
238
|
-
),
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
navigation?.instance?.setOptions({ header: undefined, ...options });
|
|
242
|
-
}, [navigation?.instance, sharedValue]);
|
|
237
|
+
const options = getSearchTitleOptions(sharedValue);
|
|
238
|
+
navigation?.instance?.setOptions({
|
|
239
|
+
header: undefined,
|
|
240
|
+
...frameOptions,
|
|
241
|
+
...options,
|
|
242
|
+
});
|
|
243
|
+
}, [navigation?.instance, sharedValue, frameOptions]);
|
|
243
244
|
|
|
244
|
-
// the search field spans the content, clear of the side bar
|
|
245
|
+
// the search field spans the content (or the stretch frame), clear of the side bar
|
|
246
|
+
// and status bar clusters
|
|
245
247
|
const setSearchHeader = (params: SearchHeaderProps) => {
|
|
246
|
-
let searchWidth =
|
|
248
|
+
let searchWidth = headerLayout.frameWidth;
|
|
247
249
|
let searchLeft = Spacing.M;
|
|
248
250
|
if (layout.sideBar) {
|
|
249
251
|
searchWidth = layout.contentWidth - Spacing.M * 2;
|
|
@@ -254,6 +256,7 @@ export const useScreenHeader = ({
|
|
|
254
256
|
searchWidth -= clearance.left + clearance.right;
|
|
255
257
|
}
|
|
256
258
|
const options: StackNavigationOptions = {
|
|
259
|
+
...frameOptions,
|
|
257
260
|
headerRight: undefined,
|
|
258
261
|
headerTitleContainerStyle: {
|
|
259
262
|
width: searchWidth,
|
package/Layout/screenTypes.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { FloatingButtonProps } from './FloatingButton';
|
|
10
10
|
import { HeaderType } from './types';
|
|
11
11
|
import { InputRef } from '../Input';
|
|
12
|
+
import type { HeaderContentLayout } from '../Application/headerLayout';
|
|
12
13
|
|
|
13
14
|
export const ANIMATED_BANNER_HEIGHT = 210;
|
|
14
15
|
|
|
@@ -77,10 +78,17 @@ export interface ScreenProps extends ViewProps {
|
|
|
77
78
|
layoutOffset?: -8 | -24 | -56 | number;
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
|
-
* Optional. Width of the right header. Defaults to the toolkit width (
|
|
81
|
+
* Optional. Width of the right header. Defaults to the toolkit width (84), or 0 when
|
|
81
82
|
* iPhone Duo floats the toolkit into its side bar.
|
|
82
83
|
*/
|
|
83
|
-
headerRightWidth?: 0 |
|
|
84
|
+
headerRightWidth?: 0 | 84 | 124 | number;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Optional. `stretch` centers back, title or search and the right cluster of the
|
|
88
|
+
* header in a 600pt frame on wide windows (foldable inner display, tablet); the
|
|
89
|
+
* background and status bar stay full width. Defaults to `grid`.
|
|
90
|
+
*/
|
|
91
|
+
contentLayout?: HeaderContentLayout;
|
|
84
92
|
|
|
85
93
|
/**
|
|
86
94
|
* Optional. Props for the floating action button.
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -150,7 +150,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
150
150
|
return text;
|
|
151
151
|
}
|
|
152
152
|
return segments.map((segment, index) => {
|
|
153
|
-
if (segment.
|
|
153
|
+
if (segment.highlight) {
|
|
154
154
|
return (
|
|
155
155
|
<Text key={index} typography={'header_s_semibold'}>
|
|
156
156
|
{segment.text}
|
package/Popup/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type HighlightSegment = { text: string;
|
|
1
|
+
type HighlightSegment = { text: string; highlight: boolean };
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* True for cased-script letters, digits and `_`; caseless scripts (CJK, Thai)
|
|
@@ -46,15 +46,12 @@ const splitHighlightText = (
|
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
48
|
if (start > lastIndex) {
|
|
49
|
-
segments.push({
|
|
50
|
-
text: text.slice(lastIndex, start),
|
|
51
|
-
isHighlighted: false,
|
|
52
|
-
});
|
|
49
|
+
segments.push({ text: text.slice(lastIndex, start), highlight: false });
|
|
53
50
|
}
|
|
54
|
-
segments.push({ text: match[0],
|
|
51
|
+
segments.push({ text: match[0], highlight: true });
|
|
55
52
|
lastIndex = end;
|
|
56
53
|
}
|
|
57
|
-
segments.push({ text: text.slice(lastIndex),
|
|
54
|
+
segments.push({ text: text.slice(lastIndex), highlight: false });
|
|
58
55
|
return segments;
|
|
59
56
|
};
|
|
60
57
|
|