UNPKG

349 kBTypeScriptView Raw
1// Type definitions for react-native 0.64
2// Project: https://github.com/facebook/react-native
3// Definitions by: Eloy Durán <https://github.com/alloy>
4// HuHuanming <https://github.com/huhuanming>
5// Kyle Roach <https://github.com/iRoachie>
6// Tim Wang <https://github.com/timwangdev>
7// Kamal Mahyuddin <https://github.com/kamal>
8// Alex Dunne <https://github.com/alexdunne>
9// Manuel Alabor <https://github.com/swissmanu>
10// Michele Bombardi <https://github.com/bm-software>
11// Martin van Dam <https://github.com/mvdam>
12// Kacper Wiszczuk <https://github.com/esemesek>
13// Ryan Nickel <https://github.com/mrnickel>
14// Souvik Ghosh <https://github.com/souvik-ghosh>
15// Cheng Gibson <https://github.com/nossbigg>
16// Saransh Kataria <https://github.com/saranshkataria>
17// Wojciech Tyczynski <https://github.com/tykus160>
18// Jake Bloom <https://github.com/jakebloom>
19// Ceyhun Ozugur <https://github.com/ceyhun>
20// Mike Martin <https://github.com/mcmar>
21// Theo Henry de Villeneuve <https://github.com/theohdv>
22// Eli White <https://github.com/TheSavior>
23// Romain Faust <https://github.com/romain-faust>
24// Be Birchall <https://github.com/bebebebebe>
25// Jesse Katsumata <https://github.com/Naturalclar>
26// Xianming Zhong <https://github.com/chinesedfan>
27// Valentyn Tolochko <https://github.com/vtolochk>
28// Sergey Sychev <https://github.com/SychevSP>
29// Kelvin Chu <https://github.com/RageBill>
30// Daiki Ihara <https://github.com/sasurau4>
31// Abe Dolinger <https://github.com/256hz>
32// Dominique Richard <https://github.com/doumart>
33// Mohamed Shaban <https://github.com/drmas>
34// André Krüger <https://github.com/akrger>
35// Jérémy Barbet <https://github.com/jeremybarbet>
36// Christian Ost <https://github.com/ca057>
37// David Sheldrick <https://github.com/ds300>
38// Natsathorn Yuthakovit <https://github.com/natsathorn>
39// ConnectDotz <https://github.com/connectdotz>
40// Marcel Lasaj <https://github.com/TheWirv>
41// Alexey Molchan <https://github.com/alexeymolchan>
42// Alex Brazier <https://github.com/alexbrazier>
43// Arafat Zahan <https://github.com/kuasha420>
44// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
45// TypeScript Version: 3.0
46
47///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48//
49// USING: these definitions are meant to be used with the TSC compiler target set to at least ES2015.
50//
51// USAGE EXAMPLES: check the RNTSExplorer project at https://github.com/bgrieder/RNTSExplorer
52//
53// CONTRIBUTING: please open pull requests
54//
55// CREDITS: This work is based on an original work made by Bernd Paradies: https://github.com/bparadie
56//
57///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
58
59/// <reference path="globals.d.ts" />
60/// <reference path="legacy-properties.d.ts" />
61/// <reference path="BatchedBridge.d.ts" />
62/// <reference path="Devtools.d.ts" />
63/// <reference path="LaunchScreen.d.ts" />
64
65import * as React from 'react';
66
67type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
68
69type Constructor<T> = new (...args: any[]) => T;
70
71export type MeasureOnSuccessCallback = (
72 x: number,
73 y: number,
74 width: number,
75 height: number,
76 pageX: number,
77 pageY: number,
78) => void;
79
80export type MeasureInWindowOnSuccessCallback = (x: number, y: number, width: number, height: number) => void;
81
82export type MeasureLayoutOnSuccessCallback = (left: number, top: number, width: number, height: number) => void;
83
84/**
85 * EventSubscription represents a subscription to a particular event. It can
86 * remove its own subscription.
87 */
88interface EventSubscription {
89 eventType: string;
90 key: number;
91 subscriber: EventSubscriptionVendor;
92
93 /**
94 * @param subscriber the subscriber that controls
95 * this subscription.
96 */
97 new (subscriber: EventSubscriptionVendor): EventSubscription;
98
99 /**
100 * Removes this subscription from the subscriber that controls it.
101 */
102 remove(): void;
103}
104
105/**
106 * EventSubscriptionVendor stores a set of EventSubscriptions that are
107 * subscribed to a particular event type.
108 */
109declare class EventSubscriptionVendor {
110 constructor();
111
112 /**
113 * Adds a subscription keyed by an event type.
114 *
115 */
116 addSubscription(eventType: string, subscription: EventSubscription): EventSubscription;
117
118 /**
119 * Removes a bulk set of the subscriptions.
120 *
121 * @param eventType - Optional name of the event type whose
122 * registered supscriptions to remove, if null remove all subscriptions.
123 */
124 removeAllSubscriptions(eventType?: string): void;
125
126 /**
127 * Removes a specific subscription. Instead of calling this function, call
128 * `subscription.remove()` directly.
129 *
130 */
131 removeSubscription(subscription: any): void;
132
133 /**
134 * Returns the array of subscriptions that are currently registered for the
135 * given event type.
136 *
137 * Note: This array can be potentially sparse as subscriptions are deleted
138 * from it when they are removed.
139 *
140 */
141 getSubscriptionsForType(eventType: string): EventSubscription[];
142}
143
144/**
145 * EmitterSubscription represents a subscription with listener and context data.
146 */
147interface EmitterSubscription extends EventSubscription {
148 emitter: EventEmitter;
149 listener: () => any;
150 context: any;
151
152 /**
153 * @param emitter - The event emitter that registered this
154 * subscription
155 * @param subscriber - The subscriber that controls
156 * this subscription
157 * @param listener - Function to invoke when the specified event is
158 * emitted
159 * @param context - Optional context object to use when invoking the
160 * listener
161 */
162 new (
163 emitter: EventEmitter,
164 subscriber: EventSubscriptionVendor,
165 listener: () => any,
166 context: any,
167 ): EmitterSubscription;
168
169 /**
170 * Removes this subscription from the emitter that registered it.
171 * Note: we're overriding the `remove()` method of EventSubscription here
172 * but deliberately not calling `super.remove()` as the responsibility
173 * for removing the subscription lies with the EventEmitter.
174 */
175 remove(): void;
176}
177
178declare class EventEmitter {
179 /**
180 *
181 * @param subscriber - Optional subscriber instance
182 * to use. If omitted, a new subscriber will be created for the emitter.
183 */
184 constructor(subscriber?: EventSubscriptionVendor | null);
185
186 /**
187 * Adds a listener to be invoked when events of the specified type are
188 * emitted. An optional calling context may be provided. The data arguments
189 * emitted will be passed to the listener function.
190 *
191 * @param eventType - Name of the event to listen to
192 * @param listener - Function to invoke when the specified event is
193 * emitted
194 * @param context - Optional context object to use when invoking the
195 * listener
196 */
197 addListener(eventType: string, listener: (...args: any[]) => any, context?: any): EmitterSubscription;
198
199 /**
200 * Removes all of the registered listeners, including those registered as
201 * listener maps.
202 *
203 * @param eventType - Optional name of the event whose registered
204 * listeners to remove
205 */
206 removeAllListeners(eventType?: string): void;
207
208 /**
209 * Removes a specific subscription. Called by the `remove()` method of the
210 * subscription itself to ensure any necessary cleanup is performed.
211 * @deprecated Use `remove` on the EventSubscription from `addListener`.
212 */
213 removeSubscription(subscription: EmitterSubscription): void;
214
215 /**
216 * Returns the number of listeners that are currently registered for the given
217 * event.
218 *
219 * @param eventType - Name of the event to query
220 */
221 listenerCount(eventType: string): number;
222
223 /**
224 * Emits an event of the given type with the given data. All handlers of that
225 * particular type will be notified.
226 *
227 * @param eventType - Name of the event to emit
228 * @param Arbitrary arguments to be passed to each registered listener
229 *
230 * @example
231 * emitter.addListener('someEvent', function(message) {
232 * console.log(message);
233 * });
234 *
235 * emitter.emit('someEvent', 'abc'); // logs 'abc'
236 */
237 emit(eventType: string, ...params: any[]): void;
238
239 /**
240 * Removes the given listener for event of specific type.
241 *
242 * @param eventType - Name of the event to emit
243 * @param listener - Function to invoke when the specified event is
244 * emitted
245 *
246 * @example
247 * emitter.removeListener('someEvent', function(message) {
248 * console.log(message);
249 * }); // removes the listener if already registered
250 * @deprecated Use `remove` on the EventSubscription from `addListener`.
251 */
252 removeListener(eventType: string, listener: (...args: any[]) => any): void;
253}
254
255/**
256 * NativeMethods provides methods to access the underlying native component directly.
257 * This can be useful in cases when you want to focus a view or measure its on-screen dimensions,
258 * for example.
259 * The methods described here are available on most of the default components provided by React Native.
260 * Note, however, that they are not available on composite components that aren't directly backed by a
261 * native view. This will generally include most components that you define in your own app.
262 * For more information, see [Direct Manipulation](https://reactnative.dev/docs/direct-manipulation).
263 * @see https://github.com/facebook/react-native/blob/master/Libraries/Renderer/shims/ReactNativeTypes.js#L87
264 */
265export interface NativeMethods {
266 /**
267 * Determines the location on screen, width, and height of the given view and
268 * returns the values via an async callback. If successful, the callback will
269 * be called with the following arguments:
270 *
271 * - x
272 * - y
273 * - width
274 * - height
275 * - pageX
276 * - pageY
277 *
278 * Note that these measurements are not available until after the rendering
279 * has been completed in native. If you need the measurements as soon as
280 * possible, consider using the [`onLayout`
281 * prop](docs/view.html#onlayout) instead.
282 */
283 measure(callback: MeasureOnSuccessCallback): void;
284
285 /**
286 * Determines the location of the given view in the window and returns the
287 * values via an async callback. If the React root view is embedded in
288 * another native view, this will give you the absolute coordinates. If
289 * successful, the callback will be called with the following
290 * arguments:
291 *
292 * - x
293 * - y
294 * - width
295 * - height
296 *
297 * Note that these measurements are not available until after the rendering
298 * has been completed in native.
299 */
300 measureInWindow(callback: MeasureInWindowOnSuccessCallback): void;
301
302 /**
303 * Like [`measure()`](#measure), but measures the view relative an ancestor,
304 * specified as `relativeToNativeComponentRef`. This means that the returned x, y
305 * are relative to the origin x, y of the ancestor view.
306 * _Can also be called with a relativeNativeNodeHandle but is deprecated._
307 */
308 measureLayout(
309 relativeToNativeComponentRef: HostComponent<unknown> | number,
310 onSuccess: MeasureLayoutOnSuccessCallback,
311 onFail: () => void /* currently unused */,
312 ): void;
313
314 /**
315 * This function sends props straight to native. They will not participate in
316 * future diff process - this means that if you do not include them in the
317 * next render, they will remain active (see [Direct
318 * Manipulation](https://reactnative.dev/docs/direct-manipulation)).
319 */
320 setNativeProps(nativeProps: object): void;
321
322 /**
323 * Requests focus for the given input or view. The exact behavior triggered
324 * will depend on the platform and type of view.
325 */
326 focus(): void;
327
328 /**
329 * Removes focus from an input or view. This is the opposite of `focus()`.
330 */
331 blur(): void;
332
333 refs: {
334 [key: string]: React.Component<any, any>;
335 };
336}
337
338/**
339 * @deprecated Use NativeMethods instead.
340 */
341export type NativeMethodsMixin = NativeMethods;
342/**
343 * @deprecated Use NativeMethods instead.
344 */
345export type NativeMethodsMixinType = NativeMethods;
346
347/**
348 * Represents a native component, such as those returned from `requireNativeComponent`.
349 *
350 * @see https://github.com/facebook/react-native/blob/v0.62.0-rc.5/Libraries/Renderer/shims/ReactNativeTypes.js
351 *
352 * @todo This should eventually be defined as an AbstractComponent, but that
353 * should first be introduced in the React typings.
354 */
355export interface HostComponent<P> extends Pick<React.ComponentClass<P>, Exclude<keyof React.ComponentClass<P>, 'new'>> {
356 new (props: P, context?: any): React.Component<P> & Readonly<NativeMethods>;
357}
358
359// see react-jsx.d.ts
360export function createElement<P>(
361 type: React.ReactType,
362 props?: P,
363 ...children: React.ReactNode[]
364): React.ReactElement<P>;
365
366export type Runnable = (appParameters: any) => void;
367
368type Task = (taskData: any) => Promise<void>;
369type TaskProvider = () => Task;
370
371type NodeHandle = number;
372
373// Similar to React.SyntheticEvent except for nativeEvent
374export interface NativeSyntheticEvent<T> extends React.BaseSyntheticEvent<T, NodeHandle, NodeHandle> {}
375
376export interface NativeTouchEvent {
377 /**
378 * Array of all touch events that have changed since the last event
379 */
380 changedTouches: NativeTouchEvent[];
381
382 /**
383 * The ID of the touch
384 */
385 identifier: string;
386
387 /**
388 * The X position of the touch, relative to the element
389 */
390 locationX: number;
391
392 /**
393 * The Y position of the touch, relative to the element
394 */
395 locationY: number;
396
397 /**
398 * The X position of the touch, relative to the screen
399 */
400 pageX: number;
401
402 /**
403 * The Y position of the touch, relative to the screen
404 */
405 pageY: number;
406
407 /**
408 * The node id of the element receiving the touch event
409 */
410 target: string;
411
412 /**
413 * A time identifier for the touch, useful for velocity calculation
414 */
415 timestamp: number;
416
417 /**
418 * Array of all current touches on the screen
419 */
420 touches: NativeTouchEvent[];
421
422 /**
423 * 3D Touch reported force
424 * @platform ios
425 */
426 force?: number | undefined;
427}
428
429export interface GestureResponderEvent extends NativeSyntheticEvent<NativeTouchEvent> {}
430
431// See https://reactnative.dev/docs/scrollview#contentoffset
432export interface PointPropType {
433 x: number;
434 y: number;
435}
436
437export interface Insets {
438 top?: number | undefined;
439 left?: number | undefined;
440 bottom?: number | undefined;
441 right?: number | undefined;
442}
443
444export interface PressableStateCallbackType {
445 readonly pressed: boolean;
446}
447
448export interface PressableAndroidRippleConfig {
449 color?: null | ColorValue | undefined;
450 borderless?: null | boolean | undefined;
451 radius?: null | number | undefined;
452}
453
454export interface PressableProps extends AccessibilityProps, Omit<ViewProps, 'style' | 'hitSlop'> {
455 /**
456 * Called when a single tap gesture is detected.
457 */
458 onPress?: null | ((event: GestureResponderEvent) => void) | undefined;
459
460 /**
461 * Called when a touch is engaged before `onPress`.
462 */
463 onPressIn?: null | ((event: GestureResponderEvent) => void) | undefined;
464
465 /**
466 * Called when a touch is released before `onPress`.
467 */
468 onPressOut?: null | ((event: GestureResponderEvent) => void) | undefined;
469
470 /**
471 * Called when a long-tap gesture is detected.
472 */
473 onLongPress?: null | ((event: GestureResponderEvent) => void) | undefined;
474
475 /**
476 * Called after the element loses focus.
477 * @platform windows
478 */
479 onBlur?: null | ((event: NativeSyntheticEvent<TargetedEvent>) => void) | undefined;
480
481 /**
482 * Called after the element is focused.
483 * @platform windows
484 */
485 onFocus?: null | ((event: NativeSyntheticEvent<TargetedEvent>) => void) | undefined;
486
487 /**
488 * Either children or a render prop that receives a boolean reflecting whether
489 * the component is currently pressed.
490 */
491 children?: React.ReactNode | ((state: PressableStateCallbackType) => React.ReactNode) | undefined;
492
493 /**
494 * Duration (in milliseconds) from `onPressIn` before `onLongPress` is called.
495 */
496 delayLongPress?: null | number | undefined;
497
498 /**
499 * Whether the press behavior is disabled.
500 */
501 disabled?: null | boolean | undefined;
502
503 /**
504 * Additional distance outside of this view in which a press is detected.
505 */
506 hitSlop?: null | Insets | number | undefined;
507
508 /**
509 * Additional distance outside of this view in which a touch is considered a
510 * press before `onPressOut` is triggered.
511 */
512 pressRetentionOffset?: null | Insets | number | undefined;
513
514 /**
515 * If true, doesn't play system sound on touch.
516 */
517 android_disableSound?: null | boolean | undefined;
518
519 /**
520 * Enables the Android ripple effect and configures its color.
521 */
522 android_ripple?: null | PressableAndroidRippleConfig | undefined;
523
524 /**
525 * Used only for documentation or testing (e.g. snapshot testing).
526 */
527 testOnly_pressed?: null | boolean | undefined;
528
529 /**
530 * Either view styles or a function that receives a boolean reflecting whether
531 * the component is currently pressed and returns view styles.
532 */
533 style?: StyleProp<ViewStyle> | ((state: PressableStateCallbackType) => StyleProp<ViewStyle>) | undefined;
534}
535
536// TODO use React.AbstractComponent when available
537export const Pressable: React.ForwardRefExoticComponent<PressableProps & React.RefAttributes<View>>;
538
539/**
540 * //FIXME: need to find documentation on which component is a TTouchable and can implement that interface
541 * @see React.DOMAtributes
542 */
543export interface Touchable {
544 onTouchStart?: ((event: GestureResponderEvent) => void) | undefined;
545 onTouchMove?: ((event: GestureResponderEvent) => void) | undefined;
546 onTouchEnd?: ((event: GestureResponderEvent) => void) | undefined;
547 onTouchCancel?: ((event: GestureResponderEvent) => void) | undefined;
548 onTouchEndCapture?: ((event: GestureResponderEvent) => void) | undefined;
549}
550export const Touchable: {
551 TOUCH_TARGET_DEBUG: boolean;
552 renderDebugView: (config: { color: string | number; hitSlop?: Insets | undefined }) => React.ReactElement | null;
553};
554
555export type ComponentProvider = () => React.ComponentType<any>;
556
557export type AppConfig = {
558 appKey: string;
559 component?: ComponentProvider | undefined;
560 run?: Runnable | undefined;
561};
562
563// https://github.com/facebook/react-native/blob/master/Libraries/ReactNative/AppRegistry.js
564/**
565 * `AppRegistry` is the JS entry point to running all React Native apps. App
566 * root components should register themselves with
567 * `AppRegistry.registerComponent`, then the native system can load the bundle
568 * for the app and then actually run the app when it's ready by invoking
569 * `AppRegistry.runApplication`.
570 *
571 * To "stop" an application when a view should be destroyed, call
572 * `AppRegistry.unmountApplicationComponentAtRootTag` with the tag that was
573 * pass into `runApplication`. These should always be used as a pair.
574 *
575 * `AppRegistry` should be `require`d early in the `require` sequence to make
576 * sure the JS execution environment is setup before other modules are
577 * `require`d.
578 */
579export namespace AppRegistry {
580 function registerConfig(config: AppConfig[]): void;
581
582 function registerComponent(appKey: string, getComponentFunc: ComponentProvider): string;
583
584 function registerRunnable(appKey: string, func: Runnable): string;
585
586 function getAppKeys(): string[];
587
588 function unmountApplicationComponentAtRootTag(rootTag: number): void;
589
590 function runApplication(appKey: string, appParameters: any): void;
591
592 function registerHeadlessTask(appKey: string, task: TaskProvider): void;
593
594 function getRunnable(appKey: string): Runnable | undefined;
595}
596
597export type LayoutAnimationType =
598 | 'spring'
599 | 'linear'
600 | 'easeInEaseOut'
601 | 'easeIn'
602 | 'easeOut'
603 | 'keyboard';
604
605export type LayoutAnimationTypes = {
606 [type in LayoutAnimationType]: type;
607}
608
609export type LayoutAnimationProperty =
610 | 'opacity'
611 | 'scaleX'
612 | 'scaleY'
613 | 'scaleXY';
614
615export type LayoutAnimationProperties = {
616 [prop in LayoutAnimationProperty]: prop;
617}
618
619export interface LayoutAnimationAnim {
620 duration?: number | undefined;
621 delay?: number | undefined;
622 springDamping?: number | undefined;
623 initialVelocity?: number | undefined;
624 type?: LayoutAnimationType | undefined;
625 property?: LayoutAnimationProperty | undefined;
626}
627
628export interface LayoutAnimationConfig {
629 duration: number;
630 create?: LayoutAnimationAnim | undefined;
631 update?: LayoutAnimationAnim | undefined;
632 delete?: LayoutAnimationAnim | undefined;
633}
634
635/** Automatically animates views to their new positions when the next layout happens.
636 * A common way to use this API is to call LayoutAnimation.configureNext before
637 * calling setState. */
638export interface LayoutAnimationStatic {
639 /** Schedules an animation to happen on the next layout.
640 * @param config Specifies animation properties:
641 * `duration` in milliseconds
642 * `create`, config for animating in new views (see Anim type)
643 * `update`, config for animating views that have been updated (see Anim type)
644 * @param onAnimationDidEnd Called when the animation finished. Only supported on iOS.
645 */
646 configureNext: (
647 config: LayoutAnimationConfig,
648 onAnimationDidEnd?: () => void,
649 onAnimationDidFail?: () => void,
650 ) => void;
651 /** Helper for creating a config for configureNext. */
652 create: (
653 duration: number,
654 type?: LayoutAnimationType,
655 creationProp?: LayoutAnimationProperty
656 ) => LayoutAnimationConfig;
657 Types: LayoutAnimationTypes;
658 Properties: LayoutAnimationProperties;
659 configChecker: (shapeTypes: { [key: string]: any }) => any;
660 Presets: {
661 easeInEaseOut: LayoutAnimationConfig;
662 linear: LayoutAnimationConfig;
663 spring: LayoutAnimationConfig;
664 };
665 easeInEaseOut: (onAnimationDidEnd?: () => void) => void;
666 linear: (onAnimationDidEnd?: () => void) => void;
667 spring: (onAnimationDidEnd?: () => void) => void;
668}
669
670type FlexAlignType = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
671
672/**
673 * Flex Prop Types
674 * @see https://reactnative.dev/docs/flexbox#proptypes
675 * @see https://reactnative.dev/docs/layout-props
676 * @see https://github.com/facebook/react-native/blob/master/Libraries/StyleSheet/LayoutPropTypes.js
677 */
678export interface FlexStyle {
679 alignContent?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'space-between' | 'space-around' | undefined;
680 alignItems?: FlexAlignType | undefined;
681 alignSelf?: 'auto' | FlexAlignType | undefined;
682 aspectRatio?: number | undefined;
683 borderBottomWidth?: number | undefined;
684 borderEndWidth?: number | string | undefined;
685 borderLeftWidth?: number | undefined;
686 borderRightWidth?: number | undefined;
687 borderStartWidth?: number | string | undefined;
688 borderTopWidth?: number | undefined;
689 borderWidth?: number | undefined;
690 bottom?: number | string | undefined;
691 display?: 'none' | 'flex' | undefined;
692 end?: number | string | undefined;
693 flex?: number | undefined;
694 flexBasis?: number | string | undefined;
695 flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse' | undefined;
696 flexGrow?: number | undefined;
697 flexShrink?: number | undefined;
698 flexWrap?: 'wrap' | 'nowrap' | 'wrap-reverse' | undefined;
699 height?: number | string | undefined;
700 justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly' | undefined;
701 left?: number | string | undefined;
702 margin?: number | string | undefined;
703 marginBottom?: number | string | undefined;
704 marginEnd?: number | string | undefined;
705 marginHorizontal?: number | string | undefined;
706 marginLeft?: number | string | undefined;
707 marginRight?: number | string | undefined;
708 marginStart?: number | string | undefined;
709 marginTop?: number | string | undefined;
710 marginVertical?: number | string | undefined;
711 maxHeight?: number | string | undefined;
712 maxWidth?: number | string | undefined;
713 minHeight?: number | string | undefined;
714 minWidth?: number | string | undefined;
715 overflow?: 'visible' | 'hidden' | 'scroll' | undefined;
716 padding?: number | string | undefined;
717 paddingBottom?: number | string | undefined;
718 paddingEnd?: number | string | undefined;
719 paddingHorizontal?: number | string | undefined;
720 paddingLeft?: number | string | undefined;
721 paddingRight?: number | string | undefined;
722 paddingStart?: number | string | undefined;
723 paddingTop?: number | string | undefined;
724 paddingVertical?: number | string | undefined;
725 position?: 'absolute' | 'relative' | undefined;
726 right?: number | string | undefined;
727 start?: number | string | undefined;
728 top?: number | string | undefined;
729 width?: number | string | undefined;
730 zIndex?: number | undefined;
731
732 /**
733 * @platform ios
734 */
735 direction?: 'inherit' | 'ltr' | 'rtl' | undefined;
736}
737
738/**
739 * @see ShadowPropTypesIOS.js
740 */
741export interface ShadowPropTypesIOSStatic {
742 /**
743 * Sets the drop shadow color
744 * @platform ios
745 */
746 shadowColor: ColorValue;
747
748 /**
749 * Sets the drop shadow offset
750 * @platform ios
751 */
752 shadowOffset: { width: number; height: number };
753
754 /**
755 * Sets the drop shadow opacity (multiplied by the color's alpha component)
756 * @platform ios
757 */
758 shadowOpacity: number;
759
760 /**
761 * Sets the drop shadow blur radius
762 * @platform ios
763 */
764 shadowRadius: number;
765}
766
767interface PerpectiveTransform {
768 perspective: number;
769}
770
771interface RotateTransform {
772 rotate: string;
773}
774
775interface RotateXTransform {
776 rotateX: string;
777}
778
779interface RotateYTransform {
780 rotateY: string;
781}
782
783interface RotateZTransform {
784 rotateZ: string;
785}
786
787interface ScaleTransform {
788 scale: number;
789}
790
791interface ScaleXTransform {
792 scaleX: number;
793}
794
795interface ScaleYTransform {
796 scaleY: number;
797}
798
799interface TranslateXTransform {
800 translateX: number;
801}
802
803interface TranslateYTransform {
804 translateY: number;
805}
806
807interface SkewXTransform {
808 skewX: string;
809}
810
811interface SkewYTransform {
812 skewY: string;
813}
814
815interface MatrixTransform {
816 matrix: number[];
817}
818
819export interface TransformsStyle {
820 transform?: (
821 | PerpectiveTransform
822 | RotateTransform
823 | RotateXTransform
824 | RotateYTransform
825 | RotateZTransform
826 | ScaleTransform
827 | ScaleXTransform
828 | ScaleYTransform
829 | TranslateXTransform
830 | TranslateYTransform
831 | SkewXTransform
832 | SkewYTransform
833 | MatrixTransform
834 )[] | undefined;
835 /**
836 * @deprecated Use matrix in transform prop instead.
837 */
838 transformMatrix?: Array<number> | undefined;
839 /**
840 * @deprecated Use rotate in transform prop instead.
841 */
842 rotation?: number | undefined;
843 /**
844 * @deprecated Use scaleX in transform prop instead.
845 */
846 scaleX?: number | undefined;
847 /**
848 * @deprecated Use scaleY in transform prop instead.
849 */
850 scaleY?: number | undefined;
851 /**
852 * @deprecated Use translateX in transform prop instead.
853 */
854 translateX?: number | undefined;
855 /**
856 * @deprecated Use translateY in transform prop instead.
857 */
858 translateY?: number | undefined;
859}
860
861export interface StyleSheetProperties {
862 hairlineWidth: number;
863 flatten<T extends string>(style: T): T;
864}
865
866export interface LayoutRectangle {
867 x: number;
868 y: number;
869 width: number;
870 height: number;
871}
872
873// @see TextProps.onLayout
874export type LayoutChangeEvent = NativeSyntheticEvent<{ layout: LayoutRectangle }>;
875
876interface TextLayoutLine {
877 ascender: number;
878 capHeight: number;
879 descender: number;
880 height: number;
881 text: string;
882 width: number;
883 x: number;
884 xHeight: number;
885 y: number;
886}
887
888/**
889 * @see TextProps.onTextLayout
890 */
891export interface TextLayoutEventData extends TargetedEvent {
892 lines: TextLayoutLine[];
893}
894
895export type FontVariant = 'small-caps' | 'oldstyle-nums' | 'lining-nums' | 'tabular-nums' | 'proportional-nums';
896export interface TextStyleIOS extends ViewStyle {
897 fontVariant?: FontVariant[] | undefined;
898 letterSpacing?: number | undefined;
899 textDecorationColor?: ColorValue | undefined;
900 textDecorationStyle?: 'solid' | 'double' | 'dotted' | 'dashed' | undefined;
901 writingDirection?: 'auto' | 'ltr' | 'rtl' | undefined;
902}
903
904export interface TextStyleAndroid extends ViewStyle {
905 textAlignVertical?: 'auto' | 'top' | 'bottom' | 'center' | undefined;
906 includeFontPadding?: boolean | undefined;
907}
908
909// @see https://reactnative.dev/docs/text#style
910export interface TextStyle extends TextStyleIOS, TextStyleAndroid, ViewStyle {
911 color?: ColorValue | undefined;
912 fontFamily?: string | undefined;
913 fontSize?: number | undefined;
914 fontStyle?: 'normal' | 'italic' | undefined;
915 /**
916 * Specifies font weight. The values 'normal' and 'bold' are supported
917 * for most fonts. Not all fonts have a variant for each of the numeric
918 * values, in that case the closest one is chosen.
919 */
920 fontWeight?: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | undefined;
921 letterSpacing?: number | undefined;
922 lineHeight?: number | undefined;
923 textAlign?: 'auto' | 'left' | 'right' | 'center' | 'justify' | undefined;
924 textDecorationLine?: 'none' | 'underline' | 'line-through' | 'underline line-through' | undefined;
925 textDecorationStyle?: 'solid' | 'double' | 'dotted' | 'dashed' | undefined;
926 textDecorationColor?: ColorValue | undefined;
927 textShadowColor?: ColorValue | undefined;
928 textShadowOffset?: { width: number; height: number } | undefined;
929 textShadowRadius?: number | undefined;
930 textTransform?: 'none' | 'capitalize' | 'uppercase' | 'lowercase' | undefined;
931 testID?: string | undefined;
932}
933
934export interface TextPropsIOS {
935 /**
936 * Specifies whether font should be scaled down automatically to fit given style constraints.
937 */
938 adjustsFontSizeToFit?: boolean | undefined;
939
940 /**
941 * Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).
942 */
943 minimumFontScale?: number | undefined;
944
945 /**
946 * When `true`, no visual change is made when text is pressed down. By
947 * default, a gray oval highlights the text on press down.
948 */
949 suppressHighlighting?: boolean | undefined;
950}
951
952export interface TextPropsAndroid {
953 /**
954 * Lets the user select text, to use the native copy and paste functionality.
955 */
956 selectable?: boolean | undefined;
957
958 /**
959 * The highlight color of the text.
960 */
961 selectionColor?: ColorValue | undefined;
962
963 /**
964 * Set text break strategy on Android API Level 23+
965 * default is `highQuality`.
966 */
967 textBreakStrategy?: 'simple' | 'highQuality' | 'balanced' | undefined;
968
969 /**
970 * Determines the types of data converted to clickable URLs in the text element.
971 * By default no data types are detected.
972 */
973 dataDetectorType?: null | 'phoneNumber' | 'link' | 'email' | 'none' | 'all' | undefined;
974
975 /**
976 * Hyphenation strategy
977 */
978 android_hyphenationFrequency?:
979 | 'normal'
980 | 'none'
981 | 'full'
982 | 'high'
983 | 'balanced' | undefined;
984}
985
986// https://reactnative.dev/docs/text#props
987export interface TextProps extends TextPropsIOS, TextPropsAndroid, AccessibilityProps {
988 /**
989 * Specifies whether fonts should scale to respect Text Size accessibility settings.
990 * The default is `true`.
991 */
992 allowFontScaling?: boolean | undefined;
993
994 /**
995 * This can be one of the following values:
996 *
997 * - `head` - The line is displayed so that the end fits in the container and the missing text
998 * at the beginning of the line is indicated by an ellipsis glyph. e.g., "...wxyz"
999 * - `middle` - The line is displayed so that the beginning and end fit in the container and the
1000 * missing text in the middle is indicated by an ellipsis glyph. "ab...yz"
1001 * - `tail` - The line is displayed so that the beginning fits in the container and the
1002 * missing text at the end of the line is indicated by an ellipsis glyph. e.g., "abcd..."
1003 * - `clip` - Lines are not drawn past the edge of the text container.
1004 *
1005 * The default is `tail`.
1006 *
1007 * `numberOfLines` must be set in conjunction with this prop.
1008 *
1009 * > `clip` is working only for iOS
1010 */
1011 ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip' | undefined;
1012
1013 /**
1014 * Line Break mode. Works only with numberOfLines.
1015 * clip is working only for iOS
1016 */
1017 lineBreakMode?: 'head' | 'middle' | 'tail' | 'clip' | undefined;
1018
1019 /**
1020 * Used to truncate the text with an ellipsis after computing the text
1021 * layout, including line wrapping, such that the total number of lines
1022 * does not exceed this number.
1023 *
1024 * This prop is commonly used with `ellipsizeMode`.
1025 */
1026 numberOfLines?: number | undefined;
1027
1028 /**
1029 * Invoked on mount and layout changes with
1030 *
1031 * {nativeEvent: { layout: {x, y, width, height}}}.
1032 */
1033 onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
1034
1035 /**
1036 * Invoked on Text layout
1037 */
1038 onTextLayout?: ((event: NativeSyntheticEvent<TextLayoutEventData>) => void) | undefined;
1039
1040 /**
1041 * This function is called on press.
1042 * Text intrinsically supports press handling with a default highlight state (which can be disabled with suppressHighlighting).
1043 */
1044 onPress?: ((event: GestureResponderEvent) => void) | undefined;
1045
1046 /**
1047 * This function is called on long press.
1048 * e.g., `onLongPress={this.increaseSize}>``
1049 */
1050 onLongPress?: ((event: GestureResponderEvent) => void) | undefined;
1051
1052 /**
1053 * @see https://reactnative.dev/docs/text#style
1054 */
1055 style?: StyleProp<TextStyle> | undefined;
1056
1057 /**
1058 * Used to locate this view in end-to-end tests.
1059 */
1060 testID?: string | undefined;
1061
1062 /**
1063 * Used to reference react managed views from native code.
1064 */
1065 nativeID?: string | undefined;
1066
1067 /**
1068 * Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values:
1069 * - null/undefined (default): inherit from the parent node or the global default (0)
1070 * - 0: no max, ignore parent/global default
1071 * - >= 1: sets the maxFontSizeMultiplier of this node to this value
1072 */
1073 maxFontSizeMultiplier?: number | null | undefined;
1074}
1075
1076/**
1077 * A React component for displaying text which supports nesting, styling, and touch handling.
1078 */
1079declare class TextComponent extends React.Component<TextProps> {}
1080declare const TextBase: Constructor<NativeMethods> & typeof TextComponent;
1081export class Text extends TextBase {}
1082
1083type DataDetectorTypes = 'phoneNumber' | 'link' | 'address' | 'calendarEvent' | 'none' | 'all';
1084
1085/**
1086 * DocumentSelectionState is responsible for maintaining selection information
1087 * for a document.
1088 *
1089 * It is intended for use by AbstractTextEditor-based components for
1090 * identifying the appropriate start/end positions to modify the
1091 * DocumentContent, and for programmatically setting browser selection when
1092 * components re-render.
1093 */
1094export interface DocumentSelectionState extends EventEmitter {
1095 new (anchor: number, focus: number): DocumentSelectionState;
1096
1097 /**
1098 * Apply an update to the state. If either offset value has changed,
1099 * set the values and emit the `change` event. Otherwise no-op.
1100 *
1101 */
1102 update(anchor: number, focus: number): void;
1103
1104 /**
1105 * Given a max text length, constrain our selection offsets to ensure
1106 * that the selection remains strictly within the text range.
1107 *
1108 */
1109 constrainLength(maxLength: number): void;
1110
1111 focus(): void;
1112 blur(): void;
1113 hasFocus(): boolean;
1114 isCollapsed(): boolean;
1115 isBackward(): boolean;
1116
1117 getAnchorOffset(): number;
1118 getFocusOffset(): number;
1119 getStartOffset(): number;
1120 getEndOffset(): number;
1121 overlaps(start: number, end: number): boolean;
1122}
1123
1124/**
1125 * IOS Specific properties for TextInput
1126 * @see https://reactnative.dev/docs/textinput#props
1127 */
1128export interface TextInputIOSProps {
1129 /**
1130 * enum('never', 'while-editing', 'unless-editing', 'always')
1131 * When the clear button should appear on the right side of the text view
1132 */
1133 clearButtonMode?: 'never' | 'while-editing' | 'unless-editing' | 'always' | undefined;
1134
1135 /**
1136 * If true, clears the text field automatically when editing begins
1137 */
1138 clearTextOnFocus?: boolean | undefined;
1139
1140 /**
1141 * Determines the types of data converted to clickable URLs in the text input.
1142 * Only valid if `multiline={true}` and `editable={false}`.
1143 * By default no data types are detected.
1144 *
1145 * You can provide one type or an array of many types.
1146 *
1147 * Possible values for `dataDetectorTypes` are:
1148 *
1149 * - `'phoneNumber'`
1150 * - `'link'`
1151 * - `'address'`
1152 * - `'calendarEvent'`
1153 * - `'none'`
1154 * - `'all'`
1155 */
1156 dataDetectorTypes?: DataDetectorTypes | DataDetectorTypes[] | undefined;
1157
1158 /**
1159 * If true, the keyboard disables the return key when there is no text and automatically enables it when there is text.
1160 * The default value is false.
1161 */
1162 enablesReturnKeyAutomatically?: boolean | undefined;
1163
1164 /**
1165 * Determines the color of the keyboard.
1166 */
1167 keyboardAppearance?: 'default' | 'light' | 'dark' | undefined;
1168
1169 /**
1170 * Provide rules for your password.
1171 * For example, say you want to require a password with at least eight characters consisting of a mix of uppercase and lowercase letters, at least one number, and at most two consecutive characters.
1172 * "required: upper; required: lower; required: digit; max-consecutive: 2; minlength: 8;"
1173 */
1174 passwordRules?: string | null | undefined;
1175
1176 /**
1177 * If `true`, allows TextInput to pass touch events to the parent component.
1178 * This allows components to be swipeable from the TextInput on iOS,
1179 * as is the case on Android by default.
1180 * If `false`, TextInput always asks to handle the input (except when disabled).
1181 */
1182 rejectResponderTermination?: boolean | null | undefined;
1183
1184 /**
1185 * See DocumentSelectionState.js, some state that is responsible for maintaining selection information for a document
1186 */
1187 selectionState?: DocumentSelectionState | undefined;
1188
1189 /**
1190 * If false, disables spell-check style (i.e. red underlines). The default value is inherited from autoCorrect
1191 */
1192 spellCheck?: boolean | undefined;
1193
1194 /**
1195 * Give the keyboard and the system information about the expected
1196 * semantic meaning for the content that users enter.
1197 *
1198 * For iOS 11+ you can set `textContentType` to `username` or `password` to
1199 * enable autofill of login details from the device keychain.
1200 *
1201 * For iOS 12+ `newPassword` can be used to indicate a new password input the
1202 * user may want to save in the keychain, and `oneTimeCode` can be used to indicate
1203 * that a field can be autofilled by a code arriving in an SMS.
1204 *
1205 * To disable autofill, set textContentType to `none`.
1206 *
1207 * Possible values for `textContentType` are:
1208 *
1209 * - `'none'`
1210 * - `'URL'`
1211 * - `'addressCity'`
1212 * - `'addressCityAndState'`
1213 * - `'addressState'`
1214 * - `'countryName'`
1215 * - `'creditCardNumber'`
1216 * - `'emailAddress'`
1217 * - `'familyName'`
1218 * - `'fullStreetAddress'`
1219 * - `'givenName'`
1220 * - `'jobTitle'`
1221 * - `'location'`
1222 * - `'middleName'`
1223 * - `'name'`
1224 * - `'namePrefix'`
1225 * - `'nameSuffix'`
1226 * - `'nickname'`
1227 * - `'organizationName'`
1228 * - `'postalCode'`
1229 * - `'streetAddressLine1'`
1230 * - `'streetAddressLine2'`
1231 * - `'sublocality'`
1232 * - `'telephoneNumber'`
1233 * - `'username'`
1234 * - `'password'`
1235 * - `'newPassword'`
1236 * - `'oneTimeCode'`
1237 *
1238 */
1239 textContentType?:
1240 | 'none'
1241 | 'URL'
1242 | 'addressCity'
1243 | 'addressCityAndState'
1244 | 'addressState'
1245 | 'countryName'
1246 | 'creditCardNumber'
1247 | 'emailAddress'
1248 | 'familyName'
1249 | 'fullStreetAddress'
1250 | 'givenName'
1251 | 'jobTitle'
1252 | 'location'
1253 | 'middleName'
1254 | 'name'
1255 | 'namePrefix'
1256 | 'nameSuffix'
1257 | 'nickname'
1258 | 'organizationName'
1259 | 'postalCode'
1260 | 'streetAddressLine1'
1261 | 'streetAddressLine2'
1262 | 'sublocality'
1263 | 'telephoneNumber'
1264 | 'username'
1265 | 'password'
1266 | 'newPassword'
1267 | 'oneTimeCode' | undefined;
1268
1269 /**
1270 * If false, scrolling of the text view will be disabled. The default value is true. Only works with multiline={true}
1271 */
1272 scrollEnabled?: boolean | undefined;
1273}
1274
1275/**
1276 * Android Specific properties for TextInput
1277 * @see https://reactnative.dev/docs/textinput#props
1278 */
1279export interface TextInputAndroidProps {
1280 /**
1281 * Determines which content to suggest on auto complete, e.g.`username`.
1282 * To disable auto complete, use `off`.
1283 *
1284 * *Android Only*
1285 *
1286 * The following values work on Android only:
1287 *
1288 * - `username`
1289 * - `password`
1290 * - `email`
1291 * - `name`
1292 * - `tel`
1293 * - `street-address`
1294 * - `postal-code`
1295 * - `cc-number`
1296 * - `cc-csc`
1297 * - `cc-exp`
1298 * - `cc-exp-month`
1299 * - `cc-exp-year`
1300 * - `off`
1301 */
1302 autoCompleteType?:
1303 | 'cc-csc'
1304 | 'cc-exp'
1305 | 'cc-exp-month'
1306 | 'cc-exp-year'
1307 | 'cc-number'
1308 | 'email'
1309 | 'name'
1310 | 'password'
1311 | 'postal-code'
1312 | 'street-address'
1313 | 'tel'
1314 | 'username'
1315 | 'off' | undefined;
1316
1317 /**
1318 * Determines whether the individual fields in your app should be included in a
1319 * view structure for autofill purposes on Android API Level 26+. Defaults to auto.
1320 * To disable auto complete, use `off`.
1321 *
1322 * *Android Only*
1323 *
1324 * The following values work on Android only:
1325 *
1326 * - `auto` - let Android decide
1327 * - `no` - not important for autofill
1328 * - `noExcludeDescendants` - this view and its children aren't important for autofill
1329 * - `yes` - is important for autofill
1330 * - `yesExcludeDescendants` - this view is important for autofill but its children aren't
1331 */
1332 importantForAutofill?: 'auto' | 'no' | 'noExcludeDescendants' | 'yes' | 'yesExcludeDescendants' | undefined;
1333
1334 /**
1335 * When false, if there is a small amount of space available around a text input (e.g. landscape orientation on a phone),
1336 * the OS may choose to have the user edit the text inside of a full screen text input mode.
1337 * When true, this feature is disabled and users will always edit the text directly inside of the text input.
1338 * Defaults to false.
1339 */
1340 disableFullscreenUI?: boolean | undefined;
1341
1342 /**
1343 * If defined, the provided image resource will be rendered on the left.
1344 */
1345 inlineImageLeft?: string | undefined;
1346
1347 /**
1348 * Padding between the inline image, if any, and the text input itself.
1349 */
1350 inlineImagePadding?: number | undefined;
1351
1352 /**
1353 * Sets the number of lines for a TextInput.
1354 * Use it with multiline set to true to be able to fill the lines.
1355 */
1356 numberOfLines?: number | undefined;
1357
1358 /**
1359 * Sets the return key to the label. Use it instead of `returnKeyType`.
1360 * @platform android
1361 */
1362 returnKeyLabel?: string | undefined;
1363
1364 /**
1365 * Set text break strategy on Android API Level 23+, possible values are simple, highQuality, balanced
1366 * The default value is simple.
1367 */
1368 textBreakStrategy?: 'simple' | 'highQuality' | 'balanced' | undefined;
1369
1370 /**
1371 * The color of the textInput underline.
1372 */
1373 underlineColorAndroid?: ColorValue | undefined;
1374
1375 /**
1376 * Vertically align text when `multiline` is set to true
1377 */
1378 textAlignVertical?: 'auto' | 'top' | 'bottom' | 'center' | undefined;
1379
1380 /**
1381 * When false, it will prevent the soft keyboard from showing when the field is focused. The default value is true
1382 */
1383 showSoftInputOnFocus?: boolean | undefined;
1384}
1385
1386export type KeyboardType = 'default' | 'email-address' | 'numeric' | 'phone-pad' | 'number-pad' | 'decimal-pad';
1387export type KeyboardTypeIOS =
1388 | 'ascii-capable'
1389 | 'numbers-and-punctuation'
1390 | 'url'
1391 | 'name-phone-pad'
1392 | 'twitter'
1393 | 'web-search';
1394export type KeyboardTypeAndroid = 'visible-password';
1395export type KeyboardTypeOptions = KeyboardType | KeyboardTypeAndroid | KeyboardTypeIOS;
1396
1397export type ReturnKeyType = 'done' | 'go' | 'next' | 'search' | 'send';
1398export type ReturnKeyTypeAndroid = 'none' | 'previous';
1399export type ReturnKeyTypeIOS = 'default' | 'google' | 'join' | 'route' | 'yahoo' | 'emergency-call';
1400export type ReturnKeyTypeOptions = ReturnKeyType | ReturnKeyTypeAndroid | ReturnKeyTypeIOS;
1401
1402export interface TargetedEvent {
1403 target: number;
1404}
1405
1406/**
1407 * @see TextInputProps.onFocus
1408 */
1409export interface TextInputFocusEventData extends TargetedEvent {
1410 text: string;
1411 eventCount: number;
1412}
1413
1414/**
1415 * @see TextInputProps.onScroll
1416 */
1417export interface TextInputScrollEventData {
1418 contentOffset: { x: number; y: number };
1419}
1420
1421/**
1422 * @see TextInputProps.onSelectionChange
1423 */
1424export interface TextInputSelectionChangeEventData extends TargetedEvent {
1425 selection: {
1426 start: number;
1427 end: number;
1428 };
1429}
1430
1431/**
1432 * @see TextInputProps.onKeyPress
1433 */
1434export interface TextInputKeyPressEventData {
1435 key: string;
1436}
1437
1438/**
1439 * @see TextInputProps.onChange
1440 */
1441export interface TextInputChangeEventData extends TargetedEvent {
1442 eventCount: number;
1443 text: string;
1444}
1445
1446/**
1447 * @see TextInputProps.onContentSizeChange
1448 */
1449export interface TextInputContentSizeChangeEventData {
1450 contentSize: { width: number; height: number };
1451}
1452
1453/**
1454 * @see TextInputProps.onEndEditing
1455 */
1456export interface TextInputEndEditingEventData {
1457 text: string;
1458}
1459
1460/**
1461 * @see TextInputProps.onSubmitEditing
1462 */
1463export interface TextInputSubmitEditingEventData {
1464 text: string;
1465}
1466
1467/**
1468 * @see TextInputProps.onTextInput
1469 */
1470export interface TextInputTextInputEventData {
1471 text: string;
1472 previousText: string;
1473 range: { start: number; end: number };
1474}
1475
1476/**
1477 * @see https://reactnative.dev/docs/textinput#props
1478 */
1479export interface TextInputProps extends ViewProps, TextInputIOSProps, TextInputAndroidProps, AccessibilityProps {
1480 /**
1481 * Specifies whether fonts should scale to respect Text Size accessibility settings.
1482 * The default is `true`.
1483 */
1484 allowFontScaling?: boolean | undefined;
1485
1486 /**
1487 * Can tell TextInput to automatically capitalize certain characters.
1488 * characters: all characters,
1489 * words: first letter of each word
1490 * sentences: first letter of each sentence (default)
1491 * none: don't auto capitalize anything
1492 *
1493 * https://reactnative.dev/docs/textinput#autocapitalize
1494 */
1495 autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters' | undefined;
1496
1497 /**
1498 * If false, disables auto-correct.
1499 * The default value is true.
1500 */
1501 autoCorrect?: boolean | undefined;
1502
1503 /**
1504 * If true, focuses the input on componentDidMount.
1505 * The default value is false.
1506 */
1507 autoFocus?: boolean | undefined;
1508
1509 /**
1510 * If true, the text field will blur when submitted.
1511 * The default value is true.
1512 */
1513 blurOnSubmit?: boolean | undefined;
1514
1515 /**
1516 * If true, caret is hidden. The default value is false.
1517 */
1518 caretHidden?: boolean | undefined;
1519
1520 /**
1521 * If true, context menu is hidden. The default value is false.
1522 */
1523 contextMenuHidden?: boolean | undefined;
1524
1525 /**
1526 * Provides an initial value that will change when the user starts typing.
1527 * Useful for simple use-cases where you don't want to deal with listening to events
1528 * and updating the value prop to keep the controlled state in sync.
1529 */
1530 defaultValue?: string | undefined;
1531
1532 /**
1533 * If false, text is not editable. The default value is true.
1534 */
1535 editable?: boolean | undefined;
1536
1537 /**
1538 * enum("default", 'numeric', 'email-address', "ascii-capable", 'numbers-and-punctuation', 'url', 'number-pad', 'phone-pad', 'name-phone-pad',
1539 * 'decimal-pad', 'twitter', 'web-search', 'visible-password')
1540 * Determines which keyboard to open, e.g.numeric.
1541 * The following values work across platforms: - default - numeric - email-address - phone-pad
1542 * The following values work on iOS: - ascii-capable - numbers-and-punctuation - url - number-pad - name-phone-pad - decimal-pad - twitter - web-search
1543 * The following values work on Android: - visible-password
1544 */
1545 keyboardType?: KeyboardTypeOptions | undefined;
1546
1547 /**
1548 * Limits the maximum number of characters that can be entered.
1549 * Use this instead of implementing the logic in JS to avoid flicker.
1550 */
1551 maxLength?: number | undefined;
1552
1553 /**
1554 * If true, the text input can be multiple lines. The default value is false.
1555 */
1556 multiline?: boolean | undefined;
1557
1558 /**
1559 * Callback that is called when the text input is blurred
1560 */
1561 onBlur?: ((e: NativeSyntheticEvent<TextInputFocusEventData>) => void) | undefined;
1562
1563 /**
1564 * Callback that is called when the text input's text changes.
1565 */
1566 onChange?: ((e: NativeSyntheticEvent<TextInputChangeEventData>) => void) | undefined;
1567
1568 /**
1569 * Callback that is called when the text input's text changes.
1570 * Changed text is passed as an argument to the callback handler.
1571 */
1572 onChangeText?: ((text: string) => void) | undefined;
1573
1574 /**
1575 * Callback that is called when the text input's content size changes.
1576 * This will be called with
1577 * `{ nativeEvent: { contentSize: { width, height } } }`.
1578 *
1579 * Only called for multiline text inputs.
1580 */
1581 onContentSizeChange?: ((e: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => void) | undefined;
1582
1583 /**
1584 * Callback that is called when text input ends.
1585 */
1586 onEndEditing?: ((e: NativeSyntheticEvent<TextInputEndEditingEventData>) => void) | undefined;
1587
1588 /**
1589 * Callback that is called when a touch is engaged.
1590 */
1591 onPressIn?: ((e: NativeSyntheticEvent<NativeTouchEvent>) => void) | undefined;
1592
1593 /**
1594 * Callback that is called when a touch is released.
1595 */
1596 onPressOut?: ((e: NativeSyntheticEvent<NativeTouchEvent>) => void) | undefined;
1597
1598 /**
1599 * Callback that is called when the text input is focused
1600 */
1601 onFocus?: ((e: NativeSyntheticEvent<TextInputFocusEventData>) => void) | undefined;
1602
1603 /**
1604 * Callback that is called when the text input selection is changed.
1605 */
1606 onSelectionChange?: ((e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => void) | undefined;
1607
1608 /**
1609 * Callback that is called when the text input's submit button is pressed.
1610 */
1611 onSubmitEditing?: ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void) | undefined;
1612
1613 /**
1614 * Callback that is called on new text input with the argument
1615 * `{ nativeEvent: { text, previousText, range: { start, end } } }`.
1616 *
1617 * This prop requires multiline={true} to be set.
1618 */
1619 onTextInput?: ((e: NativeSyntheticEvent<TextInputTextInputEventData>) => void) | undefined;
1620
1621 /**
1622 * Invoked on content scroll with
1623 * `{ nativeEvent: { contentOffset: { x, y } } }`.
1624 *
1625 * May also contain other properties from ScrollEvent but on Android contentSize is not provided for performance reasons.
1626 */
1627 onScroll?: ((e: NativeSyntheticEvent<TextInputScrollEventData>) => void) | undefined;
1628
1629 /**
1630 * Callback that is called when a key is pressed.
1631 * This will be called with
1632 * `{ nativeEvent: { key: keyValue } }`
1633 * where keyValue is 'Enter' or 'Backspace' for respective keys and the typed-in character otherwise including ' ' for space.
1634 *
1635 * Fires before onChange callbacks.
1636 * Note: on Android only the inputs from soft keyboard are handled, not the hardware keyboard inputs.
1637 */
1638 onKeyPress?: ((e: NativeSyntheticEvent<TextInputKeyPressEventData>) => void) | undefined;
1639
1640 /**
1641 * The string that will be rendered before text input has been entered
1642 */
1643 placeholder?: string | undefined;
1644
1645 /**
1646 * The text color of the placeholder string
1647 */
1648 placeholderTextColor?: ColorValue | undefined;
1649
1650 /**
1651 * enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call')
1652 * Determines how the return key should look.
1653 */
1654 returnKeyType?: ReturnKeyTypeOptions | undefined;
1655
1656 /**
1657 * If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
1658 * The default value is false.
1659 */
1660 secureTextEntry?: boolean | undefined;
1661
1662 /**
1663 * If true, all text will automatically be selected on focus
1664 */
1665 selectTextOnFocus?: boolean | undefined;
1666
1667 /**
1668 * The start and end of the text input's selection. Set start and end to
1669 * the same value to position the cursor.
1670 */
1671 selection?: { start: number; end?: number | undefined } | undefined;
1672
1673 /**
1674 * The highlight (and cursor on ios) color of the text input
1675 */
1676 selectionColor?: ColorValue | undefined;
1677
1678 /**
1679 * Styles
1680 */
1681 style?: StyleProp<TextStyle> | undefined;
1682
1683 /**
1684 * Align the input text to the left, center, or right sides of the input field.
1685 */
1686 textAlign?: 'left' | 'center' | 'right' | undefined;
1687
1688 /**
1689 * Used to locate this view in end-to-end tests
1690 */
1691 testID?: string | undefined;
1692
1693 /**
1694 * Used to connect to an InputAccessoryView. Not part of react-natives documentation, but present in examples and
1695 * code.
1696 * See https://reactnative.dev/docs/inputaccessoryview for more information.
1697 */
1698 inputAccessoryViewID?: string | undefined;
1699
1700 /**
1701 * The value to show for the text input. TextInput is a controlled component,
1702 * which means the native value will be forced to match this value prop if provided.
1703 * For most uses this works great, but in some cases this may cause flickering - one common cause is preventing edits by keeping value the same.
1704 * In addition to simply setting the same value, either set editable={false},
1705 * or set/update maxLength to prevent unwanted edits without flicker.
1706 */
1707 value?: string | undefined;
1708
1709 /**
1710 * Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values:
1711 * - null/undefined (default): inherit from the parent node or the global default (0)
1712 * - 0: no max, ignore parent/global default
1713 * - >= 1: sets the maxFontSizeMultiplier of this node to this value
1714 */
1715 maxFontSizeMultiplier?: number | null | undefined;
1716}
1717
1718/**
1719 * This class is responsible for coordinating the "focused"
1720 * state for TextInputs. All calls relating to the keyboard
1721 * should be funneled through here
1722 */
1723interface TextInputState {
1724 /**
1725 * @deprecated Use currentlyFocusedInput
1726 * Returns the ID of the currently focused text field, if one exists
1727 * If no text field is focused it returns null
1728 */
1729 currentlyFocusedField(): number;
1730
1731 /**
1732 * Returns the ref of the currently focused text field, if one exists
1733 * If no text field is focused it returns null
1734 */
1735 currentlyFocusedInput(): React.ElementRef<HostComponent<unknown>>;
1736
1737 /**
1738 * @param textField ref of the text field to focus
1739 * Focuses the specified text field
1740 * noop if the text field was already focused
1741 */
1742 focusTextInput(textField?: React.ElementRef<HostComponent<unknown>>): void;
1743
1744 /**
1745 * @param textField ref of the text field to focus
1746 * Unfocuses the specified text field
1747 * noop if it wasn't focused
1748 */
1749 blurTextInput(textField?: React.ElementRef<HostComponent<unknown>>): void;
1750}
1751
1752/**
1753 * @see https://reactnative.dev/docs/textinput#methods
1754 */
1755declare class TextInputComponent extends React.Component<TextInputProps> {}
1756declare const TextInputBase: Constructor<NativeMethods> & Constructor<TimerMixin> & typeof TextInputComponent;
1757export class TextInput extends TextInputBase {
1758 /**
1759 * Access the current focus state.
1760 */
1761 static State: TextInputState;
1762
1763 /**
1764 * Returns if the input is currently focused.
1765 */
1766 isFocused: () => boolean;
1767
1768 /**
1769 * Removes all text from the input.
1770 */
1771 clear: () => void;
1772}
1773
1774export type ToolbarAndroidAction = {
1775 /**
1776 * title: required, the title of this action
1777 */
1778 title: string;
1779
1780 /**
1781 * icon: the icon for this action, e.g. require('./some_icon.png')
1782 */
1783 icon?: ImageURISource | undefined;
1784
1785 /**
1786 * show: when to show this action as an icon or hide it in the overflow menu: always, ifRoom or never
1787 */
1788 show?: 'always' | 'ifRoom' | 'never' | undefined;
1789
1790 /**
1791 * showWithText: boolean, whether to show text alongside the icon or not
1792 */
1793 showWithText?: boolean | undefined;
1794};
1795
1796export interface ToolbarAndroidProps extends ViewProps {
1797 /**
1798 * Sets possible actions on the toolbar as part of the action menu. These are displayed as icons
1799 * or text on the right side of the widget. If they don't fit they are placed in an 'overflow'
1800 * menu.
1801 *
1802 * This property takes an array of objects, where each object has the following keys:
1803 *
1804 * * `title`: **required**, the title of this action
1805 * * `icon`: the icon for this action, e.g. `require('./some_icon.png')`
1806 * * `show`: when to show this action as an icon or hide it in the overflow menu: `always`,
1807 * `ifRoom` or `never`
1808 * * `showWithText`: boolean, whether to show text alongside the icon or not
1809 */
1810 actions?: ToolbarAndroidAction[] | undefined;
1811
1812 /**
1813 * Sets the content inset for the toolbar ending edge.
1814 * The content inset affects the valid area for Toolbar content other
1815 * than the navigation button and menu. Insets define the minimum
1816 * margin for these components and can be used to effectively align
1817 * Toolbar content along well-known gridlines.
1818 */
1819 contentInsetEnd?: number | undefined;
1820
1821 /**
1822 * Sets the content inset for the toolbar starting edge.
1823 * The content inset affects the valid area for Toolbar content
1824 * other than the navigation button and menu. Insets define the
1825 * minimum margin for these components and can be used to effectively
1826 * align Toolbar content along well-known gridlines.
1827 */
1828 contentInsetStart?: number | undefined;
1829
1830 /**
1831 * Sets the toolbar logo.
1832 */
1833 logo?: ImageURISource | undefined;
1834
1835 /**
1836 * Sets the navigation icon.
1837 */
1838 navIcon?: ImageURISource | undefined;
1839
1840 /**
1841 * Callback that is called when an action is selected. The only
1842 * argument that is passed to the callback is the position of the
1843 * action in the actions array.
1844 */
1845 onActionSelected?: ((position: number) => void) | undefined;
1846
1847 /**
1848 * Callback called when the icon is selected.
1849 */
1850 onIconClicked?: (() => void) | undefined;
1851
1852 /**
1853 * Sets the overflow icon.
1854 */
1855 overflowIcon?: ImageURISource | undefined;
1856
1857 /**
1858 * Used to set the toolbar direction to RTL.
1859 * In addition to this property you need to add
1860 * android:supportsRtl="true"
1861 * to your application AndroidManifest.xml and then call
1862 * setLayoutDirection(LayoutDirection.RTL) in your MainActivity
1863 * onCreate method.
1864 */
1865 rtl?: boolean | undefined;
1866
1867 /**
1868 * Sets the toolbar subtitle.
1869 */
1870 subtitle?: string | undefined;
1871
1872 /**
1873 * Sets the toolbar subtitle color.
1874 */
1875 subtitleColor?: ColorValue | undefined;
1876
1877 /**
1878 * Used to locate this view in end-to-end tests.
1879 */
1880 testID?: string | undefined;
1881
1882 /**
1883 * Sets the toolbar title.
1884 */
1885 title?: string | undefined;
1886
1887 /**
1888 * Sets the toolbar title color.
1889 */
1890 titleColor?: ColorValue | undefined;
1891}
1892
1893/**
1894 * React component that wraps the Android-only [`Toolbar` widget][0]. A Toolbar can display a logo,
1895 * navigation icon (e.g. hamburger menu), a title & subtitle and a list of actions. The title and
1896 * subtitle are expanded so the logo and navigation icons are displayed on the left, title and
1897 * subtitle in the middle and the actions on the right.
1898 *
1899 * If the toolbar has an only child, it will be displayed between the title and actions.
1900 *
1901 * Although the Toolbar supports remote images for the logo, navigation and action icons, this
1902 * should only be used in DEV mode where `require('./some_icon.png')` translates into a packager
1903 * URL. In release mode you should always use a drawable resource for these icons. Using
1904 * `require('./some_icon.png')` will do this automatically for you, so as long as you don't
1905 * explicitly use e.g. `{uri: 'http://...'}`, you will be good.
1906 *
1907 * [0]: https://developer.android.com/reference/android/support/v7/widget/Toolbar.html
1908 */
1909declare class ToolbarAndroidComponent extends React.Component<ToolbarAndroidProps> {}
1910declare const ToolbarAndroidBase: Constructor<NativeMethods> & typeof ToolbarAndroidComponent;
1911
1912/**
1913 * ToolbarAndroid has been deprecated and removed from the package since React Native v0.61.0.
1914 * It can now be installed and imported from `@react-native-community/datetimepicker` instead of 'react-native'.
1915 * @see https://github.com/react-native-community/toolbar-android
1916 * @deprecated
1917 */
1918export class ToolbarAndroid extends ToolbarAndroidBase {}
1919
1920/**
1921 * Gesture recognition on mobile devices is much more complicated than web.
1922 * A touch can go through several phases as the app determines what the user's intention is.
1923 * For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping.
1924 * This can even change during the duration of a touch. There can also be multiple simultaneous touches.
1925 *
1926 * The touch responder system is needed to allow components to negotiate these touch interactions
1927 * without any additional knowledge about their parent or child components.
1928 * This system is implemented in ResponderEventPlugin.js, which contains further details and documentation.
1929 *
1930 * Best Practices
1931 * Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes.
1932 * Every action should have the following attributes:
1933 * Feedback/highlighting- show the user what is handling their touch, and what will happen when they release the gesture
1934 * Cancel-ability- when making an action, the user should be able to abort it mid-touch by dragging their finger away
1935 *
1936 * These features make users more comfortable while using an app,
1937 * because it allows people to experiment and interact without fear of making mistakes.
1938 *
1939 * TouchableHighlight and Touchable*
1940 * The responder system can be complicated to use.
1941 * So we have provided an abstract Touchable implementation for things that should be "tappable".
1942 * This uses the responder system and allows you to easily configure tap interactions declaratively.
1943 * Use TouchableHighlight anywhere where you would use a button or link on web.
1944 */
1945export interface GestureResponderHandlers {
1946 /**
1947 * A view can become the touch responder by implementing the correct negotiation methods.
1948 * There are two methods to ask the view if it wants to become responder:
1949 */
1950
1951 /**
1952 * Does this view want to become responder on the start of a touch?
1953 */
1954 onStartShouldSetResponder?: ((event: GestureResponderEvent) => boolean) | undefined;
1955
1956 /**
1957 * Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness?
1958 */
1959 onMoveShouldSetResponder?: ((event: GestureResponderEvent) => boolean) | undefined;
1960
1961 /**
1962 * If the View returns true and attempts to become the responder, one of the following will happen:
1963 */
1964
1965 onResponderEnd?: ((event: GestureResponderEvent) => void) | undefined;
1966
1967 /**
1968 * The View is now responding for touch events.
1969 * This is the time to highlight and show the user what is happening
1970 */
1971 onResponderGrant?: ((event: GestureResponderEvent) => void) | undefined;
1972
1973 /**
1974 * Something else is the responder right now and will not release it
1975 */
1976 onResponderReject?: ((event: GestureResponderEvent) => void) | undefined;
1977
1978 /**
1979 * If the view is responding, the following handlers can be called:
1980 */
1981
1982 /**
1983 * The user is moving their finger
1984 */
1985 onResponderMove?: ((event: GestureResponderEvent) => void) | undefined;
1986
1987 /**
1988 * Fired at the end of the touch, ie "touchUp"
1989 */
1990 onResponderRelease?: ((event: GestureResponderEvent) => void) | undefined;
1991
1992 onResponderStart?: ((event: GestureResponderEvent) => void) | undefined;
1993
1994 /**
1995 * Something else wants to become responder.
1996 * Should this view release the responder? Returning true allows release
1997 */
1998 onResponderTerminationRequest?: ((event: GestureResponderEvent) => boolean) | undefined;
1999
2000 /**
2001 * The responder has been taken from the View.
2002 * Might be taken by other views after a call to onResponderTerminationRequest,
2003 * or might be taken by the OS without asking (happens with control center/ notification center on iOS)
2004 */
2005 onResponderTerminate?: ((event: GestureResponderEvent) => void) | undefined;
2006
2007 /**
2008 * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern,
2009 * where the deepest node is called first.
2010 * That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers.
2011 * This is desirable in most cases, because it makes sure all controls and buttons are usable.
2012 *
2013 * However, sometimes a parent will want to make sure that it becomes responder.
2014 * This can be handled by using the capture phase.
2015 * Before the responder system bubbles up from the deepest component,
2016 * it will do a capture phase, firing on*ShouldSetResponderCapture.
2017 * So if a parent View wants to prevent the child from becoming responder on a touch start,
2018 * it should have a onStartShouldSetResponderCapture handler which returns true.
2019 */
2020 onStartShouldSetResponderCapture?: ((event: GestureResponderEvent) => boolean) | undefined;
2021
2022 /**
2023 * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern,
2024 * where the deepest node is called first.
2025 * That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers.
2026 * This is desirable in most cases, because it makes sure all controls and buttons are usable.
2027 *
2028 * However, sometimes a parent will want to make sure that it becomes responder.
2029 * This can be handled by using the capture phase.
2030 * Before the responder system bubbles up from the deepest component,
2031 * it will do a capture phase, firing on*ShouldSetResponderCapture.
2032 * So if a parent View wants to prevent the child from becoming responder on a touch start,
2033 * it should have a onStartShouldSetResponderCapture handler which returns true.
2034 */
2035 onMoveShouldSetResponderCapture?: ((event: GestureResponderEvent) => boolean) | undefined;
2036}
2037
2038/**
2039 * @see https://reactnative.dev/docs/view#style
2040 * @see https://github.com/facebook/react-native/blob/master/Libraries/Components/View/ViewStylePropTypes.js
2041 */
2042export interface ViewStyle extends FlexStyle, ShadowStyleIOS, TransformsStyle {
2043 backfaceVisibility?: 'visible' | 'hidden' | undefined;
2044 backgroundColor?: ColorValue | undefined;
2045 borderBottomColor?: ColorValue | undefined;
2046 borderBottomEndRadius?: number | undefined;
2047 borderBottomLeftRadius?: number | undefined;
2048 borderBottomRightRadius?: number | undefined;
2049 borderBottomStartRadius?: number | undefined;
2050 borderBottomWidth?: number | undefined;
2051 borderColor?: ColorValue | undefined;
2052 borderEndColor?: ColorValue | undefined;
2053 borderLeftColor?: ColorValue | undefined;
2054 borderLeftWidth?: number | undefined;
2055 borderRadius?: number | undefined;
2056 borderRightColor?: ColorValue | undefined;
2057 borderRightWidth?: number | undefined;
2058 borderStartColor?: ColorValue | undefined;
2059 borderStyle?: 'solid' | 'dotted' | 'dashed' | undefined;
2060 borderTopColor?: ColorValue | undefined;
2061 borderTopEndRadius?: number | undefined;
2062 borderTopLeftRadius?: number | undefined;
2063 borderTopRightRadius?: number | undefined;
2064 borderTopStartRadius?: number | undefined;
2065 borderTopWidth?: number | undefined;
2066 borderWidth?: number | undefined;
2067 opacity?: number | undefined;
2068 testID?: string | undefined;
2069 /**
2070 * Sets the elevation of a view, using Android's underlying
2071 * [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation).
2072 * This adds a drop shadow to the item and affects z-order for overlapping views.
2073 * Only supported on Android 5.0+, has no effect on earlier versions.
2074 *
2075 * @platform android
2076 */
2077 elevation?: number | undefined;
2078}
2079
2080export type TVParallaxProperties = {
2081 /**
2082 * If true, parallax effects are enabled. Defaults to true.
2083 */
2084 enabled?: boolean | undefined;
2085
2086 /**
2087 * Defaults to 2.0.
2088 */
2089 shiftDistanceX?: number | undefined;
2090
2091 /**
2092 * Defaults to 2.0.
2093 */
2094 shiftDistanceY?: number | undefined;
2095
2096 /**
2097 * Defaults to 0.05.
2098 */
2099 tiltAngle?: number | undefined;
2100
2101 /**
2102 * Defaults to 1.0
2103 */
2104 magnification?: number | undefined;
2105
2106 /**
2107 * Defaults to 1.0
2108 */
2109 pressMagnification?: number | undefined;
2110
2111 /**
2112 * Defaults to 0.3
2113 */
2114 pressDuration?: number | undefined;
2115
2116 /**
2117 * Defaults to 0.3
2118 */
2119 pressDelay?: number | undefined;
2120};
2121
2122export interface TVViewPropsIOS {
2123 /**
2124 * *(Apple TV only)* When set to true, this view will be focusable
2125 * and navigable using the Apple TV remote.
2126 *
2127 * @platform ios
2128 */
2129 isTVSelectable?: boolean | undefined;
2130
2131 /**
2132 * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view.
2133 *
2134 * @platform ios
2135 */
2136 hasTVPreferredFocus?: boolean | undefined;
2137
2138 /**
2139 * *(Apple TV only)* Object with properties to control Apple TV parallax effects.
2140 *
2141 * @platform ios
2142 */
2143 tvParallaxProperties?: TVParallaxProperties | undefined;
2144
2145 /**
2146 * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
2147 *
2148 * @platform ios
2149 */
2150 tvParallaxShiftDistanceX?: number | undefined;
2151
2152 /**
2153 * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
2154 *
2155 * @platform ios
2156 */
2157 tvParallaxShiftDistanceY?: number | undefined;
2158
2159 /**
2160 * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05.
2161 *
2162 * @platform ios
2163 */
2164 tvParallaxTiltAngle?: number | undefined;
2165
2166 /**
2167 * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0.
2168 *
2169 * @platform ios
2170 */
2171 tvParallaxMagnification?: number | undefined;
2172}
2173
2174export interface ViewPropsIOS extends TVViewPropsIOS {
2175 /**
2176 * Whether this view should be rendered as a bitmap before compositing.
2177 *
2178 * On iOS, this is useful for animations and interactions that do not modify this component's dimensions nor its children;
2179 * for example, when translating the position of a static view, rasterization allows the renderer to reuse a cached bitmap of a static view
2180 * and quickly composite it during each frame.
2181 *
2182 * Rasterization incurs an off-screen drawing pass and the bitmap consumes memory.
2183 * Test and measure when using this property.
2184 */
2185 shouldRasterizeIOS?: boolean | undefined;
2186}
2187
2188export interface ViewPropsAndroid {
2189 /**
2190 * Views that are only used to layout their children or otherwise don't draw anything
2191 * may be automatically removed from the native hierarchy as an optimization.
2192 * Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy.
2193 */
2194 collapsable?: boolean | undefined;
2195
2196 /**
2197 * Whether this view needs to rendered offscreen and composited with an alpha in order to preserve 100% correct colors and blending behavior.
2198 * The default (false) falls back to drawing the component and its children
2199 * with an alpha applied to the paint used to draw each element instead of rendering the full component offscreen and compositing it back with an alpha value.
2200 * This default may be noticeable and undesired in the case where the View you are setting an opacity on
2201 * has multiple overlapping elements (e.g. multiple overlapping Views, or text and a background).
2202 *
2203 * Rendering offscreen to preserve correct alpha behavior is extremely expensive
2204 * and hard to debug for non-native developers, which is why it is not turned on by default.
2205 * If you do need to enable this property for an animation,
2206 * consider combining it with renderToHardwareTextureAndroid if the view contents are static (i.e. it doesn't need to be redrawn each frame).
2207 * If that property is enabled, this View will be rendered off-screen once,
2208 * saved in a hardware texture, and then composited onto the screen with an alpha each frame without having to switch rendering targets on the GPU.
2209 */
2210 needsOffscreenAlphaCompositing?: boolean | undefined;
2211
2212 /**
2213 * Whether this view should render itself (and all of its children) into a single hardware texture on the GPU.
2214 *
2215 * On Android, this is useful for animations and interactions that only modify opacity, rotation, translation, and/or scale:
2216 * in those cases, the view doesn't have to be redrawn and display lists don't need to be re-executed. The texture can just be
2217 * re-used and re-composited with different parameters. The downside is that this can use up limited video memory, so this prop should be set back to false at the end of the interaction/animation.
2218 */
2219 renderToHardwareTextureAndroid?: boolean | undefined;
2220
2221 /**
2222 * Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
2223 */
2224 focusable?: boolean | undefined;
2225}
2226
2227type Falsy = undefined | null | false;
2228interface RecursiveArray<T> extends Array<T | ReadonlyArray<T> | RecursiveArray<T>> {}
2229/** Keep a brand of 'T' so that calls to `StyleSheet.flatten` can take `RegisteredStyle<T>` and return `T`. */
2230type RegisteredStyle<T> = number & { __registeredStyleBrand: T };
2231export type StyleProp<T> = T | RegisteredStyle<T> | RecursiveArray<T | RegisteredStyle<T> | Falsy> | Falsy;
2232
2233/**
2234 * @see https://reactnative.dev/docs/accessibility#accessibility-properties
2235 */
2236export interface AccessibilityProps extends AccessibilityPropsAndroid, AccessibilityPropsIOS {
2237 /**
2238 * When true, indicates that the view is an accessibility element.
2239 * By default, all the touchable elements are accessible.
2240 */
2241 accessible?: boolean | undefined;
2242
2243 /**
2244 * Provides an array of custom actions available for accessibility.
2245 */
2246 accessibilityActions?: ReadonlyArray<AccessibilityActionInfo> | undefined;
2247
2248 /**
2249 * Overrides the text that's read by the screen reader when the user interacts with the element. By default, the
2250 * label is constructed by traversing all the children and accumulating all the Text nodes separated by space.
2251 */
2252 accessibilityLabel?: string | undefined;
2253
2254 /**
2255 * Accessibility Role tells a person using either VoiceOver on iOS or TalkBack on Android the type of element that is focused on.
2256 */
2257 accessibilityRole?: AccessibilityRole | undefined;
2258 /**
2259 * Accessibility State tells a person using either VoiceOver on iOS or TalkBack on Android the state of the element currently focused on.
2260 */
2261 accessibilityState?: AccessibilityState | undefined;
2262 /**
2263 * An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not obvious from the accessibility label.
2264 */
2265 accessibilityHint?: string | undefined;
2266 /**
2267 * Represents the current value of a component. It can be a textual description of a component's value, or for range-based components, such as sliders and progress bars,
2268 * it contains range information (minimum, current, and maximum).
2269 */
2270 accessibilityValue?: AccessibilityValue | undefined;
2271
2272 /**
2273 * When `accessible` is true, the system will try to invoke this function when the user performs an accessibility custom action.
2274 */
2275 onAccessibilityAction?: ((event: AccessibilityActionEvent) => void) | undefined;
2276}
2277
2278export type AccessibilityActionInfo = Readonly<{
2279 name: AccessibilityActionName | string;
2280 label?: string | undefined;
2281}>;
2282
2283export type AccessibilityActionName =
2284 /**
2285 * Generated when a screen reader user double taps the component.
2286 */
2287 | 'activate'
2288 /**
2289 * Generated when a screen reader user increments an adjustable component.
2290 */
2291 | 'increment'
2292 /**
2293 * Generated when a screen reader user decrements an adjustable component.
2294 */
2295 | 'decrement'
2296 /**
2297 * Generated when a TalkBack user places accessibility focus on the component and double taps and holds one finger on the screen.
2298 * @platform android
2299 */
2300 | 'longpress'
2301 /**
2302 * Generated when a VoiceOver user places focus on or inside the component and double taps with two fingers.
2303 * @platform ios
2304 * */
2305 | 'magicTap'
2306 /**
2307 * Generated when a VoiceOver user places focus on or inside the component and performs a two finger scrub gesture (left, right, left).
2308 * @platform ios
2309 * */
2310 | 'escape';
2311
2312export type AccessibilityActionEvent = NativeSyntheticEvent<
2313 Readonly<{
2314 actionName: string;
2315 }>
2316>;
2317
2318export interface AccessibilityState {
2319 /**
2320 * When true, informs accessible tools if the element is disabled
2321 */
2322 disabled?: boolean | undefined;
2323 /**
2324 * When true, informs accessible tools if the element is selected
2325 */
2326 selected?: boolean | undefined;
2327 /**
2328 * For items like Checkboxes and Toggle switches, reports their state to accessible tools
2329 */
2330 checked?: boolean | 'mixed' | undefined;
2331 /**
2332 * When present, informs accessible tools if the element is busy
2333 */
2334 busy?: boolean | undefined;
2335 /**
2336 * When present, informs accessible tools the element is expanded or collapsed
2337 */
2338 expanded?: boolean | undefined;
2339}
2340
2341export interface AccessibilityValue {
2342 /**
2343 * The minimum value of this component's range. (should be an integer)
2344 */
2345 min?: number | undefined;
2346
2347 /**
2348 * The maximum value of this component's range. (should be an integer)
2349 */
2350 max?: number | undefined;
2351
2352 /**
2353 * The current value of this component's range. (should be an integer)
2354 */
2355 now?: number | undefined;
2356
2357 /**
2358 * A textual description of this component's value. (will override minimum, current, and maximum if set)
2359 */
2360 text?: string | undefined;
2361}
2362
2363export type AccessibilityRole =
2364 | 'none'
2365 | 'button'
2366 | 'link'
2367 | 'search'
2368 | 'image'
2369 | 'keyboardkey'
2370 | 'text'
2371 | 'adjustable'
2372 | 'imagebutton'
2373 | 'header'
2374 | 'summary'
2375 | 'alert'
2376 | 'checkbox'
2377 | 'combobox'
2378 | 'menu'
2379 | 'menubar'
2380 | 'menuitem'
2381 | 'progressbar'
2382 | 'radio'
2383 | 'radiogroup'
2384 | 'scrollbar'
2385 | 'spinbutton'
2386 | 'switch'
2387 | 'tab'
2388 | 'tablist'
2389 | 'timer'
2390 | 'toolbar';
2391
2392export interface AccessibilityPropsAndroid {
2393 /**
2394 * Indicates to accessibility services whether the user should be notified when this view changes.
2395 * Works for Android API >= 19 only.
2396 * See http://developer.android.com/reference/android/view/View.html#attr_android:accessibilityLiveRegion for references.
2397 * @platform android
2398 */
2399 accessibilityLiveRegion?: 'none' | 'polite' | 'assertive' | undefined;
2400
2401 /**
2402 * Controls how view is important for accessibility which is if it fires accessibility events
2403 * and if it is reported to accessibility services that query the screen.
2404 * Works for Android only. See http://developer.android.com/reference/android/R.attr.html#importantForAccessibility for references.
2405 *
2406 * Possible values:
2407 * 'auto' - The system determines whether the view is important for accessibility - default (recommended).
2408 * 'yes' - The view is important for accessibility.
2409 * 'no' - The view is not important for accessibility.
2410 * 'no-hide-descendants' - The view is not important for accessibility, nor are any of its descendant views.
2411 */
2412 importantForAccessibility?: 'auto' | 'yes' | 'no' | 'no-hide-descendants' | undefined;
2413}
2414
2415export interface AccessibilityPropsIOS {
2416 /**
2417 * A Boolean value indicating whether the accessibility elements contained within this accessibility element
2418 * are hidden to the screen reader.
2419 * @platform ios
2420 */
2421 accessibilityElementsHidden?: boolean | undefined;
2422
2423 /**
2424 * A Boolean value indicating whether VoiceOver should ignore the elements within views that are siblings of the receiver.
2425 * @platform ios
2426 */
2427 accessibilityViewIsModal?: boolean | undefined;
2428
2429 /**
2430 * When accessibile is true, the system will invoke this function when the user performs the escape gesture (scrub with two fingers).
2431 * @platform ios
2432 */
2433 onAccessibilityEscape?: (() => void) | undefined;
2434
2435 /**
2436 * When `accessible` is true, the system will try to invoke this function when the user performs accessibility tap gesture.
2437 * @platform ios
2438 */
2439 onAccessibilityTap?: (() => void) | undefined;
2440
2441 /**
2442 * When accessible is true, the system will invoke this function when the user performs the magic tap gesture.
2443 * @platform ios
2444 */
2445 onMagicTap?: (() => void) | undefined;
2446
2447 /**
2448 * https://reactnative.dev/docs/accessibility#accessibilityignoresinvertcolorsios
2449 * @platform ios
2450 */
2451 accessibilityIgnoresInvertColors?: boolean | undefined;
2452}
2453
2454/**
2455 * @see https://reactnative.dev/docs/view#props
2456 */
2457export interface ViewProps
2458 extends ViewPropsAndroid,
2459 ViewPropsIOS,
2460 GestureResponderHandlers,
2461 Touchable,
2462 AccessibilityProps {
2463 /**
2464 * This defines how far a touch event can start away from the view.
2465 * Typical interface guidelines recommend touch targets that are at least
2466 * 30 - 40 points/density-independent pixels. If a Touchable view has
2467 * a height of 20 the touchable height can be extended to 40 with
2468 * hitSlop={{top: 10, bottom: 10, left: 0, right: 0}}
2469 * NOTE The touch area never extends past the parent view bounds and
2470 * the Z-index of sibling views always takes precedence if a touch
2471 * hits two overlapping views.
2472 */
2473 hitSlop?: Insets | undefined;
2474
2475 /**
2476 * Invoked on mount and layout changes with
2477 *
2478 * {nativeEvent: { layout: {x, y, width, height}}}.
2479 */
2480 onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
2481
2482 /**
2483 *
2484 * In the absence of auto property, none is much like CSS's none value. box-none is as if you had applied the CSS class:
2485 *
2486 * .box-none {
2487 * pointer-events: none;
2488 * }
2489 * .box-none * {
2490 * pointer-events: all;
2491 * }
2492 *
2493 * box-only is the equivalent of
2494 *
2495 * .box-only {
2496 * pointer-events: all;
2497 * }
2498 * .box-only * {
2499 * pointer-events: none;
2500 * }
2501 *
2502 * But since pointerEvents does not affect layout/appearance, and we are already deviating from the spec by adding additional modes,
2503 * we opt to not include pointerEvents on style. On some platforms, we would need to implement it as a className anyways. Using style or not is an implementation detail of the platform.
2504 */
2505 pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto' | undefined;
2506
2507 /**
2508 *
2509 * This is a special performance property exposed by RCTView and is useful for scrolling content when there are many subviews,
2510 * most of which are offscreen. For this property to be effective, it must be applied to a view that contains many subviews that extend outside its bound.
2511 * The subviews must also have overflow: hidden, as should the containing view (or one of its superviews).
2512 */
2513 removeClippedSubviews?: boolean | undefined;
2514
2515 style?: StyleProp<ViewStyle> | undefined;
2516
2517 /**
2518 * Used to locate this view in end-to-end tests.
2519 */
2520 testID?: string | undefined;
2521
2522 /**
2523 * Used to reference react managed views from native code.
2524 */
2525 nativeID?: string | undefined;
2526}
2527
2528/**
2529 * The most fundamental component for building UI, View is a container that supports layout with flexbox, style, some touch handling,
2530 * and accessibility controls, and is designed to be nested inside other views and to have 0 to many children of any type.
2531 * View maps directly to the native view equivalent on whatever platform React is running on,
2532 * whether that is a UIView, <div>, android.view, etc.
2533 */
2534declare class ViewComponent extends React.Component<ViewProps> {}
2535declare const ViewBase: Constructor<NativeMethods> & typeof ViewComponent;
2536export class View extends ViewBase {
2537 /**
2538 * Is 3D Touch / Force Touch available (i.e. will touch events include `force`)
2539 * @platform ios
2540 */
2541 static forceTouchAvailable: boolean;
2542}
2543
2544/**
2545 * @see https://reactnative.dev/docs/viewpagerandroid#props
2546 */
2547
2548export interface ViewPagerAndroidOnPageScrollEventData {
2549 position: number;
2550 offset: number;
2551}
2552
2553export interface ViewPagerAndroidOnPageSelectedEventData {
2554 position: number;
2555}
2556
2557export interface ViewPagerAndroidProps extends ViewProps {
2558 /**
2559 * Index of initial page that should be selected. Use `setPage` method to
2560 * update the page, and `onPageSelected` to monitor page changes
2561 */
2562 initialPage?: number | undefined;
2563
2564 /**
2565 * When false, the content does not scroll.
2566 * The default value is true.
2567 */
2568 scrollEnabled?: boolean | undefined;
2569
2570 /**
2571 * Executed when transitioning between pages (ether because of animation for
2572 * the requested page change or when user is swiping/dragging between pages)
2573 * The `event.nativeEvent` object for this callback will carry following data:
2574 * - position - index of first page from the left that is currently visible
2575 * - offset - value from range [0,1) describing stage between page transitions.
2576 * Value x means that (1 - x) fraction of the page at "position" index is
2577 * visible, and x fraction of the next page is visible.
2578 */
2579 onPageScroll?: ((event: NativeSyntheticEvent<ViewPagerAndroidOnPageScrollEventData>) => void) | undefined;
2580
2581 /**
2582 * This callback will be called once ViewPager finish navigating to selected page
2583 * (when user swipes between pages). The `event.nativeEvent` object passed to this
2584 * callback will have following fields:
2585 * - position - index of page that has been selected
2586 */
2587 onPageSelected?: ((event: NativeSyntheticEvent<ViewPagerAndroidOnPageSelectedEventData>) => void) | undefined;
2588
2589 /**
2590 * Function called when the page scrolling state has changed.
2591 * The page scrolling state can be in 3 states:
2592 * - idle, meaning there is no interaction with the page scroller happening at the time
2593 * - dragging, meaning there is currently an interaction with the page scroller
2594 * - settling, meaning that there was an interaction with the page scroller, and the
2595 * page scroller is now finishing it's closing or opening animation
2596 */
2597 onPageScrollStateChanged?: ((state: 'Idle' | 'Dragging' | 'Settling') => void) | undefined;
2598
2599 /**
2600 * Determines whether the keyboard gets dismissed in response to a drag.
2601 * - 'none' (the default), drags do not dismiss the keyboard.
2602 * - 'on-drag', the keyboard is dismissed when a drag begins.
2603 */
2604 keyboardDismissMode?: 'none' | 'on-drag' | undefined;
2605
2606 /**
2607 * Blank space to show between pages. This is only visible while scrolling, pages are still
2608 * edge-to-edge.
2609 */
2610 pageMargin?: number | undefined;
2611}
2612
2613declare class ViewPagerAndroidComponent extends React.Component<ViewPagerAndroidProps> {}
2614declare const ViewPagerAndroidBase: Constructor<NativeMethods> & typeof ViewPagerAndroidComponent;
2615
2616/**
2617 * ViewPagerAndroid has been removed from React Native.
2618 * It can now be installed and imported from `@react-native-community/viewpager` instead of 'react-native'.
2619 * @see https://github.com/react-native-community/react-native-viewpager
2620 * @deprecated
2621 */
2622export class ViewPagerAndroid extends ViewPagerAndroidBase {
2623 /**
2624 * A helper function to scroll to a specific page in the ViewPager.
2625 * The transition between pages will be animated.
2626 */
2627 setPage(selectedPage: number): void;
2628
2629 /**
2630 * A helper function to scroll to a specific page in the ViewPager.
2631 * The transition between pages will *not* be animated.
2632 */
2633 setPageWithoutAnimation(selectedPage: number): void;
2634}
2635
2636/**
2637 * It is a component to solve the common problem of views that need to move out of the way of the virtual keyboard.
2638 * It can automatically adjust either its position or bottom padding based on the position of the keyboard.
2639 */
2640declare class KeyboardAvoidingViewComponent extends React.Component<KeyboardAvoidingViewProps> {}
2641declare const KeyboardAvoidingViewBase: Constructor<TimerMixin> & typeof KeyboardAvoidingViewComponent;
2642export class KeyboardAvoidingView extends KeyboardAvoidingViewBase {}
2643
2644export interface KeyboardAvoidingViewProps extends ViewProps {
2645 behavior?: 'height' | 'position' | 'padding' | undefined;
2646
2647 /**
2648 * The style of the content container(View) when behavior is 'position'.
2649 */
2650 contentContainerStyle?: StyleProp<ViewStyle> | undefined;
2651
2652 /**
2653 * This is the distance between the top of the user screen and the react native view,
2654 * may be non-zero in some use cases.
2655 */
2656 keyboardVerticalOffset?: number | undefined;
2657
2658 /**
2659 * Enables or disables the KeyboardAvoidingView.
2660 *
2661 * Default is true
2662 */
2663 enabled?: boolean | undefined;
2664}
2665
2666/**
2667 * @see https://reactnative.dev/docs/segmentedcontrolios
2668 * @see SegmentedControlIOS.ios.js
2669 */
2670export interface NativeSegmentedControlIOSChangeEvent extends TargetedEvent {
2671 value: string;
2672 selectedSegmentIndex: number;
2673}
2674
2675export interface SegmentedControlIOSProps extends ViewProps {
2676 /**
2677 * If false the user won't be able to interact with the control. Default value is true.
2678 */
2679 enabled?: boolean | undefined;
2680
2681 /**
2682 * If true, then selecting a segment won't persist visually.
2683 * The onValueChange callback will still work as expected.
2684 */
2685 momentary?: boolean | undefined;
2686
2687 /**
2688 * Callback that is called when the user taps a segment;
2689 * passes the event as an argument
2690 */
2691 onChange?: ((event: NativeSyntheticEvent<NativeSegmentedControlIOSChangeEvent>) => void) | undefined;
2692
2693 /**
2694 * Callback that is called when the user taps a segment; passes the segment's value as an argument
2695 */
2696 onValueChange?: ((value: string) => void) | undefined;
2697
2698 /**
2699 * The index in props.values of the segment to be (pre)selected.
2700 */
2701 selectedIndex?: number | undefined;
2702
2703 /**
2704 * Accent color of the control.
2705 */
2706 tintColor?: ColorValue | undefined;
2707
2708 /**
2709 * The labels for the control's segment buttons, in order.
2710 */
2711 values?: string[] | undefined;
2712}
2713
2714/**
2715 * Renders nested content and automatically applies paddings reflect the portion of the view
2716 * that is not covered by navigation bars, tab bars, toolbars, and other ancestor views.
2717 * Moreover, and most importantly, Safe Area's paddings reflect physical limitation of the screen,
2718 * such as rounded corners or camera notches (aka sensor housing area on iPhone X).
2719 */
2720declare class SafeAreaViewComponent extends React.Component<ViewProps> {}
2721declare const SafeAreaViewBase: Constructor<NativeMethods> & typeof SafeAreaViewComponent;
2722export class SafeAreaView extends SafeAreaViewBase {}
2723
2724/**
2725 * A component which enables customization of the keyboard input accessory view on iOS. The input accessory view is
2726 * displayed above the keyboard whenever a TextInput has focus. This component can be used to create custom toolbars.
2727 *
2728 * To use this component wrap your custom toolbar with the InputAccessoryView component, and set a nativeID. Then, pass
2729 * that nativeID as the inputAccessoryViewID of whatever TextInput you desire.
2730 */
2731export class InputAccessoryView extends React.Component<InputAccessoryViewProps> {}
2732
2733export interface InputAccessoryViewProps {
2734 backgroundColor?: ColorValue | undefined;
2735
2736 /**
2737 * An ID which is used to associate this InputAccessoryView to specified TextInput(s).
2738 */
2739 nativeID?: string | undefined;
2740
2741 style?: StyleProp<ViewStyle> | undefined;
2742}
2743
2744/**
2745 * Use `SegmentedControlIOS` to render a UISegmentedControl iOS.
2746 *
2747 * #### Programmatically changing selected index
2748 *
2749 * The selected index can be changed on the fly by assigning the
2750 * selectIndex prop to a state variable, then changing that variable.
2751 * Note that the state variable would need to be updated as the user
2752 * selects a value and changes the index, as shown in the example below.
2753 *
2754 * ````
2755 * <SegmentedControlIOS
2756 * values={['One', 'Two']}
2757 * selectedIndex={this.state.selectedIndex}
2758 * onChange={(event) => {
2759 * this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex});
2760 * }}
2761 * />
2762 * ````
2763 */
2764declare class SegmentedControlIOSComponent extends React.Component<SegmentedControlIOSProps> {}
2765declare const SegmentedControlIOSBase: Constructor<NativeMethods> & typeof SegmentedControlIOSComponent;
2766
2767/**
2768 * SegmentedControlIOS has been extracted from react-native core and will be removed in a future release.
2769 * It can now be installed and imported from `@react-native-community/segmented-control` instead of 'react-native'.
2770 * @see https://github.com/react-native-community/segmented-control
2771 * @deprecated
2772 */
2773export class SegmentedControlIOS extends SegmentedControlIOSBase {}
2774
2775export interface NavigatorIOSProps {
2776 /**
2777 * The default background color of the navigation bar.
2778 */
2779 barTintColor?: ColorValue | undefined;
2780
2781 /**
2782 * NavigatorIOS uses "route" objects to identify child views, their props, and navigation bar configuration.
2783 * "push" and all the other navigation operations expect routes to be like this
2784 */
2785 initialRoute: Route;
2786
2787 /**
2788 * The default wrapper style for components in the navigator.
2789 * A common use case is to set the backgroundColor for every page
2790 */
2791 itemWrapperStyle?: StyleProp<ViewStyle> | undefined;
2792
2793 /**
2794 * Boolean value that indicates whether the interactive pop gesture is
2795 * enabled. This is useful for enabling/disabling the back swipe navigation
2796 * gesture.
2797 *
2798 * If this prop is not provided, the default behavior is for the back swipe
2799 * gesture to be enabled when the navigation bar is shown and disabled when
2800 * the navigation bar is hidden. Once you've provided the
2801 * `interactivePopGestureEnabled` prop, you can never restore the default
2802 * behavior.
2803 */
2804 interactivePopGestureEnabled?: boolean | undefined;
2805
2806 /**
2807 * A Boolean value that indicates whether the navigation bar is hidden
2808 */
2809 navigationBarHidden?: boolean | undefined;
2810
2811 /**
2812 * A Boolean value that indicates whether to hide the 1px hairline shadow
2813 */
2814 shadowHidden?: boolean | undefined;
2815
2816 /**
2817 * The color used for buttons in the navigation bar
2818 */
2819 tintColor?: ColorValue | undefined;
2820
2821 /**
2822 * The text color of the navigation bar title
2823 */
2824 titleTextColor?: ColorValue | undefined;
2825
2826 /**
2827 * A Boolean value that indicates whether the navigation bar is translucent
2828 */
2829 translucent?: boolean | undefined;
2830
2831 /**
2832 * NOT IN THE DOC BUT IN THE EXAMPLES
2833 */
2834 style?: StyleProp<ViewStyle> | undefined;
2835}
2836
2837/**
2838 * A navigator is an object of navigation functions that a view can call.
2839 * It is passed as a prop to any component rendered by NavigatorIOS.
2840 *
2841 * Navigator functions are also available on the NavigatorIOS component:
2842 *
2843 * @see https://reactnative.dev/docs/navigatorios#navigator
2844 */
2845export class NavigatorIOS extends React.Component<NavigatorIOSProps> {
2846 /**
2847 * Navigate forward to a new route
2848 */
2849 push: (route: Route) => void;
2850
2851 /**
2852 * Go back one page
2853 */
2854 pop: () => void;
2855
2856 /**
2857 * Go back N pages at once. When N=1, behavior matches pop()
2858 */
2859 popN: (n: number) => void;
2860
2861 /**
2862 * Replace the route for the current page and immediately load the view for the new route
2863 */
2864 replace: (route: Route) => void;
2865
2866 /**
2867 * Replace the route/view for the previous page
2868 */
2869 replacePrevious: (route: Route) => void;
2870
2871 /**
2872 * Replaces the previous route/view and transitions back to it
2873 */
2874 replacePreviousAndPop: (route: Route) => void;
2875
2876 /**
2877 * Replaces the top item and popToTop
2878 */
2879 resetTo: (route: Route) => void;
2880
2881 /**
2882 * Go back to the item for a particular route object
2883 */
2884 popToRoute(route: Route): void;
2885
2886 /**
2887 * Go back to the top item
2888 */
2889 popToTop(): void;
2890}
2891
2892/**
2893 * @see https://reactnative.dev/docs/activityindicator#props
2894 */
2895export interface ActivityIndicatorProps extends ViewProps {
2896 /**
2897 * Whether to show the indicator (true, the default) or hide it (false).
2898 */
2899 animating?: boolean | undefined;
2900
2901 /**
2902 * The foreground color of the spinner (default is gray).
2903 */
2904 color?: ColorValue | undefined;
2905
2906 /**
2907 * Whether the indicator should hide when not animating (true by default).
2908 */
2909 hidesWhenStopped?: boolean | undefined;
2910
2911 /**
2912 * Size of the indicator.
2913 * Small has a height of 20, large has a height of 36.
2914 *
2915 * enum('small', 'large')
2916 */
2917 size?: number | 'small' | 'large' | undefined;
2918
2919 style?: StyleProp<ViewStyle> | undefined;
2920}
2921
2922declare class ActivityIndicatorComponent extends React.Component<ActivityIndicatorProps> {}
2923declare const ActivityIndicatorBase: Constructor<NativeMethods> & typeof ActivityIndicatorComponent;
2924export class ActivityIndicator extends ActivityIndicatorBase {}
2925
2926/**
2927 * @see https://reactnative.dev/docs/activityindicatorios#props
2928 */
2929export interface ActivityIndicatorIOSProps extends ViewProps {
2930 /**
2931 * Whether to show the indicator (true, the default) or hide it (false).
2932 */
2933 animating?: boolean | undefined;
2934
2935 /**
2936 * The foreground color of the spinner (default is gray).
2937 */
2938 color?: ColorValue | undefined;
2939
2940 /**
2941 * Whether the indicator should hide when not animating (true by default).
2942 */
2943 hidesWhenStopped?: boolean | undefined;
2944
2945 /**
2946 * Invoked on mount and layout changes with
2947 */
2948 onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
2949
2950 /**
2951 * Size of the indicator.
2952 * Small has a height of 20, large has a height of 36.
2953 *
2954 * enum('small', 'large')
2955 */
2956 size?: 'small' | 'large' | undefined;
2957
2958 style?: StyleProp<ViewStyle> | undefined;
2959}
2960
2961export interface DatePickerIOSProps extends ViewProps {
2962 /**
2963 * The currently selected date.
2964 */
2965 date?: Date | null | undefined;
2966
2967 /**
2968 * Provides an initial value that will change when the user starts selecting
2969 * a date. It is useful for simple use-cases where you do not want to deal
2970 * with listening to events and updating the date prop to keep the
2971 * controlled state in sync. The controlled state has known bugs which
2972 * causes it to go out of sync with native. The initialDate prop is intended
2973 * to allow you to have native be source of truth.
2974 */
2975 initialDate?: Date | null | undefined;
2976
2977 /**
2978 * The date picker locale.
2979 */
2980 locale?: string | undefined;
2981
2982 /**
2983 * Maximum date.
2984 * Restricts the range of possible date/time values.
2985 */
2986 maximumDate?: Date | undefined;
2987
2988 /**
2989 * Maximum date.
2990 * Restricts the range of possible date/time values.
2991 */
2992 minimumDate?: Date | undefined;
2993
2994 /**
2995 * enum(1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30)
2996 * The interval at which minutes can be selected.
2997 */
2998 minuteInterval?: 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30 | undefined;
2999
3000 /**
3001 * enum('date', 'time', 'datetime')
3002 * The date picker mode.
3003 */
3004 mode?: 'date' | 'time' | 'datetime' | undefined;
3005
3006 /**
3007 * Date change handler.
3008 * This is called when the user changes the date or time in the UI.
3009 * The first and only argument is a Date object representing the new date and time.
3010 */
3011 onDateChange: (newDate: Date) => void;
3012
3013 /**
3014 * Timezone offset in minutes.
3015 * By default, the date picker will use the device's timezone. With this parameter, it is possible to force a certain timezone offset.
3016 * For instance, to show times in Pacific Standard Time, pass -7 * 60.
3017 */
3018 timeZoneOffsetInMinutes?: number | undefined;
3019}
3020
3021declare class DatePickerIOSComponent extends React.Component<DatePickerIOSProps> {}
3022declare const DatePickerIOSBase: Constructor<NativeMethods> & typeof DatePickerIOSComponent;
3023
3024/**
3025 * DatePickerIOS has been merged with DatePickerAndroid and will be removed in a future release.
3026 * It can now be installed and imported from `@react-native-community/datetimepicker` instead of 'react-native'.
3027 * @see https://github.com/react-native-community/datetimepicker
3028 * @deprecated
3029 */
3030export class DatePickerIOS extends DatePickerIOSBase {}
3031
3032export interface DrawerSlideEvent extends NativeSyntheticEvent<NativeTouchEvent> {}
3033
3034/**
3035 * @see DrawerLayoutAndroid.android.js
3036 */
3037export interface DrawerLayoutAndroidProps extends ViewProps {
3038 /**
3039 * Specifies the background color of the drawer. The default value
3040 * is white. If you want to set the opacity of the drawer, use rgba.
3041 * Example:
3042 * return (
3043 * <DrawerLayoutAndroid drawerBackgroundColor="rgba(0,0,0,0.5)">
3044 * </DrawerLayoutAndroid>
3045 *);
3046 */
3047 drawerBackgroundColor?: ColorValue | undefined;
3048
3049 /**
3050 * Specifies the lock mode of the drawer. The drawer can be locked
3051 * in 3 states:
3052 *
3053 * - unlocked (default), meaning that the drawer will respond
3054 * (open/close) to touch gestures.
3055 *
3056 * - locked-closed, meaning that the drawer will stay closed and not
3057 * respond to gestures.
3058 *
3059 * - locked-open, meaning that the drawer will stay opened and
3060 * not respond to gestures. The drawer may still be opened and
3061 * closed programmatically (openDrawer/closeDrawer).
3062 */
3063 drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open' | undefined;
3064
3065 /**
3066 * Specifies the side of the screen from which the drawer will slide in.
3067 * - 'left' (the default)
3068 * - 'right'
3069 */
3070 drawerPosition?: 'left' | 'right' | undefined;
3071
3072 /**
3073 * Specifies the width of the drawer, more precisely the width of the
3074 * view that be pulled in from the edge of the window.
3075 */
3076 drawerWidth?: number | undefined;
3077
3078 /**
3079 * Determines whether the keyboard gets dismissed in response to a drag.
3080 * - 'none' (the default), drags do not dismiss the keyboard.
3081 * - 'on-drag', the keyboard is dismissed when a drag begins.
3082 */
3083 keyboardDismissMode?: 'none' | 'on-drag' | undefined;
3084
3085 /**
3086 * Function called whenever the navigation view has been closed.
3087 */
3088 onDrawerClose?: (() => void) | undefined;
3089
3090 /**
3091 * Function called whenever the navigation view has been opened.
3092 */
3093 onDrawerOpen?: (() => void) | undefined;
3094
3095 /**
3096 * Function called whenever there is an interaction with the navigation view.
3097 */
3098 onDrawerSlide?: ((event: DrawerSlideEvent) => void) | undefined;
3099
3100 /**
3101 * Function called when the drawer state has changed.
3102 * The drawer can be in 3 states:
3103 * - idle, meaning there is no interaction with the navigation
3104 * view happening at the time
3105 * - dragging, meaning there is currently an interaction with the
3106 * navigation view
3107 * - settling, meaning that there was an interaction with the
3108 * navigation view, and the navigation view is now finishing
3109 * it's closing or opening animation
3110 */
3111 onDrawerStateChanged?: ((event: 'Idle' | 'Dragging' | 'Settling') => void) | undefined;
3112
3113 /**
3114 * The navigation view that will be rendered to the side of the
3115 * screen and can be pulled in.
3116 */
3117 renderNavigationView: () => JSX.Element;
3118
3119 /**
3120 * Make the drawer take the entire screen and draw the background of
3121 * the status bar to allow it to open over the status bar. It will
3122 * only have an effect on API 21+.
3123 */
3124 statusBarBackgroundColor?: ColorValue | undefined;
3125}
3126
3127interface DrawerPosition {
3128 Left: number;
3129 Right: number;
3130}
3131
3132declare class DrawerLayoutAndroidComponent extends React.Component<DrawerLayoutAndroidProps> {}
3133declare const DrawerLayoutAndroidBase: Constructor<NativeMethods> & typeof DrawerLayoutAndroidComponent;
3134export class DrawerLayoutAndroid extends DrawerLayoutAndroidBase {
3135 /**
3136 * drawer's positions.
3137 */
3138 positions: DrawerPosition;
3139
3140 /**
3141 * Opens the drawer.
3142 */
3143 openDrawer(): void;
3144
3145 /**
3146 * Closes the drawer.
3147 */
3148 closeDrawer(): void;
3149}
3150
3151/**
3152 * @see PickerIOS.ios.js
3153 */
3154export interface PickerIOSItemProps {
3155 value?: string | undefined;
3156 label?: string | undefined;
3157 textColor?: ProcessedColorValue | undefined;
3158}
3159
3160/**
3161 * @see PickerIOS.ios.js
3162 */
3163export class PickerIOSItem extends React.Component<PickerIOSItemProps> {}
3164
3165/**
3166 * @see Picker.js
3167 */
3168export interface PickerItemProps {
3169 testID?: string | undefined;
3170 color?: ColorValue | undefined;
3171 label: string;
3172 value?: string | undefined;
3173}
3174
3175export interface PickerPropsIOS extends ViewProps {
3176 /**
3177 * Style to apply to each of the item labels.
3178 * @platform ios
3179 */
3180 itemStyle?: StyleProp<TextStyle> | undefined;
3181}
3182
3183export interface PickerPropsAndroid extends ViewProps {
3184 /**
3185 * If set to false, the picker will be disabled, i.e. the user will not be able to make a
3186 * selection.
3187 * @platform android
3188 */
3189 enabled?: boolean | undefined;
3190
3191 /**
3192 * On Android, specifies how to display the selection items when the user taps on the picker:
3193 *
3194 * - 'dialog': Show a modal dialog. This is the default.
3195 * - 'dropdown': Shows a dropdown anchored to the picker view
3196 *
3197 * @platform android
3198 */
3199 mode?: 'dialog' | 'dropdown' | undefined;
3200
3201 /**
3202 * Prompt string for this picker, used on Android in dialog mode as the title of the dialog.
3203 * @platform android
3204 */
3205 prompt?: string | undefined;
3206}
3207
3208/**
3209 * @see https://reactnative.dev/docs/picker
3210 * @see Picker.js
3211 */
3212export interface PickerProps extends PickerPropsIOS, PickerPropsAndroid {
3213 /**
3214 * Callback for when an item is selected. This is called with the
3215 * following parameters:
3216 * - itemValue: the value prop of the item that was selected
3217 * - itemPosition: the index of the selected item in this picker
3218 */
3219 onValueChange?: ((itemValue: any, itemPosition: number) => void) | undefined;
3220
3221 /**
3222 * Value matching value of one of the items.
3223 * Can be a string or an integer.
3224 */
3225 selectedValue?: string | undefined;
3226
3227 style?: StyleProp<TextStyle> | undefined;
3228
3229 /**
3230 * Used to locate this view in end-to-end tests.
3231 */
3232 testId?: string | undefined;
3233}
3234
3235/**
3236 * Picker has been extracted from react-native core and will be removed in a future release.
3237 * It can now be installed and imported from `@react-native-community/picker` instead of 'react-native'.
3238 * @see https://github.com/react-native-community/react-native-picker
3239 * @deprecated
3240 */
3241export class Picker extends React.Component<PickerProps> {
3242 /**
3243 * On Android, display the options in a dialog.
3244 */
3245 static MODE_DIALOG: string;
3246
3247 /**
3248 * On Android, display the options in a dropdown (this is the default).
3249 */
3250 static MODE_DROPDOWN: string;
3251
3252 static Item: React.ComponentType<PickerItemProps>;
3253}
3254
3255/**
3256 * @see https://reactnative.dev/docs/pickerios
3257 * @see PickerIOS.ios.js
3258 */
3259export interface PickerIOSProps extends ViewProps {
3260 itemStyle?: StyleProp<TextStyle> | undefined;
3261 onValueChange?: ((value: string) => void) | undefined;
3262 selectedValue?: string | undefined;
3263}
3264
3265/**
3266 * @see https://reactnative.dev/docs/pickerios
3267 * @see PickerIOS.ios.js
3268 */
3269declare class PickerIOSComponent extends React.Component<PickerIOSProps> {}
3270declare const PickerIOSBase: Constructor<NativeMethods> & typeof PickerIOSComponent;
3271/**
3272 * PickerIOS has been extracted from react-native core and will be removed in a future release.
3273 * It can now be installed and imported from `@react-native-community/picker` instead of 'react-native'.
3274 * @see https://github.com/react-native-community/react-native-picker
3275 * @deprecated
3276 */
3277export class PickerIOS extends PickerIOSBase {
3278 static Item: typeof PickerIOSItem;
3279}
3280
3281/**
3282 * ProgressBarAndroid has been extracted from react-native core and will be removed in a future release.
3283 * It can now be installed and imported from `@react-native-community/progress-bar-android` instead of 'react-native'.
3284 * @see https://github.com/react-native-community/progress-bar-android
3285 * @deprecated
3286 */
3287export interface ProgressBarAndroidProps extends ViewProps {
3288 /**
3289 * Style of the ProgressBar. One of:
3290 Horizontal
3291 Normal (default)
3292 Small
3293 Large
3294 Inverse
3295 SmallInverse
3296 LargeInverse
3297 */
3298 styleAttr?: 'Horizontal' | 'Normal' | 'Small' | 'Large' | 'Inverse' | 'SmallInverse' | 'LargeInverse' | undefined;
3299
3300 /**
3301 * If the progress bar will show indeterminate progress.
3302 * Note that this can only be false if styleAttr is Horizontal.
3303 */
3304 indeterminate?: boolean | undefined;
3305
3306 /**
3307 * The progress value (between 0 and 1).
3308 */
3309 progress?: number | undefined;
3310
3311 /**
3312 * Whether to show the ProgressBar (true, the default) or hide it (false).
3313 */
3314 animating?: boolean | undefined;
3315
3316 /**
3317 * Color of the progress bar.
3318 */
3319 color?: ColorValue | undefined;
3320
3321 /**
3322 * Used to locate this view in end-to-end tests.
3323 */
3324 testID?: string | undefined;
3325}
3326/**
3327 * React component that wraps the Android-only `ProgressBar`. This component is used to indicate
3328 * that the app is loading or there is some activity in the app.
3329 */
3330declare class ProgressBarAndroidComponent extends React.Component<ProgressBarAndroidProps> {}
3331declare const ProgressBarAndroidBase: Constructor<NativeMethods> & typeof ProgressBarAndroidComponent;
3332/**
3333 * ProgressBarAndroid has been extracted from react-native core and will be removed in a future release.
3334 * It can now be installed and imported from `@react-native-community/progress-bar-android` instead of 'react-native'.
3335 * @see https://github.com/react-native-progress-view/progress-bar-android
3336 * @deprecated
3337 */
3338export class ProgressBarAndroid extends ProgressBarAndroidBase {}
3339
3340/**
3341 * @see https://reactnative.dev/docs/progressviewios
3342 * @see ProgressViewIOS.ios.js
3343 */
3344export interface ProgressViewIOSProps extends ViewProps {
3345 /**
3346 * The progress bar style.
3347 */
3348 progressViewStyle?: 'default' | 'bar' | undefined;
3349
3350 /**
3351 * The progress value (between 0 and 1).
3352 */
3353 progress?: number | undefined;
3354
3355 /**
3356 * The tint color of the progress bar itself.
3357 */
3358 progressTintColor?: ColorValue | undefined;
3359
3360 /**
3361 * The tint color of the progress bar track.
3362 */
3363 trackTintColor?: ColorValue | undefined;
3364
3365 /**
3366 * A stretchable image to display as the progress bar.
3367 */
3368 progressImage?: ImageURISource | ImageURISource[] | undefined;
3369
3370 /**
3371 * A stretchable image to display behind the progress bar.
3372 */
3373 trackImage?: ImageURISource | ImageURISource[] | undefined;
3374}
3375declare class ProgressViewIOSComponent extends React.Component<ProgressViewIOSProps> {}
3376declare const ProgressViewIOSBase: Constructor<NativeMethods> & typeof ProgressViewIOSComponent;
3377/**
3378 * ProgressViewIOS has been extracted from react-native core and will be removed in a future release.
3379 * It can now be installed and imported from `@react-native-community/progress-view` instead of 'react-native'.
3380 * @see https://github.com/react-native-community/progress-view
3381 * @deprecated
3382 */
3383export class ProgressViewIOS extends ProgressViewIOSBase {}
3384
3385export interface RefreshControlPropsIOS extends ViewProps {
3386 /**
3387 * The color of the refresh indicator.
3388 */
3389 tintColor?: ColorValue | undefined;
3390
3391 /**
3392 * The title displayed under the refresh indicator.
3393 */
3394 title?: string | undefined;
3395
3396 /**
3397 * Title color.
3398 */
3399 titleColor?: ColorValue | undefined;
3400}
3401
3402export interface RefreshControlPropsAndroid extends ViewProps {
3403 /**
3404 * The colors (at least one) that will be used to draw the refresh indicator.
3405 */
3406 colors?: ColorValue[] | undefined;
3407
3408 /**
3409 * Whether the pull to refresh functionality is enabled.
3410 */
3411 enabled?: boolean | undefined;
3412
3413 /**
3414 * The background color of the refresh indicator.
3415 */
3416 progressBackgroundColor?: ColorValue | undefined;
3417
3418 /**
3419 * Size of the refresh indicator, see RefreshControl.SIZE.
3420 */
3421 size?: number | undefined;
3422
3423 /**
3424 * Progress view top offset
3425 * @platform android
3426 */
3427 progressViewOffset?: number | undefined;
3428}
3429
3430export interface RefreshControlProps extends RefreshControlPropsIOS, RefreshControlPropsAndroid {
3431 /**
3432 * Called when the view starts refreshing.
3433 */
3434 onRefresh?: (() => void) | undefined;
3435
3436 /**
3437 * Whether the view should be indicating an active refresh.
3438 */
3439 refreshing: boolean;
3440}
3441
3442/**
3443 * This component is used inside a ScrollView or ListView to add pull to refresh
3444 * functionality. When the ScrollView is at `scrollY: 0`, swiping down
3445 * triggers an `onRefresh` event.
3446 *
3447 * __Note:__ `refreshing` is a controlled prop, this is why it needs to be set to true
3448 * in the `onRefresh` function otherwise the refresh indicator will stop immediately.
3449 */
3450declare class RefreshControlComponent extends React.Component<RefreshControlProps> {}
3451declare const RefreshControlBase: Constructor<NativeMethods> & typeof RefreshControlComponent;
3452export class RefreshControl extends RefreshControlBase {
3453 static SIZE: Object; // Undocumented
3454}
3455
3456export interface RecyclerViewBackedScrollViewProps extends ScrollViewProps {}
3457
3458/**
3459 * Wrapper around android native recycler view.
3460 *
3461 * It simply renders rows passed as children in a separate recycler view cells
3462 * similarly to how `ScrollView` is doing it. Thanks to the fact that it uses
3463 * native `RecyclerView` though, rows that are out of sight are going to be
3464 * automatically detached (similarly on how this would work with
3465 * `removeClippedSubviews = true` on a `ScrollView.js`).
3466 *
3467 * CAUTION: This is an experimental component and should only be used together
3468 * with javascript implementation of list view (see ListView.js). In order to
3469 * use it pass this component as `renderScrollComponent` to the list view. For
3470 * now only horizontal scrolling is supported.
3471 */
3472declare class RecyclerViewBackedScrollViewComponent extends React.Component<RecyclerViewBackedScrollViewProps> {}
3473declare const RecyclerViewBackedScrollViewBase: Constructor<ScrollResponderMixin> &
3474 typeof RecyclerViewBackedScrollViewComponent;
3475export class RecyclerViewBackedScrollView extends RecyclerViewBackedScrollViewBase {
3476 /**
3477 * A helper function to scroll to a specific point in the scrollview.
3478 * This is currently used to help focus on child textviews, but can also
3479 * be used to quickly scroll to any element we want to focus. Syntax:
3480 *
3481 * scrollResponderScrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
3482 *
3483 * Note: The weird argument signature is due to the fact that, for historical reasons,
3484 * the function also accepts separate arguments as an alternative to the options object.
3485 * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
3486 */
3487 scrollTo(y?: number | { x?: number | undefined; y?: number | undefined; animated?: boolean | undefined }, x?: number, animated?: boolean): void;
3488
3489 /**
3490 * Returns a reference to the underlying scroll responder, which supports
3491 * operations like `scrollTo`. All ScrollView-like components should
3492 * implement this method so that they can be composed while providing access
3493 * to the underlying scroll responder's methods.
3494 */
3495 getScrollResponder(): JSX.Element;
3496}
3497
3498export interface SliderPropsAndroid extends ViewProps {
3499 /**
3500 * Color of the foreground switch grip.
3501 */
3502 thumbTintColor?: ColorValue | undefined;
3503}
3504
3505export interface SliderPropsIOS extends ViewProps {
3506 /**
3507 * Assigns a maximum track image. Only static images are supported.
3508 * The leftmost pixel of the image will be stretched to fill the track.
3509 */
3510 maximumTrackImage?: ImageURISource | undefined;
3511
3512 /**
3513 * Assigns a minimum track image. Only static images are supported.
3514 * The rightmost pixel of the image will be stretched to fill the track.
3515 */
3516 minimumTrackImage?: ImageURISource | undefined;
3517
3518 /**
3519 * Sets an image for the thumb. Only static images are supported.
3520 */
3521 thumbImage?: ImageURISource | undefined;
3522
3523 /**
3524 * Assigns a single image for the track. Only static images
3525 * are supported. The center pixel of the image will be stretched
3526 * to fill the track.
3527 */
3528 trackImage?: ImageURISource | undefined;
3529}
3530
3531export interface SliderProps extends SliderPropsIOS, SliderPropsAndroid {
3532 /**
3533 * If true the user won't be able to move the slider.
3534 * Default value is false.
3535 */
3536 disabled?: boolean | undefined;
3537
3538 /**
3539 * The color used for the track to the right of the button.
3540 * Overrides the default blue gradient image.
3541 */
3542 maximumTrackTintColor?: ColorValue | undefined;
3543
3544 /**
3545 * Initial maximum value of the slider. Default value is 1.
3546 */
3547 maximumValue?: number | undefined;
3548
3549 /**
3550 * The color used for the track to the left of the button.
3551 * Overrides the default blue gradient image.
3552 */
3553 minimumTrackTintColor?: ColorValue | undefined;
3554
3555 /**
3556 * Initial minimum value of the slider. Default value is 0.
3557 */
3558 minimumValue?: number | undefined;
3559
3560 /**
3561 * Callback called when the user finishes changing the value (e.g. when the slider is released).
3562 */
3563 onSlidingComplete?: ((value: number) => void) | undefined;
3564
3565 /**
3566 * Callback continuously called while the user is dragging the slider.
3567 */
3568 onValueChange?: ((value: number) => void) | undefined;
3569
3570 /**
3571 * Step value of the slider. The value should be between 0 and (maximumValue - minimumValue). Default value is 0.
3572 */
3573 step?: number | undefined;
3574
3575 /**
3576 * Used to style and layout the Slider. See StyleSheet.js and ViewStylePropTypes.js for more info.
3577 */
3578 style?: StyleProp<ViewStyle> | undefined;
3579
3580 /**
3581 * Used to locate this view in UI automation tests.
3582 */
3583 testID?: string | undefined;
3584
3585 /**
3586 * Initial value of the slider. The value should be between minimumValue
3587 * and maximumValue, which default to 0 and 1 respectively.
3588 * Default value is 0.
3589 * This is not a controlled component, you don't need to update
3590 * the value during dragging.
3591 */
3592 value?: number | undefined;
3593}
3594
3595/**
3596 * A component used to select a single value from a range of values.
3597 */
3598declare class SliderComponent extends React.Component<SliderProps> {}
3599declare const SliderBase: Constructor<NativeMethods> & typeof SliderComponent;
3600/**
3601 * Slider has been extracted from react-native core and will be removed in a future release.
3602 * It can now be installed and imported from `@react-native-community/slider` instead of 'react-native'.
3603 * @see https://github.com/callstack/react-native-slider
3604 * @deprecated
3605 */
3606export class Slider extends SliderBase {}
3607/** SliderIOS has been removed from react-native.
3608 * It can now be installed and imported from `@react-native-community/slider` instead of 'react-native'.
3609 * @see https://github.com/callstack/react-native-slider
3610 * @deprecated
3611 */
3612export type SliderIOS = Slider;
3613
3614/**
3615 * SwitchIOS Component has been removed from react-native in favor of Switch Component
3616 * https://github.com/facebook/react-native/pull/9891/files
3617 * @deprecated see SwitchProps
3618 */
3619export interface SwitchIOSProps extends ViewProps {
3620 /**
3621 * If true the user won't be able to toggle the switch. Default value is false.
3622 */
3623 disabled?: boolean | undefined;
3624
3625 /**
3626 * Background color when the switch is turned on.
3627 */
3628 onTintColor?: ColorValue | undefined;
3629
3630 /**
3631 * Callback that is called when the user toggles the switch.
3632 */
3633 onValueChange?: ((value: boolean) => void) | undefined;
3634
3635 /**
3636 * Background color for the switch round button.
3637 */
3638 thumbTintColor?: ColorValue | undefined;
3639
3640 /**
3641 * Background color when the switch is turned off.
3642 */
3643 tintColor?: ColorValue | undefined;
3644
3645 /**
3646 * The value of the switch, if true the switch will be turned on. Default value is false.
3647 */
3648 value?: boolean | undefined;
3649}
3650
3651/**
3652 * SwitchIOS component has been removed from react-native in favor of Switch component
3653 * https://github.com/facebook/react-native/pull/9891/files
3654 * @deprecated see Switch
3655 */
3656export class SwitchIOS extends React.Component<SwitchIOSProps> {}
3657
3658export type ImageResizeMode = 'cover' | 'contain' | 'stretch' | 'repeat' | 'center';
3659
3660/**
3661 * @see ImageResizeMode.js
3662 */
3663export interface ImageResizeModeStatic {
3664 /**
3665 * contain - The image will be resized such that it will be completely
3666 * visible, contained within the frame of the View.
3667 */
3668 contain: ImageResizeMode;
3669 /**
3670 * cover - The image will be resized such that the entire area of the view
3671 * is covered by the image, potentially clipping parts of the image.
3672 */
3673 cover: ImageResizeMode;
3674 /**
3675 * stretch - The image will be stretched to fill the entire frame of the
3676 * view without clipping. This may change the aspect ratio of the image,
3677 * distoring it. Only supported on iOS.
3678 */
3679 stretch: ImageResizeMode;
3680 /**
3681 * center - The image will be scaled down such that it is completely visible,
3682 * if bigger than the area of the view.
3683 * The image will not be scaled up.
3684 */
3685 center: ImageResizeMode;
3686
3687 /**
3688 * repeat - The image will be repeated to cover the frame of the View. The
3689 * image will keep it's size and aspect ratio.
3690 */
3691 repeat: ImageResizeMode;
3692}
3693
3694export interface ShadowStyleIOS {
3695 shadowColor?: ColorValue | undefined;
3696 shadowOffset?: { width: number; height: number } | undefined;
3697 shadowOpacity?: number | undefined;
3698 shadowRadius?: number | undefined;
3699}
3700
3701/**
3702 * Image style
3703 * @see https://reactnative.dev/docs/image#style
3704 * @see https://github.com/facebook/react-native/blob/master/Libraries/Image/ImageStylePropTypes.js
3705 */
3706export interface ImageStyle extends FlexStyle, ShadowStyleIOS, TransformsStyle {
3707 resizeMode?: ImageResizeMode | undefined;
3708 backfaceVisibility?: 'visible' | 'hidden' | undefined;
3709 borderBottomLeftRadius?: number | undefined;
3710 borderBottomRightRadius?: number | undefined;
3711 backgroundColor?: ColorValue | undefined;
3712 borderColor?: ColorValue | undefined;
3713 borderWidth?: number | undefined;
3714 borderRadius?: number | undefined;
3715 borderTopLeftRadius?: number | undefined;
3716 borderTopRightRadius?: number | undefined;
3717 overflow?: 'visible' | 'hidden' | undefined;
3718 overlayColor?: ColorValue | undefined;
3719 tintColor?: ColorValue | undefined;
3720 opacity?: number | undefined;
3721}
3722
3723/*
3724 * @see https://github.com/facebook/react-native/blob/master/Libraries/Image/ImageSourcePropType.js
3725 */
3726export interface ImageURISource {
3727 /**
3728 * `uri` is a string representing the resource identifier for the image, which
3729 * could be an http address, a local file path, or the name of a static image
3730 * resource (which should be wrapped in the `require('./path/to/image.png')`
3731 * function).
3732 */
3733 uri?: string | undefined;
3734 /**
3735 * `bundle` is the iOS asset bundle which the image is included in. This
3736 * will default to [NSBundle mainBundle] if not set.
3737 * @platform ios
3738 */
3739 bundle?: string | undefined;
3740 /**
3741 * `method` is the HTTP Method to use. Defaults to GET if not specified.
3742 */
3743 method?: string | undefined;
3744 /**
3745 * `headers` is an object representing the HTTP headers to send along with the
3746 * request for a remote image.
3747 */
3748 headers?: { [key: string]: string } | undefined;
3749 /**
3750 * `cache` determines how the requests handles potentially cached
3751 * responses.
3752 *
3753 * - `default`: Use the native platforms default strategy. `useProtocolCachePolicy` on iOS.
3754 *
3755 * - `reload`: The data for the URL will be loaded from the originating source.
3756 * No existing cache data should be used to satisfy a URL load request.
3757 *
3758 * - `force-cache`: The existing cached data will be used to satisfy the request,
3759 * regardless of its age or expiration date. If there is no existing data in the cache
3760 * corresponding the request, the data is loaded from the originating source.
3761 *
3762 * - `only-if-cached`: The existing cache data will be used to satisfy a request, regardless of
3763 * its age or expiration date. If there is no existing data in the cache corresponding
3764 * to a URL load request, no attempt is made to load the data from the originating source,
3765 * and the load is considered to have failed.
3766 *
3767 * @platform ios
3768 */
3769 cache?: 'default' | 'reload' | 'force-cache' | 'only-if-cached' | undefined;
3770 /**
3771 * `body` is the HTTP body to send with the request. This must be a valid
3772 * UTF-8 string, and will be sent exactly as specified, with no
3773 * additional encoding (e.g. URL-escaping or base64) applied.
3774 */
3775 body?: string | undefined;
3776 /**
3777 * `width` and `height` can be specified if known at build time, in which case
3778 * these will be used to set the default `<Image/>` component dimensions.
3779 */
3780 width?: number | undefined;
3781 height?: number | undefined;
3782 /**
3783 * `scale` is used to indicate the scale factor of the image. Defaults to 1.0 if
3784 * unspecified, meaning that one image pixel equates to one display point / DIP.
3785 */
3786 scale?: number | undefined;
3787}
3788
3789export type ImageRequireSource = number;
3790
3791/**
3792 * @see ImagePropsIOS.onProgress
3793 */
3794export interface ImageProgressEventDataIOS {
3795 loaded: number;
3796 total: number;
3797}
3798
3799export interface ImagePropsIOS {
3800 /**
3801 * blurRadius: the blur radius of the blur filter added to the image
3802 * @platform ios
3803 */
3804 blurRadius?: number | undefined;
3805
3806 /**
3807 * When the image is resized, the corners of the size specified by capInsets will stay a fixed size,
3808 * but the center content and borders of the image will be stretched.
3809 * This is useful for creating resizable rounded buttons, shadows, and other resizable assets.
3810 * More info on Apple documentation
3811 */
3812 capInsets?: Insets | undefined;
3813
3814 /**
3815 * Invoked on download progress with {nativeEvent: {loaded, total}}
3816 */
3817 onProgress?: ((event: NativeSyntheticEvent<ImageProgressEventDataIOS>) => void) | undefined;
3818
3819 /**
3820 * Invoked when a partial load of the image is complete. The definition of
3821 * what constitutes a "partial load" is loader specific though this is meant
3822 * for progressive JPEG loads.
3823 * @platform ios
3824 */
3825 onPartialLoad?: (() => void) | undefined;
3826}
3827
3828interface ImagePropsAndroid {
3829 /**
3830 * The mechanism that should be used to resize the image when the image's dimensions
3831 * differ from the image view's dimensions. Defaults to auto.
3832 *
3833 * 'auto': Use heuristics to pick between resize and scale.
3834 *
3835 * 'resize': A software operation which changes the encoded image in memory before it gets decoded.
3836 * This should be used instead of scale when the image is much larger than the view.
3837 *
3838 * 'scale': The image gets drawn downscaled or upscaled. Compared to resize, scale is faster (usually hardware accelerated)
3839 * and produces higher quality images. This should be used if the image is smaller than the view.
3840 * It should also be used if the image is slightly bigger than the view.
3841 */
3842 resizeMethod?: 'auto' | 'resize' | 'scale' | undefined;
3843
3844 /**
3845 * Duration of fade in animation in ms. Defaults to 300
3846 *
3847 * @platform android
3848 */
3849 fadeDuration?: number | undefined;
3850
3851 /**
3852 * Required if loading images via 'uri' from drawable folder on Android.
3853 * Explanation: https://medium.com/@adamjacobb/react-native-performance-images-adf5843e120
3854 */
3855 width?: number | undefined;
3856
3857 /**
3858 * Required if loading images via 'uri' from drawable folder on Android
3859 * Explanation: https://medium.com/@adamjacobb/react-native-performance-images-adf5843e120
3860 */
3861 height?: number | undefined;
3862}
3863
3864/**
3865 * @see https://reactnative.dev/docs/image#source
3866 */
3867export type ImageSourcePropType = ImageURISource | ImageURISource[] | ImageRequireSource;
3868
3869export interface ImageLoadEventData {
3870 source: {
3871 height: number;
3872 width: number;
3873 uri: string;
3874 };
3875}
3876
3877export interface ImageErrorEventData {
3878 error: any;
3879}
3880
3881/**
3882 * @see https://reactnative.dev/docs/image#resolveassetsource
3883 */
3884export interface ImageResolvedAssetSource {
3885 height: number;
3886 width: number;
3887 scale: number;
3888 uri: string;
3889}
3890
3891/**
3892 * @see https://reactnative.dev/docs/image
3893 */
3894export interface ImagePropsBase extends ImagePropsIOS, ImagePropsAndroid, AccessibilityProps {
3895 /**
3896 * onLayout function
3897 *
3898 * Invoked on mount and layout changes with
3899 *
3900 * {nativeEvent: { layout: {x, y, width, height} }}.
3901 */
3902 onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
3903
3904 /**
3905 * Invoked on load error with {nativeEvent: {error}}
3906 */
3907 onError?: ((error: NativeSyntheticEvent<ImageErrorEventData>) => void) | undefined;
3908
3909 /**
3910 * Invoked when load completes successfully
3911 * { source: { uri, height, width } }.
3912 */
3913 onLoad?: ((event: NativeSyntheticEvent<ImageLoadEventData>) => void) | undefined;
3914
3915 /**
3916 * Invoked when load either succeeds or fails
3917 */
3918 onLoadEnd?: (() => void) | undefined;
3919
3920 /**
3921 * Invoked on load start
3922 */
3923 onLoadStart?: (() => void) | undefined;
3924
3925 progressiveRenderingEnabled?: boolean | undefined;
3926
3927 borderRadius?: number | undefined;
3928
3929 borderTopLeftRadius?: number | undefined;
3930
3931 borderTopRightRadius?: number | undefined;
3932
3933 borderBottomLeftRadius?: number | undefined;
3934
3935 borderBottomRightRadius?: number | undefined;
3936
3937 /**
3938 * Determines how to resize the image when the frame doesn't match the raw
3939 * image dimensions.
3940 *
3941 * 'cover': Scale the image uniformly (maintain the image's aspect ratio)
3942 * so that both dimensions (width and height) of the image will be equal
3943 * to or larger than the corresponding dimension of the view (minus padding).
3944 *
3945 * 'contain': Scale the image uniformly (maintain the image's aspect ratio)
3946 * so that both dimensions (width and height) of the image will be equal to
3947 * or less than the corresponding dimension of the view (minus padding).
3948 *
3949 * 'stretch': Scale width and height independently, This may change the
3950 * aspect ratio of the src.
3951 *
3952 * 'repeat': Repeat the image to cover the frame of the view.
3953 * The image will keep it's size and aspect ratio. (iOS only)
3954 *
3955 * 'center': Scale the image down so that it is completely visible,
3956 * if bigger than the area of the view.
3957 * The image will not be scaled up.
3958 */
3959 resizeMode?: ImageResizeMode | undefined;
3960
3961 /**
3962 * The mechanism that should be used to resize the image when the image's dimensions
3963 * differ from the image view's dimensions. Defaults to `auto`.
3964 *
3965 * - `auto`: Use heuristics to pick between `resize` and `scale`.
3966 *
3967 * - `resize`: A software operation which changes the encoded image in memory before it
3968 * gets decoded. This should be used instead of `scale` when the image is much larger
3969 * than the view.
3970 *
3971 * - `scale`: The image gets drawn downscaled or upscaled. Compared to `resize`, `scale` is
3972 * faster (usually hardware accelerated) and produces higher quality images. This
3973 * should be used if the image is smaller than the view. It should also be used if the
3974 * image is slightly bigger than the view.
3975 *
3976 * More details about `resize` and `scale` can be found at http://frescolib.org/docs/resizing-rotating.html.
3977 *
3978 * @platform android
3979 */
3980 resizeMethod?: 'auto' | 'resize' | 'scale' | undefined;
3981
3982 /**
3983 * The image source (either a remote URL or a local file resource).
3984 *
3985 * This prop can also contain several remote URLs, specified together with their width and height and potentially with scale/other URI arguments.
3986 * The native side will then choose the best uri to display based on the measured size of the image container.
3987 * A cache property can be added to control how networked request interacts with the local cache.
3988 *
3989 * The currently supported formats are png, jpg, jpeg, bmp, gif, webp (Android only), psd (iOS only).
3990 */
3991 source: ImageSourcePropType;
3992
3993 /**
3994 * similarly to `source`, this property represents the resource used to render
3995 * the loading indicator for the image, displayed until image is ready to be
3996 * displayed, typically after when it got downloaded from network.
3997 */
3998 loadingIndicatorSource?: ImageURISource | undefined;
3999
4000 /**
4001 * A unique identifier for this element to be used in UI Automation testing scripts.
4002 */
4003 testID?: string | undefined;
4004
4005 /**
4006 * Used to reference react managed images from native code.
4007 */
4008 nativeID?: string | undefined;
4009
4010 /**
4011 * A static image to display while downloading the final image off the network.
4012 */
4013 defaultSource?: ImageURISource | number | undefined;
4014}
4015
4016export interface ImageProps extends ImagePropsBase {
4017 /**
4018 *
4019 * Style
4020 */
4021 style?: StyleProp<ImageStyle> | undefined;
4022}
4023
4024declare class ImageComponent extends React.Component<ImageProps> {}
4025declare const ImageBase: Constructor<NativeMethods> & typeof ImageComponent;
4026export class Image extends ImageBase {
4027 static getSize(uri: string, success: (width: number, height: number) => void, failure?: (error: any) => void): any;
4028 static getSizeWithHeaders(
4029 uri: string,
4030 headers: { [index: string]: string },
4031 success: (width: number, height: number) => void,
4032 failure?: (error: any) => void,
4033 ): any;
4034 static prefetch(url: string): Promise<boolean>;
4035 static abortPrefetch?(requestId: number): void;
4036 static queryCache?(urls: string[]): Promise<{ [url: string]: 'memory' | 'disk' | 'disk/memory' }>;
4037
4038 /**
4039 * @see https://reactnative.dev/docs/image#resolveassetsource
4040 */
4041 static resolveAssetSource(source: ImageSourcePropType): ImageResolvedAssetSource;
4042}
4043
4044export interface ImageBackgroundProps extends ImagePropsBase {
4045 imageStyle?: StyleProp<ImageStyle> | undefined;
4046 style?: StyleProp<ViewStyle> | undefined;
4047 imageRef?(image: Image): void;
4048}
4049
4050declare class ImageBackgroundComponent extends React.Component<ImageBackgroundProps> {}
4051declare const ImageBackgroundBase: Constructor<NativeMethods> & typeof ImageBackgroundComponent;
4052export class ImageBackground extends ImageBackgroundBase {
4053 resizeMode: ImageResizeMode;
4054 getSize(uri: string, success: (width: number, height: number) => void, failure: (error: any) => void): any;
4055 prefetch(url: string): any;
4056 abortPrefetch?(requestId: number): void;
4057 queryCache?(urls: string[]): Promise<{ [url: string]: 'memory' | 'disk' | 'disk/memory' }>;
4058}
4059
4060export interface ViewToken {
4061 item: any;
4062 key: string;
4063 index: number | null;
4064 isViewable: boolean;
4065 section?: any;
4066}
4067
4068export interface ViewabilityConfig {
4069 /**
4070 * Minimum amount of time (in milliseconds) that an item must be physically viewable before the
4071 * viewability callback will be fired. A high number means that scrolling through content without
4072 * stopping will not mark the content as viewable.
4073 */
4074 minimumViewTime?: number | undefined;
4075
4076 /**
4077 * Percent of viewport that must be covered for a partially occluded item to count as
4078 * "viewable", 0-100. Fully visible items are always considered viewable. A value of 0 means
4079 * that a single pixel in the viewport makes the item viewable, and a value of 100 means that
4080 * an item must be either entirely visible or cover the entire viewport to count as viewable.
4081 */
4082 viewAreaCoveragePercentThreshold?: number | undefined;
4083
4084 /**
4085 * Similar to `viewAreaCoveragePercentThreshold`, but considers the percent of the item that is visible,
4086 * rather than the fraction of the viewable area it covers.
4087 */
4088 itemVisiblePercentThreshold?: number | undefined;
4089
4090 /**
4091 * Nothing is considered viewable until the user scrolls or `recordInteraction` is called after
4092 * render.
4093 */
4094 waitForInteraction?: boolean | undefined;
4095}
4096
4097export interface ViewabilityConfigCallbackPair {
4098 viewabilityConfig: ViewabilityConfig;
4099 onViewableItemsChanged: ((info: { viewableItems: Array<ViewToken>; changed: Array<ViewToken> }) => void) | null;
4100}
4101
4102export type ViewabilityConfigCallbackPairs = ViewabilityConfigCallbackPair[];
4103
4104/**
4105 * @see https://reactnative.dev/docs/flatlist#props
4106 */
4107
4108export interface ListRenderItemInfo<ItemT> {
4109 item: ItemT;
4110
4111 index: number;
4112
4113 separators: {
4114 highlight: () => void;
4115 unhighlight: () => void;
4116 updateProps: (select: 'leading' | 'trailing', newProps: any) => void;
4117 };
4118}
4119
4120export type ListRenderItem<ItemT> = (info: ListRenderItemInfo<ItemT>) => React.ReactElement | null;
4121
4122export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
4123 /**
4124 * Rendered in between each item, but not at the top or bottom
4125 */
4126 ItemSeparatorComponent?: React.ComponentType<any> | null | undefined;
4127
4128 /**
4129 * Rendered when the list is empty.
4130 */
4131 ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4132
4133 /**
4134 * Rendered at the very end of the list.
4135 */
4136 ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4137
4138 /**
4139 * Styling for internal View for ListFooterComponent
4140 */
4141 ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;
4142
4143 /**
4144 * Rendered at the very beginning of the list.
4145 */
4146 ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4147
4148 /**
4149 * Styling for internal View for ListHeaderComponent
4150 */
4151 ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;
4152
4153 /**
4154 * Optional custom style for multi-item rows generated when numColumns > 1
4155 */
4156 columnWrapperStyle?: StyleProp<ViewStyle> | undefined;
4157
4158 /**
4159 * Determines when the keyboard should stay visible after a tap.
4160 * - 'never' (the default), tapping outside of the focused text input when the keyboard is up dismisses the keyboard. When this happens, children won't receive the tap.
4161 * - 'always', the keyboard will not dismiss automatically, and the scroll view will not catch taps, but children of the scroll view can catch taps.
4162 * - 'handled', the keyboard will not dismiss automatically when the tap was handled by a children, (or captured by an ancestor).
4163 * - false, deprecated, use 'never' instead
4164 * - true, deprecated, use 'always' instead
4165 */
4166 keyboardShouldPersistTaps?: boolean | 'always' | 'never' | 'handled' | undefined;
4167
4168 /**
4169 * For simplicity, data is just a plain array. If you want to use something else,
4170 * like an immutable list, use the underlying VirtualizedList directly.
4171 */
4172 data: ReadonlyArray<ItemT> | null | undefined;
4173
4174 /**
4175 * A marker property for telling the list to re-render (since it implements PureComponent).
4176 * If any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the `data` prop,
4177 * stick it here and treat it immutably.
4178 */
4179 extraData?: any;
4180
4181 /**
4182 * `getItemLayout` is an optional optimization that lets us skip measurement of dynamic
4183 * content if you know the height of items a priori. getItemLayout is the most efficient,
4184 * and is easy to use if you have fixed height items, for example:
4185 * ```
4186 * getItemLayout={(data, index) => (
4187 * {length: ITEM_HEIGHT, offset: ITEM_HEIGHT * index, index}
4188 * )}
4189 * ```
4190 * Remember to include separator length (height or width) in your offset calculation if you specify
4191 * `ItemSeparatorComponent`.
4192 */
4193 getItemLayout?: ((
4194 data: Array<ItemT> | null | undefined,
4195 index: number,
4196 ) => { length: number; offset: number; index: number }) | undefined;
4197
4198 /**
4199 * If true, renders items next to each other horizontally instead of stacked vertically.
4200 */
4201 horizontal?: boolean | null | undefined;
4202
4203 /**
4204 * How many items to render in the initial batch
4205 */
4206 initialNumToRender?: number | undefined;
4207
4208 /**
4209 * Instead of starting at the top with the first item, start at initialScrollIndex
4210 */
4211 initialScrollIndex?: number | null | undefined;
4212
4213 /**
4214 * Used to extract a unique key for a given item at the specified index. Key is used for caching
4215 * and as the react key to track item re-ordering. The default extractor checks `item.key`, then
4216 * falls back to using the index, like React does.
4217 */
4218 keyExtractor?: ((item: ItemT, index: number) => string) | undefined;
4219
4220 /**
4221 * Uses legacy MetroListView instead of default VirtualizedSectionList
4222 */
4223 legacyImplementation?: boolean | undefined;
4224
4225 /**
4226 * Multiple columns can only be rendered with `horizontal={false}` and will zig-zag like a `flexWrap` layout.
4227 * Items should all be the same height - masonry layouts are not supported.
4228 */
4229 numColumns?: number | undefined;
4230
4231 /**
4232 * Called once when the scroll position gets within onEndReachedThreshold of the rendered content.
4233 */
4234 onEndReached?: ((info: { distanceFromEnd: number }) => void) | null | undefined;
4235
4236 /**
4237 * How far from the end (in units of visible length of the list) the bottom edge of the
4238 * list must be from the end of the content to trigger the `onEndReached` callback.
4239 * Thus a value of 0.5 will trigger `onEndReached` when the end of the content is
4240 * within half the visible length of the list.
4241 */
4242 onEndReachedThreshold?: number | null | undefined;
4243
4244 /**
4245 * If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality.
4246 * Make sure to also set the refreshing prop correctly.
4247 */
4248 onRefresh?: (() => void) | null | undefined;
4249
4250 /**
4251 * Called when the viewability of rows changes, as defined by the `viewablePercentThreshold` prop.
4252 */
4253 onViewableItemsChanged?: ((info: { viewableItems: Array<ViewToken>; changed: Array<ViewToken> }) => void) | null | undefined;
4254
4255 /**
4256 * Set this true while waiting for new data from a refresh.
4257 */
4258 refreshing?: boolean | null | undefined;
4259
4260 /**
4261 * Takes an item from data and renders it into the list. Typical usage:
4262 * ```
4263 * _renderItem = ({item}) => (
4264 * <TouchableOpacity onPress={() => this._onPress(item)}>
4265 * <Text>{item.title}</Text>
4266 * <TouchableOpacity/>
4267 * );
4268 * ...
4269 * <FlatList data={[{title: 'Title Text', key: 'item1'}]} renderItem={this._renderItem} />
4270 * ```
4271 * Provides additional metadata like `index` if you need it.
4272 */
4273 renderItem: ListRenderItem<ItemT> | null | undefined;
4274
4275 /**
4276 * See `ViewabilityHelper` for flow type and further documentation.
4277 */
4278 viewabilityConfig?: any;
4279
4280 /**
4281 * Note: may have bugs (missing content) in some circumstances - use at your own risk.
4282 *
4283 * This may improve scroll performance for large lists.
4284 */
4285 removeClippedSubviews?: boolean | undefined;
4286
4287 /**
4288 * Fades out the edges of the the scroll content.
4289 *
4290 * If the value is greater than 0, the fading edges will be set accordingly
4291 * to the current scroll direction and position,
4292 * indicating if there is more content to show.
4293 *
4294 * The default value is 0.
4295 * @platform android
4296 */
4297 fadingEdgeLength?: number | undefined;
4298}
4299
4300export class FlatList<ItemT = any> extends React.Component<FlatListProps<ItemT>> {
4301 /**
4302 * Scrolls to the end of the content. May be janky without `getItemLayout` prop.
4303 */
4304 scrollToEnd: (params?: { animated?: boolean | null | undefined }) => void;
4305
4306 /**
4307 * Scrolls to the item at the specified index such that it is positioned in the viewable area
4308 * such that viewPosition 0 places it at the top, 1 at the bottom, and 0.5 centered in the middle.
4309 * Cannot scroll to locations outside the render window without specifying the getItemLayout prop.
4310 */
4311 scrollToIndex: (params: {
4312 animated?: boolean | null | undefined;
4313 index: number;
4314 viewOffset?: number | undefined;
4315 viewPosition?: number | undefined;
4316 }) => void;
4317
4318 /**
4319 * Requires linear scan through data - use `scrollToIndex` instead if possible.
4320 * May be janky without `getItemLayout` prop.
4321 */
4322 scrollToItem: (params: { animated?: boolean | null | undefined; item: ItemT; viewPosition?: number | undefined }) => void;
4323
4324 /**
4325 * Scroll to a specific content pixel offset, like a normal `ScrollView`.
4326 */
4327 scrollToOffset: (params: { animated?: boolean | null | undefined; offset: number }) => void;
4328
4329 /**
4330 * Tells the list an interaction has occurred, which should trigger viewability calculations,
4331 * e.g. if waitForInteractions is true and the user has not scrolled. This is typically called
4332 * by taps on items or by navigation actions.
4333 */
4334 recordInteraction: () => void;
4335
4336 /**
4337 * Displays the scroll indicators momentarily.
4338 */
4339 flashScrollIndicators: () => void;
4340
4341 /**
4342 * Provides a handle to the underlying scroll responder.
4343 */
4344 getScrollResponder: () => JSX.Element | null | undefined;
4345
4346 /**
4347 * Provides a reference to the underlying host component
4348 */
4349 getNativeScrollRef: () => React.RefObject<View> | React.RefObject<ScrollViewComponent> | null | undefined;
4350
4351 getScrollableNode: () => any;
4352
4353 // TODO: use `unknown` instead of `any` for Typescript >= 3.0
4354 setNativeProps: (props: { [key: string]: any }) => void;
4355}
4356
4357/**
4358 * @see https://reactnative.dev/docs/sectionlist
4359 */
4360
4361type DefaultSectionT = {
4362 [key: string]: any;
4363};
4364
4365export interface SectionBase<ItemT, SectionT = DefaultSectionT> {
4366 data: ReadonlyArray<ItemT>;
4367
4368 key?: string | undefined;
4369
4370 renderItem?: SectionListRenderItem<ItemT, SectionT> | undefined;
4371
4372 ItemSeparatorComponent?: React.ComponentType<any> | null | undefined;
4373
4374 keyExtractor?: ((item: ItemT, index: number) => string) | undefined;
4375}
4376
4377export type SectionListData<ItemT, SectionT = DefaultSectionT> = SectionBase<ItemT, SectionT> & SectionT;
4378
4379/**
4380 * @see https://reactnative.dev/docs/sectionlist.html#props
4381 */
4382
4383export interface SectionListRenderItemInfo<ItemT, SectionT = DefaultSectionT> extends ListRenderItemInfo<ItemT> {
4384 section: SectionListData<ItemT, SectionT>;
4385}
4386
4387export type SectionListRenderItem<ItemT, SectionT = DefaultSectionT> = (
4388 info: SectionListRenderItemInfo<ItemT, SectionT>,
4389) => React.ReactElement | null;
4390
4391export interface SectionListProps<ItemT, SectionT = DefaultSectionT>
4392 extends VirtualizedListWithoutRenderItemProps<ItemT> {
4393 /**
4394 * Rendered in between adjacent Items within each section.
4395 */
4396 ItemSeparatorComponent?: React.ComponentType<any> | null | undefined;
4397
4398 /**
4399 * Rendered when the list is empty.
4400 */
4401 ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4402
4403 /**
4404 * Rendered at the very end of the list.
4405 */
4406 ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4407
4408 /**
4409 * Rendered at the very beginning of the list.
4410 */
4411 ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4412
4413 /**
4414 * Rendered in between each section.
4415 */
4416 SectionSeparatorComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4417
4418 /**
4419 * A marker property for telling the list to re-render (since it implements PureComponent).
4420 * If any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the `data` prop,
4421 * stick it here and treat it immutably.
4422 */
4423 extraData?: any;
4424
4425 /**
4426 * `getItemLayout` is an optional optimization that lets us skip measurement of dynamic
4427 * content if you know the height of items a priori. getItemLayout is the most efficient,
4428 * and is easy to use if you have fixed height items, for example:
4429 * ```
4430 * getItemLayout={(data, index) => (
4431 * {length: ITEM_HEIGHT, offset: ITEM_HEIGHT * index, index}
4432 * )}
4433 * ```
4434 */
4435 getItemLayout?: ((
4436 data: SectionListData<ItemT, SectionT>[] | null,
4437 index: number,
4438 ) => { length: number; offset: number; index: number }) | undefined;
4439
4440 /**
4441 * How many items to render in the initial batch
4442 */
4443 initialNumToRender?: number | undefined;
4444
4445 /**
4446 * Reverses the direction of scroll. Uses scale transforms of -1.
4447 */
4448 inverted?: boolean | null | undefined;
4449
4450 /**
4451 * Used to extract a unique key for a given item at the specified index. Key is used for caching
4452 * and as the react key to track item re-ordering. The default extractor checks `item.key`, then
4453 * falls back to using the index, like React does.
4454 */
4455 keyExtractor?: ((item: ItemT, index: number) => string) | undefined;
4456
4457 /**
4458 * Called once when the scroll position gets within onEndReachedThreshold of the rendered content.
4459 */
4460 onEndReached?: ((info: { distanceFromEnd: number }) => void) | null | undefined;
4461
4462 /**
4463 * How far from the end (in units of visible length of the list) the bottom edge of the
4464 * list must be from the end of the content to trigger the `onEndReached` callback.
4465 * Thus a value of 0.5 will trigger `onEndReached` when the end of the content is
4466 * within half the visible length of the list.
4467 */
4468 onEndReachedThreshold?: number | null | undefined;
4469
4470 /**
4471 * If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality.
4472 * Make sure to also set the refreshing prop correctly.
4473 */
4474 onRefresh?: (() => void) | null | undefined;
4475
4476 /**
4477 * Used to handle failures when scrolling to an index that has not been measured yet.
4478 * Recommended action is to either compute your own offset and `scrollTo` it, or scroll as far
4479 * as possible and then try again after more items have been rendered.
4480 */
4481 onScrollToIndexFailed?: ((info: {
4482 index: number;
4483 highestMeasuredFrameIndex: number;
4484 averageItemLength: number;
4485 }) => void) | undefined;
4486
4487 /**
4488 * Set this true while waiting for new data from a refresh.
4489 */
4490 refreshing?: boolean | null | undefined;
4491
4492 /**
4493 * Default renderer for every item in every section. Can be over-ridden on a per-section basis.
4494 */
4495 renderItem?: SectionListRenderItem<ItemT, SectionT> | undefined;
4496
4497 /**
4498 * Rendered at the top of each section. Sticky headers are not yet supported.
4499 */
4500 renderSectionHeader?: ((info: { section: SectionListData<ItemT, SectionT> }) => React.ReactElement | null) | undefined;
4501
4502 /**
4503 * Rendered at the bottom of each section.
4504 */
4505 renderSectionFooter?: ((info: { section: SectionListData<ItemT, SectionT> }) => React.ReactElement | null) | undefined;
4506
4507 /**
4508 * An array of objects with data for each section.
4509 */
4510 sections: ReadonlyArray<SectionListData<ItemT, SectionT>>;
4511
4512 /**
4513 * Render a custom scroll component, e.g. with a differently styled `RefreshControl`.
4514 */
4515 renderScrollComponent?: ((props: ScrollViewProps) => React.ReactElement<ScrollViewProps>) | undefined;
4516
4517 /**
4518 * Note: may have bugs (missing content) in some circumstances - use at your own risk.
4519 *
4520 * This may improve scroll performance for large lists.
4521 */
4522 removeClippedSubviews?: boolean | undefined;
4523
4524 /**
4525 * Makes section headers stick to the top of the screen until the next one pushes it off.
4526 * Only enabled by default on iOS because that is the platform standard there.
4527 */
4528 stickySectionHeadersEnabled?: boolean | undefined;
4529
4530 /**
4531 * Uses legacy MetroListView instead of default VirtualizedSectionList
4532 */
4533 legacyImplementation?: boolean | undefined;
4534}
4535
4536export interface SectionListScrollParams {
4537 animated?: boolean | undefined;
4538 itemIndex: number;
4539 sectionIndex: number;
4540 viewOffset?: number | undefined;
4541 viewPosition?: number | undefined;
4542}
4543
4544export class SectionList<ItemT = any, SectionT = DefaultSectionT> extends React.Component<
4545 SectionListProps<ItemT, SectionT>
4546> {
4547 /**
4548 * Scrolls to the item at the specified sectionIndex and itemIndex (within the section)
4549 * positioned in the viewable area such that viewPosition 0 places it at the top
4550 * (and may be covered by a sticky header), 1 at the bottom, and 0.5 centered in the middle.
4551 */
4552 scrollToLocation(params: SectionListScrollParams): void;
4553
4554 /**
4555 * Tells the list an interaction has occurred, which should trigger viewability calculations, e.g.
4556 * if `waitForInteractions` is true and the user has not scrolled. This is typically called by
4557 * taps on items or by navigation actions.
4558 */
4559 recordInteraction(): void;
4560
4561 /**
4562 * Displays the scroll indicators momentarily.
4563 *
4564 * @platform ios
4565 */
4566 flashScrollIndicators(): void;
4567
4568 /**
4569 * Provides a handle to the underlying scroll responder.
4570 */
4571 getScrollResponder(): ScrollView | undefined;
4572
4573 /**
4574 * Provides a handle to the underlying scroll node.
4575 */
4576 getScrollableNode(): NodeHandle | undefined;
4577}
4578
4579/* This definition is deprecated because it extends the wrong base type */
4580export interface SectionListStatic<ItemT, SectionT = DefaultSectionT>
4581 extends React.ComponentClass<SectionListProps<ItemT, SectionT>> {
4582 /**
4583 * Scrolls to the item at the specified sectionIndex and itemIndex (within the section)
4584 * positioned in the viewable area such that viewPosition 0 places it at the top
4585 * (and may be covered by a sticky header), 1 at the bottom, and 0.5 centered in the middle.
4586 */
4587 scrollToLocation?(params: SectionListScrollParams): void;
4588}
4589
4590/**
4591 * @see https://reactnative.dev/docs/virtualizedlist
4592 */
4593
4594export class VirtualizedList<ItemT> extends React.Component<VirtualizedListProps<ItemT>> {
4595 scrollToEnd: (params?: { animated?: boolean | undefined }) => void;
4596 scrollToIndex: (params: { animated?: boolean | undefined; index: number; viewOffset?: number | undefined; viewPosition?: number | undefined }) => void;
4597 scrollToItem: (params: { animated?: boolean | undefined; item: ItemT; viewPosition?: number | undefined }) => void;
4598
4599 /**
4600 * Scroll to a specific content pixel offset in the list.
4601 * Param `offset` expects the offset to scroll to. In case of horizontal is true, the
4602 * offset is the x-value, in any other case the offset is the y-value.
4603 * Param `animated` (true by default) defines whether the list should do an animation while scrolling.
4604 */
4605 scrollToOffset: (params: { animated?: boolean | undefined; offset: number }) => void;
4606
4607 recordInteraction: () => void;
4608}
4609
4610/**
4611 * @see https://reactnative.dev/docs/virtualizedlist#props
4612 */
4613
4614export interface VirtualizedListProps<ItemT> extends VirtualizedListWithoutRenderItemProps<ItemT> {
4615 renderItem: ListRenderItem<ItemT> | null | undefined;
4616}
4617
4618export interface VirtualizedListWithoutRenderItemProps<ItemT> extends ScrollViewProps {
4619 /**
4620 * Rendered when the list is empty. Can be a React Component Class, a render function, or
4621 * a rendered element.
4622 */
4623 ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4624
4625 /**
4626 * Rendered at the bottom of all the items. Can be a React Component Class, a render function, or
4627 * a rendered element.
4628 */
4629 ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4630
4631 /**
4632 * Rendered at the top of all the items. Can be a React Component Class, a render function, or
4633 * a rendered element.
4634 */
4635 ListHeaderComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
4636
4637 /**
4638 * The default accessor functions assume this is an Array<{key: string}> but you can override
4639 * getItem, getItemCount, and keyExtractor to handle any type of index-based data.
4640 */
4641 data?: any;
4642
4643 /**
4644 * `debug` will turn on extra logging and visual overlays to aid with debugging both usage and
4645 * implementation, but with a significant perf hit.
4646 */
4647 debug?: boolean | undefined;
4648
4649 /**
4650 * DEPRECATED: Virtualization provides significant performance and memory optimizations, but fully
4651 * unmounts react instances that are outside of the render window. You should only need to disable
4652 * this for debugging purposes.
4653 */
4654 disableVirtualization?: boolean | undefined;
4655
4656 /**
4657 * A marker property for telling the list to re-render (since it implements `PureComponent`). If
4658 * any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
4659 * `data` prop, stick it here and treat it immutably.
4660 */
4661 extraData?: any;
4662
4663 /**
4664 * A generic accessor for extracting an item from any sort of data blob.
4665 */
4666 getItem?: ((data: any, index: number) => ItemT) | undefined;
4667
4668 /**
4669 * Determines how many items are in the data blob.
4670 */
4671 getItemCount?: ((data: any) => number) | undefined;
4672
4673 getItemLayout?: ((
4674 data: any,
4675 index: number,
4676 ) => {
4677 length: number;
4678 offset: number;
4679 index: number;
4680 }) | undefined;
4681
4682 horizontal?: boolean | null | undefined;
4683
4684 /**
4685 * How many items to render in the initial batch. This should be enough to fill the screen but not
4686 * much more. Note these items will never be unmounted as part of the windowed rendering in order
4687 * to improve perceived performance of scroll-to-top actions.
4688 */
4689 initialNumToRender?: number | undefined;
4690
4691 /**
4692 * Instead of starting at the top with the first item, start at `initialScrollIndex`. This
4693 * disables the "scroll to top" optimization that keeps the first `initialNumToRender` items
4694 * always rendered and immediately renders the items starting at this initial index. Requires
4695 * `getItemLayout` to be implemented.
4696 */
4697 initialScrollIndex?: number | null | undefined;
4698
4699 /**
4700 * Reverses the direction of scroll. Uses scale transforms of -1.
4701 */
4702 inverted?: boolean | null | undefined;
4703
4704 keyExtractor?: ((item: ItemT, index: number) => string) | undefined;
4705
4706 listKey?: string | undefined;
4707
4708 /**
4709 * The maximum number of items to render in each incremental render batch. The more rendered at
4710 * once, the better the fill rate, but responsiveness my suffer because rendering content may
4711 * interfere with responding to button taps or other interactions.
4712 */
4713 maxToRenderPerBatch?: number | undefined;
4714
4715 onEndReached?: ((info: { distanceFromEnd: number }) => void) | null | undefined;
4716
4717 onEndReachedThreshold?: number | null | undefined;
4718
4719 onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
4720
4721 /**
4722 * If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make
4723 * sure to also set the `refreshing` prop correctly.
4724 */
4725 onRefresh?: (() => void) | null | undefined;
4726
4727 /**
4728 * Used to handle failures when scrolling to an index that has not been measured yet.
4729 * Recommended action is to either compute your own offset and `scrollTo` it, or scroll as far
4730 * as possible and then try again after more items have been rendered.
4731 */
4732 onScrollToIndexFailed?: ((info: {
4733 index: number;
4734 highestMeasuredFrameIndex: number;
4735 averageItemLength: number;
4736 }) => void) | undefined;
4737
4738 /**
4739 * Called when the viewability of rows changes, as defined by the
4740 * `viewabilityConfig` prop.
4741 */
4742 onViewableItemsChanged?: ((info: { viewableItems: Array<ViewToken>; changed: Array<ViewToken> }) => void) | null | undefined;
4743
4744 /**
4745 * Set this when offset is needed for the loading indicator to show correctly.
4746 * @platform android
4747 */
4748 progressViewOffset?: number | undefined;
4749
4750 /**
4751 * Set this true while waiting for new data from a refresh.
4752 */
4753 refreshing?: boolean | null | undefined;
4754
4755 /**
4756 * Note: may have bugs (missing content) in some circumstances - use at your own risk.
4757 *
4758 * This may improve scroll performance for large lists.
4759 */
4760 removeClippedSubviews?: boolean | undefined;
4761
4762 /**
4763 * Render a custom scroll component, e.g. with a differently styled `RefreshControl`.
4764 */
4765 renderScrollComponent?: ((props: ScrollViewProps) => React.ReactElement<ScrollViewProps>) | undefined;
4766
4767 /**
4768 * Amount of time between low-pri item render batches, e.g. for rendering items quite a ways off
4769 * screen. Similar fill rate/responsiveness tradeoff as `maxToRenderPerBatch`.
4770 */
4771 updateCellsBatchingPeriod?: number | undefined;
4772
4773 viewabilityConfig?: ViewabilityConfig | undefined;
4774
4775 viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs | undefined;
4776
4777 /**
4778 * Determines the maximum number of items rendered outside of the visible area, in units of
4779 * visible lengths. So if your list fills the screen, then `windowSize={21}` (the default) will
4780 * render the visible screen area plus up to 10 screens above and 10 below the viewport. Reducing
4781 * this number will reduce memory consumption and may improve performance, but will increase the
4782 * chance that fast scrolling may reveal momentary blank areas of unrendered content.
4783 */
4784 windowSize?: number | undefined;
4785
4786 CellRendererComponent?: React.ComponentType<any> | undefined;
4787}
4788
4789/**
4790 * @see https://reactnative.dev/docs/listview#props
4791 */
4792export interface ListViewProps extends ScrollViewProps {
4793 /**
4794 * An instance of [ListView.DataSource](docs/listviewdatasource.html) to use
4795 */
4796 dataSource: ListViewDataSource;
4797
4798 /**
4799 * Flag indicating whether empty section headers should be rendered.
4800 * In the future release empty section headers will be rendered by
4801 * default, and the flag will be deprecated. If empty sections are not
4802 * desired to be rendered their indices should be excluded from
4803 * sectionID object.
4804 */
4805 enableEmptySections?: boolean | undefined;
4806
4807 /**
4808 * How many rows to render on initial component mount. Use this to make
4809 * it so that the first screen worth of data apears at one time instead of
4810 * over the course of multiple frames.
4811 */
4812 initialListSize?: number | undefined;
4813
4814 /**
4815 * (visibleRows, changedRows) => void
4816 *
4817 * Called when the set of visible rows changes. `visibleRows` maps
4818 * { sectionID: { rowID: true }} for all the visible rows, and
4819 * `changedRows` maps { sectionID: { rowID: true | false }} for the rows
4820 * that have changed their visibility, with true indicating visible, and
4821 * false indicating the view has moved out of view.
4822 */
4823 onChangeVisibleRows?: ((
4824 visibleRows: Array<{ [sectionId: string]: { [rowID: string]: boolean } }>,
4825 changedRows: Array<{ [sectionId: string]: { [rowID: string]: boolean } }>,
4826 ) => void) | undefined;
4827
4828 /**
4829 * Called when all rows have been rendered and the list has been scrolled
4830 * to within onEndReachedThreshold of the bottom. The native scroll
4831 * event is provided.
4832 */
4833 onEndReached?: (() => void) | undefined;
4834
4835 /**
4836 * Threshold in pixels for onEndReached.
4837 */
4838 onEndReachedThreshold?: number | undefined;
4839
4840 /**
4841 * Number of rows to render per event loop.
4842 */
4843 pageSize?: number | undefined;
4844
4845 /**
4846 * A performance optimization for improving scroll perf of
4847 * large lists, used in conjunction with overflow: 'hidden' on the row
4848 * containers. Use at your own risk.
4849 */
4850 removeClippedSubviews?: boolean | undefined;
4851
4852 /**
4853 * () => renderable
4854 *
4855 * The header and footer are always rendered (if these props are provided)
4856 * on every render pass. If they are expensive to re-render, wrap them
4857 * in StaticContainer or other mechanism as appropriate. Footer is always
4858 * at the bottom of the list, and header at the top, on every render pass.
4859 */
4860 renderFooter?: (() => React.ReactElement) | undefined;
4861
4862 /**
4863 * () => renderable
4864 *
4865 * The header and footer are always rendered (if these props are provided)
4866 * on every render pass. If they are expensive to re-render, wrap them
4867 * in StaticContainer or other mechanism as appropriate. Footer is always
4868 * at the bottom of the list, and header at the top, on every render pass.
4869 */
4870 renderHeader?: (() => React.ReactElement) | undefined;
4871
4872 /**
4873 * (rowData, sectionID, rowID) => renderable
4874 * Takes a data entry from the data source and its ids and should return
4875 * a renderable component to be rendered as the row. By default the data
4876 * is exactly what was put into the data source, but it's also possible to
4877 * provide custom extractors.
4878 */
4879 renderRow: (
4880 rowData: any,
4881 sectionID: string | number,
4882 rowID: string | number,
4883 highlightRow?: boolean,
4884 ) => React.ReactElement;
4885
4886 /**
4887 * A function that returns the scrollable component in which the list rows are rendered.
4888 * Defaults to returning a ScrollView with the given props.
4889 */
4890 renderScrollComponent?: ((props: ScrollViewProps) => React.ReactElement<ScrollViewProps>) | undefined;
4891
4892 /**
4893 * (sectionData, sectionID) => renderable
4894 *
4895 * If provided, a sticky header is rendered for this section. The sticky
4896 * behavior means that it will scroll with the content at the top of the
4897 * section until it reaches the top of the screen, at which point it will
4898 * stick to the top until it is pushed off the screen by the next section
4899 * header.
4900 */
4901 renderSectionHeader?: ((sectionData: any, sectionId: string | number) => React.ReactElement) | undefined;
4902
4903 /**
4904 * (sectionID, rowID, adjacentRowHighlighted) => renderable
4905 * If provided, a renderable component to be rendered as the separator below each row
4906 * but not the last row if there is a section header below.
4907 * Take a sectionID and rowID of the row above and whether its adjacent row is highlighted.
4908 */
4909 renderSeparator?: ((
4910 sectionID: string | number,
4911 rowID: string | number,
4912 adjacentRowHighlighted?: boolean,
4913 ) => React.ReactElement) | undefined;
4914
4915 /**
4916 * How early to start rendering rows before they come on screen, in
4917 * pixels.
4918 */
4919 scrollRenderAheadDistance?: number | undefined;
4920
4921 /**
4922 * An array of child indices determining which children get docked to the
4923 * top of the screen when scrolling. For example, passing
4924 * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the
4925 * top of the scroll view. This property is not supported in conjunction
4926 * with `horizontal={true}`.
4927 * @platform ios
4928 */
4929 stickyHeaderIndices?: number[] | undefined;
4930
4931 /**
4932 * Makes the sections headers sticky. The sticky behavior means that it will scroll with the
4933 * content at the top of the section until it reaches the top of the screen, at which point it
4934 * will stick to the top until it is pushed off the screen by the next section header. This
4935 * property is not supported in conjunction with `horizontal={true}`. Only enabled by default
4936 * on iOS because of typical platform standards.
4937 */
4938 stickySectionHeadersEnabled?: boolean | undefined;
4939}
4940
4941interface TimerMixin {
4942 setTimeout: typeof setTimeout;
4943 clearTimeout: typeof clearTimeout;
4944 setInterval: typeof setInterval;
4945 clearInterval: typeof clearInterval;
4946 setImmediate: typeof setImmediate;
4947 clearImmediate: typeof clearImmediate;
4948 requestAnimationFrame: typeof requestAnimationFrame;
4949 cancelAnimationFrame: typeof cancelAnimationFrame;
4950}
4951
4952declare class ListViewComponent extends React.Component<ListViewProps> {}
4953declare const ListViewBase: Constructor<ScrollResponderMixin> & Constructor<TimerMixin> & typeof ListViewComponent;
4954/**
4955 * @deprecated See Flatlist or SectionList
4956 * or use `deprecated-react-native-listview`
4957 * @see https://fb.me/nolistview
4958 */
4959export class ListView extends ListViewBase {
4960 static DataSource: ListViewDataSource;
4961
4962 /**
4963 * Exports some data, e.g. for perf investigations or analytics.
4964 */
4965 getMetrics: () => {
4966 contentLength: number;
4967 totalRows: number;
4968 renderedRows: number;
4969 visibleRows: number;
4970 };
4971
4972 /**
4973 * Provides a handle to the underlying scroll responder.
4974 */
4975 getScrollResponder: () => any;
4976
4977 /**
4978 * Scrolls to a given x, y offset, either immediately or with a smooth animation.
4979 *
4980 * See `ScrollView#scrollTo`.
4981 */
4982 scrollTo: (y?: number | { x?: number | undefined; y?: number | undefined; animated?: boolean | undefined }, x?: number, animated?: boolean) => void;
4983}
4984
4985interface MaskedViewIOSProps extends ViewProps {
4986 maskElement: React.ReactElement;
4987}
4988
4989/**
4990 * @see https://reactnative.dev/docs/maskedviewios
4991 */
4992declare class MaskedViewComponent extends React.Component<MaskedViewIOSProps> {}
4993declare const MaskedViewBase: Constructor<NativeMethods> & typeof MaskedViewComponent;
4994/**
4995 * MaskedViewIOS has been extracted from react-native core and will be removed in a future release.
4996 * It can now be installed and imported from `@react-native-community/masked-view` instead of 'react-native'.
4997 * @see https://github.com/react-native-community/react-native-masked-view
4998 * @deprecated
4999 */
5000export class MaskedViewIOS extends MaskedViewBase {}
5001
5002export interface ModalBaseProps {
5003 /**
5004 * @deprecated Use animationType instead
5005 */
5006 animated?: boolean | undefined;
5007 /**
5008 * The `animationType` prop controls how the modal animates.
5009 *
5010 * - `slide` slides in from the bottom
5011 * - `fade` fades into view
5012 * - `none` appears without an animation
5013 */
5014 animationType?: 'none' | 'slide' | 'fade' | undefined;
5015 /**
5016 * The `transparent` prop determines whether your modal will fill the entire view.
5017 * Setting this to `true` will render the modal over a transparent background.
5018 */
5019 transparent?: boolean | undefined;
5020 /**
5021 * The `visible` prop determines whether your modal is visible.
5022 */
5023 visible?: boolean | undefined;
5024 /**
5025 * The `onRequestClose` prop allows passing a function that will be called once the modal has been dismissed.
5026 * _On the Android platform, this is a required function._
5027 */
5028 onRequestClose?: (() => void) | undefined;
5029 /**
5030 * The `onShow` prop allows passing a function that will be called once the modal has been shown.
5031 */
5032 onShow?: ((event: NativeSyntheticEvent<any>) => void) | undefined;
5033}
5034
5035export interface ModalPropsIOS {
5036 /**
5037 * The `presentationStyle` determines the style of modal to show
5038 */
5039 presentationStyle?: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen' | undefined;
5040
5041 /**
5042 * The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations.
5043 * On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field.
5044 */
5045 supportedOrientations?: Array<
5046 'portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right'
5047 > | undefined;
5048
5049 /**
5050 * The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed.
5051 */
5052 onDismiss?: (() => void) | undefined;
5053
5054 /**
5055 * The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed.
5056 * The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation.
5057 */
5058 onOrientationChange?: ((event: NativeSyntheticEvent<any>) => void) | undefined;
5059}
5060
5061export interface ModalPropsAndroid {
5062 /**
5063 * Controls whether to force hardware acceleration for the underlying window.
5064 */
5065 hardwareAccelerated?: boolean | undefined;
5066
5067 /**
5068 * Determines whether your modal should go under the system statusbar.
5069 */
5070 statusBarTranslucent?: boolean | undefined;
5071}
5072
5073export type ModalProps = ModalBaseProps & ModalPropsIOS & ModalPropsAndroid & ViewProps;
5074
5075export class Modal extends React.Component<ModalProps> {}
5076
5077/**
5078 * @see https://github.com/facebook/react-native/blob/0.34-stable\Libraries\Components\Touchable\Touchable.js
5079 */
5080interface TouchableMixin {
5081 /**
5082 * Invoked when the item should be highlighted. Mixers should implement this
5083 * to visually distinguish the `VisualRect` so that the user knows that
5084 * releasing a touch will result in a "selection" (analog to click).
5085 */
5086 touchableHandleActivePressIn(e: GestureResponderEvent): void;
5087
5088 /**
5089 * Invoked when the item is "active" (in that it is still eligible to become
5090 * a "select") but the touch has left the `PressRect`. Usually the mixer will
5091 * want to unhighlight the `VisualRect`. If the user (while pressing) moves
5092 * back into the `PressRect` `touchableHandleActivePressIn` will be invoked
5093 * again and the mixer should probably highlight the `VisualRect` again. This
5094 * event will not fire on an `touchEnd/mouseUp` event, only move events while
5095 * the user is depressing the mouse/touch.
5096 */
5097 touchableHandleActivePressOut(e: GestureResponderEvent): void;
5098
5099 /**
5100 * Invoked when the item is "selected" - meaning the interaction ended by
5101 * letting up while the item was either in the state
5102 * `RESPONDER_ACTIVE_PRESS_IN` or `RESPONDER_INACTIVE_PRESS_IN`.
5103 */
5104 touchableHandlePress(e: GestureResponderEvent): void;
5105
5106 /**
5107 * Invoked when the item is long pressed - meaning the interaction ended by
5108 * letting up while the item was in `RESPONDER_ACTIVE_LONG_PRESS_IN`. If
5109 * `touchableHandleLongPress` is *not* provided, `touchableHandlePress` will
5110 * be called as it normally is. If `touchableHandleLongPress` is provided, by
5111 * default any `touchableHandlePress` callback will not be invoked. To
5112 * override this default behavior, override `touchableLongPressCancelsPress`
5113 * to return false. As a result, `touchableHandlePress` will be called when
5114 * lifting up, even if `touchableHandleLongPress` has also been called.
5115 */
5116 touchableHandleLongPress(e: GestureResponderEvent): void;
5117
5118 /**
5119 * Returns the amount to extend the `HitRect` into the `PressRect`. Positive
5120 * numbers mean the size expands outwards.
5121 */
5122 touchableGetPressRectOffset(): Insets;
5123
5124 /**
5125 * Returns the number of millis to wait before triggering a highlight.
5126 */
5127 touchableGetHighlightDelayMS(): number;
5128
5129 // These methods are undocumented but still being used by TouchableMixin internals
5130 touchableGetLongPressDelayMS(): number;
5131 touchableGetPressOutDelayMS(): number;
5132 touchableGetHitSlop(): Insets;
5133}
5134
5135export interface TouchableWithoutFeedbackPropsIOS {
5136 /**
5137 * *(Apple TV only)* TV preferred focus (see documentation for the View component).
5138 *
5139 * @platform ios
5140 */
5141 hasTVPreferredFocus?: boolean | undefined;
5142
5143 /**
5144 * *(Apple TV only)* Object with properties to control Apple TV parallax effects.
5145 *
5146 * enabled: If true, parallax effects are enabled. Defaults to true.
5147 * shiftDistanceX: Defaults to 2.0.
5148 * shiftDistanceY: Defaults to 2.0.
5149 * tiltAngle: Defaults to 0.05.
5150 * magnification: Defaults to 1.0.
5151 * pressMagnification: Defaults to 1.0.
5152 * pressDuration: Defaults to 0.3.
5153 * pressDelay: Defaults to 0.0.
5154 *
5155 * @platform ios
5156 */
5157 tvParallaxProperties?: TVParallaxProperties | undefined;
5158}
5159
5160export interface TouchableWithoutFeedbackPropsAndroid {
5161 /**
5162 * If true, doesn't play a system sound on touch.
5163 *
5164 * @platform android
5165 */
5166 touchSoundDisabled?: boolean | null | undefined;
5167}
5168
5169/**
5170 * @see https://reactnative.dev/docs/touchablewithoutfeedback#props
5171 */
5172export interface TouchableWithoutFeedbackProps
5173 extends TouchableWithoutFeedbackPropsIOS,
5174 TouchableWithoutFeedbackPropsAndroid,
5175 AccessibilityProps {
5176 /**
5177 * Delay in ms, from onPressIn, before onLongPress is called.
5178 */
5179 delayLongPress?: number | undefined;
5180
5181 /**
5182 * Delay in ms, from the start of the touch, before onPressIn is called.
5183 */
5184 delayPressIn?: number | undefined;
5185
5186 /**
5187 * Delay in ms, from the release of the touch, before onPressOut is called.
5188 */
5189 delayPressOut?: number | undefined;
5190
5191 /**
5192 * If true, disable all interactions for this component.
5193 */
5194 disabled?: boolean | null | undefined;
5195
5196 /**
5197 * This defines how far your touch can start away from the button.
5198 * This is added to pressRetentionOffset when moving off of the button.
5199 * NOTE The touch area never extends past the parent view bounds and
5200 * the Z-index of sibling views always takes precedence if a touch hits
5201 * two overlapping views.
5202 */
5203 hitSlop?: Insets | undefined;
5204
5205 /**
5206 * When `accessible` is true (which is the default) this may be called when
5207 * the OS-specific concept of "blur" occurs, meaning the element lost focus.
5208 * Some platforms may not have the concept of blur.
5209 */
5210 onBlur?: ((e: NativeSyntheticEvent<TargetedEvent>) => void) | undefined;
5211
5212 /**
5213 * When `accessible` is true (which is the default) this may be called when
5214 * the OS-specific concept of "focus" occurs. Some platforms may not have
5215 * the concept of focus.
5216 */
5217 onFocus?: ((e: NativeSyntheticEvent<TargetedEvent>) => void) | undefined;
5218
5219 /**
5220 * Invoked on mount and layout changes with
5221 * {nativeEvent: {layout: {x, y, width, height}}}
5222 */
5223 onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
5224
5225 onLongPress?: ((event: GestureResponderEvent) => void) | undefined;
5226
5227 /**
5228 * Called when the touch is released,
5229 * but not if cancelled (e.g. by a scroll that steals the responder lock).
5230 */
5231 onPress?: ((event: GestureResponderEvent) => void) | undefined;
5232
5233 onPressIn?: ((event: GestureResponderEvent) => void) | undefined;
5234
5235 onPressOut?: ((event: GestureResponderEvent) => void) | undefined;
5236
5237 /**
5238 * //FIXME: not in doc but available in examples
5239 */
5240 style?: StyleProp<ViewStyle> | undefined;
5241
5242 /**
5243 * When the scroll view is disabled, this defines how far your
5244 * touch may move off of the button, before deactivating the button.
5245 * Once deactivated, try moving it back and you'll see that the button
5246 * is once again reactivated! Move it back and forth several times
5247 * while the scroll view is disabled. Ensure you pass in a constant
5248 * to reduce memory allocations.
5249 */
5250 pressRetentionOffset?: Insets | undefined;
5251
5252 /**
5253 * Used to locate this view in end-to-end tests.
5254 */
5255 testID?: string | undefined;
5256}
5257
5258/**
5259 * Do not use unless you have a very good reason.
5260 * All the elements that respond to press should have a visual feedback when touched.
5261 * This is one of the primary reason a "web" app doesn't feel "native".
5262 *
5263 * @see https://reactnative.dev/docs/touchablewithoutfeedback
5264 */
5265declare class TouchableWithoutFeedbackComponent extends React.Component<TouchableWithoutFeedbackProps> {}
5266declare const TouchableWithoutFeedbackBase: Constructor<TimerMixin> &
5267 Constructor<TouchableMixin> &
5268 typeof TouchableWithoutFeedbackComponent;
5269export class TouchableWithoutFeedback extends TouchableWithoutFeedbackBase {}
5270
5271/**
5272 * @see https://reactnative.dev/docs/touchablehighlight#props
5273 */
5274export interface TouchableHighlightProps extends TouchableWithoutFeedbackProps {
5275 /**
5276 * Determines what the opacity of the wrapped view should be when touch is active.
5277 */
5278 activeOpacity?: number | undefined;
5279
5280 /**
5281 *
5282 * Called immediately after the underlay is hidden
5283 */
5284 onHideUnderlay?: (() => void) | undefined;
5285
5286 /**
5287 * Called immediately after the underlay is shown
5288 */
5289 onShowUnderlay?: (() => void) | undefined;
5290
5291 /**
5292 * @see https://reactnative.dev/docs/view#style
5293 */
5294 style?: StyleProp<ViewStyle> | undefined;
5295
5296 /**
5297 * The color of the underlay that will show through when the touch is active.
5298 */
5299 underlayColor?: ColorValue | undefined;
5300}
5301
5302/**
5303 * A wrapper for making views respond properly to touches.
5304 * On press down, the opacity of the wrapped view is decreased,
5305 * which allows the underlay color to show through, darkening or tinting the view.
5306 * The underlay comes from adding a view to the view hierarchy,
5307 * which can sometimes cause unwanted visual artifacts if not used correctly,
5308 * for example if the backgroundColor of the wrapped view isn't explicitly set to an opaque color.
5309 *
5310 * NOTE: TouchableHighlight supports only one child
5311 * If you wish to have several child components, wrap them in a View.
5312 *
5313 * @see https://reactnative.dev/docs/touchablehighlight
5314 */
5315declare class TouchableHighlightComponent extends React.Component<TouchableHighlightProps> {}
5316declare const TouchableHighlightBase: Constructor<NativeMethods> &
5317 Constructor<TimerMixin> &
5318 Constructor<TouchableMixin> &
5319 typeof TouchableHighlightComponent;
5320export class TouchableHighlight extends TouchableHighlightBase {}
5321
5322/**
5323 * @see https://reactnative.dev/docs/touchableopacity#props
5324 */
5325export interface TouchableOpacityProps extends TouchableWithoutFeedbackProps {
5326 /**
5327 * Determines what the opacity of the wrapped view should be when touch is active.
5328 * Defaults to 0.2
5329 */
5330 activeOpacity?: number | undefined;
5331}
5332
5333/**
5334 * A wrapper for making views respond properly to touches.
5335 * On press down, the opacity of the wrapped view is decreased, dimming it.
5336 * This is done without actually changing the view hierarchy,
5337 * and in general is easy to add to an app without weird side-effects.
5338 *
5339 * @see https://reactnative.dev/docs/touchableopacity
5340 */
5341declare class TouchableOpacityComponent extends React.Component<TouchableOpacityProps> {}
5342declare const TouchableOpacityBase: Constructor<TimerMixin> &
5343 Constructor<TouchableMixin> &
5344 Constructor<NativeMethods> &
5345 typeof TouchableOpacityComponent;
5346export class TouchableOpacity extends TouchableOpacityBase {
5347 /**
5348 * Animate the touchable to a new opacity.
5349 */
5350 setOpacityTo: (value: number) => void;
5351}
5352
5353interface BaseBackgroundPropType {
5354 type: string;
5355 rippleRadius?: number | null | undefined;
5356}
5357
5358interface RippleBackgroundPropType extends BaseBackgroundPropType {
5359 type: 'RippleAndroid';
5360 borderless: boolean;
5361 color?: number | null | undefined;
5362}
5363
5364interface ThemeAttributeBackgroundPropType extends BaseBackgroundPropType {
5365 type: 'ThemeAttrAndroid';
5366 attribute: string;
5367}
5368
5369type BackgroundPropType = RippleBackgroundPropType | ThemeAttributeBackgroundPropType;
5370
5371/**
5372 * @see https://reactnative.dev/docs/touchableopacity#props
5373 */
5374export interface TouchableNativeFeedbackProps extends TouchableWithoutFeedbackProps {
5375 /**
5376 * Determines the type of background drawable that's going to be used to display feedback.
5377 * It takes an object with type property and extra data depending on the type.
5378 * It's recommended to use one of the following static methods to generate that dictionary:
5379 * 1) TouchableNativeFeedback.SelectableBackground() - will create object that represents android theme's
5380 * default background for selectable elements (?android:attr/selectableItemBackground)
5381 * 2) TouchableNativeFeedback.SelectableBackgroundBorderless() - will create object that represent android
5382 * theme's default background for borderless selectable elements
5383 * (?android:attr/selectableItemBackgroundBorderless). Available on android API level 21+
5384 * 3) TouchableNativeFeedback.Ripple(color, borderless) - will create object that represents ripple drawable
5385 * with specified color (as a string). If property borderless evaluates to true the ripple will render
5386 * outside of the view bounds (see native actionbar buttons as an example of that behavior). This background
5387 * type is available on Android API level 21+
5388 */
5389 background?: BackgroundPropType | undefined;
5390 useForeground?: boolean | undefined;
5391}
5392
5393/**
5394 * A wrapper for making views respond properly to touches (Android only).
5395 * On Android this component uses native state drawable to display touch feedback.
5396 * At the moment it only supports having a single View instance as a child node,
5397 * as it's implemented by replacing that View with another instance of RCTView node with some additional properties set.
5398 *
5399 * Background drawable of native feedback touchable can be customized with background property.
5400 *
5401 * @see https://reactnative.dev/docs/touchablenativefeedback#content
5402 */
5403declare class TouchableNativeFeedbackComponent extends React.Component<TouchableNativeFeedbackProps> {}
5404declare const TouchableNativeFeedbackBase: Constructor<TouchableMixin> & typeof TouchableNativeFeedbackComponent;
5405export class TouchableNativeFeedback extends TouchableNativeFeedbackBase {
5406 /**
5407 * Creates an object that represents android theme's default background for
5408 * selectable elements (?android:attr/selectableItemBackground).
5409 *
5410 * @param rippleRadius The radius of ripple effect
5411 */
5412 static SelectableBackground(rippleRadius?: number | null): ThemeAttributeBackgroundPropType;
5413
5414 /**
5415 * Creates an object that represent android theme's default background for borderless
5416 * selectable elements (?android:attr/selectableItemBackgroundBorderless).
5417 * Available on android API level 21+.
5418 *
5419 * @param rippleRadius The radius of ripple effect
5420 */
5421 static SelectableBackgroundBorderless(rippleRadius?: number | null): ThemeAttributeBackgroundPropType;
5422
5423 /**
5424 * Creates an object that represents ripple drawable with specified color (as a
5425 * string). If property `borderless` evaluates to true the ripple will
5426 * render outside of the view bounds (see native actionbar buttons as an
5427 * example of that behavior). This background type is available on Android
5428 * API level 21+.
5429 *
5430 * @param color The ripple color
5431 * @param borderless If the ripple can render outside it's bounds
5432 * @param rippleRadius The radius of ripple effect
5433 */
5434 static Ripple(color: ColorValue, borderless: boolean, rippleRadius?: number | null): RippleBackgroundPropType;
5435 static canUseNativeForeground(): boolean;
5436}
5437
5438export interface Route {
5439 component?: React.ComponentType<any> | undefined;
5440 id?: string | undefined;
5441 title?: string | undefined;
5442 passProps?: Object | undefined;
5443
5444 //anything else
5445 [key: string]: any;
5446
5447 //Commonly found properties
5448 backButtonTitle?: string | undefined;
5449 content?: string | undefined;
5450 message?: string | undefined;
5451 index?: number | undefined;
5452 onRightButtonPress?: (() => void) | undefined;
5453 rightButtonTitle?: string | undefined;
5454 wrapperStyle?: any;
5455}
5456
5457interface InteractionMixin {
5458 createInteractionHandle(): number;
5459 clearInteractionHandle(clearHandle: number): void;
5460 /**
5461 * Schedule work for after all interactions have completed.
5462 *
5463 */
5464 runAfterInteractions(callback: () => any): void;
5465}
5466
5467interface SubscribableMixin {
5468 /**
5469 * Special form of calling `addListener` that *guarantees* that a
5470 * subscription *must* be tied to a component instance, and therefore will
5471 * be cleaned up when the component is unmounted. It is impossible to create
5472 * the subscription and pass it in - this method must be the one to create
5473 * the subscription and therefore can guarantee it is retained in a way that
5474 * will be cleaned up.
5475 *
5476 * @param eventEmitter emitter to subscribe to.
5477 * @param eventType Type of event to listen to.
5478 * @param listener Function to invoke when event occurs.
5479 * @param context Object to use as listener context.
5480 */
5481 addListenerOn(eventEmitter: any, eventType: string, listener: () => any, context: any): void;
5482}
5483
5484// @see https://github.com/facebook/react-native/blob/0.34-stable\Libraries\StyleSheet\StyleSheetTypes.js
5485export namespace StyleSheet {
5486 type NamedStyles<T> = { [P in keyof T]: ViewStyle | TextStyle | ImageStyle };
5487
5488 /**
5489 * Creates a StyleSheet style reference from the given object.
5490 */
5491 export function create<T extends NamedStyles<T> | NamedStyles<any>>(styles: T | NamedStyles<T>): T;
5492
5493 /**
5494 * Flattens an array of style objects, into one aggregated style object.
5495 * Alternatively, this method can be used to lookup IDs, returned by
5496 * StyleSheet.register.
5497 *
5498 * > **NOTE**: Exercise caution as abusing this can tax you in terms of
5499 * > optimizations.
5500 * >
5501 * > IDs enable optimizations through the bridge and memory in general. Referring
5502 * > to style objects directly will deprive you of these optimizations.
5503 *
5504 * Example:
5505 * ```
5506 * const styles = StyleSheet.create({
5507 * listItem: {
5508 * flex: 1,
5509 * fontSize: 16,
5510 * color: 'white'
5511 * },
5512 * selectedListItem: {
5513 * color: 'green'
5514 * }
5515 * });
5516 *
5517 * StyleSheet.flatten([styles.listItem, styles.selectedListItem])
5518 * // returns { flex: 1, fontSize: 16, color: 'green' }
5519 * ```
5520 * Alternative use:
5521 * ```
5522 * StyleSheet.flatten(styles.listItem);
5523 * // return { flex: 1, fontSize: 16, color: 'white' }
5524 * // Simply styles.listItem would return its ID (number)
5525 * ```
5526 * This method internally uses `StyleSheetRegistry.getStyleByID(style)`
5527 * to resolve style objects represented by IDs. Thus, an array of style
5528 * objects (instances of StyleSheet.create), are individually resolved to,
5529 * their respective objects, merged as one and then returned. This also explains
5530 * the alternative use.
5531 */
5532 export function flatten<T>(style?: StyleProp<T>): T extends (infer U)[] ? U : T;
5533
5534 /**
5535 * Combines two styles such that style2 will override any styles in style1.
5536 * If either style is falsy, the other one is returned without allocating
5537 * an array, saving allocations and maintaining reference equality for
5538 * PureComponent checks.
5539 */
5540 export function compose<T>(
5541 style1: StyleProp<T> | Array<StyleProp<T>>,
5542 style2: StyleProp<T> | Array<StyleProp<T>>,
5543 ): StyleProp<T>;
5544
5545 /**
5546 * WARNING: EXPERIMENTAL. Breaking changes will probably happen a lot and will
5547 * not be reliably announced. The whole thing might be deleted, who knows? Use
5548 * at your own risk.
5549 *
5550 * Sets a function to use to pre-process a style property value. This is used
5551 * internally to process color and transform values. You should not use this
5552 * unless you really know what you are doing and have exhausted other options.
5553 */
5554 export function setStyleAttributePreprocessor(property: string, process: (nextProp: any) => any): void;
5555
5556 /**
5557 * This is defined as the width of a thin line on the platform. It can be
5558 * used as the thickness of a border or division between two elements.
5559 * Example:
5560 * ```
5561 * {
5562 * borderBottomColor: '#bbb',
5563 * borderBottomWidth: StyleSheet.hairlineWidth
5564 * }
5565 * ```
5566 *
5567 * This constant will always be a round number of pixels (so a line defined
5568 * by it look crisp) and will try to match the standard width of a thin line
5569 * on the underlying platform. However, you should not rely on it being a
5570 * constant size, because on different platforms and screen densities its
5571 * value may be calculated differently.
5572 */
5573 export const hairlineWidth: number;
5574
5575 interface AbsoluteFillStyle {
5576 position: 'absolute';
5577 left: 0;
5578 right: 0;
5579 top: 0;
5580 bottom: 0;
5581 }
5582
5583 /**
5584 * Sometimes you may want `absoluteFill` but with a couple tweaks - `absoluteFillObject` can be
5585 * used to create a customized entry in a `StyleSheet`, e.g.:
5586 *
5587 * const styles = StyleSheet.create({
5588 * wrapper: {
5589 * ...StyleSheet.absoluteFillObject,
5590 * top: 10,
5591 * backgroundColor: 'transparent',
5592 * },
5593 * });
5594 */
5595 export const absoluteFillObject: AbsoluteFillStyle;
5596
5597 /**
5598 * A very common pattern is to create overlays with position absolute and zero positioning,
5599 * so `absoluteFill` can be used for convenience and to reduce duplication of these repeated
5600 * styles.
5601 */
5602 export const absoluteFill: RegisteredStyle<AbsoluteFillStyle>;
5603}
5604
5605export interface RelayProfiler {
5606 attachProfileHandler(name: string, handler: (name: string, state?: any) => () => void): void;
5607
5608 attachAggregateHandler(name: string, handler: (name: string, callback: () => void) => void): void;
5609}
5610
5611export interface SystraceStatic {
5612 setEnabled(enabled: boolean): void;
5613
5614 /**
5615 * beginEvent/endEvent for starting and then ending a profile within the same call stack frame
5616 **/
5617 beginEvent(profileName?: any, args?: any): void;
5618 endEvent(): void;
5619
5620 /**
5621 * beginAsyncEvent/endAsyncEvent for starting and then ending a profile where the end can either
5622 * occur on another thread or out of the current stack frame, eg await
5623 * the returned cookie variable should be used as input into the endAsyncEvent call to end the profile
5624 **/
5625 beginAsyncEvent(profileName?: any): any;
5626 endAsyncEvent(profileName?: any, cookie?: any): void;
5627
5628 /**
5629 * counterEvent registers the value to the profileName on the systrace timeline
5630 **/
5631 counterEvent(profileName?: any, value?: any): void;
5632
5633 /**
5634 * Relay profiles use await calls, so likely occur out of current stack frame
5635 * therefore async variant of profiling is used
5636 **/
5637 attachToRelayProfiler(relayProfiler: RelayProfiler): void;
5638
5639 /* This is not called by default due to perf overhead but it's useful
5640 if you want to find traces which spend too much time in JSON. */
5641 swizzleJSON(): void;
5642
5643 /**
5644 * Measures multiple methods of a class. For example, you can do:
5645 * Systrace.measureMethods(JSON, 'JSON', ['parse', 'stringify']);
5646 *
5647 * @param methodNames Map from method names to method display names.
5648 */
5649 measureMethods(object: any, objectName: string, methodNames: Array<string>): void;
5650
5651 /**
5652 * Returns an profiled version of the input function. For example, you can:
5653 * JSON.parse = Systrace.measure('JSON', 'parse', JSON.parse);
5654 *
5655 * @return replacement function
5656 */
5657 measure<T extends Function>(objName: string, fnName: string, func: T): T;
5658}
5659
5660/**
5661 * //FIXME: Could not find docs. Inferred from examples and jscode : ListViewDataSource.js
5662 */
5663export interface DataSourceAssetCallback {
5664 rowHasChanged?: ((r1: any, r2: any) => boolean) | undefined;
5665 sectionHeaderHasChanged?: ((h1: any, h2: any) => boolean) | undefined;
5666 getRowData?: ((dataBlob: any, sectionID: number | string, rowID: number | string) => any) | undefined;
5667 getSectionHeaderData?: ((dataBlob: any, sectionID: number | string) => any) | undefined;
5668}
5669
5670/**
5671 * Provides efficient data processing and access to the
5672 * `ListView` component. A `ListViewDataSource` is created with functions for
5673 * extracting data from the input blob, and comparing elements (with default
5674 * implementations for convenience). The input blob can be as simple as an
5675 * array of strings, or an object with rows nested inside section objects.
5676 *
5677 * To update the data in the datasource, use `cloneWithRows` (or
5678 * `cloneWithRowsAndSections` if you care about sections). The data in the
5679 * data source is immutable, so you can't modify it directly. The clone methods
5680 * suck in the new data and compute a diff for each row so ListView knows
5681 * whether to re-render it or not.
5682 */
5683export interface ListViewDataSource {
5684 /**
5685 * You can provide custom extraction and `hasChanged` functions for section
5686 * headers and rows. If absent, data will be extracted with the
5687 * `defaultGetRowData` and `defaultGetSectionHeaderData` functions.
5688 *
5689 * The default extractor expects data of one of the following forms:
5690 *
5691 * { sectionID_1: { rowID_1: <rowData1>, ... }, ... }
5692 *
5693 * or
5694 *
5695 * { sectionID_1: [ <rowData1>, <rowData2>, ... ], ... }
5696 *
5697 * or
5698 *
5699 * [ [ <rowData1>, <rowData2>, ... ], ... ]
5700 *
5701 * The constructor takes in a params argument that can contain any of the
5702 * following:
5703 *
5704 * - getRowData(dataBlob, sectionID, rowID);
5705 * - getSectionHeaderData(dataBlob, sectionID);
5706 * - rowHasChanged(prevRowData, nextRowData);
5707 * - sectionHeaderHasChanged(prevSectionData, nextSectionData);
5708 */
5709 new (onAsset: DataSourceAssetCallback): ListViewDataSource;
5710
5711 /**
5712 * Clones this `ListViewDataSource` with the specified `dataBlob` and
5713 * `rowIdentities`. The `dataBlob` is just an aribitrary blob of data. At
5714 * construction an extractor to get the interesting information was defined
5715 * (or the default was used).
5716 *
5717 * The `rowIdentities` is is a 2D array of identifiers for rows.
5718 * ie. [['a1', 'a2'], ['b1', 'b2', 'b3'], ...]. If not provided, it's
5719 * assumed that the keys of the section data are the row identities.
5720 *
5721 * Note: This function does NOT clone the data in this data source. It simply
5722 * passes the functions defined at construction to a new data source with
5723 * the data specified. If you wish to maintain the existing data you must
5724 * handle merging of old and new data separately and then pass that into
5725 * this function as the `dataBlob`.
5726 */
5727 cloneWithRows(
5728 dataBlob: Array<any> | { [key: string]: any },
5729 rowIdentities?: Array<string | number>,
5730 ): ListViewDataSource;
5731
5732 /**
5733 * This performs the same function as the `cloneWithRows` function but here
5734 * you also specify what your `sectionIdentities` are. If you don't care
5735 * about sections you should safely be able to use `cloneWithRows`.
5736 *
5737 * `sectionIdentities` is an array of identifiers for sections.
5738 * ie. ['s1', 's2', ...]. If not provided, it's assumed that the
5739 * keys of dataBlob are the section identities.
5740 *
5741 * Note: this returns a new object!
5742 */
5743 cloneWithRowsAndSections(
5744 dataBlob: Array<any> | { [key: string]: any },
5745 sectionIdentities?: Array<string | number>,
5746 rowIdentities?: Array<Array<string | number>>,
5747 ): ListViewDataSource;
5748
5749 getRowCount(): number;
5750 getRowAndSectionCount(): number;
5751
5752 /**
5753 * Returns if the row is dirtied and needs to be rerendered
5754 */
5755 rowShouldUpdate(sectionIndex: number, rowIndex: number): boolean;
5756
5757 /**
5758 * Gets the data required to render the row.
5759 */
5760 getRowData(sectionIndex: number, rowIndex: number): any;
5761
5762 /**
5763 * Gets the rowID at index provided if the dataSource arrays were flattened,
5764 * or null of out of range indexes.
5765 */
5766 getRowIDForFlatIndex(index: number): string;
5767
5768 /**
5769 * Gets the sectionID at index provided if the dataSource arrays were flattened,
5770 * or null for out of range indexes.
5771 */
5772 getSectionIDForFlatIndex(index: number): string;
5773
5774 /**
5775 * Returns an array containing the number of rows in each section
5776 */
5777 getSectionLengths(): Array<number>;
5778
5779 /**
5780 * Returns if the section header is dirtied and needs to be rerendered
5781 */
5782 sectionHeaderShouldUpdate(sectionIndex: number): boolean;
5783
5784 /**
5785 * Gets the data required to render the section header
5786 */
5787 getSectionHeaderData(sectionIndex: number): any;
5788}
5789
5790/**
5791 * @see https://reactnative.dev/docs/tabbarios-item#props
5792 */
5793export interface TabBarIOSItemProps extends ViewProps {
5794 /**
5795 * Little red bubble that sits at the top right of the icon.
5796 */
5797 badge?: string | number | undefined;
5798
5799 /**
5800 * Background color for the badge. Available since iOS 10.
5801 */
5802 badgeColor?: ColorValue | undefined;
5803
5804 /**
5805 * A custom icon for the tab. It is ignored when a system icon is defined.
5806 */
5807 icon?: ImageURISource | undefined;
5808
5809 /**
5810 * Callback when this tab is being selected,
5811 * you should change the state of your component to set selected={true}.
5812 */
5813 onPress?: (() => void) | undefined;
5814
5815 /**
5816 * If set to true it renders the image as original,
5817 * it defaults to being displayed as a template
5818 */
5819 renderAsOriginal?: boolean | undefined;
5820
5821 /**
5822 * It specifies whether the children are visible or not. If you see a blank content, you probably forgot to add a selected one.
5823 */
5824 selected?: boolean | undefined;
5825
5826 /**
5827 * A custom icon when the tab is selected.
5828 * It is ignored when a system icon is defined. If left empty, the icon will be tinted in blue.
5829 */
5830 selectedIcon?: ImageURISource | undefined;
5831
5832 /**
5833 * React style object.
5834 */
5835 style?: StyleProp<ViewStyle> | undefined;
5836
5837 /**
5838 * Items comes with a few predefined system icons.
5839 * Note that if you are using them, the title and selectedIcon will be overridden with the system ones.
5840 *
5841 * enum('bookmarks', 'contacts', 'downloads', 'favorites', 'featured', 'history', 'more', 'most-recent', 'most-viewed', 'recents', 'search', 'top-rated')
5842 */
5843 systemIcon?:
5844 | 'bookmarks'
5845 | 'contacts'
5846 | 'downloads'
5847 | 'favorites'
5848 | 'featured'
5849 | 'history'
5850 | 'more'
5851 | 'most-recent'
5852 | 'most-viewed'
5853 | 'recents'
5854 | 'search'
5855 | 'top-rated' | undefined;
5856
5857 /**
5858 * Text that appears under the icon. It is ignored when a system icon is defined.
5859 */
5860 title?: string | undefined;
5861}
5862
5863export class TabBarIOSItem extends React.Component<TabBarIOSItemProps> {}
5864
5865/**
5866 * @see https://reactnative.dev/docs/tabbarios#props
5867 */
5868export interface TabBarIOSProps extends ViewProps {
5869 /**
5870 * Background color of the tab bar
5871 */
5872 barTintColor?: ColorValue | undefined;
5873
5874 /**
5875 * Specifies tab bar item positioning. Available values are:
5876 * - fill - distributes items across the entire width of the tab bar
5877 * - center - centers item in the available tab bar space
5878 * - auto (default) - distributes items dynamically according to the
5879 * user interface idiom. In a horizontally compact environment (e.g. iPhone 5)
5880 * this value defaults to `fill`, in a horizontally regular one (e.g. iPad)
5881 * it defaults to center.
5882 */
5883 itemPositioning?: 'fill' | 'center' | 'auto' | undefined;
5884
5885 /**
5886 * Color of the currently selected tab icon
5887 */
5888 tintColor?: ColorValue | undefined;
5889
5890 /**
5891 * A Boolean value that indicates whether the tab bar is translucent
5892 */
5893 translucent?: boolean | undefined;
5894
5895 /**
5896 * Color of text on unselected tabs
5897 */
5898 unselectedTintColor?: ColorValue | undefined;
5899
5900 /**
5901 * Color of unselected tab icons. Available since iOS 10.
5902 */
5903 unselectedItemTintColor?: ColorValue | undefined;
5904}
5905
5906/**
5907 * TabBarIOS has been removed from react-native
5908 * @deprecated
5909 */
5910export class TabBarIOS extends React.Component<TabBarIOSProps> {
5911 static Item: typeof TabBarIOSItem;
5912}
5913
5914export interface PixelRatioStatic {
5915 /*
5916 Returns the device pixel density. Some examples:
5917 PixelRatio.get() === 1
5918 mdpi Android devices (160 dpi)
5919 PixelRatio.get() === 1.5
5920 hdpi Android devices (240 dpi)
5921 PixelRatio.get() === 2
5922 iPhone 4, 4S
5923 iPhone 5, 5c, 5s
5924 iPhone 6
5925 xhdpi Android devices (320 dpi)
5926 PixelRatio.get() === 3
5927 iPhone 6 plus
5928 xxhdpi Android devices (480 dpi)
5929 PixelRatio.get() === 3.5
5930 Nexus 6
5931 */
5932 get(): number;
5933
5934 /*
5935 Returns the scaling factor for font sizes. This is the ratio that is
5936 used to calculate the absolute font size, so any elements that
5937 heavily depend on that should use this to do calculations.
5938
5939 If a font scale is not set, this returns the device pixel ratio.
5940
5941 Currently this is only implemented on Android and reflects the user
5942 preference set in Settings > Display > Font size,
5943 on iOS it will always return the default pixel ratio.
5944 */
5945 getFontScale(): number;
5946
5947 /**
5948 * Converts a layout size (dp) to pixel size (px).
5949 * Guaranteed to return an integer number.
5950 */
5951 getPixelSizeForLayoutSize(layoutSize: number): number;
5952
5953 /**
5954 * Rounds a layout size (dp) to the nearest layout size that
5955 * corresponds to an integer number of pixels. For example,
5956 * on a device with a PixelRatio of 3,
5957 * PixelRatio.roundToNearestPixel(8.4) = 8.33,
5958 * which corresponds to exactly (8.33 * 3) = 25 pixels.
5959 */
5960 roundToNearestPixel(layoutSize: number): number;
5961
5962 /**
5963 * No-op for iOS, but used on the web. Should not be documented. [sic]
5964 */
5965 startDetecting(): void;
5966}
5967
5968/**
5969 * @see https://reactnative.dev/docs/platform-specific-code#content
5970 */
5971export type PlatformOSType = 'ios' | 'android' | 'macos' | 'windows' | 'web' | 'native';
5972type PlatformConstants = {
5973 isTesting: boolean;
5974 reactNativeVersion: { major: number; minor: number; patch: number; prerelease?: number | null | undefined };
5975};
5976interface PlatformStatic {
5977 isTV: boolean;
5978 isTesting: boolean;
5979 Version: number | string;
5980 constants: PlatformConstants;
5981
5982 /**
5983 * @see https://reactnative.dev/docs/platform-specific-code#content
5984 */
5985 select<T>(
5986 specifics: ({ [platform in PlatformOSType]?: T } & { default: T }) | { [platform in PlatformOSType]: T },
5987 ): T;
5988 select<T>(specifics: { [platform in PlatformOSType]?: T }): T | undefined;
5989}
5990
5991interface PlatformIOSStatic extends PlatformStatic {
5992 constants: PlatformConstants & {
5993 forceTouchAvailable: boolean;
5994 interfaceIdiom: string;
5995 osVersion: string;
5996 systemName: string;
5997 };
5998 OS: 'ios';
5999 isPad: boolean;
6000 isTVOS: boolean;
6001 Version: string;
6002}
6003
6004interface PlatformAndroidStatic extends PlatformStatic {
6005 constants: PlatformConstants & {
6006 Version: number;
6007 Release: string;
6008 Serial: string;
6009 Fingerprint: string;
6010 Model: string;
6011 Brand: string;
6012 Manufacturer: string;
6013 ServerHost?: string | undefined;
6014 uiMode: 'car' | 'desk' | 'normal' | 'tv' | 'watch' | 'unknown';
6015 };
6016 OS: 'android';
6017 Version: number;
6018}
6019
6020interface PlatformMacOSStatic extends PlatformStatic {
6021 OS: 'macos';
6022 Version: string;
6023 constants: PlatformConstants & {
6024 osVersion: string;
6025 }
6026}
6027
6028interface PlatformWindowsOSStatic extends PlatformStatic {
6029 OS: 'windows';
6030 Version: number;
6031 constants: PlatformConstants & {
6032 osVersion: number;
6033 }
6034}
6035
6036interface PlatformWebStatic extends PlatformStatic {
6037 OS: 'web';
6038}
6039
6040type OpaqueColorValue = symbol & { __TYPE__: 'Color' };
6041export type ColorValue = string | OpaqueColorValue;
6042
6043export type ProcessedColorValue = number | OpaqueColorValue;
6044
6045type DynamicColorIOSTuple = {
6046 light: ColorValue;
6047 dark: ColorValue;
6048};
6049
6050/**
6051 * Specify color to display depending on the current system appearance settings
6052 *
6053 * @param tuple Colors you want to use for "light mode" and "dark mode"
6054 * @platform ios
6055 */
6056export function DynamicColorIOS(tuple: DynamicColorIOSTuple): OpaqueColorValue;
6057
6058/**
6059 * Select native platform color
6060 * The color must match the string that exists on the native platform
6061 *
6062 * @see https://reactnative.dev/docs/platformcolor#example
6063 */
6064export function PlatformColor(...colors: string[]): OpaqueColorValue;
6065
6066/**
6067 * Deprecated - subclass NativeEventEmitter to create granular event modules instead of
6068 * adding all event listeners directly to RCTDeviceEventEmitter.
6069 */
6070interface DeviceEventEmitterStatic extends EventEmitter {
6071 sharedSubscriber: EventSubscriptionVendor;
6072 new (): DeviceEventEmitterStatic;
6073 addListener(type: string, listener: (data: any) => void, context?: any): EmitterSubscription;
6074}
6075
6076// Used by Dimensions below
6077export interface ScaledSize {
6078 width: number;
6079 height: number;
6080 scale: number;
6081 fontScale: number;
6082}
6083
6084/**
6085 * Initial dimensions are set before `runApplication` is called so they should
6086 * be available before any other require's are run, but may be updated later.
6087 *
6088 * Note: Although dimensions are available immediately, they may change (e.g
6089 * due to device rotation) so any rendering logic or styles that depend on
6090 * these constants should try to call this function on every render, rather
6091 * than caching the value (for example, using inline styles rather than
6092 * setting a value in a `StyleSheet`).
6093 *
6094 * Example: `const {height, width} = Dimensions.get('window');`
6095 *
6096 * @param dim Name of dimension as defined when calling `set`.
6097 * @returns Value for the dimension.
6098 * @see https://reactnative.dev/docs/dimensions#content
6099 */
6100export interface Dimensions {
6101 /**
6102 * Initial dimensions are set before runApplication is called so they
6103 * should be available before any other require's are run, but may be
6104 * updated later.
6105 * Note: Although dimensions are available immediately, they may
6106 * change (e.g due to device rotation) so any rendering logic or
6107 * styles that depend on these constants should try to call this
6108 * function on every render, rather than caching the value (for
6109 * example, using inline styles rather than setting a value in a
6110 * StyleSheet).
6111 * Example: const {height, width} = Dimensions.get('window');
6112 @param dim Name of dimension as defined when calling set.
6113 @returns Value for the dimension.
6114 */
6115 get(dim: 'window' | 'screen'): ScaledSize;
6116
6117 /**
6118 * This should only be called from native code by sending the didUpdateDimensions event.
6119 * @param dims Simple string-keyed object of dimensions to set
6120 */
6121 set(dims: { [key: string]: any }): void;
6122
6123 /**
6124 * Add an event listener for dimension changes
6125 *
6126 * @param type the type of event to listen to
6127 * @param handler the event handler
6128 */
6129 addEventListener(
6130 type: 'change',
6131 handler: ({ window, screen }: { window: ScaledSize; screen: ScaledSize }) => void,
6132 ): void;
6133
6134 /**
6135 * Remove an event listener
6136 *
6137 * @param type the type of event
6138 * @param handler the event handler
6139 */
6140 removeEventListener(
6141 type: 'change',
6142 handler: ({ window, screen }: { window: ScaledSize; screen: ScaledSize }) => void,
6143 ): void;
6144}
6145
6146export function useWindowDimensions(): ScaledSize;
6147
6148export type SimpleTask = {
6149 name: string;
6150 gen: () => void;
6151};
6152export type PromiseTask = {
6153 name: string;
6154 gen: () => Promise<any>;
6155};
6156
6157export type Handle = number;
6158
6159export interface InteractionManagerStatic {
6160 Events: {
6161 interactionStart: string;
6162 interactionComplete: string;
6163 };
6164
6165 /**
6166 * Adds a listener to be invoked when events of the specified type are
6167 * emitted. An optional calling context may be provided. The data arguments
6168 * emitted will be passed to the listener function.
6169 *
6170 * @param eventType - Name of the event to listen to
6171 * @param listener - Function to invoke when the specified event is
6172 * emitted
6173 * @param context - Optional context object to use when invoking the
6174 * listener
6175 */
6176 addListener(eventType: string, listener: (...args: any[]) => any, context?: any): EmitterSubscription;
6177
6178 /**
6179 * Schedule a function to run after all interactions have completed.
6180 * Returns a cancellable
6181 */
6182 runAfterInteractions(
6183 task?: (() => any) | SimpleTask | PromiseTask,
6184 ): {
6185 then: (onfulfilled?: () => any, onrejected?: () => any) => Promise<any>;
6186 done: (...args: any[]) => any;
6187 cancel: () => void;
6188 };
6189
6190 /**
6191 * Notify manager that an interaction has started.
6192 */
6193 createInteractionHandle(): Handle;
6194
6195 /**
6196 * Notify manager that an interaction has completed.
6197 */
6198 clearInteractionHandle(handle: Handle): void;
6199
6200 /**
6201 * A positive number will use setTimeout to schedule any tasks after
6202 * the eventLoopRunningTime hits the deadline value, otherwise all
6203 * tasks will be executed in one setImmediate batch (default).
6204 */
6205 setDeadline(deadline: number): void;
6206}
6207
6208export interface ScrollResponderEvent extends NativeSyntheticEvent<NativeTouchEvent> {}
6209
6210interface ScrollResponderMixin extends SubscribableMixin {
6211 /**
6212 * Invoke this from an `onScroll` event.
6213 */
6214 scrollResponderHandleScrollShouldSetResponder(): boolean;
6215
6216 /**
6217 * Merely touch starting is not sufficient for a scroll view to become the
6218 * responder. Being the "responder" means that the very next touch move/end
6219 * event will result in an action/movement.
6220 *
6221 * Invoke this from an `onStartShouldSetResponder` event.
6222 *
6223 * `onStartShouldSetResponder` is used when the next move/end will trigger
6224 * some UI movement/action, but when you want to yield priority to views
6225 * nested inside of the view.
6226 *
6227 * There may be some cases where scroll views actually should return `true`
6228 * from `onStartShouldSetResponder`: Any time we are detecting a standard tap
6229 * that gives priority to nested views.
6230 *
6231 * - If a single tap on the scroll view triggers an action such as
6232 * recentering a map style view yet wants to give priority to interaction
6233 * views inside (such as dropped pins or labels), then we would return true
6234 * from this method when there is a single touch.
6235 *
6236 * - Similar to the previous case, if a two finger "tap" should trigger a
6237 * zoom, we would check the `touches` count, and if `>= 2`, we would return
6238 * true.
6239 *
6240 */
6241 scrollResponderHandleStartShouldSetResponder(): boolean;
6242
6243 /**
6244 * There are times when the scroll view wants to become the responder
6245 * (meaning respond to the next immediate `touchStart/touchEnd`), in a way
6246 * that *doesn't* give priority to nested views (hence the capture phase):
6247 *
6248 * - Currently animating.
6249 * - Tapping anywhere that is not the focused input, while the keyboard is
6250 * up (which should dismiss the keyboard).
6251 *
6252 * Invoke this from an `onStartShouldSetResponderCapture` event.
6253 */
6254 scrollResponderHandleStartShouldSetResponderCapture(e: ScrollResponderEvent): boolean;
6255
6256 /**
6257 * Invoke this from an `onResponderReject` event.
6258 *
6259 * Some other element is not yielding its role as responder. Normally, we'd
6260 * just disable the `UIScrollView`, but a touch has already began on it, the
6261 * `UIScrollView` will not accept being disabled after that. The easiest
6262 * solution for now is to accept the limitation of disallowing this
6263 * altogether. To improve this, find a way to disable the `UIScrollView` after
6264 * a touch has already started.
6265 */
6266 scrollResponderHandleResponderReject(): any;
6267
6268 /**
6269 * We will allow the scroll view to give up its lock iff it acquired the lock
6270 * during an animation. This is a very useful default that happens to satisfy
6271 * many common user experiences.
6272 *
6273 * - Stop a scroll on the left edge, then turn that into an outer view's
6274 * backswipe.
6275 * - Stop a scroll mid-bounce at the top, continue pulling to have the outer
6276 * view dismiss.
6277 * - However, without catching the scroll view mid-bounce (while it is
6278 * motionless), if you drag far enough for the scroll view to become
6279 * responder (and therefore drag the scroll view a bit), any backswipe
6280 * navigation of a swipe gesture higher in the view hierarchy, should be
6281 * rejected.
6282 */
6283 scrollResponderHandleTerminationRequest(): boolean;
6284
6285 /**
6286 * Invoke this from an `onTouchEnd` event.
6287 *
6288 * @param e Event.
6289 */
6290 scrollResponderHandleTouchEnd(e: ScrollResponderEvent): void;
6291
6292 /**
6293 * Invoke this from an `onResponderRelease` event.
6294 */
6295 scrollResponderHandleResponderRelease(e: ScrollResponderEvent): void;
6296
6297 scrollResponderHandleScroll(e: ScrollResponderEvent): void;
6298
6299 /**
6300 * Invoke this from an `onResponderGrant` event.
6301 */
6302 scrollResponderHandleResponderGrant(e: ScrollResponderEvent): void;
6303
6304 /**
6305 * Unfortunately, `onScrollBeginDrag` also fires when *stopping* the scroll
6306 * animation, and there's not an easy way to distinguish a drag vs. stopping
6307 * momentum.
6308 *
6309 * Invoke this from an `onScrollBeginDrag` event.
6310 */
6311 scrollResponderHandleScrollBeginDrag(e: ScrollResponderEvent): void;
6312
6313 /**
6314 * Invoke this from an `onScrollEndDrag` event.
6315 */
6316 scrollResponderHandleScrollEndDrag(e: ScrollResponderEvent): void;
6317
6318 /**
6319 * Invoke this from an `onMomentumScrollBegin` event.
6320 */
6321 scrollResponderHandleMomentumScrollBegin(e: ScrollResponderEvent): void;
6322
6323 /**
6324 * Invoke this from an `onMomentumScrollEnd` event.
6325 */
6326 scrollResponderHandleMomentumScrollEnd(e: ScrollResponderEvent): void;
6327
6328 /**
6329 * Invoke this from an `onTouchStart` event.
6330 *
6331 * Since we know that the `SimpleEventPlugin` occurs later in the plugin
6332 * order, after `ResponderEventPlugin`, we can detect that we were *not*
6333 * permitted to be the responder (presumably because a contained view became
6334 * responder). The `onResponderReject` won't fire in that case - it only
6335 * fires when a *current* responder rejects our request.
6336 *
6337 * @param e Touch Start event.
6338 */
6339 scrollResponderHandleTouchStart(e: ScrollResponderEvent): void;
6340
6341 /**
6342 * Invoke this from an `onTouchMove` event.
6343 *
6344 * Since we know that the `SimpleEventPlugin` occurs later in the plugin
6345 * order, after `ResponderEventPlugin`, we can detect that we were *not*
6346 * permitted to be the responder (presumably because a contained view became
6347 * responder). The `onResponderReject` won't fire in that case - it only
6348 * fires when a *current* responder rejects our request.
6349 *
6350 * @param e Touch Start event.
6351 */
6352 scrollResponderHandleTouchMove(e: ScrollResponderEvent): void;
6353
6354 /**
6355 * A helper function for this class that lets us quickly determine if the
6356 * view is currently animating. This is particularly useful to know when
6357 * a touch has just started or ended.
6358 */
6359 scrollResponderIsAnimating(): boolean;
6360
6361 /**
6362 * Returns the node that represents native view that can be scrolled.
6363 * Components can pass what node to use by defining a `getScrollableNode`
6364 * function otherwise `this` is used.
6365 */
6366 scrollResponderGetScrollableNode(): any;
6367
6368 /**
6369 * A helper function to scroll to a specific point in the scrollview.
6370 * This is currently used to help focus on child textviews, but can also
6371 * be used to quickly scroll to any element we want to focus. Syntax:
6372 *
6373 * scrollResponderScrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
6374 *
6375 * Note: The weird argument signature is due to the fact that, for historical reasons,
6376 * the function also accepts separate arguments as an alternative to the options object.
6377 * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
6378 */
6379 scrollResponderScrollTo(
6380 x?: number | { x?: number | undefined; y?: number | undefined; animated?: boolean | undefined },
6381 y?: number,
6382 animated?: boolean,
6383 ): void;
6384
6385 /**
6386 * A helper function to zoom to a specific rect in the scrollview. The argument has the shape
6387 * {x: number; y: number; width: number; height: number; animated: boolean = true}
6388 *
6389 * @platform ios
6390 */
6391 scrollResponderZoomTo(
6392 rect: { x: number; y: number; width: number; height: number; animated?: boolean | undefined },
6393 animated?: boolean, // deprecated, put this inside the rect argument instead
6394 ): void;
6395
6396 /**
6397 * This method should be used as the callback to onFocus in a TextInputs'
6398 * parent view. Note that any module using this mixin needs to return
6399 * the parent view's ref in getScrollViewRef() in order to use this method.
6400 * @param nodeHandle The TextInput node handle
6401 * @param additionalOffset The scroll view's top "contentInset".
6402 * Default is 0.
6403 * @param preventNegativeScrolling Whether to allow pulling the content
6404 * down to make it meet the keyboard's top. Default is false.
6405 */
6406 scrollResponderScrollNativeHandleToKeyboard(
6407 nodeHandle: any,
6408 additionalOffset?: number,
6409 preventNegativeScrollOffset?: boolean,
6410 ): void;
6411
6412 /**
6413 * The calculations performed here assume the scroll view takes up the entire
6414 * screen - even if has some content inset. We then measure the offsets of the
6415 * keyboard, and compensate both for the scroll view's "contentInset".
6416 *
6417 * @param left Position of input w.r.t. table view.
6418 * @param top Position of input w.r.t. table view.
6419 * @param width Width of the text input.
6420 * @param height Height of the text input.
6421 */
6422 scrollResponderInputMeasureAndScrollToKeyboard(left: number, top: number, width: number, height: number): void;
6423
6424 scrollResponderTextInputFocusError(e: ScrollResponderEvent): void;
6425
6426 /**
6427 * `componentWillMount` is the closest thing to a standard "constructor" for
6428 * React components.
6429 *
6430 * The `keyboardWillShow` is called before input focus.
6431 */
6432 componentWillMount(): void;
6433
6434 /**
6435 * Warning, this may be called several times for a single keyboard opening.
6436 * It's best to store the information in this method and then take any action
6437 * at a later point (either in `keyboardDidShow` or other).
6438 *
6439 * Here's the order that events occur in:
6440 * - focus
6441 * - willShow {startCoordinates, endCoordinates} several times
6442 * - didShow several times
6443 * - blur
6444 * - willHide {startCoordinates, endCoordinates} several times
6445 * - didHide several times
6446 *
6447 * The `ScrollResponder` providesModule callbacks for each of these events.
6448 * Even though any user could have easily listened to keyboard events
6449 * themselves, using these `props` callbacks ensures that ordering of events
6450 * is consistent - and not dependent on the order that the keyboard events are
6451 * subscribed to. This matters when telling the scroll view to scroll to where
6452 * the keyboard is headed - the scroll responder better have been notified of
6453 * the keyboard destination before being instructed to scroll to where the
6454 * keyboard will be. Stick to the `ScrollResponder` callbacks, and everything
6455 * will work.
6456 *
6457 * WARNING: These callbacks will fire even if a keyboard is displayed in a
6458 * different navigation pane. Filter out the events to determine if they are
6459 * relevant to you. (For example, only if you receive these callbacks after
6460 * you had explicitly focused a node etc).
6461 */
6462 scrollResponderKeyboardWillShow(e: ScrollResponderEvent): void;
6463
6464 scrollResponderKeyboardWillHide(e: ScrollResponderEvent): void;
6465
6466 scrollResponderKeyboardDidShow(e: ScrollResponderEvent): void;
6467
6468 scrollResponderKeyboardDidHide(e: ScrollResponderEvent): void;
6469}
6470
6471export interface ScrollViewPropsIOS {
6472 /**
6473 * When true the scroll view bounces horizontally when it reaches the end
6474 * even if the content is smaller than the scroll view itself. The default
6475 * value is true when `horizontal={true}` and false otherwise.
6476 */
6477 alwaysBounceHorizontal?: boolean | undefined;
6478 /**
6479 * When true the scroll view bounces vertically when it reaches the end
6480 * even if the content is smaller than the scroll view itself. The default
6481 * value is false when `horizontal={true}` and true otherwise.
6482 */
6483 alwaysBounceVertical?: boolean | undefined;
6484
6485 /**
6486 * Controls whether iOS should automatically adjust the content inset for scroll views that are placed behind a navigation bar or tab bar/ toolbar.
6487 * The default value is true.
6488 */
6489 automaticallyAdjustContentInsets?: boolean | undefined; // true
6490
6491 /**
6492 * When true the scroll view bounces when it reaches the end of the
6493 * content if the content is larger then the scroll view along the axis of
6494 * the scroll direction. When false it disables all bouncing even if
6495 * the `alwaysBounce*` props are true. The default value is true.
6496 */
6497 bounces?: boolean | undefined;
6498 /**
6499 * When true gestures can drive zoom past min/max and the zoom will animate
6500 * to the min/max value at gesture end otherwise the zoom will not exceed
6501 * the limits.
6502 */
6503 bouncesZoom?: boolean | undefined;
6504
6505 /**
6506 * When false once tracking starts won't try to drag if the touch moves.
6507 * The default value is true.
6508 */
6509 canCancelContentTouches?: boolean | undefined;
6510
6511 /**
6512 * When true the scroll view automatically centers the content when the
6513 * content is smaller than the scroll view bounds; when the content is
6514 * larger than the scroll view this property has no effect. The default
6515 * value is false.
6516 */
6517 centerContent?: boolean | undefined;
6518
6519 /**
6520 * The amount by which the scroll view content is inset from the edges of the scroll view.
6521 * Defaults to {0, 0, 0, 0}.
6522 */
6523 contentInset?: Insets | undefined; // zeros
6524
6525 /**
6526 * Used to manually set the starting scroll offset.
6527 * The default value is {x: 0, y: 0}
6528 */
6529 contentOffset?: PointPropType | undefined; // zeros
6530
6531 /**
6532 * This property specifies how the safe area insets are used to modify the content area of the scroll view.
6533 * The default value of this property must be 'automatic'. But the default value is 'never' until RN@0.51.
6534 */
6535 contentInsetAdjustmentBehavior?: 'automatic' | 'scrollableAxes' | 'never' | 'always' | undefined;
6536
6537 /**
6538 * When true the ScrollView will try to lock to only vertical or horizontal
6539 * scrolling while dragging. The default value is false.
6540 */
6541 directionalLockEnabled?: boolean | undefined;
6542
6543 /**
6544 * The style of the scroll indicators.
6545 * - default (the default), same as black.
6546 * - black, scroll indicator is black. This style is good against
6547 * a white content background.
6548 * - white, scroll indicator is white. This style is good against
6549 * a black content background.
6550 */
6551 indicatorStyle?: 'default' | 'black' | 'white' | undefined;
6552
6553 /**
6554 * When set, the scroll view will adjust the scroll position so that the first child
6555 * that is currently visible and at or beyond minIndexForVisible will not change position.
6556 * This is useful for lists that are loading content in both directions, e.g. a chat thread,
6557 * where new messages coming in might otherwise cause the scroll position to jump. A value
6558 * of 0 is common, but other values such as 1 can be used to skip loading spinners or other
6559 * content that should not maintain position.
6560 *
6561 * The optional autoscrollToTopThreshold can be used to make the content automatically scroll
6562 * to the top after making the adjustment if the user was within the threshold of the top
6563 * before the adjustment was made. This is also useful for chat-like applications where you
6564 * want to see new messages scroll into place, but not if the user has scrolled up a ways and
6565 * it would be disruptive to scroll a bunch.
6566 *
6567 * Caveat 1: Reordering elements in the scrollview with this enabled will probably cause
6568 * jumpiness and jank. It can be fixed, but there are currently no plans to do so. For now,
6569 * don't re-order the content of any ScrollViews or Lists that use this feature.
6570 *
6571 * Caveat 2: This uses contentOffset and frame.origin in native code to compute visibility.
6572 * Occlusion, transforms, and other complexity won't be taken into account as to whether
6573 * content is "visible" or not.
6574 */
6575 maintainVisibleContentPosition?: null | {
6576 autoscrollToTopThreshold?: number | null | undefined;
6577 minIndexForVisible: number;
6578 } | undefined;
6579 /**
6580 * The maximum allowed zoom scale. The default value is 1.0.
6581 */
6582 maximumZoomScale?: number | undefined;
6583
6584 /**
6585 * The minimum allowed zoom scale. The default value is 1.0.
6586 */
6587 minimumZoomScale?: number | undefined;
6588
6589 /**
6590 * Called when a scrolling animation ends.
6591 */
6592 onScrollAnimationEnd?: (() => void) | undefined;
6593
6594 /**
6595 * When true, ScrollView allows use of pinch gestures to zoom in and out.
6596 * The default value is true.
6597 */
6598 pinchGestureEnabled?: boolean | undefined;
6599
6600 /**
6601 * This controls how often the scroll event will be fired while scrolling (as a time interval in ms).
6602 * A lower number yields better accuracy for code that is tracking the scroll position,
6603 * but can lead to scroll performance problems due to the volume of information being sent over the bridge.
6604 * The default value is zero, which means the scroll event will be sent only once each time the view is scrolled.
6605 */
6606 scrollEventThrottle?: number | undefined; // null
6607
6608 /**
6609 * The amount by which the scroll view indicators are inset from the edges of the scroll view.
6610 * This should normally be set to the same value as the contentInset.
6611 * Defaults to {0, 0, 0, 0}.
6612 */
6613 scrollIndicatorInsets?: Insets | undefined; //zeroes
6614
6615 /**
6616 * When true, the scroll view can be programmatically scrolled beyond its
6617 * content size. The default value is false.
6618 * @platform ios
6619 */
6620 scrollToOverflowEnabled?: boolean | undefined;
6621
6622 /**
6623 * When true the scroll view scrolls to top when the status bar is tapped.
6624 * The default value is true.
6625 */
6626 scrollsToTop?: boolean | undefined;
6627
6628 /**
6629 * When `snapToInterval` is set, `snapToAlignment` will define the relationship of the the snapping to the scroll view.
6630 * - `start` (the default) will align the snap at the left (horizontal) or top (vertical)
6631 * - `center` will align the snap in the center
6632 * - `end` will align the snap at the right (horizontal) or bottom (vertical)
6633 */
6634 snapToAlignment?: 'start' | 'center' | 'end' | undefined;
6635
6636 /**
6637 * Fires when the scroll view scrolls to top after the status bar has been tapped
6638 * @platform ios
6639 */
6640 onScrollToTop?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined;
6641
6642 /**
6643 * The current scale of the scroll view content. The default value is 1.0.
6644 */
6645 zoomScale?: number | undefined;
6646}
6647
6648export interface ScrollViewPropsAndroid {
6649 /**
6650 * Sometimes a scrollview takes up more space than its content fills.
6651 * When this is the case, this prop will fill the rest of the
6652 * scrollview with a color to avoid setting a background and creating
6653 * unnecessary overdraw. This is an advanced optimization that is not
6654 * needed in the general case.
6655 */
6656 endFillColor?: ColorValue | undefined;
6657
6658 /**
6659 * Tag used to log scroll performance on this scroll view. Will force
6660 * momentum events to be turned on (see sendMomentumEvents). This doesn't do
6661 * anything out of the box and you need to implement a custom native
6662 * FpsListener for it to be useful.
6663 * @platform android
6664 */
6665 scrollPerfTag?: string | undefined;
6666
6667 /**
6668 * Used to override default value of overScroll mode.
6669
6670 * Possible values:
6671 * - 'auto' - Default value, allow a user to over-scroll this view only if the content is large enough to meaningfully scroll.
6672 * - 'always' - Always allow a user to over-scroll this view.
6673 * - 'never' - Never allow a user to over-scroll this view.
6674 */
6675 overScrollMode?: 'auto' | 'always' | 'never' | undefined;
6676
6677 /**
6678 * Enables nested scrolling for Android API level 21+. Nested scrolling is supported by default on iOS.
6679 */
6680 nestedScrollEnabled?: boolean | undefined;
6681
6682 /**
6683 * Fades out the edges of the the scroll content.
6684 *
6685 * If the value is greater than 0, the fading edges will be set accordingly
6686 * to the current scroll direction and position,
6687 * indicating if there is more content to show.
6688 *
6689 * The default value is 0.
6690 * @platform android
6691 */
6692 fadingEdgeLength?: number | undefined;
6693
6694 /**
6695 * Causes the scrollbars not to turn transparent when they are not in use. The default value is false.
6696 */
6697 persistentScrollbar?: boolean | undefined;
6698}
6699
6700export interface ScrollViewProps extends ViewProps, ScrollViewPropsIOS, ScrollViewPropsAndroid, Touchable {
6701 /**
6702 * These styles will be applied to the scroll view content container which
6703 * wraps all of the child views. Example:
6704 *
6705 * return (
6706 * <ScrollView contentContainerStyle={styles.contentContainer}>
6707 * </ScrollView>
6708 * );
6709 * ...
6710 * const styles = StyleSheet.create({
6711 * contentContainer: {
6712 * paddingVertical: 20
6713 * }
6714 * });
6715 */
6716 contentContainerStyle?: StyleProp<ViewStyle> | undefined;
6717
6718 /**
6719 * A floating-point number that determines how quickly the scroll view
6720 * decelerates after the user lifts their finger. You may also use string
6721 * shortcuts `"normal"` and `"fast"` which match the underlying iOS settings
6722 * for `UIScrollViewDecelerationRateNormal` and
6723 * `UIScrollViewDecelerationRateFast` respectively.
6724 *
6725 * - `'normal'`: 0.998 on iOS, 0.985 on Android (the default)
6726 * - `'fast'`: 0.99 on iOS, 0.9 on Android
6727 */
6728 decelerationRate?: 'fast' | 'normal' | number | undefined;
6729
6730 /**
6731 * When true the scroll view's children are arranged horizontally in a row
6732 * instead of vertically in a column. The default value is false.
6733 */
6734 horizontal?: boolean | null | undefined;
6735
6736 /**
6737 * If sticky headers should stick at the bottom instead of the top of the
6738 * ScrollView. This is usually used with inverted ScrollViews.
6739 */
6740 invertStickyHeaders?: boolean | undefined;
6741
6742 /**
6743 * Determines whether the keyboard gets dismissed in response to a drag.
6744 * - 'none' (the default) drags do not dismiss the keyboard.
6745 * - 'onDrag' the keyboard is dismissed when a drag begins.
6746 * - 'interactive' the keyboard is dismissed interactively with the drag
6747 * and moves in synchrony with the touch; dragging upwards cancels the
6748 * dismissal.
6749 */
6750 keyboardDismissMode?: 'none' | 'interactive' | 'on-drag' | undefined;
6751
6752 /**
6753 * Determines when the keyboard should stay visible after a tap.
6754 * - 'never' (the default), tapping outside of the focused text input when the keyboard is up dismisses the keyboard. When this happens, children won't receive the tap.
6755 * - 'always', the keyboard will not dismiss automatically, and the scroll view will not catch taps, but children of the scroll view can catch taps.
6756 * - 'handled', the keyboard will not dismiss automatically when the tap was handled by a children, (or captured by an ancestor).
6757 * - false, deprecated, use 'never' instead
6758 * - true, deprecated, use 'always' instead
6759 */
6760 keyboardShouldPersistTaps?: boolean | 'always' | 'never' | 'handled' | undefined;
6761
6762 /**
6763 * Called when scrollable content view of the ScrollView changes.
6764 * Handler function is passed the content width and content height as parameters: (contentWidth, contentHeight)
6765 * It's implemented using onLayout handler attached to the content container which this ScrollView renders.
6766 *
6767 */
6768 onContentSizeChange?: ((w: number, h: number) => void) | undefined;
6769
6770 /**
6771 * Fires at most once per frame during scrolling.
6772 * The frequency of the events can be contolled using the scrollEventThrottle prop.
6773 */
6774 onScroll?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined;
6775
6776 /**
6777 * Fires if a user initiates a scroll gesture.
6778 */
6779 onScrollBeginDrag?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined;
6780
6781 /**
6782 * Fires when a user has finished scrolling.
6783 */
6784 onScrollEndDrag?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined;
6785
6786 /**
6787 * Fires when scroll view has finished moving
6788 */
6789 onMomentumScrollEnd?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined;
6790
6791 /**
6792 * Fires when scroll view has begun moving
6793 */
6794 onMomentumScrollBegin?: ((event: NativeSyntheticEvent<NativeScrollEvent>) => void) | undefined;
6795
6796 /**
6797 * When true the scroll view stops on multiples of the scroll view's size
6798 * when scrolling. This can be used for horizontal pagination. The default
6799 * value is false.
6800 */
6801 pagingEnabled?: boolean | undefined;
6802
6803 /**
6804 * When false, the content does not scroll. The default value is true
6805 */
6806 scrollEnabled?: boolean | undefined; // true
6807
6808 /**
6809 * Experimental: When true offscreen child views (whose `overflow` value is
6810 * `hidden`) are removed from their native backing superview when offscreen.
6811 * This canimprove scrolling performance on long lists. The default value is
6812 * false.
6813 */
6814 removeClippedSubviews?: boolean | undefined;
6815
6816 /**
6817 * When true, shows a horizontal scroll indicator.
6818 */
6819 showsHorizontalScrollIndicator?: boolean | undefined;
6820
6821 /**
6822 * When true, shows a vertical scroll indicator.
6823 */
6824 showsVerticalScrollIndicator?: boolean | undefined;
6825
6826 /**
6827 * Style
6828 */
6829 style?: StyleProp<ViewStyle> | undefined;
6830
6831 /**
6832 * A RefreshControl component, used to provide pull-to-refresh
6833 * functionality for the ScrollView.
6834 */
6835 refreshControl?: React.ReactElement<RefreshControlProps> | undefined;
6836
6837 /**
6838 * When set, causes the scroll view to stop at multiples of the value of `snapToInterval`.
6839 * This can be used for paginating through children that have lengths smaller than the scroll view.
6840 * Used in combination with `snapToAlignment` and `decelerationRate="fast"`. Overrides less
6841 * configurable `pagingEnabled` prop.
6842 */
6843 snapToInterval?: number | undefined;
6844
6845 /**
6846 * When set, causes the scroll view to stop at the defined offsets. This can be used for
6847 * paginating through variously sized children that have lengths smaller than the scroll view.
6848 * Typically used in combination with `decelerationRate="fast"`. Overrides less configurable
6849 * `pagingEnabled` and `snapToInterval` props.
6850 */
6851 snapToOffsets?: number[] | undefined;
6852
6853 /**
6854 * Use in conjunction with `snapToOffsets`. By default, the beginning of the list counts as a
6855 * snap offset. Set `snapToStart` to false to disable this behavior and allow the list to scroll
6856 * freely between its start and the first `snapToOffsets` offset. The default value is true.
6857 */
6858 snapToStart?: boolean | undefined;
6859
6860 /**
6861 * Use in conjunction with `snapToOffsets`. By default, the end of the list counts as a snap
6862 * offset. Set `snapToEnd` to false to disable this behavior and allow the list to scroll freely
6863 * between its end and the last `snapToOffsets` offset. The default value is true.
6864 */
6865 snapToEnd?: boolean | undefined;
6866
6867 /**
6868 * An array of child indices determining which children get docked to the
6869 * top of the screen when scrolling. For example passing
6870 * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the
6871 * top of the scroll view. This property is not supported in conjunction
6872 * with `horizontal={true}`.
6873 */
6874 stickyHeaderIndices?: number[] | undefined;
6875
6876 /**
6877 * When true, the scroll view stops on the next index (in relation to scroll position at release)
6878 * regardless of how fast the gesture is. This can be used for horizontal pagination when the page
6879 * is less than the width of the ScrollView. The default value is false.
6880 */
6881 disableIntervalMomentum?: boolean | undefined;
6882
6883 /**
6884 * When true, the default JS pan responder on the ScrollView is disabled, and full control over
6885 * touches inside the ScrollView is left to its child components. This is particularly useful
6886 * if `snapToInterval` is enabled, since it does not follow typical touch patterns. Do not use
6887 * this on regular ScrollView use cases without `snapToInterval` as it may cause unexpected
6888 * touches to occur while scrolling. The default value is false.
6889 */
6890 disableScrollViewPanResponder?: boolean | undefined;
6891}
6892
6893declare class ScrollViewComponent extends React.Component<ScrollViewProps> {}
6894declare const ScrollViewBase: Constructor<ScrollResponderMixin> & typeof ScrollViewComponent;
6895export class ScrollView extends ScrollViewBase {
6896 /**
6897 * Scrolls to a given x, y offset, either immediately or with a smooth animation.
6898 * Syntax:
6899 *
6900 * scrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
6901 *
6902 * Note: The weird argument signature is due to the fact that, for historical reasons,
6903 * the function also accepts separate arguments as an alternative to the options object.
6904 * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
6905 */
6906 scrollTo(y?: number | { x?: number | undefined; y?: number | undefined; animated?: boolean | undefined }, x?: number, animated?: boolean): void;
6907
6908 /**
6909 * A helper function that scrolls to the end of the scrollview;
6910 * If this is a vertical ScrollView, it scrolls to the bottom.
6911 * If this is a horizontal ScrollView scrolls to the right.
6912 *
6913 * The options object has an animated prop, that enables the scrolling animation or not.
6914 * The animated prop defaults to true
6915 */
6916 scrollToEnd(options?: { animated: boolean }): void;
6917
6918 /**
6919 * Displays the scroll indicators momentarily.
6920 */
6921 flashScrollIndicators(): void;
6922
6923 /**
6924 * Returns a reference to the underlying scroll responder, which supports
6925 * operations like `scrollTo`. All ScrollView-like components should
6926 * implement this method so that they can be composed while providing access
6927 * to the underlying scroll responder's methods.
6928 */
6929 getScrollResponder(): ScrollResponderMixin;
6930
6931 getScrollableNode(): any;
6932
6933 // Undocumented
6934 getInnerViewNode(): any;
6935
6936 /**
6937 * @deprecated Use scrollTo instead
6938 */
6939 scrollWithoutAnimationTo?: ((y: number, x: number) => void) | undefined;
6940
6941 /**
6942 * This function sends props straight to native. They will not participate in
6943 * future diff process - this means that if you do not include them in the
6944 * next render, they will remain active (see [Direct
6945 * Manipulation](https://reactnative.dev/docs/direct-manipulation)).
6946 */
6947 setNativeProps(nativeProps: object): void;
6948}
6949
6950export interface NativeScrollRectangle {
6951 left: number;
6952 top: number;
6953 bottom: number;
6954 right: number;
6955}
6956
6957export interface NativeScrollPoint {
6958 x: number;
6959 y: number;
6960}
6961
6962export interface NativeScrollVelocity {
6963 x: number;
6964 y: number;
6965}
6966
6967export interface NativeScrollSize {
6968 height: number;
6969 width: number;
6970}
6971
6972export interface NativeScrollEvent {
6973 contentInset: NativeScrollRectangle;
6974 contentOffset: NativeScrollPoint;
6975 contentSize: NativeScrollSize;
6976 layoutMeasurement: NativeScrollSize;
6977 velocity?: NativeScrollVelocity | undefined;
6978 zoomScale: number;
6979 /**
6980 * @platform ios
6981 */
6982 targetContentOffset?: NativeScrollPoint | undefined;
6983}
6984
6985export interface SnapshotViewIOSProps extends ViewProps {
6986 // A callback when the Snapshot view is ready to be compared
6987 onSnapshotReady(): any;
6988
6989 // A name to identify the individual instance to the SnapshotView
6990 testIdentifier: string;
6991}
6992
6993declare class SnapshotViewIOSComponent extends React.Component<SnapshotViewIOSProps> {}
6994declare const SnapshotViewIOSBase: Constructor<NativeMethods> & typeof SnapshotViewIOSComponent;
6995export class SnapshotViewIOS extends SnapshotViewIOSBase {}
6996
6997// Deduced from
6998// https://github.com/facebook/react-native/commit/052cd7eb8afa7a805ef13e940251be080499919c
6999
7000/**
7001 * Data source wrapper around ListViewDataSource to allow for tracking of
7002 * which row is swiped open and close opened row(s) when another row is swiped
7003 * open.
7004 *
7005 * See https://github.com/facebook/react-native/pull/5602 for why
7006 * ListViewDataSource is not subclassed.
7007 */
7008export interface SwipeableListViewDataSource {
7009 cloneWithRowsAndSections(
7010 dataBlob: any,
7011 sectionIdentities?: Array<string>,
7012 rowIdentities?: Array<Array<string>>,
7013 ): SwipeableListViewDataSource;
7014 getDataSource(): ListViewDataSource;
7015 getOpenRowID(): string;
7016 getFirstRowID(): string;
7017 setOpenRowID(rowID: string): SwipeableListViewDataSource;
7018}
7019
7020export interface SwipeableListViewProps {
7021 /**
7022 * To alert the user that swiping is possible, the first row can bounce
7023 * on component mount.
7024 */
7025 bounceFirstRowOnMount: boolean;
7026
7027 /**
7028 * Use `SwipeableListView.getNewDataSource()` to get a data source to use,
7029 * then use it just like you would a normal ListView data source
7030 */
7031 dataSource: SwipeableListViewDataSource;
7032
7033 // Maximum distance to open to after a swipe
7034 maxSwipeDistance: number;
7035
7036 // Callback method to render the swipeable view
7037 renderRow: (
7038 rowData: any,
7039 sectionID: string | number,
7040 rowID: string | number,
7041 highlightRow?: boolean,
7042 ) => React.ReactElement;
7043
7044 // Callback method to render the view that will be unveiled on swipe
7045 renderQuickActions(rowData: any, sectionID: string | number, rowID: string | number): React.ReactElement;
7046}
7047
7048/**
7049 * SwipeableListView has been removed from React Native.
7050 * See https://fb.me/nolistview for more information or use `deprecated-react-native-swipeable-listview`.
7051 * @deprecated
7052 */
7053export class SwipeableListView extends React.Component<SwipeableListViewProps> {
7054 static getNewDataSource(): SwipeableListViewDataSource;
7055}
7056
7057//////////////////////////////////////////////////////////////////////////
7058//
7059// A P I s
7060//
7061//////////////////////////////////////////////////////////////////////////
7062
7063/**
7064 * @see: https://reactnative.dev/docs/actionsheetios#content
7065 */
7066export interface ActionSheetIOSOptions {
7067 title?: string | undefined;
7068 options: string[];
7069 cancelButtonIndex?: number | undefined;
7070 destructiveButtonIndex?: number | undefined;
7071 message?: string | undefined;
7072 anchor?: number | undefined;
7073 tintColor?: ColorValue | ProcessedColorValue | undefined;
7074 userInterfaceStyle?: string | undefined;
7075 disabledButtonIndices?: number[] | undefined;
7076}
7077
7078export interface ShareActionSheetIOSOptions {
7079 message?: string | undefined;
7080 url?: string | undefined;
7081 subject?: string | undefined;
7082 /** The activities to exclude from the ActionSheet.
7083 * For example: ['com.apple.UIKit.activity.PostToTwitter']
7084 */
7085 excludedActivityTypes?: string[] | undefined;
7086}
7087
7088/**
7089 * @see https://reactnative.dev/docs/actionsheetios#content
7090 */
7091export interface ActionSheetIOSStatic {
7092 /**
7093 * Display an iOS action sheet. The `options` object must contain one or more
7094 * of:
7095 * - `options` (array of strings) - a list of button titles (required)
7096 * - `cancelButtonIndex` (int) - index of cancel button in `options`
7097 * - `destructiveButtonIndex` (int) - index of destructive button in `options`
7098 * - `title` (string) - a title to show above the action sheet
7099 * - `message` (string) - a message to show below the title
7100 */
7101 showActionSheetWithOptions: (options: ActionSheetIOSOptions, callback: (buttonIndex: number) => void) => void;
7102
7103 /**
7104 * Display the iOS share sheet. The `options` object should contain
7105 * one or both of `message` and `url` and can additionally have
7106 * a `subject` or `excludedActivityTypes`:
7107 *
7108 * - `url` (string) - a URL to share
7109 * - `message` (string) - a message to share
7110 * - `subject` (string) - a subject for the message
7111 * - `excludedActivityTypes` (array) - the activities to exclude from the ActionSheet
7112 *
7113 * NOTE: if `url` points to a local file, or is a base64-encoded
7114 * uri, the file it points to will be loaded and shared directly.
7115 * In this way, you can share images, videos, PDF files, etc.
7116 */
7117 showShareActionSheetWithOptions: (
7118 options: ShareActionSheetIOSOptions,
7119 failureCallback: (error: Error) => void,
7120 successCallback: (success: boolean, method: string) => void,
7121 ) => void;
7122}
7123
7124export type ShareContent =
7125 | {
7126 title?: string | undefined;
7127 message: string;
7128 }
7129 | {
7130 title?: string | undefined;
7131 url: string;
7132 };
7133
7134export type ShareOptions = {
7135 dialogTitle?: string | undefined;
7136 excludedActivityTypes?: Array<string> | undefined;
7137 tintColor?: ColorValue | undefined;
7138 subject?: string | undefined;
7139};
7140
7141export type ShareSharedAction = {
7142 action: 'sharedAction';
7143 activityType?: string | undefined;
7144};
7145
7146export type ShareDismissedAction = {
7147 action: 'dismissedAction';
7148};
7149
7150export type ShareAction = ShareSharedAction | ShareDismissedAction;
7151
7152export interface ShareStatic {
7153 /**
7154 * Open a dialog to share text content.
7155 *
7156 * In iOS, Returns a Promise which will be invoked an object containing `action`, `activityType`.
7157 * If the user dismissed the dialog, the Promise will still be resolved with action being `Share.dismissedAction`
7158 * and all the other keys being undefined.
7159 *
7160 * In Android, Returns a Promise which always be resolved with action being `Share.sharedAction`.
7161 *
7162 * ### Content
7163 *
7164 * - `message` - a message to share
7165 * - `title` - title of the message
7166 *
7167 * #### iOS
7168 *
7169 * - `url` - an URL to share
7170 *
7171 * At least one of URL and message is required.
7172 *
7173 * ### Options
7174 *
7175 * #### iOS
7176 *
7177 * - `excludedActivityTypes`
7178 * - `tintColor`
7179 *
7180 * #### Android
7181 *
7182 * - `dialogTitle`
7183 *
7184 */
7185 share(content: ShareContent, options?: ShareOptions): Promise<ShareAction>;
7186 sharedAction: 'sharedAction';
7187 dismissedAction: 'dismissedAction';
7188}
7189
7190type AccessibilityChangeEventName =
7191 | 'change' // deprecated, maps to screenReaderChanged
7192 | 'boldTextChanged' // iOS-only Event
7193 | 'grayscaleChanged' // iOS-only Event
7194 | 'invertColorsChanged' // iOS-only Event
7195 | 'reduceMotionChanged'
7196 | 'screenReaderChanged'
7197 | 'reduceTransparencyChanged'; // iOS-only Event
7198
7199type AccessibilityChangeEvent = boolean;
7200
7201type AccessibilityChangeEventHandler = (event: AccessibilityChangeEvent) => void;
7202
7203type AccessibilityAnnouncementEventName = 'announcementFinished'; // iOS-only Event
7204
7205type AccessibilityAnnouncementFinishedEvent = {
7206 announcement: string;
7207 success: boolean;
7208};
7209
7210type AccessibilityAnnouncementFinishedEventHandler = (event: AccessibilityAnnouncementFinishedEvent) => void;
7211
7212/**
7213 * @see https://reactnative.dev/docs/accessibilityinfo
7214 */
7215export interface AccessibilityInfoStatic {
7216 /**
7217 * Query whether bold text is currently enabled.
7218 *
7219 * @platform ios
7220 */
7221 isBoldTextEnabled: () => Promise<boolean>;
7222
7223 /**
7224 * Query whether grayscale is currently enabled.
7225 *
7226 * @platform ios
7227 */
7228 isGrayscaleEnabled: () => Promise<boolean>;
7229
7230 /**
7231 * Query whether invert colors is currently enabled.
7232 *
7233 * @platform ios
7234 */
7235 isInvertColorsEnabled: () => Promise<boolean>;
7236
7237 /**
7238 * Query whether reduce motion is currently enabled.
7239 */
7240 isReduceMotionEnabled: () => Promise<boolean>;
7241
7242 /**
7243 * Query whether reduce transparency is currently enabled.
7244 *
7245 * @platform ios
7246 */
7247 isReduceTransparencyEnabled: () => Promise<boolean>;
7248
7249 /**
7250 * Query whether a screen reader is currently enabled.
7251 */
7252 isScreenReaderEnabled: () => Promise<boolean>;
7253
7254 /**
7255 * Query whether a screen reader is currently enabled.
7256 *
7257 * @deprecated use isScreenReaderChanged instead
7258 */
7259 fetch: () => Promise<boolean>;
7260
7261 /**
7262 * Add an event handler. Supported events:
7263 * - announcementFinished: iOS-only event. Fires when the screen reader has finished making an announcement.
7264 * The argument to the event handler is a dictionary with these keys:
7265 * - announcement: The string announced by the screen reader.
7266 * - success: A boolean indicating whether the announcement was successfully made.
7267 * - AccessibilityEventName constants other than announcementFinished: Fires on accessibility feature change.
7268 * The argument to the event handler is a boolean.
7269 * The boolean is true when the related event's feature is enabled and false otherwise.
7270 *
7271 */
7272 addEventListener(eventName: AccessibilityChangeEventName, handler: AccessibilityChangeEventHandler): void;
7273 addEventListener(
7274 eventName: AccessibilityAnnouncementEventName,
7275 handler: AccessibilityAnnouncementFinishedEventHandler,
7276 ): void;
7277
7278 /**
7279 * Remove an event handler.
7280 */
7281 removeEventListener(eventName: AccessibilityChangeEventName, handler: AccessibilityChangeEventHandler): void;
7282 removeEventListener(
7283 eventName: AccessibilityAnnouncementEventName,
7284 handler: AccessibilityAnnouncementFinishedEventHandler,
7285 ): void;
7286
7287 /**
7288 * Set accessibility focus to a react component.
7289 */
7290 setAccessibilityFocus: (reactTag: number) => void;
7291
7292 /**
7293 * Post a string to be announced by the screen reader.
7294 */
7295 announceForAccessibility: (announcement: string) => void;
7296}
7297
7298/**
7299 * @see https://reactnative.dev/docs/alert#content
7300 */
7301export interface AlertButton {
7302 text?: string | undefined;
7303 onPress?: ((value?: string) => void) | undefined;
7304 style?: 'default' | 'cancel' | 'destructive' | undefined;
7305}
7306
7307interface AlertOptions {
7308 /** @platform android */
7309 cancelable?: boolean | undefined;
7310 /** @platform android */
7311 onDismiss?: (() => void) | undefined;
7312}
7313
7314/**
7315 * Launches an alert dialog with the specified title and message.
7316 *
7317 * Optionally provide a list of buttons. Tapping any button will fire the
7318 * respective onPress callback and dismiss the alert. By default, the only
7319 * button will be an 'OK' button.
7320 *
7321 * This is an API that works both on iOS and Android and can show static
7322 * alerts. To show an alert that prompts the user to enter some information,
7323 * see `AlertIOS`; entering text in an alert is common on iOS only.
7324 *
7325 * ## iOS
7326 *
7327 * On iOS you can specify any number of buttons. Each button can optionally
7328 * specify a style, which is one of 'default', 'cancel' or 'destructive'.
7329 *
7330 * ## Android
7331 *
7332 * On Android at most three buttons can be specified. Android has a concept
7333 * of a neutral, negative and a positive button:
7334 *
7335 * - If you specify one button, it will be the 'positive' one (such as 'OK')
7336 * - Two buttons mean 'negative', 'positive' (such as 'Cancel', 'OK')
7337 * - Three buttons mean 'neutral', 'negative', 'positive' (such as 'Later', 'Cancel', 'OK')
7338 *
7339 * ```
7340 * // Works on both iOS and Android
7341 * Alert.alert(
7342 * 'Alert Title',
7343 * 'My Alert Msg',
7344 * [
7345 * {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
7346 * {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
7347 * {text: 'OK', onPress: () => console.log('OK Pressed')},
7348 * ]
7349 * )
7350 * ```
7351 */
7352export interface AlertStatic {
7353 alert: (title: string, message?: string, buttons?: AlertButton[], options?: AlertOptions) => void;
7354 prompt: (
7355 title: string,
7356 message?: string,
7357 callbackOrButtons?: ((text: string) => void) | AlertButton[],
7358 type?: AlertType,
7359 defaultValue?: string,
7360 keyboardType?: string,
7361 ) => void;
7362}
7363
7364export type AlertType = 'default' | 'plain-text' | 'secure-text' | 'login-password';
7365
7366/**
7367 * AppState can tell you if the app is in the foreground or background,
7368 * and notify you when the state changes.
7369 *
7370 * AppState is frequently used to determine the intent and proper behavior
7371 * when handling push notifications.
7372 *
7373 * App State Events
7374 * change - This even is received when the app state has changed.
7375 * focus [Android] - Received when the app gains focus (the user is interacting with the app).
7376 * blur [Android] - Received when the user is not actively interacting with the app.
7377 *
7378 * App States
7379 * active - The app is running in the foreground
7380 * background - The app is running in the background. The user is either in another app or on the home screen
7381 * inactive [iOS] - This is a transition state that currently never happens for typical React Native apps.
7382 * unknown [iOS] - Initial value until the current app state is determined
7383 * extension [iOS] - The app is running as an app extension
7384 *
7385 * For more information, see Apple's documentation: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html
7386 *
7387 * @see https://reactnative.dev/docs/appstate#app-states
7388 */
7389export type AppStateEvent = 'change' | 'memoryWarning' | 'blur' | 'focus';
7390export type AppStateStatus = 'active' | 'background' | 'inactive' | 'unknown' | 'extension';
7391
7392export interface AppStateStatic {
7393 currentState: AppStateStatus;
7394
7395 /**
7396 * Add a handler to AppState changes by listening to the change event
7397 * type and providing the handler
7398 */
7399 addEventListener(type: AppStateEvent, listener: (state: AppStateStatus) => void): void;
7400
7401 /**
7402 * Remove a handler by passing the change event type and the handler
7403 */
7404 removeEventListener(type: AppStateEvent, listener: (state: AppStateStatus) => void): void;
7405}
7406
7407/**
7408 * AsyncStorage is a simple, unencrypted, asynchronous, persistent, key-value storage
7409 * system that is global to the app. It should be used instead of LocalStorage.
7410 *
7411 * It is recommended that you use an abstraction on top of `AsyncStorage`
7412 * instead of `AsyncStorage` directly for anything more than light usage since
7413 * it operates globally.
7414 *
7415 * On iOS, `AsyncStorage` is backed by native code that stores small values in a
7416 * serialized dictionary and larger values in separate files. On Android,
7417 * `AsyncStorage` will use either [RocksDB](http://rocksdb.org/) or SQLite
7418 * based on what is available.
7419 *
7420 * @see https://reactnative.dev/docs/asyncstorage#content
7421 */
7422export interface AsyncStorageStatic {
7423 /**
7424 * Fetches key and passes the result to callback, along with an Error if there is any.
7425 */
7426 getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise<string | null>;
7427
7428 /**
7429 * Sets value for key and calls callback on completion, along with an Error if there is any
7430 */
7431 setItem(key: string, value: string, callback?: (error?: Error) => void): Promise<void>;
7432
7433 removeItem(key: string, callback?: (error?: Error) => void): Promise<void>;
7434
7435 /**
7436 * Merges existing value with input value, assuming they are stringified json. Returns a Promise object.
7437 * Not supported by all native implementation
7438 */
7439 mergeItem(key: string, value: string, callback?: (error?: Error) => void): Promise<void>;
7440
7441 /**
7442 * Erases all AsyncStorage for all clients, libraries, etc. You probably don't want to call this.
7443 * Use removeItem or multiRemove to clear only your own keys instead.
7444 */
7445 clear(callback?: (error?: Error) => void): Promise<void>;
7446
7447 /**
7448 * Gets all keys known to the app, for all callers, libraries, etc
7449 */
7450 getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise<string[]>;
7451
7452 /**
7453 * multiGet invokes callback with an array of key-value pair arrays that matches the input format of multiSet
7454 */
7455 multiGet(
7456 keys: string[],
7457 callback?: (errors?: Error[], result?: [string, string][]) => void,
7458 ): Promise<[string, string][]>;
7459
7460 /**
7461 * multiSet and multiMerge take arrays of key-value array pairs that match the output of multiGet,
7462 *
7463 * multiSet([['k1', 'val1'], ['k2', 'val2']], cb);
7464 */
7465 multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise<void>;
7466
7467 /**
7468 * Delete all the keys in the keys array.
7469 */
7470 multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise<void>;
7471
7472 /**
7473 * Merges existing values with input values, assuming they are stringified json.
7474 * Returns a Promise object.
7475 *
7476 * Not supported by all native implementations.
7477 */
7478 multiMerge(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise<void>;
7479}
7480
7481export type BackPressEventName = 'hardwareBackPress';
7482
7483/**
7484 * Detect hardware back button presses, and programmatically invoke the
7485 * default back button functionality to exit the app if there are no
7486 * listeners or if none of the listeners return true.
7487 * The event subscriptions are called in reverse order
7488 * (i.e. last registered subscription first), and if one subscription
7489 * returns true then subscriptions registered earlier
7490 * will not be called.
7491 *
7492 * @see https://reactnative.dev/docs/backhandler.html
7493 */
7494export interface BackHandlerStatic {
7495 exitApp(): void;
7496 addEventListener(eventName: BackPressEventName, handler: () => boolean | null | undefined): NativeEventSubscription;
7497 removeEventListener(eventName: BackPressEventName, handler: () => boolean | null | undefined): void;
7498}
7499
7500export interface ButtonProps {
7501 title: string;
7502 onPress: (ev: NativeSyntheticEvent<NativeTouchEvent>) => void;
7503 color?: ColorValue | undefined;
7504 accessibilityLabel?: string | undefined;
7505 disabled?: boolean | undefined;
7506
7507 /**
7508 * Used to locate this button in end-to-end tests.
7509 */
7510 testID?: string | undefined;
7511}
7512
7513export class Button extends React.Component<ButtonProps> {}
7514
7515export type CameraRollGroupType = 'Album' | 'All' | 'Event' | 'Faces' | 'Library' | 'PhotoStream' | 'SavedPhotos';
7516export type CameraRollAssetType = 'All' | 'Videos' | 'Photos';
7517
7518export interface CameraRollFetchParams {
7519 first: number;
7520 after?: string | undefined;
7521 groupTypes?: CameraRollGroupType | undefined;
7522 groupName?: string | undefined;
7523 assetType?: CameraRollAssetType | undefined;
7524}
7525
7526export interface CameraRollNodeInfo {
7527 image: Image;
7528 group_name: string;
7529 timestamp: number;
7530 location: any;
7531}
7532
7533export interface CameraRollEdgeInfo {
7534 node: CameraRollNodeInfo;
7535}
7536
7537export interface CameraRollAssetInfo {
7538 edges: CameraRollEdgeInfo[];
7539 page_info: {
7540 has_next_page: boolean;
7541 end_cursor: string;
7542 };
7543}
7544
7545export interface GetPhotosParamType {
7546 first: number;
7547 after?: string | undefined;
7548 groupTypes?: CameraRollGroupType | undefined;
7549 groupName?: string | undefined;
7550 assetType?: CameraRollAssetType | undefined;
7551 mimeTypes?: string[] | undefined;
7552}
7553
7554export interface GetPhotosReturnType {
7555 edges: {
7556 node: {
7557 type: string;
7558 group_name: string;
7559 image: {
7560 uri: string;
7561 height: number;
7562 width: number;
7563 playableDuration: number;
7564 isStored?: boolean | undefined;
7565 };
7566 timestamp: number;
7567 location: {
7568 latitude: number;
7569 longitude: number;
7570 altitude: number;
7571 heading: number;
7572 speed: number;
7573 };
7574 };
7575 }[];
7576
7577 page_info: {
7578 has_next_page: boolean;
7579 start_cursor?: string | undefined;
7580 end_cursor?: string | undefined;
7581 };
7582}
7583
7584/**
7585 * CameraRoll provides access to the local camera roll / gallery.
7586 * Before using this you must link the RCTCameraRoll library.
7587 * You can refer to (Linking)[https://reactnative.dev/docs/linking-libraries-ios] for help.
7588 */
7589export interface CameraRollStatic {
7590 GroupTypesOptions: CameraRollGroupType[]; //'Album','All','Event','Faces','Library','PhotoStream','SavedPhotos'
7591 AssetTypeOptions: CameraRollAssetType[]; // "All", "Videos", "Photos"
7592
7593 /**
7594 * Saves the image to the camera roll / gallery.
7595 *
7596 * @tag On Android, this is a local URI, such as "file:///sdcard/img.png".
7597 * On iOS, the tag can be one of the following:
7598 * local URI
7599 * assets-library tag
7600 * a tag not matching any of the above, which means the image data will be stored in memory (and consume memory as long as the process is alive)
7601 *
7602 * @deprecated use saveToCameraRoll instead
7603 */
7604 saveImageWithTag(tag: string): Promise<string>;
7605
7606 /**
7607 * Saves the photo or video to the camera roll / gallery.
7608 *
7609 * On Android, the tag must be a local image or video URI, such as `"file:///sdcard/img.png"`.
7610 *
7611 * On iOS, the tag can be any image URI (including local, remote asset-library and base64 data URIs)
7612 * or a local video file URI (remote or data URIs are not supported for saving video at this time).
7613 *
7614 * If the tag has a file extension of .mov or .mp4, it will be inferred as a video. Otherwise
7615 * it will be treated as a photo. To override the automatic choice, you can pass an optional
7616 * `type` parameter that must be one of 'photo' or 'video'.
7617 *
7618 * Returns a Promise which will resolve with the new URI.
7619 */
7620 saveToCameraRoll(tag: string, type?: 'photo' | 'video'): Promise<string>;
7621
7622 /**
7623 * Invokes callback with photo identifier objects from the local camera roll of the device matching shape defined by getPhotosReturnChecker.
7624 *
7625 * @param params See getPhotosParamChecker.
7626 */
7627 getPhotos(params: GetPhotosParamType): Promise<GetPhotosReturnType>;
7628}
7629
7630/** Clipboard gives you an interface for setting and getting content from Clipboard on both iOS and Android */
7631export interface ClipboardStatic {
7632 getString(): Promise<string>;
7633 setString(content: string): void;
7634}
7635
7636export interface DatePickerAndroidOpenOptions {
7637 date?: Date | number | undefined;
7638 minDate?: Date | number | undefined;
7639 maxDate?: Date | number | undefined;
7640 mode?: 'calendar' | 'spinner' | 'default' | undefined;
7641}
7642
7643// Deduced from DatePickerAndroid.android.js
7644export interface DatePickerAndroidDateSetAction {
7645 action: 'dateSetAction';
7646 year: number;
7647 month: number;
7648 day: number;
7649}
7650
7651export interface DatePickerAndroidDismissedAction {
7652 action: 'dismissedAction';
7653}
7654
7655export type DatePickerAndroidOpenReturn = DatePickerAndroidDateSetAction | DatePickerAndroidDismissedAction;
7656
7657export interface DatePickerAndroidStatic {
7658 /**
7659 * Opens the standard Android date picker dialog.
7660 *
7661 * The available keys for the options object are:
7662 * - date (Date object or timestamp in milliseconds) - date to show by default
7663 * - minDate (Date or timestamp in milliseconds) - minimum date that can be selected
7664 * - maxDate (Date object or timestamp in milliseconds) - maximum date that can be selected
7665 * - mode (enum('calendar', 'spinner', 'default')) - To set the date-picker mode to calendar/spinner/default
7666 * - 'calendar': Show a date picker in calendar mode.
7667 * - 'spinner': Show a date picker in spinner mode.
7668 * - 'default': Show a default native date picker(spinner/calendar) based on android versions.
7669 *
7670 * Returns a Promise which will be invoked an object containing action, year, month (0-11), day if the user picked a date.
7671 * If the user dismissed the dialog, the Promise will still be resolved with action being DatePickerAndroid.dismissedAction and all the other keys being undefined.
7672 * Always check whether the action before reading the values.
7673 *
7674 * Note the native date picker dialog has some UI glitches on Android 4 and lower when using the minDate and maxDate options.
7675 */
7676 open(options?: DatePickerAndroidOpenOptions): Promise<DatePickerAndroidOpenReturn>;
7677
7678 /**
7679 * A date has been selected.
7680 */
7681 dateSetAction: 'dateSetAction';
7682
7683 /**
7684 * The dialog has been dismissed.
7685 */
7686 dismissedAction: 'dismissedAction';
7687}
7688
7689export interface LinkingStatic extends NativeEventEmitter {
7690 /**
7691 * Add a handler to Linking changes by listening to the `url` event type
7692 * and providing the handler
7693 */
7694 addEventListener(type: string, handler: (event: { url: string }) => void): void;
7695
7696 /**
7697 * Remove a handler by passing the `url` event type and the handler
7698 */
7699 removeEventListener(type: string, handler: (event: { url: string }) => void): void;
7700
7701 /**
7702 * Try to open the given url with any of the installed apps.
7703 * You can use other URLs, like a location (e.g. "geo:37.484847,-122.148386"), a contact, or any other URL that can be opened with the installed apps.
7704 * NOTE: This method will fail if the system doesn't know how to open the specified URL. If you're passing in a non-http(s) URL, it's best to check {@code canOpenURL} first.
7705 * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
7706 */
7707 openURL(url: string): Promise<any>;
7708
7709 /**
7710 * Determine whether or not an installed app can handle a given URL.
7711 * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
7712 * NOTE: As of iOS 9, your app needs to provide the LSApplicationQueriesSchemes key inside Info.plist.
7713 * @param URL the URL to open
7714 */
7715 canOpenURL(url: string): Promise<boolean>;
7716
7717 /**
7718 * If the app launch was triggered by an app link with, it will give the link url, otherwise it will give null
7719 * NOTE: To support deep linking on Android, refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents
7720 */
7721 getInitialURL(): Promise<string | null>;
7722
7723 /**
7724 * Open the Settings app and displays the app’s custom settings, if it has any.
7725 */
7726 openSettings(): Promise<void>;
7727
7728 /**
7729 * Sends an Android Intent - a broad surface to express Android functions. Useful for deep-linking to settings pages,
7730 * opening an SMS app with a message draft in place, and more. See https://developer.android.com/reference/kotlin/android/content/Intent?hl=en
7731 */
7732 sendIntent(action: string, extras?: Array<{ key: string; value: string | number | boolean }>): Promise<void>;
7733}
7734
7735export interface LogBoxStatic {
7736 /**
7737 * Silence any logs that match the given strings or regexes.
7738 */
7739 ignoreLogs(patterns: (string | RegExp)[]): void;
7740
7741 /**
7742 * Toggle error and warning notifications
7743 * Note: this only disables notifications, uncaught errors will still open a full screen LogBox.
7744 * @param ignore whether to ignore logs or not
7745 */
7746 ignoreAllLogs(ignore?: boolean): void;
7747
7748 install(): void;
7749 uninstall(): void;
7750}
7751
7752export interface PanResponderGestureState {
7753 /**
7754 * ID of the gestureState- persisted as long as there at least one touch on
7755 */
7756 stateID: number;
7757
7758 /**
7759 * the latest screen coordinates of the recently-moved touch
7760 */
7761 moveX: number;
7762
7763 /**
7764 * the latest screen coordinates of the recently-moved touch
7765 */
7766 moveY: number;
7767
7768 /**
7769 * the screen coordinates of the responder grant
7770 */
7771 x0: number;
7772
7773 /**
7774 * the screen coordinates of the responder grant
7775 */
7776 y0: number;
7777
7778 /**
7779 * accumulated distance of the gesture since the touch started
7780 */
7781 dx: number;
7782
7783 /**
7784 * accumulated distance of the gesture since the touch started
7785 */
7786 dy: number;
7787
7788 /**
7789 * current velocity of the gesture
7790 */
7791 vx: number;
7792
7793 /**
7794 * current velocity of the gesture
7795 */
7796 vy: number;
7797
7798 /**
7799 * Number of touches currently on screen
7800 */
7801 numberActiveTouches: number;
7802
7803 // All `gestureState` accounts for timeStamps up until:
7804 _accountsForMovesUpTo: number;
7805}
7806
7807/**
7808 * @see documentation of GestureResponderHandlers
7809 */
7810export interface PanResponderCallbacks {
7811 onMoveShouldSetPanResponder?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean) | undefined;
7812 onStartShouldSetPanResponder?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean) | undefined;
7813 onPanResponderGrant?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => void) | undefined;
7814 onPanResponderMove?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => void) | undefined;
7815 onPanResponderRelease?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => void) | undefined;
7816 onPanResponderTerminate?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => void) | undefined;
7817
7818 onMoveShouldSetPanResponderCapture?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean) | undefined;
7819 onStartShouldSetPanResponderCapture?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean) | undefined;
7820 onPanResponderReject?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => void) | undefined;
7821 onPanResponderStart?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => void) | undefined;
7822 onPanResponderEnd?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => void) | undefined;
7823 onPanResponderTerminationRequest?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean) | undefined;
7824 onShouldBlockNativeResponder?: ((e: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean) | undefined;
7825}
7826
7827export interface PanResponderInstance {
7828 panHandlers: GestureResponderHandlers;
7829}
7830
7831/**
7832 * PanResponder reconciles several touches into a single gesture.
7833 * It makes single-touch gestures resilient to extra touches,
7834 * and can be used to recognize simple multi-touch gestures.
7835 *
7836 * It provides a predictable wrapper of the responder handlers provided by the gesture responder system.
7837 * For each handler, it provides a new gestureState object alongside the normal event.
7838 */
7839export interface PanResponderStatic {
7840 /**
7841 * @param config Enhanced versions of all of the responder callbacks
7842 * that provide not only the typical `ResponderSyntheticEvent`, but also the
7843 * `PanResponder` gesture state. Simply replace the word `Responder` with
7844 * `PanResponder` in each of the typical `onResponder*` callbacks. For
7845 * example, the `config` object would look like:
7846 *
7847 * - `onMoveShouldSetPanResponder: (e, gestureState) => {...}`
7848 * - `onMoveShouldSetPanResponderCapture: (e, gestureState) => {...}`
7849 * - `onStartShouldSetPanResponder: (e, gestureState) => {...}`
7850 * - `onStartShouldSetPanResponderCapture: (e, gestureState) => {...}`
7851 * - `onPanResponderReject: (e, gestureState) => {...}`
7852 * - `onPanResponderGrant: (e, gestureState) => {...}`
7853 * - `onPanResponderStart: (e, gestureState) => {...}`
7854 * - `onPanResponderEnd: (e, gestureState) => {...}`
7855 * - `onPanResponderRelease: (e, gestureState) => {...}`
7856 * - `onPanResponderMove: (e, gestureState) => {...}`
7857 * - `onPanResponderTerminate: (e, gestureState) => {...}`
7858 * - `onPanResponderTerminationRequest: (e, gestureState) => {...}`
7859 * - `onShouldBlockNativeResponder: (e, gestureState) => {...}`
7860 *
7861 * In general, for events that have capture equivalents, we update the
7862 * gestureState once in the capture phase and can use it in the bubble phase
7863 * as well.
7864 *
7865 * Be careful with onStartShould* callbacks. They only reflect updated
7866 * `gestureState` for start/end events that bubble/capture to the Node.
7867 * Once the node is the responder, you can rely on every start/end event
7868 * being processed by the gesture and `gestureState` being updated
7869 * accordingly. (numberActiveTouches) may not be totally accurate unless you
7870 * are the responder.
7871 */
7872 create(config: PanResponderCallbacks): PanResponderInstance;
7873}
7874
7875export interface Rationale {
7876 title: string;
7877 message: string;
7878 buttonPositive: string;
7879 buttonNegative?: string | undefined;
7880 buttonNeutral?: string | undefined;
7881}
7882
7883export type Permission =
7884 | 'android.permission.READ_CALENDAR'
7885 | 'android.permission.WRITE_CALENDAR'
7886 | 'android.permission.CAMERA'
7887 | 'android.permission.READ_CONTACTS'
7888 | 'android.permission.WRITE_CONTACTS'
7889 | 'android.permission.GET_ACCOUNTS'
7890 | 'android.permission.ACCESS_FINE_LOCATION'
7891 | 'android.permission.ACCESS_COARSE_LOCATION'
7892 | 'android.permission.RECORD_AUDIO'
7893 | 'android.permission.READ_PHONE_STATE'
7894 | 'android.permission.CALL_PHONE'
7895 | 'android.permission.READ_CALL_LOG'
7896 | 'android.permission.WRITE_CALL_LOG'
7897 | 'com.android.voicemail.permission.ADD_VOICEMAIL'
7898 | 'android.permission.USE_SIP'
7899 | 'android.permission.PROCESS_OUTGOING_CALLS'
7900 | 'android.permission.BODY_SENSORS'
7901 | 'android.permission.SEND_SMS'
7902 | 'android.permission.RECEIVE_SMS'
7903 | 'android.permission.READ_SMS'
7904 | 'android.permission.RECEIVE_WAP_PUSH'
7905 | 'android.permission.RECEIVE_MMS'
7906 | 'android.permission.READ_EXTERNAL_STORAGE'
7907 | 'android.permission.WRITE_EXTERNAL_STORAGE';
7908
7909export type PermissionStatus = 'granted' | 'denied' | 'never_ask_again';
7910
7911export interface PermissionsAndroidStatic {
7912 /**
7913 * A list of permission results that are returned
7914 */
7915 RESULTS: { [key: string]: PermissionStatus };
7916 /**
7917 * A list of specified "dangerous" permissions that require prompting the user
7918 */
7919 PERMISSIONS: { [key: string]: Permission };
7920 new (): PermissionsAndroidStatic;
7921 /**
7922 * @deprecated Use check instead
7923 */
7924 checkPermission(permission: Permission): Promise<boolean>;
7925 /**
7926 * Returns a promise resolving to a boolean value as to whether the specified
7927 * permissions has been granted
7928 */
7929 check(permission: Permission): Promise<boolean>;
7930 /**
7931 * @deprecated Use request instead
7932 */
7933 requestPermission(permission: Permission, rationale?: Rationale): Promise<boolean>;
7934 /**
7935 * Prompts the user to enable a permission and returns a promise resolving to a
7936 * string value indicating whether the user allowed or denied the request
7937 *
7938 * If the optional rationale argument is included (which is an object with a
7939 * title and message), this function checks with the OS whether it is necessary
7940 * to show a dialog explaining why the permission is needed
7941 * (https://developer.android.com/training/permissions/requesting.html#explain)
7942 * and then shows the system permission dialog
7943 */
7944 request(permission: Permission, rationale?: Rationale): Promise<PermissionStatus>;
7945 /**
7946 * Prompts the user to enable multiple permissions in the same dialog and
7947 * returns an object with the permissions as keys and strings as values
7948 * indicating whether the user allowed or denied the request
7949 */
7950 requestMultiple(permissions: Array<Permission>): Promise<{ [key in Permission]: PermissionStatus }>;
7951}
7952
7953export interface PushNotificationPermissions {
7954 alert?: boolean | undefined;
7955 badge?: boolean | undefined;
7956 sound?: boolean | undefined;
7957}
7958
7959export interface PushNotification {
7960 /**
7961 * An alias for `getAlert` to get the notification's main message string
7962 */
7963 getMessage(): string | Object;
7964
7965 /**
7966 * Gets the sound string from the `aps` object
7967 */
7968 getSound(): string;
7969
7970 /**
7971 * Gets the category string from the `aps` object
7972 */
7973 getCategory(): string;
7974
7975 /**
7976 * Gets the notification's main message from the `aps` object
7977 */
7978 getAlert(): string | Object;
7979
7980 /**
7981 * Gets the content-available number from the `aps` object
7982 */
7983 getContentAvailable(): number;
7984
7985 /**
7986 * Gets the badge count number from the `aps` object
7987 */
7988 getBadgeCount(): number;
7989
7990 /**
7991 * Gets the data object on the notif
7992 */
7993 getData(): Object;
7994
7995 /**
7996 * iOS Only
7997 * Signifies remote notification handling is complete
7998 */
7999 finish(result: string): void;
8000}
8001
8002type PresentLocalNotificationDetails = {
8003 alertBody: string;
8004 alertAction: string;
8005 alertTitle?: string | undefined;
8006 soundName?: string | undefined;
8007 category?: string | undefined;
8008 userInfo?: Object | undefined;
8009 applicationIconBadgeNumber?: number | undefined;
8010};
8011
8012type ScheduleLocalNotificationDetails = {
8013 alertAction?: string | undefined;
8014 alertBody?: string | undefined;
8015 alertTitle?: string | undefined;
8016 applicationIconBadgeNumber?: number | undefined;
8017 category?: string | undefined;
8018 fireDate?: number | string | undefined;
8019 isSilent?: boolean | undefined;
8020 repeatInterval?: 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | undefined;
8021 soundName?: string | undefined;
8022 userInfo?: Object | undefined;
8023};
8024
8025export type PushNotificationEventName = 'notification' | 'localNotification' | 'register' | 'registrationError';
8026
8027type FetchResult = {
8028 NewData: 'UIBackgroundFetchResultNewData';
8029 NoData: 'UIBackgroundFetchResultNoData';
8030 ResultFailed: 'UIBackgroundFetchResultFailed';
8031};
8032
8033/**
8034 * Handle push notifications for your app, including permission handling and icon badge number.
8035 * @see https://reactnative.dev/docs/pushnotificationios#content
8036 *
8037 * //FIXME: BGR: The documentation seems completely off compared to the actual js implementation. I could never get the example to run
8038 */
8039export interface PushNotificationIOSStatic {
8040 /**
8041 * Schedules the localNotification for immediate presentation.
8042 * details is an object containing:
8043 * alertBody : The message displayed in the notification alert.
8044 * alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
8045 * soundName : The sound played when the notification is fired (optional).
8046 * category : The category of this notification, required for actionable notifications (optional).
8047 * userInfo : An optional object containing additional notification data.
8048 * applicationIconBadgeNumber (optional) : The number to display as the app's icon badge. The default value of this property is 0, which means that no badge is displayed.
8049 */
8050 presentLocalNotification(details: PresentLocalNotificationDetails): void;
8051
8052 /**
8053 * Schedules the localNotification for future presentation.
8054 * details is an object containing:
8055 * fireDate : The date and time when the system should deliver the notification.
8056 * alertBody : The message displayed in the notification alert.
8057 * alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
8058 * soundName : The sound played when the notification is fired (optional).
8059 * category : The category of this notification, required for actionable notifications (optional).
8060 * userInfo : An optional object containing additional notification data.
8061 * applicationIconBadgeNumber (optional) : The number to display as the app's icon badge. Setting the number to 0 removes the icon badge.
8062 */
8063 scheduleLocalNotification(details: ScheduleLocalNotificationDetails): void;
8064
8065 /**
8066 * Cancels all scheduled localNotifications
8067 */
8068 cancelAllLocalNotifications(): void;
8069
8070 /**
8071 * Cancel local notifications.
8072 * Optionally restricts the set of canceled notifications to those notifications whose userInfo fields match the corresponding fields in the userInfo argument.
8073 */
8074 cancelLocalNotifications(userInfo: Object): void;
8075
8076 /**
8077 * Sets the badge number for the app icon on the home screen
8078 */
8079 setApplicationIconBadgeNumber(number: number): void;
8080
8081 /**
8082 * Gets the current badge number for the app icon on the home screen
8083 */
8084 getApplicationIconBadgeNumber(callback: (badge: number) => void): void;
8085
8086 /**
8087 * Gets the local notifications that are currently scheduled.
8088 */
8089 getScheduledLocalNotifications(callback: (notifications: ScheduleLocalNotificationDetails[]) => void): void;
8090
8091 /**
8092 * Attaches a listener to remote notifications while the app is running in the
8093 * foreground or the background.
8094 *
8095 * The handler will get be invoked with an instance of `PushNotificationIOS`
8096 *
8097 * The type MUST be 'notification'
8098 */
8099 addEventListener(
8100 type: 'notification' | 'localNotification',
8101 handler: (notification: PushNotification) => void,
8102 ): void;
8103
8104 /**
8105 * Fired when the user registers for remote notifications.
8106 *
8107 * The handler will be invoked with a hex string representing the deviceToken.
8108 *
8109 * The type MUST be 'register'
8110 */
8111 addEventListener(type: 'register', handler: (deviceToken: string) => void): void;
8112
8113 /**
8114 * Fired when the user fails to register for remote notifications.
8115 * Typically occurs when APNS is having issues, or the device is a simulator.
8116 *
8117 * The handler will be invoked with {message: string, code: number, details: any}.
8118 *
8119 * The type MUST be 'registrationError'
8120 */
8121 addEventListener(
8122 type: 'registrationError',
8123 handler: (error: { message: string; code: number; details: any }) => void,
8124 ): void;
8125
8126 /**
8127 * Removes the event listener. Do this in `componentWillUnmount` to prevent
8128 * memory leaks
8129 */
8130 removeEventListener(
8131 type: PushNotificationEventName,
8132 handler:
8133 | ((notification: PushNotification) => void)
8134 | ((deviceToken: string) => void)
8135 | ((error: { message: string; code: number; details: any }) => void),
8136 ): void;
8137
8138 /**
8139 * Requests all notification permissions from iOS, prompting the user's
8140 * dialog box.
8141 */
8142 requestPermissions(permissions?: PushNotificationPermissions[]): void;
8143
8144 /**
8145 * Requests all notification permissions from iOS, prompting the user's
8146 * dialog box.
8147 */
8148 requestPermissions(permissions?: PushNotificationPermissions): Promise<PushNotificationPermissions>;
8149
8150 /**
8151 * Unregister for all remote notifications received via Apple Push
8152 * Notification service.
8153 * You should call this method in rare circumstances only, such as when
8154 * a new version of the app removes support for all types of remote
8155 * notifications. Users can temporarily prevent apps from receiving
8156 * remote notifications through the Notifications section of the
8157 * Settings app. Apps unregistered through this method can always
8158 * re-register.
8159 */
8160 abandonPermissions(): void;
8161
8162 /**
8163 * See what push permissions are currently enabled. `callback` will be
8164 * invoked with a `permissions` object:
8165 *
8166 * - `alert` :boolean
8167 * - `badge` :boolean
8168 * - `sound` :boolean
8169 */
8170 checkPermissions(callback: (permissions: PushNotificationPermissions) => void): void;
8171
8172 /**
8173 * This method returns a promise that resolves to either the notification
8174 * object if the app was launched by a push notification, or `null` otherwise.
8175 */
8176 getInitialNotification(): Promise<PushNotification | null>;
8177
8178 /**
8179 * iOS fetch results that best describe the result of a finished remote notification handler.
8180 * For a list of possible values, see `PushNotificationIOS.FetchResult`.
8181 */
8182 FetchResult: FetchResult;
8183}
8184
8185export interface SettingsStatic {
8186 get(key: string): any;
8187 set(settings: Object): void;
8188 watchKeys(keys: string | Array<string>, callback: () => void): number;
8189 clearWatch(watchId: number): void;
8190}
8191
8192export type StatusBarStyle = 'default' | 'light-content' | 'dark-content';
8193
8194export type StatusBarAnimation = 'none' | 'fade' | 'slide';
8195
8196export interface StatusBarPropsIOS {
8197 /**
8198 * If the network activity indicator should be visible.
8199 *
8200 * @platform ios
8201 */
8202 networkActivityIndicatorVisible?: boolean | undefined;
8203
8204 /**
8205 * The transition effect when showing and hiding the status bar using
8206 * the hidden prop. Defaults to 'fade'.
8207 *
8208 * @platform ios
8209 */
8210 showHideTransition?: null | 'fade' | 'slide' | 'none' | undefined;
8211}
8212
8213export interface StatusBarPropsAndroid {
8214 /**
8215 * The background color of the status bar.
8216 *
8217 * @platform android
8218 */
8219 backgroundColor?: ColorValue | undefined;
8220
8221 /**
8222 * If the status bar is translucent. When translucent is set to true,
8223 * the app will draw under the status bar. This is useful when using a
8224 * semi transparent status bar color.
8225 *
8226 * @platform android
8227 */
8228 translucent?: boolean | undefined;
8229}
8230
8231export interface StatusBarProps extends StatusBarPropsIOS, StatusBarPropsAndroid {
8232 /**
8233 * If the transition between status bar property changes should be
8234 * animated. Supported for backgroundColor, barStyle and hidden.
8235 */
8236 animated?: boolean | undefined;
8237
8238 /**
8239 * Sets the color of the status bar text.
8240 */
8241 barStyle?: null | StatusBarStyle | undefined;
8242
8243 /**
8244 * If the status bar is hidden.
8245 */
8246 hidden?: boolean | undefined;
8247}
8248
8249export class StatusBar extends React.Component<StatusBarProps> {
8250 /**
8251 * The current height of the status bar on the device.
8252 * @platform android
8253 */
8254 static currentHeight?: number | undefined;
8255
8256 /**
8257 * Show or hide the status bar
8258 * @param hidden The dialog's title.
8259 * @param animation Optional animation when
8260 * changing the status bar hidden property.
8261 */
8262 static setHidden: (hidden: boolean, animation?: StatusBarAnimation) => void;
8263
8264 /**
8265 * Set the status bar style
8266 * @param style Status bar style to set
8267 * @param animated Animate the style change.
8268 */
8269 static setBarStyle: (style: StatusBarStyle, animated?: boolean) => void;
8270
8271 /**
8272 * Control the visibility of the network activity indicator
8273 * @param visible Show the indicator.
8274 */
8275 static setNetworkActivityIndicatorVisible: (visible: boolean) => void;
8276
8277 /**
8278 * Set the background color for the status bar
8279 * @param color Background color.
8280 * @param animated Animate the style change.
8281 */
8282 static setBackgroundColor: (color: ColorValue, animated?: boolean) => void;
8283
8284 /**
8285 * Control the translucency of the status bar
8286 * @param translucent Set as translucent.
8287 */
8288 static setTranslucent: (translucent: boolean) => void;
8289
8290 /**
8291 * Push a StatusBar entry onto the stack.
8292 * The return value should be passed to `popStackEntry` when complete.
8293 *
8294 * @param props Object containing the StatusBar props to use in the stack entry.
8295 */
8296 static pushStackEntry: (props: StatusBarProps) => StatusBarProps;
8297
8298 /**
8299 * Pop a StatusBar entry from the stack.
8300 *
8301 * @param entry Entry returned from `pushStackEntry`.
8302 */
8303 static popStackEntry: (entry: StatusBarProps) => void;
8304
8305 /**
8306 * Replace an existing StatusBar stack entry with new props.
8307 *
8308 * @param entry Entry returned from `pushStackEntry` to replace.
8309 * @param props Object containing the StatusBar props to use in the replacement stack entry.
8310 */
8311 static replaceStackEntry: (entry: StatusBarProps, props: StatusBarProps) => StatusBarProps;
8312}
8313
8314/**
8315 * @deprecated Use StatusBar instead
8316 */
8317export interface StatusBarIOSStatic extends NativeEventEmitter {}
8318
8319export interface TimePickerAndroidOpenOptions {
8320 hour?: number | undefined;
8321 minute?: number | undefined;
8322 is24Hour?: boolean | undefined;
8323 mode?: 'clock' | 'spinner' | 'default' | undefined;
8324}
8325
8326export interface TimePickerAndroidTimeSetAction {
8327 action: 'timeSetAction';
8328 hour: number;
8329 minute: number;
8330}
8331
8332export interface TimePickerAndroidDismissedAction {
8333 action: 'dismissedAction';
8334}
8335
8336export type TimePickerAndroidOpenReturn = TimePickerAndroidTimeSetAction | TimePickerAndroidDismissedAction;
8337
8338/**
8339 * Opens the standard Android time picker dialog.
8340 *
8341 * ### Example
8342 *
8343 * ```
8344 * try {
8345 * const {action, hour, minute} = await TimePickerAndroid.open({
8346 * hour: 14,
8347 * minute: 0,
8348 * is24Hour: false, // Will display '2 PM'
8349 * });
8350 * if (action !== TimePickerAndroid.dismissedAction) {
8351 * // Selected hour (0-23), minute (0-59)
8352 * }
8353 * } catch ({code, message}) {
8354 * console.warn('Cannot open time picker', message);
8355 * }
8356 * ```
8357 */
8358export interface TimePickerAndroidStatic {
8359 /**
8360 * Opens the standard Android time picker dialog.
8361 *
8362 * The available keys for the `options` object are:
8363 * * `hour` (0-23) - the hour to show, defaults to the current time
8364 * * `minute` (0-59) - the minute to show, defaults to the current time
8365 * * `is24Hour` (boolean) - If `true`, the picker uses the 24-hour format. If `false`,
8366 * the picker shows an AM/PM chooser. If undefined, the default for the current locale
8367 * is used.
8368 * * `mode` (enum('clock', 'spinner', 'default')) - set the time picker mode
8369 * * 'clock': Show a time picker in clock mode.
8370 * * 'spinner': Show a time picker in spinner mode.
8371 * * 'default': Show a default time picker based on Android versions.
8372 *
8373 * Returns a Promise which will be invoked an object containing `action`, `hour` (0-23),
8374 * `minute` (0-59) if the user picked a time. If the user dismissed the dialog, the Promise will
8375 * still be resolved with action being `TimePickerAndroid.dismissedAction` and all the other keys
8376 * being undefined. **Always** check whether the `action` before reading the values.
8377 */
8378 open(options: TimePickerAndroidOpenOptions): Promise<TimePickerAndroidOpenReturn>;
8379
8380 /**
8381 * A time has been selected.
8382 */
8383 timeSetAction: 'timeSetAction';
8384
8385 /**
8386 * The dialog has been dismissed.
8387 */
8388 dismissedAction: 'dismissedAction';
8389}
8390
8391/**
8392 * This exposes the native ToastAndroid module as a JS module. This has a function 'show'
8393 * which takes the following parameters:
8394 *
8395 * 1. String message: A string with the text to toast
8396 * 2. int duration: The duration of the toast. May be ToastAndroid.SHORT or ToastAndroid.LONG
8397 *
8398 * There is also a function `showWithGravity` to specify the layout gravity. May be
8399 * ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER
8400 */
8401export interface ToastAndroidStatic {
8402 /**
8403 * String message: A string with the text to toast
8404 * int duration: The duration of the toast.
8405 * May be ToastAndroid.SHORT or ToastAndroid.LONG
8406 */
8407 show(message: string, duration: number): void;
8408 /** `gravity` may be ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER */
8409 showWithGravity(message: string, duration: number, gravity: number): void;
8410
8411 showWithGravityAndOffset(
8412 message: string,
8413 duration: number,
8414 gravity: number,
8415 xOffset: number,
8416 yOffset: number,
8417 ): void;
8418 // Toast duration constants
8419 SHORT: number;
8420 LONG: number;
8421 // Toast gravity constants
8422 TOP: number;
8423 BOTTOM: number;
8424 CENTER: number;
8425}
8426
8427export interface UIManagerStatic {
8428 /**
8429 * Capture an image of the screen, window or an individual view. The image
8430 * will be stored in a temporary file that will only exist for as long as the
8431 * app is running.
8432 *
8433 * The `view` argument can be the literal string `window` if you want to
8434 * capture the entire window, or it can be a reference to a specific
8435 * React Native component.
8436 *
8437 * The `options` argument may include:
8438 * - width/height (number) - the width and height of the image to capture.
8439 * - format (string) - either 'png' or 'jpeg'. Defaults to 'png'.
8440 * - quality (number) - the quality when using jpeg. 0.0 - 1.0 (default).
8441 *
8442 * Returns a Promise<string> (tempFilePath)
8443 * @platform ios
8444 */
8445 takeSnapshot: (
8446 view?: 'window' | React.ReactElement | number,
8447 options?: {
8448 width?: number | undefined;
8449 height?: number | undefined;
8450 format?: 'png' | 'jpeg' | undefined;
8451 quality?: number | undefined;
8452 },
8453 ) => Promise<string>;
8454
8455 /**
8456 * Determines the location on screen, width, and height of the given view and
8457 * returns the values via an async callback. If successful, the callback will
8458 * be called with the following arguments:
8459 *
8460 * - x
8461 * - y
8462 * - width
8463 * - height
8464 * - pageX
8465 * - pageY
8466 *
8467 * Note that these measurements are not available until after the rendering
8468 * has been completed in native. If you need the measurements as soon as
8469 * possible, consider using the [`onLayout`
8470 * prop](docs/view.html#onlayout) instead.
8471 *
8472 * @deprecated Use `ref.measure` instead.
8473 */
8474 measure(node: number, callback: MeasureOnSuccessCallback): void;
8475
8476 /**
8477 * Determines the location of the given view in the window and returns the
8478 * values via an async callback. If the React root view is embedded in
8479 * another native view, this will give you the absolute coordinates. If
8480 * successful, the callback will be called with the following
8481 * arguments:
8482 *
8483 * - x
8484 * - y
8485 * - width
8486 * - height
8487 *
8488 * Note that these measurements are not available until after the rendering
8489 * has been completed in native.
8490 *
8491 * @deprecated Use `ref.measureInWindow` instead.
8492 */
8493 measureInWindow(node: number, callback: MeasureInWindowOnSuccessCallback): void;
8494
8495 /**
8496 * Like [`measure()`](#measure), but measures the view relative an ancestor,
8497 * specified as `relativeToNativeNode`. This means that the returned x, y
8498 * are relative to the origin x, y of the ancestor view.
8499 *
8500 * As always, to obtain a native node handle for a component, you can use
8501 * `React.findNodeHandle(component)`.
8502 *
8503 * @deprecated Use `ref.measureLayout` instead.
8504 */
8505 measureLayout(
8506 node: number,
8507 relativeToNativeNode: number,
8508 onFail: () => void /* currently unused */,
8509 onSuccess: MeasureLayoutOnSuccessCallback,
8510 ): void;
8511
8512 /**
8513 * Automatically animates views to their new positions when the
8514 * next layout happens.
8515 *
8516 * A common way to use this API is to call it before calling `setState`.
8517 *
8518 * Note that in order to get this to work on **Android** you need to set the following flags via `UIManager`:
8519 *
8520 * UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);
8521 */
8522 setLayoutAnimationEnabledExperimental(value: boolean): void;
8523
8524 /**
8525 * Used to display an Android PopupMenu. If a menu item is pressed, the success callback will
8526 * be called with the following arguments:
8527 *
8528 * - item - the menu item.
8529 * - index - index of the pressed item in array. Returns `undefined` if cancelled.
8530 *
8531 * To obtain a native node handle for a component, you can use
8532 * `React.findNodeHandle(component)`.
8533 *
8534 * Note that this works only on Android
8535 */
8536 showPopupMenu(
8537 node: number,
8538 items: string[],
8539 error: () => void /* currently unused */,
8540 success: (item: string, index: number | undefined) => void,
8541 ): void;
8542
8543 getViewManagerConfig: (
8544 name: string,
8545 ) => {
8546 Commands: { [key: string]: number };
8547 };
8548
8549 /**
8550 * Used to call a native view method from JavaScript
8551 *
8552 * reactTag - Id of react view.
8553 * commandID - Id of the native method that should be called.
8554 * commandArgs - Args of the native method that we can pass from JS to native.
8555 */
8556 dispatchViewManagerCommand: (reactTag: number | null, commandID: number | string, commandArgs?: Array<any>) => void;
8557}
8558
8559export interface SwitchPropsIOS extends ViewProps {
8560 /**
8561 * Background color when the switch is turned on.
8562 *
8563 * @deprecated use trackColor instead
8564 */
8565 onTintColor?: ColorValue | undefined;
8566
8567 /**
8568 * Color of the foreground switch grip.
8569 *
8570 * @deprecated use thumbColor instead
8571 */
8572 thumbTintColor?: ColorValue | undefined;
8573
8574 /**
8575 * Background color when the switch is turned off.
8576 *
8577 * @deprecated use trackColor instead
8578 */
8579 tintColor?: ColorValue | undefined;
8580}
8581
8582export interface SwitchChangeEvent extends React.SyntheticEvent {
8583 value: boolean
8584}
8585
8586export interface SwitchProps extends SwitchPropsIOS {
8587 /**
8588 * Color of the foreground switch grip.
8589 */
8590 thumbColor?: ColorValue | undefined;
8591
8592 /**
8593 * Custom colors for the switch track
8594 *
8595 * Color when false and color when true
8596 */
8597 trackColor?: { false?: ColorValue | null | undefined; true?: ColorValue | null | undefined } | undefined;
8598
8599 /**
8600 * If true the user won't be able to toggle the switch.
8601 * Default value is false.
8602 */
8603 disabled?: boolean | undefined;
8604
8605 /**
8606 * Invoked with the the change event as an argument when the value changes.
8607 */
8608 onChange?: ((event: SwitchChangeEvent) => Promise<void> | void) | null | undefined;
8609
8610 /**
8611 * Invoked with the new value when the value changes.
8612 */
8613 onValueChange?: ((value: boolean) => Promise<void> | void) | null | undefined;
8614
8615 /**
8616 * Used to locate this view in end-to-end tests.
8617 */
8618 testID?: string | undefined;
8619
8620 /**
8621 * The value of the switch. If true the switch will be turned on.
8622 * Default value is false.
8623 */
8624 value?: boolean | undefined;
8625
8626 /**
8627 * On iOS, custom color for the background.
8628 * Can be seen when the switch value is false or when the switch is disabled.
8629 */
8630 ios_backgroundColor?: ColorValue | undefined;
8631
8632 style?: StyleProp<ViewStyle> | undefined;
8633}
8634
8635/**
8636 * Renders a boolean input.
8637 *
8638 * This is a controlled component that requires an `onValueChange` callback that
8639 * updates the `value` prop in order for the component to reflect user actions.
8640 * If the `value` prop is not updated, the component will continue to render
8641 * the supplied `value` prop instead of the expected result of any user actions.
8642 */
8643declare class SwitchComponent extends React.Component<SwitchProps> {}
8644declare const SwitchBase: Constructor<NativeMethods> & typeof SwitchComponent;
8645export class Switch extends SwitchBase {}
8646
8647/**
8648 * The Vibration API is exposed at `Vibration.vibrate()`.
8649 * The vibration is asynchronous so this method will return immediately.
8650 *
8651 * There will be no effect on devices that do not support Vibration, eg. the simulator.
8652 *
8653 * **Note for android**
8654 * add `<uses-permission android:name="android.permission.VIBRATE"/>` to `AndroidManifest.xml`
8655 *
8656 * **Android Usage:**
8657 *
8658 * [0, 500, 200, 500]
8659 * V(0.5s) --wait(0.2s)--> V(0.5s)
8660 *
8661 * [300, 500, 200, 500]
8662 * --wait(0.3s)--> V(0.5s) --wait(0.2s)--> V(0.5s)
8663 *
8664 * **iOS Usage:**
8665 * if first argument is 0, it will not be included in pattern array.
8666 *
8667 * [0, 1000, 2000, 3000]
8668 * V(fixed) --wait(1s)--> V(fixed) --wait(2s)--> V(fixed) --wait(3s)--> V(fixed)
8669 */
8670export interface VibrationStatic {
8671 vibrate(pattern?: number | number[] | null, repeat?: boolean | null): void;
8672
8673 /**
8674 * Stop vibration
8675 */
8676 cancel(): void;
8677}
8678
8679type ColorSchemeName = 'light' | 'dark' | null | undefined;
8680
8681export namespace Appearance {
8682 type AppearancePreferences = {
8683 colorScheme: ColorSchemeName;
8684 };
8685
8686 type AppearanceListener = (preferences: AppearancePreferences) => void;
8687
8688 /**
8689 * Note: Although color scheme is available immediately, it may change at any
8690 * time. Any rendering logic or styles that depend on this should try to call
8691 * this function on every render, rather than caching the value (for example,
8692 * using inline styles rather than setting a value in a `StyleSheet`).
8693 *
8694 * Example: `const colorScheme = Appearance.getColorScheme();`
8695 */
8696 export function getColorScheme(): ColorSchemeName;
8697
8698 /**
8699 * Add an event handler that is fired when appearance preferences change.
8700 */
8701 export function addChangeListener(listener: AppearanceListener): void;
8702
8703 /**
8704 * Remove an event handler.
8705 */
8706 export function removeChangeListener(listener: AppearanceListener): void;
8707}
8708
8709/**
8710 * A new useColorScheme hook is provided as the preferred way of accessing
8711 * the user's preferred color scheme (aka Dark Mode).
8712 */
8713export function useColorScheme(): ColorSchemeName;
8714
8715/**
8716 * This class implements common easing functions. The math is pretty obscure,
8717 * but this cool website has nice visual illustrations of what they represent:
8718 * http://xaedes.de/dev/transitions/
8719 */
8720export type EasingFunction = (value: number) => number;
8721export interface EasingStatic {
8722 step0: EasingFunction;
8723 step1: EasingFunction;
8724 linear: EasingFunction;
8725 ease: EasingFunction;
8726 quad: EasingFunction;
8727 cubic: EasingFunction;
8728 poly(n: number): EasingFunction;
8729 sin: EasingFunction;
8730 circle: EasingFunction;
8731 exp: EasingFunction;
8732 elastic(bounciness: number): EasingFunction;
8733 back(s: number): EasingFunction;
8734 bounce: EasingFunction;
8735 bezier(x1: number, y1: number, x2: number, y2: number): EasingFunction;
8736 in(easing: EasingFunction): EasingFunction;
8737 out(easing: EasingFunction): EasingFunction;
8738 inOut(easing: EasingFunction): EasingFunction;
8739}
8740
8741// We need to alias these views so we can reference them in the Animated
8742// namespace where their names are shadowed.
8743declare const _View: typeof View;
8744declare const _Image: typeof Image;
8745declare const _Text: typeof Text;
8746declare const _ScrollView: typeof ScrollView;
8747export namespace Animated {
8748 type AnimatedValue = Value;
8749 type AnimatedValueXY = ValueXY;
8750
8751 class Animated {
8752 // Internal class, no public API.
8753 }
8754
8755 class AnimatedNode {
8756 /**
8757 * Adds an asynchronous listener to the value so you can observe updates from
8758 * animations. This is useful because there is no way to
8759 * synchronously read the value because it might be driven natively.
8760 *
8761 * See https://reactnative.dev/docs/animatedvalue.html#addlistener
8762 */
8763 addListener(callback: (value: any) => any): string;
8764 /**
8765 * Unregister a listener. The `id` param shall match the identifier
8766 * previously returned by `addListener()`.
8767 *
8768 * See https://reactnative.dev/docs/animatedvalue.html#removelistener
8769 */
8770 removeListener(id: string): void;
8771 /**
8772 * Remove all registered listeners.
8773 *
8774 * See https://reactnative.dev/docs/animatedvalue.html#removealllisteners
8775 */
8776 removeAllListeners(): void;
8777
8778 hasListeners(): boolean;
8779 }
8780
8781 class AnimatedWithChildren extends AnimatedNode {
8782 // Internal class, no public API.
8783 }
8784
8785 class AnimatedInterpolation extends AnimatedWithChildren {
8786 interpolate(config: InterpolationConfigType): AnimatedInterpolation;
8787 }
8788
8789 type ExtrapolateType = 'extend' | 'identity' | 'clamp';
8790
8791 type InterpolationConfigType = {
8792 inputRange: number[];
8793 outputRange: number[] | string[];
8794 easing?: ((input: number) => number) | undefined;
8795 extrapolate?: ExtrapolateType | undefined;
8796 extrapolateLeft?: ExtrapolateType | undefined;
8797 extrapolateRight?: ExtrapolateType | undefined;
8798 };
8799
8800 type ValueListenerCallback = (state: { value: number }) => void;
8801
8802 /**
8803 * Standard value for driving animations. One `Animated.Value` can drive
8804 * multiple properties in a synchronized fashion, but can only be driven by one
8805 * mechanism at a time. Using a new mechanism (e.g. starting a new animation,
8806 * or calling `setValue`) will stop any previous ones.
8807 */
8808 export class Value extends AnimatedWithChildren {
8809 constructor(value: number);
8810
8811 /**
8812 * Directly set the value. This will stop any animations running on the value
8813 * and update all the bound properties.
8814 */
8815 setValue(value: number): void;
8816
8817 /**
8818 * Sets an offset that is applied on top of whatever value is set, whether via
8819 * `setValue`, an animation, or `Animated.event`. Useful for compensating
8820 * things like the start of a pan gesture.
8821 */
8822 setOffset(offset: number): void;
8823
8824 /**
8825 * Merges the offset value into the base value and resets the offset to zero.
8826 * The final output of the value is unchanged.
8827 */
8828 flattenOffset(): void;
8829
8830 /**
8831 * Sets the offset value to the base value, and resets the base value to zero.
8832 * The final output of the value is unchanged.
8833 */
8834 extractOffset(): void;
8835
8836 /**
8837 * Adds an asynchronous listener to the value so you can observe updates from
8838 * animations. This is useful because there is no way to
8839 * synchronously read the value because it might be driven natively.
8840 */
8841 addListener(callback: ValueListenerCallback): string;
8842
8843 removeListener(id: string): void;
8844
8845 removeAllListeners(): void;
8846
8847 /**
8848 * Stops any running animation or tracking. `callback` is invoked with the
8849 * final value after stopping the animation, which is useful for updating
8850 * state to match the animation position with layout.
8851 */
8852 stopAnimation(callback?: (value: number) => void): void;
8853
8854 /**
8855 * Interpolates the value before updating the property, e.g. mapping 0-1 to
8856 * 0-10.
8857 */
8858 interpolate(config: InterpolationConfigType): AnimatedInterpolation;
8859 }
8860
8861 type ValueXYListenerCallback = (value: { x: number; y: number }) => void;
8862
8863 /**
8864 * 2D Value for driving 2D animations, such as pan gestures. Almost identical
8865 * API to normal `Animated.Value`, but multiplexed. Contains two regular
8866 * `Animated.Value`s under the hood.
8867 */
8868 export class ValueXY extends AnimatedWithChildren {
8869 x: AnimatedValue;
8870 y: AnimatedValue;
8871
8872 constructor(valueIn?: { x: number | AnimatedValue; y: number | AnimatedValue });
8873
8874 setValue(value: { x: number; y: number }): void;
8875
8876 setOffset(offset: { x: number; y: number }): void;
8877
8878 flattenOffset(): void;
8879
8880 extractOffset(): void;
8881
8882 stopAnimation(callback?: (value: { x: number; y: number }) => void): void;
8883
8884 addListener(callback: ValueXYListenerCallback): string;
8885
8886 removeListener(id: string): void;
8887
8888 /**
8889 * Converts `{x, y}` into `{left, top}` for use in style, e.g.
8890 *
8891 *```javascript
8892 * style={this.state.anim.getLayout()}
8893 *```
8894 */
8895 getLayout(): { [key: string]: AnimatedValue };
8896
8897 /**
8898 * Converts `{x, y}` into a useable translation transform, e.g.
8899 *
8900 *```javascript
8901 * style={{
8902 * transform: this.state.anim.getTranslateTransform()
8903 * }}
8904 *```
8905 */
8906 getTranslateTransform(): [{ translateX: AnimatedValue }, { translateY: AnimatedValue }];
8907 }
8908
8909 type EndResult = { finished: boolean };
8910 type EndCallback = (result: EndResult) => void;
8911
8912 export interface CompositeAnimation {
8913 /**
8914 * Animations are started by calling start() on your animation.
8915 * start() takes a completion callback that will be called when the
8916 * animation is done or when the animation is done because stop() was
8917 * called on it before it could finish.
8918 *
8919 * @param callback - Optional function that will be called
8920 * after the animation finished running normally or when the animation
8921 * is done because stop() was called on it before it could finish
8922 *
8923 * @example
8924 * Animated.timing({}).start(({ finished }) => {
8925 * // completion callback
8926 * });
8927 */
8928 start: (callback?: EndCallback) => void;
8929 /**
8930 * Stops any running animation.
8931 */
8932 stop: () => void;
8933 /**
8934 * Stops any running animation and resets the value to its original.
8935 */
8936 reset: () => void;
8937 }
8938
8939 interface AnimationConfig {
8940 isInteraction?: boolean | undefined;
8941 useNativeDriver: boolean;
8942 }
8943
8944 /**
8945 * Animates a value from an initial velocity to zero based on a decay
8946 * coefficient.
8947 */
8948 export function decay(value: AnimatedValue | AnimatedValueXY, config: DecayAnimationConfig): CompositeAnimation;
8949
8950 interface DecayAnimationConfig extends AnimationConfig {
8951 velocity: number | { x: number; y: number };
8952 deceleration?: number | undefined;
8953 }
8954
8955 /**
8956 * Animates a value along a timed easing curve. The `Easing` module has tons
8957 * of pre-defined curves, or you can use your own function.
8958 */
8959 export const timing: (value: AnimatedValue | AnimatedValueXY, config: TimingAnimationConfig) => CompositeAnimation;
8960
8961 interface TimingAnimationConfig extends AnimationConfig {
8962 toValue: number | AnimatedValue | { x: number; y: number } | AnimatedValueXY | AnimatedInterpolation;
8963 easing?: ((value: number) => number) | undefined;
8964 duration?: number | undefined;
8965 delay?: number | undefined;
8966 }
8967
8968 interface SpringAnimationConfig extends AnimationConfig {
8969 toValue: number | AnimatedValue | { x: number; y: number } | AnimatedValueXY;
8970 overshootClamping?: boolean | undefined;
8971 restDisplacementThreshold?: number | undefined;
8972 restSpeedThreshold?: number | undefined;
8973 velocity?: number | { x: number; y: number } | undefined;
8974 bounciness?: number | undefined;
8975 speed?: number | undefined;
8976 tension?: number | undefined;
8977 friction?: number | undefined;
8978 stiffness?: number | undefined;
8979 mass?: number | undefined;
8980 damping?: number | undefined;
8981 delay?: number | undefined;
8982 }
8983
8984 interface LoopAnimationConfig {
8985 iterations?: number | undefined; // default -1 for infinite
8986 /**
8987 * Defaults to `true`
8988 */
8989 resetBeforeIteration?: boolean | undefined;
8990 }
8991
8992 /**
8993 * Creates a new Animated value composed from two Animated values added
8994 * together.
8995 */
8996 export function add(a: Animated, b: Animated): AnimatedAddition;
8997
8998 class AnimatedAddition extends AnimatedInterpolation {}
8999
9000 /**
9001 * Creates a new Animated value composed by subtracting the second Animated
9002 * value from the first Animated value.
9003 */
9004 export function subtract(a: Animated, b: Animated): AnimatedSubtraction;
9005
9006 class AnimatedSubtraction extends AnimatedInterpolation {}
9007
9008 /**
9009 * Creates a new Animated value composed by dividing the first Animated
9010 * value by the second Animated value.
9011 */
9012 export function divide(a: Animated, b: Animated): AnimatedDivision;
9013
9014 class AnimatedDivision extends AnimatedInterpolation {}
9015
9016 /**
9017 * Creates a new Animated value composed from two Animated values multiplied
9018 * together.
9019 */
9020 export function multiply(a: Animated, b: Animated): AnimatedMultiplication;
9021
9022 class AnimatedMultiplication extends AnimatedInterpolation {}
9023
9024 /**
9025 * Creates a new Animated value that is the (non-negative) modulo of the
9026 * provided Animated value
9027 */
9028 export function modulo(a: Animated, modulus: number): AnimatedModulo;
9029
9030 class AnimatedModulo extends AnimatedInterpolation {}
9031
9032 /**
9033 * Create a new Animated value that is limited between 2 values. It uses the
9034 * difference between the last value so even if the value is far from the bounds
9035 * it will start changing when the value starts getting closer again.
9036 * (`value = clamp(value + diff, min, max)`).
9037 *
9038 * This is useful with scroll events, for example, to show the navbar when
9039 * scrolling up and to hide it when scrolling down.
9040 */
9041 export function diffClamp(a: Animated, min: number, max: number): AnimatedDiffClamp;
9042
9043 class AnimatedDiffClamp extends AnimatedInterpolation {}
9044
9045 /**
9046 * Starts an animation after the given delay.
9047 */
9048 export function delay(time: number): CompositeAnimation;
9049
9050 /**
9051 * Starts an array of animations in order, waiting for each to complete
9052 * before starting the next. If the current running animation is stopped, no
9053 * following animations will be started.
9054 */
9055 export function sequence(animations: Array<CompositeAnimation>): CompositeAnimation;
9056
9057 /**
9058 * Array of animations may run in parallel (overlap), but are started in
9059 * sequence with successive delays. Nice for doing trailing effects.
9060 */
9061
9062 export function stagger(time: number, animations: Array<CompositeAnimation>): CompositeAnimation;
9063
9064 /**
9065 * Loops a given animation continuously, so that each time it reaches the end,
9066 * it resets and begins again from the start. Can specify number of times to
9067 * loop using the key 'iterations' in the config. Will loop without blocking
9068 * the UI thread if the child animation is set to 'useNativeDriver'.
9069 */
9070
9071 export function loop(animation: CompositeAnimation, config?: LoopAnimationConfig): CompositeAnimation;
9072
9073 /**
9074 * Spring animation based on Rebound and Origami. Tracks velocity state to
9075 * create fluid motions as the `toValue` updates, and can be chained together.
9076 */
9077 export function spring(value: AnimatedValue | AnimatedValueXY, config: SpringAnimationConfig): CompositeAnimation;
9078
9079 type ParallelConfig = {
9080 stopTogether?: boolean | undefined; // If one is stopped, stop all. default: true
9081 };
9082
9083 /**
9084 * Starts an array of animations all at the same time. By default, if one
9085 * of the animations is stopped, they will all be stopped. You can override
9086 * this with the `stopTogether` flag.
9087 */
9088 export function parallel(animations: Array<CompositeAnimation>, config?: ParallelConfig): CompositeAnimation;
9089
9090 type Mapping = { [key: string]: Mapping } | AnimatedValue;
9091 interface EventConfig<T> {
9092 listener?: ((event: NativeSyntheticEvent<T>) => void) | undefined;
9093 useNativeDriver: boolean;
9094 }
9095
9096 /**
9097 * Takes an array of mappings and extracts values from each arg accordingly,
9098 * then calls `setValue` on the mapped outputs. e.g.
9099 *
9100 *```javascript
9101 * onScroll={Animated.event(
9102 * [{nativeEvent: {contentOffset: {x: this._scrollX}}}]
9103 * {listener}, // Optional async listener
9104 * )
9105 * ...
9106 * onPanResponderMove: Animated.event([
9107 * null, // raw event arg ignored
9108 * {dx: this._panX}, // gestureState arg
9109 * ]),
9110 *```
9111 */
9112 export function event<T>(argMapping: Array<Mapping | null>, config?: EventConfig<T>): (...args: any[]) => void;
9113
9114 export type ComponentProps<T> = T extends React.ComponentType<infer P> | React.Component<infer P> ? P : never;
9115
9116 export type LegacyRef<C> = { getNode(): C };
9117
9118 type Nullable = undefined | null;
9119 type Primitive = string | number | boolean | symbol;
9120 type Builtin = Function | Date | Error | RegExp;
9121
9122 interface WithAnimatedArray<P> extends Array<WithAnimatedValue<P>> {}
9123 type WithAnimatedObject<T> = {
9124 [K in keyof T]: WithAnimatedValue<T[K]>;
9125 };
9126
9127 export type WithAnimatedValue<T> = T extends Builtin | Nullable
9128 ? T
9129 : T extends Primitive
9130 ? T | Value | AnimatedInterpolation // add `Value` and `AnimatedInterpolation` but also preserve original T
9131 : T extends Array<infer P>
9132 ? WithAnimatedArray<P>
9133 : T extends {}
9134 ? WithAnimatedObject<T>
9135 : T; // in case it's something we don't yet know about (for .e.g bigint)
9136
9137 type NonAnimatedProps = 'key' | 'ref';
9138
9139 type TAugmentRef<T> = T extends React.Ref<infer R> ? React.Ref<R | LegacyRef<R>> : never;
9140
9141 export type AnimatedProps<T> = {
9142 [key in keyof T]: key extends NonAnimatedProps
9143 ? key extends 'ref'
9144 ? TAugmentRef<T[key]>
9145 : T[key]
9146 : WithAnimatedValue<T[key]>;
9147 };
9148
9149 export interface AnimatedComponent<T extends React.ComponentType<any>>
9150 extends React.FC<AnimatedProps<React.ComponentPropsWithRef<T>>> {}
9151
9152 /**
9153 * Make any React component Animatable. Used to create `Animated.View`, etc.
9154 */
9155 export function createAnimatedComponent<T extends React.ComponentType<any>>(component: T): AnimatedComponent<T>;
9156
9157 /**
9158 * Animated variants of the basic native views. Accepts Animated.Value for
9159 * props and style.
9160 */
9161 export const View: AnimatedComponent<typeof _View>;
9162 export const Image: AnimatedComponent<typeof _Image>;
9163 export const Text: AnimatedComponent<typeof _Text>;
9164 export const ScrollView: AnimatedComponent<typeof _ScrollView>;
9165
9166 /**
9167 * FlatList and SectionList infer generic Type defined under their `data` and `section` props.
9168 */
9169 export class FlatList<ItemT = any> extends React.Component<AnimatedProps<FlatListProps<ItemT>>> {}
9170 export class SectionList<ItemT = any, SectionT = DefaultSectionT> extends React.Component<
9171 AnimatedProps<SectionListProps<ItemT, SectionT>>
9172 > {}
9173}
9174
9175// tslint:disable-next-line:interface-name
9176export interface I18nManagerStatic {
9177 getConstants: () => {
9178 isRTL: boolean;
9179 doLeftAndRightSwapInRTL: boolean;
9180 localeIdentifier?: string | null | undefined;
9181 };
9182 allowRTL: (allowRTL: boolean) => void;
9183 forceRTL: (forceRTL: boolean) => void;
9184 swapLeftAndRightInRTL: (swapLeftAndRight: boolean) => void;
9185 isRTL: boolean;
9186 doLeftAndRightSwapInRTL: boolean;
9187}
9188
9189export interface OpenCameraDialogOptions {
9190 /** Defaults to false */
9191 videoMode?: boolean | undefined;
9192}
9193
9194export interface OpenSelectDialogOptions {
9195 /** Defaults to true */
9196 showImages?: boolean | undefined;
9197 /** Defaults to false */
9198 showVideos?: boolean | undefined;
9199}
9200
9201/** [imageURL|tempImageTag, height, width] */
9202export type ImagePickerResult = [string, number, number];
9203
9204export interface ImagePickerIOSStatic {
9205 canRecordVideos(callback: (value: boolean) => void): void;
9206 canUseCamera(callback: (value: boolean) => void): void;
9207 openCameraDialog(
9208 config: OpenCameraDialogOptions,
9209 successCallback: (args: ImagePickerResult) => void,
9210 cancelCallback: (args: any[]) => void,
9211 ): void;
9212 openSelectDialog(
9213 config: OpenSelectDialogOptions,
9214 successCallback: (args: ImagePickerResult) => void,
9215 cancelCallback: (args: any[]) => void,
9216 ): void;
9217}
9218
9219export interface ImageStoreStatic {
9220 /**
9221 * Check if the ImageStore contains image data for the specified URI.
9222 * @platform ios
9223 */
9224 hasImageForTag(uri: string, callback: (hasImage: boolean) => void): void;
9225
9226 /**
9227 * Delete an image from the ImageStore. Images are stored in memory and
9228 * must be manually removed when you are finished with them, otherwise they
9229 * will continue to use up RAM until the app is terminated. It is safe to
9230 * call `removeImageForTag()` without first calling `hasImageForTag()`, it
9231 * will simply fail silently.
9232 * @platform ios
9233 */
9234 removeImageForTag(uri: string): void;
9235
9236 /**
9237 * Stores a base64-encoded image in the ImageStore, and returns a URI that
9238 * can be used to access or display the image later. Images are stored in
9239 * memory only, and must be manually deleted when you are finished with
9240 * them by calling `removeImageForTag()`.
9241 *
9242 * Note that it is very inefficient to transfer large quantities of binary
9243 * data between JS and native code, so you should avoid calling this more
9244 * than necessary.
9245 * @platform ios
9246 */
9247 addImageFromBase64(base64ImageData: string, success: (uri: string) => void, failure: (error: any) => void): void;
9248
9249 /**
9250 * Retrieves the base64-encoded data for an image in the ImageStore. If the
9251 * specified URI does not match an image in the store, the failure callback
9252 * will be called.
9253 *
9254 * Note that it is very inefficient to transfer large quantities of binary
9255 * data between JS and native code, so you should avoid calling this more
9256 * than necessary. To display an image in the ImageStore, you can just pass
9257 * the URI to an `<Image/>` component; there is no need to retrieve the
9258 * base64 data.
9259 */
9260 getBase64ForTag(uri: string, success: (base64ImageData: string) => void, failure: (error: any) => void): void;
9261}
9262
9263//
9264// Interfacing with Native Modules
9265// https://reactnative.dev/docs/native-modules-ios
9266//
9267
9268export interface NativeEventSubscription {
9269 /**
9270 * Call this method to un-subscribe from a native-event
9271 */
9272 remove(): void;
9273}
9274
9275/**
9276 * Receive events from native-code
9277 * Deprecated - subclass NativeEventEmitter to create granular event modules instead of
9278 * adding all event listeners directly to RCTNativeAppEventEmitter.
9279 * @see https://github.com/facebook/react-native/blob/0.34-stable\Libraries\EventEmitter\RCTNativeAppEventEmitter.js
9280 * @see https://reactnative.dev/docs/native-modules-ios#sending-events-to-javascript
9281 */
9282type RCTNativeAppEventEmitter = DeviceEventEmitterStatic;
9283
9284interface ImageCropData {
9285 /**
9286 * The top-left corner of the cropped image, specified in the original
9287 * image's coordinate space.
9288 */
9289 offset: {
9290 x: number;
9291 y: number;
9292 };
9293
9294 /**
9295 * The size (dimensions) of the cropped image, specified in the original
9296 * image's coordinate space.
9297 */
9298 size: {
9299 width: number;
9300 height: number;
9301 };
9302
9303 /**
9304 * (Optional) size to scale the cropped image to.
9305 */
9306 displaySize?: { width: number; height: number } | undefined;
9307
9308 /**
9309 * (Optional) the resizing mode to use when scaling the image. If the
9310 * `displaySize` param is not specified, this has no effect.
9311 */
9312 resizeMode?: 'contain' | 'cover' | 'stretch' | undefined;
9313}
9314
9315interface ImageEditorStatic {
9316 /**
9317 * Crop the image specified by the URI param. If URI points to a remote
9318 * image, it will be downloaded automatically. If the image cannot be
9319 * loaded/downloaded, the failure callback will be called.
9320 *
9321 * If the cropping process is successful, the resultant cropped image
9322 * will be stored in the ImageStore, and the URI returned in the success
9323 * callback will point to the image in the store. Remember to delete the
9324 * cropped image from the ImageStore when you are done with it.
9325 */
9326 cropImage(
9327 uri: string,
9328 cropData: ImageCropData,
9329 success: (uri: string) => void,
9330 failure: (error: Object) => void,
9331 ): void;
9332}
9333
9334export type KeyboardEventName =
9335 | 'keyboardWillShow'
9336 | 'keyboardDidShow'
9337 | 'keyboardWillHide'
9338 | 'keyboardDidHide'
9339 | 'keyboardWillChangeFrame'
9340 | 'keyboardDidChangeFrame';
9341
9342export type KeyboardEventEasing = 'easeIn' | 'easeInEaseOut' | 'easeOut' | 'linear' | 'keyboard';
9343
9344type ScreenRect = {
9345 screenX: number;
9346 screenY: number;
9347 width: number;
9348 height: number;
9349};
9350
9351interface KeyboardEventIOS {
9352 /**
9353 * @platform ios
9354 */
9355 startCoordinates: ScreenRect;
9356 /**
9357 * @platform ios
9358 */
9359 isEventFromThisApp: boolean;
9360}
9361
9362export interface KeyboardEvent extends Partial<KeyboardEventIOS> {
9363 /**
9364 * Always set to 0 on Android.
9365 */
9366 duration: number;
9367 /**
9368 * Always set to "keyboard" on Android.
9369 */
9370 easing: KeyboardEventEasing;
9371 endCoordinates: ScreenRect;
9372}
9373
9374type KeyboardEventListener = (event: KeyboardEvent) => void;
9375
9376export interface KeyboardStatic extends NativeEventEmitter {
9377 /**
9378 * Dismisses the active keyboard and removes focus.
9379 */
9380 dismiss: () => void;
9381 /**
9382 * The `addListener` function connects a JavaScript function to an identified native
9383 * keyboard notification event.
9384 *
9385 * This function then returns the reference to the listener.
9386 *
9387 * {string} eventName The `nativeEvent` is the string that identifies the event you're listening for. This
9388 *can be any of the following:
9389 *
9390 * - `keyboardWillShow`
9391 * - `keyboardDidShow`
9392 * - `keyboardWillHide`
9393 * - `keyboardDidHide`
9394 * - `keyboardWillChangeFrame`
9395 * - `keyboardDidChangeFrame`
9396 *
9397 * Note that if you set `android:windowSoftInputMode` to `adjustResize` or `adjustNothing`,
9398 * only `keyboardDidShow` and `keyboardDidHide` events will be available on Android.
9399 * `keyboardWillShow` as well as `keyboardWillHide` are generally not available on Android
9400 * since there is no native corresponding event.
9401 *
9402 * {function} callback function to be called when the event fires.
9403 */
9404 addListener: (eventType: KeyboardEventName, listener: KeyboardEventListener) => EmitterSubscription;
9405 /**
9406 * Useful for syncing TextInput (or other keyboard accessory view) size of
9407 * position changes with keyboard movements.
9408 */
9409 scheduleLayoutAnimation: (event: KeyboardEvent) => void;
9410}
9411
9412/**
9413 * The DevSettings module exposes methods for customizing settings for developers in development.
9414 */
9415export interface DevSettingsStatic extends NativeEventEmitter {
9416 /**
9417 * Adds a custom menu item to the developer menu.
9418 *
9419 * @param title - The title of the menu item. Is internally used as id and should therefore be unique.
9420 * @param handler - The callback invoked when pressing the menu item.
9421 */
9422 addMenuItem(title: string, handler: () => any): void;
9423
9424 /**
9425 * Reload the application.
9426 *
9427 * @param reason
9428 */
9429 reload(reason?: string): void;
9430}
9431
9432export const DevSettings: DevSettingsStatic;
9433
9434//////////////////////////////////////////////////////////////////////////
9435//
9436// R E - E X P O R T S
9437//
9438//////////////////////////////////////////////////////////////////////////
9439
9440//////////// APIS //////////////
9441export const ActionSheetIOS: ActionSheetIOSStatic;
9442export type ActionSheetIOS = ActionSheetIOSStatic;
9443
9444export const AccessibilityInfo: AccessibilityInfoStatic;
9445export type AccessibilityInfo = AccessibilityInfoStatic;
9446
9447export const Alert: AlertStatic;
9448export type Alert = AlertStatic;
9449
9450export const AppState: AppStateStatic;
9451export type AppState = AppStateStatic;
9452
9453/**
9454 * AsyncStorage has been extracted from react-native core and will be removed in a future release.
9455 * It can now be installed and imported from `@react-native-community/async-storage` instead of 'react-native'.
9456 * @see https://github.com/react-native-community/async-storage
9457 * @deprecated
9458 */
9459export const AsyncStorage: AsyncStorageStatic;
9460/**
9461 * AsyncStorage has been extracted from react-native core and will be removed in a future release.
9462 * It can now be installed and imported from `@react-native-community/async-storage` instead of 'react-native'.
9463 * @see https://github.com/react-native-community/async-storage
9464 * @deprecated
9465 */
9466export type AsyncStorage = AsyncStorageStatic;
9467
9468export const BackHandler: BackHandlerStatic;
9469export type BackHandler = BackHandlerStatic;
9470
9471/**
9472 * CameraRoll has been removed from React Native.
9473 * It can now be installed and imported from `@react-native-community/cameraroll` instead of 'react-native'.
9474 * @see https://github.com/react-native-community/react-native-cameraroll
9475 * @deprecated
9476 */
9477export const CameraRoll: CameraRollStatic;
9478/**
9479 * CameraRoll has been removed from React Native.
9480 * It can now be installed and imported from `@react-native-community/cameraroll` instead of 'react-native'.
9481 * @see https://github.com/react-native-community/react-native-cameraroll
9482 * @deprecated
9483 */
9484export type CameraRoll = CameraRollStatic;
9485
9486/**
9487 * Clipboard has been extracted from react-native core and will be removed in a future release.
9488 * It can now be installed and imported from `@react-native-community/clipboard` instead of 'react-native'.
9489 * @see https://github.com/react-native-community/clipboard
9490 * @deprecated
9491 */
9492export const Clipboard: ClipboardStatic;
9493/**
9494 * Clipboard has been extracted from react-native core and will be removed in a future release.
9495 * It can now be installed and imported from `@react-native-community/clipboard` instead of 'react-native'.
9496 * @see https://github.com/react-native-community/clipboard
9497 * @deprecated
9498 */
9499export type Clipboard = ClipboardStatic;
9500
9501/**
9502 * DatePickerAndroid has been merged with DatePickerIOS and will be removed in a future release.
9503 * It can now be installed and imported from `@react-native-community/datetimepicker` instead of 'react-native'.
9504 * @see https://github.com/react-native-community/datetimepicker
9505 * @deprecated
9506 */
9507export const DatePickerAndroid: DatePickerAndroidStatic;
9508/**
9509 * DatePickerAndroid has been merged with DatePickerIOS and will be removed in a future release.
9510 * It can now be installed and imported from `@react-native-community/datetimepicker` instead of 'react-native'.
9511 * @see https://github.com/react-native-community/datetimepicker
9512 * @deprecated
9513 */
9514export type DatePickerAndroid = DatePickerAndroidStatic;
9515
9516export const Dimensions: Dimensions;
9517
9518export type Easing = EasingStatic;
9519export const Easing: EasingStatic;
9520
9521/** https://reactnative.dev/blog/2016/08/19/right-to-left-support-for-react-native-apps */
9522export const I18nManager: I18nManagerStatic;
9523export type I18nManager = I18nManagerStatic;
9524
9525/**
9526 * ImageEditor has been removed from React Native.
9527 * It can now be installed and imported from `@react-native-community/image-editor` instead of 'react-native'.
9528 * @see https://github.com/react-native-community/react-native-image-editor
9529 * @deprecated
9530 */
9531export const ImageEditor: ImageEditorStatic;
9532export type ImageEditor = ImageEditorStatic;
9533
9534/**
9535 * ImagePickerIOS has been extracted from react-native core and will be removed in a future release.
9536 * Please upgrade to use either `@react-native-community/react-native-image-picker` or 'expo-image-picker'.
9537 * If you cannot upgrade to a different library, please install the deprecated `@react-native-community/image-picker-ios` package.
9538 * @see https://github.com/react-native-community/react-native-image-picker-ios
9539 * @deprecated
9540 */
9541export const ImagePickerIOS: ImagePickerIOSStatic;
9542export type ImagePickerIOS = ImagePickerIOSStatic;
9543
9544/**
9545 * ImageStore has been removed from React Native.
9546 * To get a base64-encoded string from a local image use either of the following third-party libraries:
9547 * * expo-file-system: `readAsStringAsync(filepath, 'base64')`
9548 * * react-native-fs: `readFile(filepath, 'base64')`
9549 * @deprecated
9550 */
9551export const ImageStore: ImageStoreStatic;
9552export type ImageStore = ImageStoreStatic;
9553
9554export const InteractionManager: InteractionManagerStatic;
9555
9556export const Keyboard: KeyboardStatic;
9557
9558export const LayoutAnimation: LayoutAnimationStatic;
9559export type LayoutAnimation = LayoutAnimationStatic;
9560
9561export const Linking: LinkingStatic;
9562export type Linking = LinkingStatic;
9563
9564export const LogBox: LogBoxStatic;
9565export type LogBox = LogBoxStatic;
9566
9567export const PanResponder: PanResponderStatic;
9568export type PanResponder = PanResponderStatic;
9569
9570export const PermissionsAndroid: PermissionsAndroidStatic;
9571export type PermissionsAndroid = PermissionsAndroidStatic;
9572
9573/**
9574 * PushNotificationIOS has been extracted from react-native core and will be removed in a future release.
9575 * It can now be installed and imported from `@react-native-community/push-notification-ios` instead of 'react-native'.
9576 * @see https://github.com/react-native-community/react-native-push-notification-ios
9577 * @deprecated
9578 */
9579export const PushNotificationIOS: PushNotificationIOSStatic;
9580/**
9581 * PushNotificationIOS has been extracted from react-native core and will be removed in a future release.
9582 * It can now be installed and imported from `@react-native-community/push-notification-ios` instead of 'react-native'.
9583 * @see https://github.com/react-native-community/react-native-push-notification-ios
9584 * @deprecated
9585 */
9586export type PushNotificationIOS = PushNotificationIOSStatic;
9587
9588export const Settings: SettingsStatic;
9589export type Settings = SettingsStatic;
9590
9591export const Share: ShareStatic;
9592export type Share = ShareStatic;
9593
9594/**
9595 * @deprecated Use StatusBar instead
9596 */
9597export const StatusBarIOS: StatusBarIOSStatic;
9598export type StatusBarIOS = StatusBarIOSStatic;
9599
9600export const Systrace: SystraceStatic;
9601export type Systrace = SystraceStatic;
9602
9603/**
9604 * TimePickerAndroid has been removed from React Native.
9605 * It can now be installed and imported from `@react-native-community/datetimepicker` instead of 'react-native'.
9606 * @see https://github.com/react-native-community/datetimepicker
9607 * @deprecated
9608 */
9609export const TimePickerAndroid: TimePickerAndroidStatic;
9610/**
9611 * TimePickerAndroid has been removed from React Native.
9612 * It can now be installed and imported from `@react-native-community/datetimepicker` instead of 'react-native'.
9613 * @see https://github.com/react-native-community/datetimepicker
9614 * @deprecated
9615 */
9616export type TimePickerAndroid = TimePickerAndroidStatic;
9617
9618export const ToastAndroid: ToastAndroidStatic;
9619export type ToastAndroid = ToastAndroidStatic;
9620
9621export const UIManager: UIManagerStatic;
9622export type UIManager = UIManagerStatic;
9623
9624export const Vibration: VibrationStatic;
9625export type Vibration = VibrationStatic;
9626
9627export const ShadowPropTypesIOS: ShadowPropTypesIOSStatic;
9628
9629//////////// Plugins //////////////
9630
9631export const DeviceEventEmitter: DeviceEventEmitterStatic;
9632
9633/**
9634 * The React Native implementation of the IOS RCTEventEmitter which is required when creating
9635 * a module that communicates with IOS
9636 */
9637type NativeModule = {
9638 /**
9639 * Add the provided eventType as an active listener
9640 * @param eventType name of the event for which we are registering listener
9641 */
9642 addListener: (eventType: string) => void;
9643
9644 /**
9645 * Remove a specified number of events. There are no eventTypes in this case, as
9646 * the native side doesn't remove the name, but only manages a counter of total
9647 * listeners
9648 * @param count number of listeners to remove (of any type)
9649 */
9650 removeListeners: (count: number) => void;
9651};
9652
9653/**
9654 * Abstract base class for implementing event-emitting modules. This implements
9655 * a subset of the standard EventEmitter node module API.
9656 */
9657declare class NativeEventEmitter extends EventEmitter {
9658 /**
9659 * @param nativeModule the NativeModule implementation. This is required on IOS and will throw
9660 * an invariant error if undefined.
9661 */
9662 constructor(nativeModule?: NativeModule);
9663
9664 /**
9665 * Add the specified listener, this call passes through to the NativeModule
9666 * addListener
9667 *
9668 * @param eventType name of the event for which we are registering listener
9669 * @param listener the listener function
9670 * @param context context of the listener
9671 */
9672 addListener(eventType: string, listener: (event: any) => void, context?: Object): EmitterSubscription;
9673
9674 /**
9675 * @param eventType name of the event whose registered listeners to remove
9676 */
9677 removeAllListeners(eventType: string): void;
9678
9679 /**
9680 * Removes a subscription created by the addListener, the EventSubscription#remove()
9681 * function actually calls through to this.
9682 */
9683 removeSubscription(subscription: EmitterSubscription): void;
9684}
9685
9686/**
9687 * Deprecated - subclass NativeEventEmitter to create granular event modules instead of
9688 * adding all event listeners directly to RCTNativeAppEventEmitter.
9689 */
9690export const NativeAppEventEmitter: RCTNativeAppEventEmitter;
9691
9692/**
9693 * Interface for NativeModules which allows to augment NativeModules with type informations.
9694 * See react-native-sensor-manager for example.
9695 */
9696interface NativeModulesStatic {
9697 [name: string]: any;
9698}
9699
9700/**
9701 * Native Modules written in ObjectiveC/Swift/Java exposed via the RCTBridge
9702 * Define lazy getters for each module. These will return the module if already loaded, or load it if not.
9703 * See https://reactnative.dev/docs/native-modules-ios
9704 * Use:
9705 * <code>const MyModule = NativeModules.ModuleName</code>
9706 */
9707export const NativeModules: NativeModulesStatic;
9708export const Platform:
9709 | PlatformIOSStatic
9710 | PlatformAndroidStatic
9711 | PlatformWindowsOSStatic
9712 | PlatformMacOSStatic
9713 | PlatformWebStatic;
9714export const PixelRatio: PixelRatioStatic;
9715
9716/**
9717 * Creates values that can be used like React components which represent native
9718 * view managers. You should create JavaScript modules that wrap these values so
9719 * that the results are memoized. Example:
9720 *
9721 * const View = requireNativeComponent('RCTView');
9722 *
9723 * The concrete return type of `requireNativeComponent` is a string, but the declared type is
9724 * `HostComponent` because TypeScript assumes anonymous JSX intrinsics (e.g. a `string`) not
9725 * to have any props.
9726 */
9727export function requireNativeComponent<T>(viewName: string): HostComponent<T>;
9728
9729export function findNodeHandle(
9730 componentOrHandle: null | number | React.Component<any, any> | React.ComponentClass<any>,
9731): null | number;
9732
9733export function processColor(color?: number | ColorValue): ProcessedColorValue | null | undefined;
9734
9735/**
9736 * YellowBox has been replaced with LogBox.
9737 * @see LogBox
9738 * @deprecated
9739 */
9740export const YellowBox: React.ComponentClass<any, any> & { ignoreWarnings: (warnings: string[]) => void };
9741
9742/**
9743 * LogBox is enabled by default so there is no need to call unstable_enableLogBox() anymore. This is a no op and will be removed in the next version.
9744 * @deprecated
9745 */
9746export function unstable_enableLogBox(): void;
9747
9748/**
9749 * React Native also implements unstable_batchedUpdates
9750 */
9751export function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
9752export function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
9753export function unstable_batchedUpdates(callback: () => any): void;
9754
9755//////////////////////////////////////////////////////////////////////////
9756//
9757// Additional ( and controversial)
9758//
9759//////////////////////////////////////////////////////////////////////////
9760
9761export function __spread(target: any, ...sources: any[]): any;
9762
9763type ErrorHandlerCallback = (error: any, isFatal?: boolean) => void;
9764
9765export interface ErrorUtils {
9766 setGlobalHandler: (callback: ErrorHandlerCallback) => void;
9767 getGlobalHandler: () => ErrorHandlerCallback;
9768}
9769
9770//
9771// Add-Ons
9772//
9773export namespace addons {
9774 //FIXME: Documentation ?
9775 export interface TestModuleStatic {
9776 verifySnapshot: (done: (indicator?: any) => void) => void;
9777 markTestPassed: (indicator: any) => void;
9778 markTestCompleted: () => void;
9779 }
9780
9781 export const TestModule: TestModuleStatic;
9782 export type TestModule = TestModuleStatic;
9783}
9784
9785//
9786// Prop Types
9787//
9788export const ColorPropType: React.Validator<string>;
9789export const EdgeInsetsPropType: React.Validator<Insets>;
9790export const PointPropType: React.Validator<PointPropType>;
9791export const ViewPropTypes: React.ValidationMap<ViewProps>;
9792export const TextPropTypes: React.ValidationMap<TextProps>;
9793export const ImagePropTypes: React.ValidationMap<ImageProps>;
9794
9795declare global {
9796 interface NodeRequire {
9797 (id: string): any;
9798 }
9799
9800 var require: NodeRequire;
9801
9802 /**
9803 * Console polyfill
9804 * @see https://reactnative.dev/docs/javascript-environment#polyfills
9805 */
9806 interface Console {
9807 error(message?: any, ...optionalParams: any[]): void;
9808 info(message?: any, ...optionalParams: any[]): void;
9809 log(message?: any, ...optionalParams: any[]): void;
9810 warn(message?: any, ...optionalParams: any[]): void;
9811 trace(message?: any, ...optionalParams: any[]): void;
9812 debug(message?: any, ...optionalParams: any[]): void;
9813 table(...data: any[]): void;
9814 groupCollapsed(label?: string): void;
9815 groupEnd(): void;
9816 group(label?: string): void;
9817 /**
9818 * @deprecated Use LogBox.ignoreAllLogs(disable) instead
9819 */
9820 disableYellowBox: boolean;
9821 /**
9822 * @deprecated Use LogBox.ignoreLogs(patterns) instead
9823 */
9824 ignoredYellowBox: string[];
9825 }
9826
9827 var console: Console;
9828
9829 /**
9830 * This contains the non-native `XMLHttpRequest` object, which you can use if you want to route network requests
9831 * through DevTools (to trace them):
9832 *
9833 * global.XMLHttpRequest = global.originalXMLHttpRequest;
9834 *
9835 * @see https://github.com/facebook/react-native/issues/934
9836 */
9837 const originalXMLHttpRequest: any;
9838
9839 const __BUNDLE_START_TIME__: number;
9840 const ErrorUtils: ErrorUtils;
9841
9842 /**
9843 * This variable is set to true when react-native is running in Dev mode
9844 * Typical usage:
9845 * <code> if (__DEV__) console.log('Running in dev mode')</code>
9846 */
9847 const __DEV__: boolean;
9848
9849 const HermesInternal: null | {};
9850}
9851
\No newline at end of file