UNPKG

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