@momo-kits/foundation 0.169.7 → 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.
@@ -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({ header: undefined, ...options });
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: StackNavigationOptions = {
226
- headerShown: true,
227
- headerTransparent: true,
228
- headerBackground: () => null,
229
- headerTitle: (props: any) => (
230
- <HeaderTitle
231
- {...props}
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 and status bar clusters
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 = layout.width - 24;
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,
@@ -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 (73), or 0 when
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 | 73 | 110 | number;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.169.7",
3
+ "version": "0.169.9-beta.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},