microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
e45838cbf8bb84beab7d36042bcdbc57fe0319c8

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

ReactTypings/react-native/react-native.d.ts

8437lines · modecode

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