1 | import React from 'react';
|
2 | import {
|
3 | Animated,
|
4 | NativeSyntheticEvent,
|
5 | ViewProps,
|
6 | View,
|
7 | TargetedEvent,
|
8 | TextInputFocusEventData,
|
9 | ColorValue,
|
10 | } from 'react-native';
|
11 | import { NativeStackNavigatorProps } from './native-stack/types';
|
12 |
|
13 | export type SearchBarCommands = {
|
14 | focus: () => void;
|
15 | blur: () => void;
|
16 | clearText: () => void;
|
17 | toggleCancelButton: (show: boolean) => void;
|
18 | setText: (text: string) => void;
|
19 | cancelSearch: () => void;
|
20 | };
|
21 |
|
22 | export type BackButtonDisplayMode = 'default' | 'generic' | 'minimal';
|
23 | export type StackPresentationTypes =
|
24 | | 'push'
|
25 | | 'modal'
|
26 | | 'transparentModal'
|
27 | | 'containedModal'
|
28 | | 'containedTransparentModal'
|
29 | | 'fullScreenModal'
|
30 | | 'formSheet';
|
31 | export type StackAnimationTypes =
|
32 | | 'default'
|
33 | | 'fade'
|
34 | | 'fade_from_bottom'
|
35 | | 'flip'
|
36 | | 'none'
|
37 | | 'simple_push'
|
38 | | 'slide_from_bottom'
|
39 | | 'slide_from_right'
|
40 | | 'slide_from_left'
|
41 | | 'ios';
|
42 | export type BlurEffectTypes =
|
43 | | 'extraLight'
|
44 | | 'light'
|
45 | | 'dark'
|
46 | | 'regular'
|
47 | | 'prominent'
|
48 | | 'systemUltraThinMaterial'
|
49 | | 'systemThinMaterial'
|
50 | | 'systemMaterial'
|
51 | | 'systemThickMaterial'
|
52 | | 'systemChromeMaterial'
|
53 | | 'systemUltraThinMaterialLight'
|
54 | | 'systemThinMaterialLight'
|
55 | | 'systemMaterialLight'
|
56 | | 'systemThickMaterialLight'
|
57 | | 'systemChromeMaterialLight'
|
58 | | 'systemUltraThinMaterialDark'
|
59 | | 'systemThinMaterialDark'
|
60 | | 'systemMaterialDark'
|
61 | | 'systemThickMaterialDark'
|
62 | | 'systemChromeMaterialDark';
|
63 | export type ScreenReplaceTypes = 'push' | 'pop';
|
64 | export type SwipeDirectionTypes = 'vertical' | 'horizontal';
|
65 | export type ScreenOrientationTypes =
|
66 | | 'default'
|
67 | | 'all'
|
68 | | 'portrait'
|
69 | | 'portrait_up'
|
70 | | 'portrait_down'
|
71 | | 'landscape'
|
72 | | 'landscape_left'
|
73 | | 'landscape_right';
|
74 | export type HeaderSubviewTypes =
|
75 | | 'back'
|
76 | | 'right'
|
77 | | 'left'
|
78 | | 'center'
|
79 | | 'searchBar';
|
80 |
|
81 | export type HeaderHeightChangeEventType = {
|
82 | headerHeight: number;
|
83 | };
|
84 |
|
85 | export type TransitionProgressEventType = {
|
86 | progress: number;
|
87 | closing: number;
|
88 | goingForward: number;
|
89 | };
|
90 |
|
91 | export type GestureResponseDistanceType = {
|
92 | start?: number;
|
93 | end?: number;
|
94 | top?: number;
|
95 | bottom?: number;
|
96 | };
|
97 |
|
98 | export type SheetDetentTypes = 'medium' | 'large' | 'all';
|
99 | export type SearchBarPlacement = 'automatic' | 'inline' | 'stacked';
|
100 |
|
101 | export interface ScreenProps extends ViewProps {
|
102 | active?: 0 | 1 | Animated.AnimatedInterpolation<number>;
|
103 | activityState?: 0 | 1 | 2 | Animated.AnimatedInterpolation<number>;
|
104 | children?: React.ReactNode;
|
105 | /**
|
106 | * Boolean indicating that swipe dismissal should trigger animation provided by `stackAnimation`. Defaults to `false`.
|
107 | *
|
108 | * @platform ios
|
109 | */
|
110 | customAnimationOnSwipe?: boolean;
|
111 | /**
|
112 | * All children screens should have the same value of their "enabled" prop as their container.
|
113 | */
|
114 | enabled?: boolean;
|
115 | /**
|
116 | * Internal boolean used to not attach events used only by native-stack. It prevents non native-stack navigators from sending transition progress from their Screen components.
|
117 | */
|
118 | isNativeStack?: boolean;
|
119 | /**
|
120 | * Internal boolean used to detect if current header has large title on iOS.
|
121 | */
|
122 | hasLargeHeader?: boolean;
|
123 | /**
|
124 | * Whether inactive screens should be suspended from re-rendering. Defaults to `false`.
|
125 | * When `enableFreeze()` is run at the top of the application defaults to `true`.
|
126 | */
|
127 | freezeOnBlur?: boolean;
|
128 | /**
|
129 | * Boolean indicating whether the swipe gesture should work on whole screen. Swiping with this option results in the same transition animation as `simple_push` by default.
|
130 | * It can be changed to other custom animations with `customAnimationOnSwipe` prop, but default iOS swipe animation is not achievable due to usage of custom recognizer.
|
131 | * Defaults to `false`.
|
132 | *
|
133 | * @platform ios
|
134 | */
|
135 | fullScreenSwipeEnabled?: boolean;
|
136 | /**
|
137 | * Whether you can use gestures to dismiss this screen. Defaults to `true`.
|
138 | *
|
139 | * @platform ios
|
140 | */
|
141 | gestureEnabled?: boolean;
|
142 | /**
|
143 | * Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenSwipeEnabled`.
|
144 | *
|
145 | * @platform ios
|
146 | */
|
147 | gestureResponseDistance?: GestureResponseDistanceType;
|
148 | /**
|
149 | * Whether the home indicator should be hidden on this screen. Defaults to `false`.
|
150 | *
|
151 | * @platform ios
|
152 | */
|
153 | homeIndicatorHidden?: boolean;
|
154 | /**
|
155 | * Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`.
|
156 | *
|
157 | * @platform ios
|
158 | */
|
159 | hideKeyboardOnSwipe?: boolean;
|
160 | /**
|
161 | * Boolean indicating whether, when the Android default back button is clicked, the `pop` action should be performed on the native side or on the JS side to be able to prevent it.
|
162 | * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
|
163 | * Defaults to `false`.
|
164 | *
|
165 | * @platform android
|
166 | */
|
167 | nativeBackButtonDismissalEnabled?: boolean;
|
168 | /**
|
169 | * Sets the navigation bar color. Defaults to initial status bar color.
|
170 | *
|
171 | * @platform android
|
172 | */
|
173 | navigationBarColor?: ColorValue;
|
174 | /**
|
175 | * Boolean indicating whether the content should be visible behind the navigation bar. Defaults to `false`.
|
176 | *
|
177 | * @platform android
|
178 | */
|
179 | navigationBarTranslucent?: boolean;
|
180 | /**
|
181 | * Sets the visibility of the navigation bar. Defaults to `false`.
|
182 | *
|
183 | * @platform android
|
184 | */
|
185 | navigationBarHidden?: boolean;
|
186 | /**
|
187 | * A callback that gets called when the current screen appears.
|
188 | */
|
189 | onAppear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
190 | onComponentRef?: (view: unknown) => void;
|
191 | /**
|
192 | * A callback that gets called when the current screen disappears.
|
193 | */
|
194 | onDisappear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
195 | /**
|
196 | * A callback that gets called when the current screen is dismissed by hardware back (on Android) or dismiss gesture (swipe back or down).
|
197 | * The callback takes the number of dismissed screens as an argument since iOS 14 native header back button can pop more than 1 screen at a time.
|
198 | */
|
199 | onDismissed?: (e: NativeSyntheticEvent<{ dismissCount: number }>) => void;
|
200 | /**
|
201 | * A callback that gets called when the header height has changed.
|
202 | */
|
203 | onHeaderHeightChange?: (
|
204 | e: NativeSyntheticEvent<HeaderHeightChangeEventType>
|
205 | ) => void;
|
206 | /**
|
207 | * A callback that gets called after swipe back is canceled.
|
208 | */
|
209 | onGestureCancel?: (e: NativeSyntheticEvent<null>) => void;
|
210 | /**
|
211 | * An internal callback that gets called when the native header back button is clicked on Android and `enableNativeBackButtonDismissal` is set to `false`. It dismises the screen using `navigation.pop()`.
|
212 | *
|
213 | * @platform android
|
214 | */
|
215 | onHeaderBackButtonClicked?: () => void;
|
216 | /**
|
217 | * An internal callback called when screen is dismissed by gesture or by native header back button and `preventNativeDismiss` is set to `true`.
|
218 | *
|
219 | * @platform ios
|
220 | */
|
221 | onNativeDismissCancelled?: (
|
222 | e: NativeSyntheticEvent<{ dismissCount: number }>
|
223 | ) => void;
|
224 | /**
|
225 | * An internal callback called every frame during the transition of screens of `native-stack`, used to feed transition context.
|
226 | */
|
227 | onTransitionProgress?: (
|
228 | e: NativeSyntheticEvent<TransitionProgressEventType>
|
229 | ) => void;
|
230 | /**
|
231 | * A callback that gets called when the current screen will appear. This is called as soon as the transition begins.
|
232 | */
|
233 | onWillAppear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
234 | /**
|
235 | * A callback that gets called when the current screen will disappear. This is called as soon as the transition begins.
|
236 | */
|
237 | onWillDisappear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
238 | /**
|
239 | * Boolean indicating whether to prevent current screen from being dismissed.
|
240 | * Defaults to `false`.
|
241 | *
|
242 | * @platform ios
|
243 | */
|
244 | preventNativeDismiss?: boolean;
|
245 | ref?: React.Ref<View>;
|
246 | /**
|
247 | * How should the screen replacing another screen animate. Defaults to `pop`.
|
248 | * The following values are currently supported:
|
249 | * - "push" – the new screen will perform push animation.
|
250 | * - "pop" – the new screen will perform pop animation.
|
251 | */
|
252 | replaceAnimation?: ScreenReplaceTypes;
|
253 | /**
|
254 | * In which orientation should the screen appear.
|
255 | * The following values are currently supported:
|
256 | * - "default" - resolves to "all" without "portrait_down" on iOS. On Android, this lets the system decide the best orientation.
|
257 | * - "all" – all orientations are permitted
|
258 | * - "portrait" – portrait orientations are permitted
|
259 | * - "portrait_up" – right-side portrait orientation is permitted
|
260 | * - "portrait_down" – upside-down portrait orientation is permitted
|
261 | * - "landscape" – landscape orientations are permitted
|
262 | * - "landscape_left" – landscape-left orientation is permitted
|
263 | * - "landscape_right" – landscape-right orientation is permitted
|
264 | */
|
265 | screenOrientation?: ScreenOrientationTypes;
|
266 | /**
|
267 | * Describes heights where a sheet can rest.
|
268 | * Works only when `stackPresentation` is set to `formSheet`.
|
269 | * Defaults to `large`.
|
270 | *
|
271 | * Available values:
|
272 | *
|
273 | * - `large` - only large detent level will be allowed
|
274 | * - `medium` - only medium detent level will be allowed
|
275 | * - `all` - all detent levels will be allowed
|
276 | *
|
277 | * @platform ios
|
278 | */
|
279 | sheetAllowedDetents?: SheetDetentTypes;
|
280 | /**
|
281 | * Whether the sheet should expand to larger detent when scrolling.
|
282 | * Works only when `stackPresentation` is set to `formSheet`.
|
283 | * Defaults to `true`.
|
284 | *
|
285 | * @platform ios
|
286 | */
|
287 | sheetExpandsWhenScrolledToEdge?: boolean;
|
288 | /**
|
289 | * The corner radius that the sheet will try to render with.
|
290 | * Works only when `stackPresentation` is set to `formSheet`.
|
291 | *
|
292 | * If set to non-negative value it will try to render sheet with provided radius, else it will apply system default.
|
293 | *
|
294 | * If left unset system default is used.
|
295 | *
|
296 | * @platform ios
|
297 | */
|
298 | sheetCornerRadius?: number;
|
299 | /**
|
300 | * Boolean indicating whether the sheet shows a grabber at the top.
|
301 | * Works only when `stackPresentation` is set to `formSheet`.
|
302 | * Defaults to `false`.
|
303 | *
|
304 | * @platform ios
|
305 | */
|
306 | sheetGrabberVisible?: boolean;
|
307 | /**
|
308 | * The largest sheet detent for which a view underneath won't be dimmed.
|
309 | * Works only when `stackPresentation` is set to `formSheet`.
|
310 | *
|
311 | * If this prop is set to:
|
312 | *
|
313 | * - `large` - the view underneath won't be dimmed at any detent level
|
314 | * - `medium` - the view underneath will be dimmed only when detent level is `large`
|
315 | * - `all` - the view underneath will be dimmed for any detent level
|
316 | *
|
317 | * Defaults to `all`.
|
318 | *
|
319 | * @platform ios
|
320 | */
|
321 | sheetLargestUndimmedDetent?: SheetDetentTypes;
|
322 | /**
|
323 | * How the screen should appear/disappear when pushed or popped at the top of the stack.
|
324 | * The following values are currently supported:
|
325 | * - "default" – uses a platform default animation
|
326 | * - "fade" – fades screen in or out
|
327 | * - "fade_from_bottom" – performs a fade from bottom animation
|
328 | * - "flip" – flips the screen, requires stackPresentation: "modal" (iOS only)
|
329 | * - "simple_push" – performs a default animation, but without shadow and native header transition (iOS only)
|
330 | * - `slide_from_bottom` – performs a slide from bottom animation
|
331 | * - "slide_from_right" - slide in the new screen from right to left (Android only, resolves to default transition on iOS)
|
332 | * - "slide_from_left" - slide in the new screen from left to right
|
333 | * - "ios" - iOS like slide in animation (Android only, resolves to default transition on iOS)
|
334 | * - "none" – the screen appears/dissapears without an animation
|
335 | */
|
336 | stackAnimation?: StackAnimationTypes;
|
337 | /**
|
338 | * How should the screen be presented.
|
339 | * The following values are currently supported:
|
340 | * - "push" – the new screen will be pushed onto a stack which on iOS means that the default animation will be slide from the side, the animation on Android may vary depending on the OS version and theme.
|
341 | * - "modal" – the new screen will be presented modally. In addition this allow for a nested stack to be rendered inside such screens.
|
342 | * - "transparentModal" – the new screen will be presented modally but in addition the second to last screen will remain attached to the stack container such that if the top screen is non opaque the content below can still be seen. If "modal" is used instead the below screen will get unmounted as soon as the transition ends.
|
343 | * - "containedModal" – will use "UIModalPresentationCurrentContext" modal style on iOS and will fallback to "modal" on Android.
|
344 | * - "containedTransparentModal" – will use "UIModalPresentationOverCurrentContext" modal style on iOS and will fallback to "transparentModal" on Android.
|
345 | * - "fullScreenModal" – will use "UIModalPresentationFullScreen" modal style on iOS and will fallback to "modal" on Android.
|
346 | * - "formSheet" – will use "UIModalPresentationFormSheet" modal style on iOS and will fallback to "modal" on Android.
|
347 | */
|
348 | stackPresentation?: StackPresentationTypes;
|
349 | /**
|
350 | * Sets the status bar animation (similar to the `StatusBar` component). Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS.
|
351 | */
|
352 | statusBarAnimation?: 'none' | 'fade' | 'slide';
|
353 | /**
|
354 | * Sets the status bar color (similar to the `StatusBar` component). Defaults to initial status bar color.
|
355 | *
|
356 | * @platform android
|
357 | */
|
358 | statusBarColor?: ColorValue;
|
359 | /**
|
360 | * Whether the status bar should be hidden on this screen. Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS. Defaults to `false`.
|
361 | */
|
362 | statusBarHidden?: boolean;
|
363 | /**
|
364 | * Sets the status bar color (similar to the `StatusBar` component). Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS. Defaults to `auto`.
|
365 | */
|
366 | statusBarStyle?: 'inverted' | 'auto' | 'light' | 'dark';
|
367 | /**
|
368 | * Sets the translucency of the status bar. Defaults to `false`.
|
369 | *
|
370 | * @platform android
|
371 | */
|
372 | statusBarTranslucent?: boolean;
|
373 | /**
|
374 | * Sets the direction in which you should swipe to dismiss the screen.
|
375 | * When using `vertical` option, options `fullScreenSwipeEnabled: true`, `customAnimationOnSwipe: true` and `stackAnimation: 'slide_from_bottom'` are set by default.
|
376 | * The following values are supported:
|
377 | * - `vertical` – dismiss screen vertically
|
378 | * - `horizontal` – dismiss screen horizontally (default)
|
379 | *
|
380 | * @platform ios
|
381 | */
|
382 | swipeDirection?: SwipeDirectionTypes;
|
383 | /**
|
384 | * Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.
|
385 | * The duration of `default` and `flip` transitions isn't customizable.
|
386 | *
|
387 | * @platform ios
|
388 | */
|
389 | transitionDuration?: number;
|
390 | }
|
391 |
|
392 | export interface ScreenContainerProps extends ViewProps {
|
393 | children?: React.ReactNode;
|
394 | /**
|
395 | * A prop that gives users an option to switch between using Screens for the navigator (container). All children screens should have the same value of their "enabled" prop as their container.
|
396 | */
|
397 | enabled?: boolean;
|
398 | /**
|
399 | * A prop to be used in navigators always showing only one screen (providing only `0` or `2` `activityState` values) for better implementation of `ScreenContainer` on iOS.
|
400 | */
|
401 | hasTwoStates?: boolean;
|
402 | }
|
403 |
|
404 | export interface GestureDetectorBridge {
|
405 | stackUseEffectCallback: (
|
406 | stackRef: React.MutableRefObject<React.Ref<NativeStackNavigatorProps>>
|
407 | ) => void;
|
408 | }
|
409 |
|
410 | export interface ScreenStackProps extends ViewProps {
|
411 | children?: React.ReactNode;
|
412 | /**
|
413 | * A callback that gets called when the current screen finishes its transition.
|
414 | */
|
415 | onFinishTransitioning?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
416 | gestureDetectorBridge?: React.MutableRefObject<GestureDetectorBridge>;
|
417 | ref?: React.MutableRefObject<React.Ref<View>>;
|
418 | }
|
419 |
|
420 | export interface ScreenStackHeaderConfigProps extends ViewProps {
|
421 | /**
|
422 | * Whether to show the back button with custom left side of the header.
|
423 | */
|
424 | backButtonInCustomView?: boolean;
|
425 | /**
|
426 | * Controls the color of the navigation header.
|
427 | */
|
428 | backgroundColor?: ColorValue;
|
429 | /**
|
430 | * Title to display in the back button.
|
431 | * @platform ios.
|
432 | */
|
433 | backTitle?: string;
|
434 | /**
|
435 | * Allows for customizing font family to be used for back button title on iOS.
|
436 | * @platform ios
|
437 | */
|
438 | backTitleFontFamily?: string;
|
439 | /**
|
440 | * Allows for customizing font size to be used for back button title on iOS.
|
441 | * @platform ios
|
442 | */
|
443 | backTitleFontSize?: number;
|
444 | /**
|
445 | * Whether the back button title should be visible or not. Defaults to `true`.
|
446 | * @platform ios
|
447 | */
|
448 | backTitleVisible?: boolean;
|
449 | /**
|
450 | * Blur effect to be applied to the header. Works with backgroundColor's alpha < 1.
|
451 | * @platform ios
|
452 | */
|
453 | blurEffect?: BlurEffectTypes;
|
454 | /**
|
455 | * Pass HeaderLeft, HeaderRight and HeaderTitle
|
456 | */
|
457 | children?: React.ReactNode;
|
458 | /**
|
459 | * Controls the color of items rendered on the header. This includes back icon, back text (iOS only) and title text. If you want the title to have different color use titleColor property.
|
460 | */
|
461 | color?: ColorValue;
|
462 | /**
|
463 | * Whether the stack should be in rtl or ltr form.
|
464 | */
|
465 | direction?: 'rtl' | 'ltr';
|
466 | /**
|
467 | * Boolean indicating whether to show the menu on longPress of iOS >= 14 back button.
|
468 | * @platform ios
|
469 | */
|
470 | disableBackButtonMenu?: boolean;
|
471 | /**
|
472 | * How the back button behaves by default (when not customized). Available on iOS>=14, and is used only when none of: `backTitleFontFamily`, `backTitleFontSize`, `disableBackButtonMenu` or `backTitle` is set.
|
473 | * The following values are currently supported (they correspond to https://developer.apple.com/documentation/uikit/uinavigationitembackbuttondisplaymode?language=objc):
|
474 | * - "default" – show given back button previous controller title, system generic or just icon based on available space
|
475 | * - "generic" – show given system generic or just icon based on available space
|
476 | * - "minimal" – show just an icon
|
477 | * @platform ios
|
478 | */
|
479 | backButtonDisplayMode?: BackButtonDisplayMode;
|
480 | /**
|
481 | * When set to true the header will be hidden while the parent Screen is on the top of the stack. The default value is false.
|
482 | */
|
483 | hidden?: boolean;
|
484 | /**
|
485 | * Boolean indicating whether to hide the back button in header.
|
486 | */
|
487 | hideBackButton?: boolean;
|
488 | /**
|
489 | * Boolean indicating whether to hide the elevation shadow or the bottom border on the header.
|
490 | */
|
491 | hideShadow?: boolean;
|
492 | /**
|
493 | * Boolean to set native property to prefer large title header (like in iOS setting).
|
494 | * For large title to collapse on scroll, the content of the screen should be wrapped in a scrollable view such as `ScrollView` or `FlatList`.
|
495 | * If the scrollable area doesn't fill the screen, the large title won't collapse on scroll.
|
496 | * Only supported on iOS.
|
497 | *
|
498 | * @platform ios
|
499 | */
|
500 | largeTitle?: boolean;
|
501 | /**
|
502 | * Controls the color of the navigation header when the edge of any scrollable content reaches the matching edge of the navigation bar.
|
503 | */
|
504 | largeTitleBackgroundColor?: ColorValue;
|
505 | /**
|
506 | * Customize the color to be used for the large title. By default uses the titleColor property.
|
507 | * @platform ios
|
508 | */
|
509 | largeTitleColor?: ColorValue;
|
510 | /**
|
511 | * Customize font family to be used for the large title.
|
512 | * @platform ios
|
513 | */
|
514 | largeTitleFontFamily?: string;
|
515 | /**
|
516 | * Customize the size of the font to be used for the large title.
|
517 | * @platform ios
|
518 | */
|
519 | largeTitleFontSize?: number;
|
520 | /**
|
521 | * Customize the weight of the font to be used for the large title.
|
522 | * @platform ios
|
523 | */
|
524 | largeTitleFontWeight?: string;
|
525 | /**
|
526 | * Boolean that allows for disabling drop shadow under navigation header when the edge of any scrollable content reaches the matching edge of the navigation bar.
|
527 | */
|
528 | largeTitleHideShadow?: boolean;
|
529 | /**
|
530 | * Callback which is executed when screen header is attached
|
531 | */
|
532 | onAttached?: () => void;
|
533 | /**
|
534 | * Callback which is executed when screen header is detached
|
535 | */
|
536 | onDetached?: () => void;
|
537 | /**
|
538 | * String that can be displayed in the header as a fallback for `headerTitle`.
|
539 | */
|
540 | title?: string;
|
541 | /**
|
542 | * Allows for setting text color of the title.
|
543 | */
|
544 | titleColor?: ColorValue;
|
545 | /**
|
546 | * Customize font family to be used for the title.
|
547 | */
|
548 | titleFontFamily?: string;
|
549 | /**
|
550 | * Customize the size of the font to be used for the title.
|
551 | */
|
552 | titleFontSize?: number;
|
553 | /**
|
554 | * Customize the weight of the font to be used for the title.
|
555 | */
|
556 | titleFontWeight?: string;
|
557 | /**
|
558 | * A flag to that lets you opt out of insetting the header. You may want to
|
559 | * set this to `false` if you use an opaque status bar. Defaults to `true`.
|
560 | * Only supported on Android. Insets are always applied on iOS because the
|
561 | * header cannot be opaque.
|
562 | *
|
563 | * @platform android
|
564 | */
|
565 | topInsetEnabled?: boolean;
|
566 | /**
|
567 | * Boolean indicating whether the navigation bar is translucent.
|
568 | */
|
569 | translucent?: boolean;
|
570 | }
|
571 |
|
572 | export interface SearchBarProps {
|
573 | /**
|
574 | * Reference to imperatively modify search bar.
|
575 | *
|
576 | * Currently supported operations are:
|
577 | *
|
578 | * * `focus` - focuses the search bar
|
579 | * * `blur` - removes focus from the search bar
|
580 | * * `clearText` - removes any text present in the search bar input field
|
581 | * * `setText` - sets the search bar's content to given value
|
582 | * * `cancelSearch` - cancel search in search bar.
|
583 | * * `toggleCancelButton` - depending on passed boolean value, hides or shows cancel button (iOS only)
|
584 | */
|
585 | ref?: React.RefObject<SearchBarCommands>;
|
586 |
|
587 | /**
|
588 | * The auto-capitalization behavior
|
589 | */
|
590 | autoCapitalize?: 'none' | 'words' | 'sentences' | 'characters';
|
591 | /**
|
592 | * Automatically focuses search bar on mount
|
593 | *
|
594 | * @platform android
|
595 | */
|
596 | autoFocus?: boolean;
|
597 | /**
|
598 | * The search field background color
|
599 | */
|
600 | barTintColor?: ColorValue;
|
601 | /**
|
602 | * The color for the cursor caret and cancel button text.
|
603 | *
|
604 | * @platform ios
|
605 | */
|
606 | tintColor?: ColorValue;
|
607 | /**
|
608 | * The text to be used instead of default `Cancel` button text
|
609 | *
|
610 | * @platform ios
|
611 | */
|
612 | cancelButtonText?: string;
|
613 | /**
|
614 | * Specifies whether the back button should close search bar's text input or not.
|
615 | *
|
616 | * @platform android
|
617 | */
|
618 | disableBackButtonOverride?: boolean;
|
619 | /**
|
620 | * Indicates whether to hide the navigation bar
|
621 | *
|
622 | * @platform ios
|
623 | */
|
624 | hideNavigationBar?: boolean;
|
625 | /**
|
626 | * Indicates whether to hide the search bar when scrolling
|
627 | *
|
628 | * @platform ios
|
629 | */
|
630 | hideWhenScrolling?: boolean;
|
631 |
|
632 | /**
|
633 | * Sets type of the input. Defaults to `text`.
|
634 | *
|
635 | * @platform android
|
636 | */
|
637 | inputType?: 'text' | 'phone' | 'number' | 'email';
|
638 | /**
|
639 | * Indicates whether to obscure the underlying content
|
640 | */
|
641 | obscureBackground?: boolean;
|
642 | /**
|
643 | * A callback that gets called when search bar has lost focus
|
644 | */
|
645 | onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
646 | /**
|
647 | * A callback that gets called when the cancel button is pressed
|
648 | *
|
649 | * @platform ios
|
650 | */
|
651 | onCancelButtonPress?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
652 |
|
653 | /**
|
654 | * A callback that gets called when the text changes. It receives the current text value of the search bar.
|
655 | */
|
656 | onChangeText?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
|
657 |
|
658 | /**
|
659 | * A callback that gets called when search bar is closed
|
660 | *
|
661 | * @platform android
|
662 | */
|
663 | onClose?: () => void;
|
664 | /**
|
665 | * A callback that gets called when search bar has received focus
|
666 | */
|
667 | onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
668 | /**
|
669 | * A callback that gets called when search bar is opened
|
670 | *
|
671 | * @platform android
|
672 | */
|
673 | onOpen?: () => void;
|
674 | /**
|
675 | * A callback that gets called when the search button is pressed. It receives the current text value of the search bar.
|
676 | */
|
677 | onSearchButtonPress?: (
|
678 | e: NativeSyntheticEvent<TextInputFocusEventData>
|
679 | ) => void;
|
680 | /**
|
681 | * Text displayed when search field is empty
|
682 | */
|
683 | placeholder?: string;
|
684 | /**
|
685 | * Position of the search bar
|
686 | *
|
687 | * Supported values:
|
688 | *
|
689 | * * `automatic` - the search bar is placed according to current layout
|
690 | * * `inline` - the search bar is placed on the trailing edge of navigation bar
|
691 | * * `stacked` - the search bar is placed below the other content in navigation bar
|
692 | *
|
693 | * Defaults to `stacked`
|
694 | *
|
695 | * @platform iOS (>= 16.0)
|
696 | */
|
697 | placement?: SearchBarPlacement;
|
698 | /**
|
699 | * The search field text color
|
700 | */
|
701 | textColor?: ColorValue;
|
702 | /**
|
703 | * The search hint text color
|
704 | *
|
705 | * @plaform android
|
706 | */
|
707 | hintTextColor?: ColorValue;
|
708 | /**
|
709 | * The search and close icon color shown in the header
|
710 | *
|
711 | * @plaform android
|
712 | */
|
713 | headerIconColor?: ColorValue;
|
714 | /**
|
715 | * Show the search hint icon when search bar is focused
|
716 | *
|
717 | * @plaform android
|
718 | * @default true
|
719 | */
|
720 | shouldShowHintSearchIcon?: boolean;
|
721 | }
|