microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2060f3fb58b7b63aad46de40f379c3b94c5ee76d

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

8427lines · 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 /**
4537 * Creates a StyleSheet style reference from the given object.
4538 */
4539 export function create<T>( styles: T ): T;
4540
4541 /**
4542 * Flattens an array of style objects, into one aggregated style object.
4543 * Alternatively, this method can be used to lookup IDs, returned by
4544 * StyleSheet.register.
4545 *
4546 * > **NOTE**: Exercise caution as abusing this can tax you in terms of
4547 * > optimizations.
4548 * >
4549 * > IDs enable optimizations through the bridge and memory in general. Refering
4550 * > to style objects directly will deprive you of these optimizations.
4551 *
4552 * Example:
4553 * ```
4554 * var styles = StyleSheet.create({
4555 * listItem: {
4556 * flex: 1,
4557 * fontSize: 16,
4558 * color: 'white'
4559 * },
4560 * selectedListItem: {
4561 * color: 'green'
4562 * }
4563 * });
4564 *
4565 * StyleSheet.flatten([styles.listItem, styles.selectedListItem])
4566 * // returns { flex: 1, fontSize: 16, color: 'green' }
4567 * ```
4568 * Alternative use:
4569 * ```
4570 * StyleSheet.flatten(styles.listItem);
4571 * // return { flex: 1, fontSize: 16, color: 'white' }
4572 * // Simply styles.listItem would return its ID (number)
4573 * ```
4574 * This method internally uses `StyleSheetRegistry.getStyleByID(style)`
4575 * to resolve style objects represented by IDs. Thus, an array of style
4576 * objects (instances of StyleSheet.create), are individually resolved to,
4577 * their respective objects, merged as one and then returned. This also explains
4578 * the alternative use.
4579 */
4580 export function flatten(style?: Style | Style[]): Style
4581
4582 /**
4583 * This is defined as the width of a thin line on the platform. It can be
4584 * used as the thickness of a border or division between two elements.
4585 * Example:
4586 * ```
4587 * {
4588 * borderBottomColor: '#bbb',
4589 * borderBottomWidth: StyleSheet.hairlineWidth
4590 * }
4591 * ```
4592 *
4593 * This constant will always be a round number of pixels (so a line defined
4594 * by it look crisp) and will try to match the standard width of a thin line
4595 * on the underlying platform. However, you should not rely on it being a
4596 * constant size, because on different platforms and screen densities its
4597 * value may be calculated differently.
4598 */
4599 export var hairlineWidth: number
4600
4601 /**
4602 * A very common pattern is to create overlays with position absolute and zero positioning,
4603 * so `absoluteFill` can be used for convenience and to reduce duplication of these repeated
4604 * styles.
4605 */
4606 export var absoluteFill: number
4607
4608 /**
4609 * Sometimes you may want `absoluteFill` but with a couple tweaks - `absoluteFillObject` can be
4610 * used to create a customized entry in a `StyleSheet`, e.g.:
4611 *
4612 * const styles = StyleSheet.create({
4613 * wrapper: {
4614 * ...StyleSheet.absoluteFillObject,
4615 * top: 10,
4616 * backgroundColor: 'transparent',
4617 * },
4618 * });
4619 */
4620 export var absoluteFillObject: {
4621 position: string
4622 left: number
4623 right: number
4624 top: number
4625 bottom: number
4626 }
4627 }
4628
4629 export type RelayProfiler = {
4630 attachProfileHandler(
4631 name: string,
4632 handler: (name: string, state?: any) => () => void
4633 ): void,
4634
4635 attachAggregateHandler(
4636 name: string,
4637 handler: (name: string, callback: () => void) => void
4638 ): void,
4639 }
4640
4641 export interface SystraceStatic {
4642 setEnabled(enabled: boolean): void
4643 /**
4644 * beginEvent/endEvent for starting and then ending a profile within the same call stack frame
4645 **/
4646 beginEvent(profileName?: any, args?: any): void
4647 endEvent(): void
4648 /**
4649 * beginAsyncEvent/endAsyncEvent for starting and then ending a profile where the end can either
4650 * occur on another thread or out of the current stack frame, eg await
4651 * the returned cookie variable should be used as input into the endAsyncEvent call to end the profile
4652 **/
4653 beginAsyncEvent(profileName?: any): any
4654 endAsyncEvent(profileName?: any, cookie?: any): void
4655 /**
4656 * counterEvent registers the value to the profileName on the systrace timeline
4657 **/
4658 counterEvent(profileName?: any, value?: any): void
4659 /**
4660 * Relay profiles use await calls, so likely occur out of current stack frame
4661 * therefore async variant of profiling is used
4662 **/
4663 attachToRelayProfiler(relayProfiler: RelayProfiler): void
4664 /* This is not called by default due to perf overhead but it's useful
4665 if you want to find traces which spend too much time in JSON. */
4666 swizzleJSON(): void
4667 /**
4668 * Measures multiple methods of a class. For example, you can do:
4669 * Systrace.measureMethods(JSON, 'JSON', ['parse', 'stringify']);
4670 *
4671 * @param object
4672 * @param objectName
4673 * @param methodNames Map from method names to method display names.
4674 */
4675 measureMethods(object: any, objectName: string, methodNames: Array<string>): void
4676 /**
4677 * Returns an profiled version of the input function. For example, you can:
4678 * JSON.parse = Systrace.measure('JSON', 'parse', JSON.parse);
4679 *
4680 * @param objName
4681 * @param fnName
4682 * @param {function} func
4683 * @return {function} replacement function
4684 */
4685 measure(objName: string, fnName: string, func: Function): Function
4686 }
4687
4688 /**
4689 * //FIXME: Could not find docs. Inferred from examples and jscode : ListViewDataSource.js
4690 */
4691 export interface DataSourceAssetCallback {
4692 rowHasChanged?: ( r1: any, r2: any ) => boolean
4693 sectionHeaderHasChanged?: ( h1: any, h2: any ) => boolean
4694 getRowData?: <T>( dataBlob: any, sectionID: number | string, rowID: number | string ) => T
4695 getSectionHeaderData?: <T>( dataBlob: any, sectionID: number | string ) => T
4696 }
4697
4698 /**
4699 * Provides efficient data processing and access to the
4700 * `ListView` component. A `ListViewDataSource` is created with functions for
4701 * extracting data from the input blob, and comparing elements (with default
4702 * implementations for convenience). The input blob can be as simple as an
4703 * array of strings, or an object with rows nested inside section objects.
4704 *
4705 * To update the data in the datasource, use `cloneWithRows` (or
4706 * `cloneWithRowsAndSections` if you care about sections). The data in the
4707 * data source is immutable, so you can't modify it directly. The clone methods
4708 * suck in the new data and compute a diff for each row so ListView knows
4709 * whether to re-render it or not.
4710 *
4711 * In this example, a component receives data in chunks, handled by
4712 * `_onDataArrived`, which concats the new data onto the old data and updates the
4713 * data source. We use `concat` to create a new array - mutating `this._data`,
4714 * e.g. with `this._data.push(newRowData)`, would be an error. `_rowHasChanged`
4715 * understands the shape of the row data and knows how to efficiently compare
4716 * it.
4717 *
4718 * ```
4719 * getInitialState: function() {
4720 * var ds = new ListViewDataSource({rowHasChanged: this._rowHasChanged});
4721 * return {ds};
4722 * },
4723 * _onDataArrived(newData) {
4724 * this._data = this._data.concat(newData);
4725 * this.setState({
4726 * ds: this.state.ds.cloneWithRows(this._data)
4727 * });
4728 * }
4729 * ```
4730 */
4731 export interface ListViewDataSource {
4732 /**
4733 * You can provide custom extraction and `hasChanged` functions for section
4734 * headers and rows. If absent, data will be extracted with the
4735 * `defaultGetRowData` and `defaultGetSectionHeaderData` functions.
4736 *
4737 * The default extractor expects data of one of the following forms:
4738 *
4739 * { sectionID_1: { rowID_1: <rowData1>, ... }, ... }
4740 *
4741 * or
4742 *
4743 * { sectionID_1: [ <rowData1>, <rowData2>, ... ], ... }
4744 *
4745 * or
4746 *
4747 * [ [ <rowData1>, <rowData2>, ... ], ... ]
4748 *
4749 * The constructor takes in a params argument that can contain any of the
4750 * following:
4751 *
4752 * - getRowData(dataBlob, sectionID, rowID);
4753 * - getSectionHeaderData(dataBlob, sectionID);
4754 * - rowHasChanged(prevRowData, nextRowData);
4755 * - sectionHeaderHasChanged(prevSectionData, nextSectionData);
4756 */
4757 new( onAsset: DataSourceAssetCallback ): ListViewDataSource;
4758
4759 /**
4760 * Clones this `ListViewDataSource` with the specified `dataBlob` and
4761 * `rowIdentities`. The `dataBlob` is just an aribitrary blob of data. At
4762 * construction an extractor to get the interesting informatoin was defined
4763 * (or the default was used).
4764 *
4765 * The `rowIdentities` is is a 2D array of identifiers for rows.
4766 * ie. [['a1', 'a2'], ['b1', 'b2', 'b3'], ...]. If not provided, it's
4767 * assumed that the keys of the section data are the row identities.
4768 *
4769 * Note: This function does NOT clone the data in this data source. It simply
4770 * passes the functions defined at construction to a new data source with
4771 * the data specified. If you wish to maintain the existing data you must
4772 * handle merging of old and new data separately and then pass that into
4773 * this function as the `dataBlob`.
4774 */
4775 cloneWithRows<T>( dataBlob: Array<any> | {[key: string ]: any}, rowIdentities?: Array<string | number> ): ListViewDataSource
4776
4777 /**
4778 * This performs the same function as the `cloneWithRows` function but here
4779 * you also specify what your `sectionIdentities` are. If you don't care
4780 * about sections you should safely be able to use `cloneWithRows`.
4781 *
4782 * `sectionIdentities` is an array of identifiers for sections.
4783 * ie. ['s1', 's2', ...]. If not provided, it's assumed that the
4784 * keys of dataBlob are the section identities.
4785 *
4786 * Note: this returns a new object!
4787 */
4788 cloneWithRowsAndSections( dataBlob: Array<any> | {[key: string]: any}, sectionIdentities?: Array<string | number>, rowIdentities?: Array<Array<string | number>> ): ListViewDataSource
4789
4790 getRowCount(): number
4791 getRowAndSectionCount(): number
4792
4793 /**
4794 * Returns if the row is dirtied and needs to be rerendered
4795 */
4796 rowShouldUpdate(sectionIndex: number, rowIndex: number): boolean
4797
4798 /**
4799 * Gets the data required to render the row.
4800 */
4801 getRowData( sectionIndex: number, rowIndex: number ): any
4802
4803 /**
4804 * Gets the rowID at index provided if the dataSource arrays were flattened,
4805 * or null of out of range indexes.
4806 */
4807 getRowIDForFlatIndex( index: number ): string
4808
4809 /**
4810 * Gets the sectionID at index provided if the dataSource arrays were flattened,
4811 * or null for out of range indexes.
4812 */
4813 getSectionIDForFlatIndex( index: number ): string
4814
4815 /**
4816 * Returns an array containing the number of rows in each section
4817 */
4818 getSectionLengths(): Array<number>
4819
4820 /**
4821 * Returns if the section header is dirtied and needs to be rerendered
4822 */
4823 sectionHeaderShouldUpdate( sectionIndex: number ): boolean
4824
4825 /**
4826 * Gets the data required to render the section header
4827 */
4828 getSectionHeaderData( sectionIndex: number ): any
4829 }
4830
4831 /**
4832 * @see https://facebook.github.io/react-native/docs/tabbarios-item.html#props
4833 */
4834 export interface TabBarItemProperties extends ViewProperties, React.Props<TabBarItemStatic> {
4835
4836 /**
4837 * Little red bubble that sits at the top right of the icon.
4838 */
4839 badge?: string | number
4840
4841 /**
4842 * A custom icon for the tab. It is ignored when a system icon is defined.
4843 */
4844 icon?: ImageURISource
4845
4846 /**
4847 * Callback when this tab is being selected,
4848 * you should change the state of your component to set selected={true}.
4849 */
4850 onPress?: () => void
4851
4852 /**
4853 * If set to true it renders the image as original,
4854 * it defaults to being displayed as a template
4855 */
4856 renderAsOriginal?: boolean
4857
4858 /**
4859 * It specifies whether the children are visible or not. If you see a blank content, you probably forgot to add a selected one.
4860 */
4861 selected?: boolean
4862
4863 /**
4864 * A custom icon when the tab is selected.
4865 * It is ignored when a system icon is defined. If left empty, the icon will be tinted in blue.
4866 */
4867 selectedIcon?: ImageURISource
4868
4869 /**
4870 * React style object.
4871 */
4872 style?: ViewStyle
4873
4874 /**
4875 * Items comes with a few predefined system icons.
4876 * Note that if you are using them, the title and selectedIcon will be overriden with the system ones.
4877 *
4878 * enum('bookmarks', 'contacts', 'downloads', 'favorites', 'featured', 'history', 'more', 'most-recent', 'most-viewed', 'recents', 'search', 'top-rated')
4879 */
4880 systemIcon?: "bookmarks" | "contacts" | "downloads" | "favorites" | "featured" | "history" | "more" | "most-recent" | "most-viewed" | "recents" | "search" | "top-rated"
4881
4882 /**
4883 * Text that appears under the icon. It is ignored when a system icon is defined.
4884 */
4885 title?: string
4886
4887 ref?: Ref<TabBarItemStatic & ViewStatic>
4888 }
4889
4890 export interface TabBarItemStatic extends React.ComponentClass<TabBarItemProperties> {
4891 }
4892
4893 /**
4894 * @see https://facebook.github.io/react-native/docs/tabbarios.html#props
4895 */
4896 export interface TabBarIOSProperties extends ViewProperties, React.Props<TabBarIOSStatic> {
4897
4898 /**
4899 * Background color of the tab bar
4900 */
4901 barTintColor?: string
4902
4903 /**
4904 * Specifies tab bar item positioning. Available values are:
4905 * - fill - distributes items across the entire width of the tab bar
4906 * - center - centers item in the available tab bar space
4907 * - auto (default) - distributes items dynamically according to the
4908 * user interface idiom. In a horizontally compact environment (e.g. iPhone 5)
4909 * this value defaults to `fill`, in a horizontally regular one (e.g. iPad)
4910 * it defaults to center.
4911 */
4912 itemPositioning?: 'fill' | 'center' | 'auto'
4913
4914 /**
4915 * Color of the currently selected tab icon
4916 */
4917 tintColor?: string
4918
4919 /**
4920 * A Boolean value that indicates whether the tab bar is translucent
4921 */
4922 translucent?: boolean
4923
4924 /**
4925 * Color of text on unselected tabs
4926 */
4927 unselectedTintColor?: string
4928
4929 ref?: Ref<TabBarIOSStatic & ViewStatic>
4930 }
4931
4932 export interface TabBarIOSStatic extends React.ComponentClass<TabBarIOSProperties> {
4933 Item: TabBarItemStatic;
4934 }
4935
4936
4937 export interface PixelRatioStatic {
4938
4939 /*
4940 Returns the device pixel density. Some examples:
4941 PixelRatio.get() === 1
4942 mdpi Android devices (160 dpi)
4943 PixelRatio.get() === 1.5
4944 hdpi Android devices (240 dpi)
4945 PixelRatio.get() === 2
4946 iPhone 4, 4S
4947 iPhone 5, 5c, 5s
4948 iPhone 6
4949 xhdpi Android devices (320 dpi)
4950 PixelRatio.get() === 3
4951 iPhone 6 plus
4952 xxhdpi Android devices (480 dpi)
4953 PixelRatio.get() === 3.5
4954 Nexus 6
4955 */
4956 get(): number;
4957
4958 /*
4959 Returns the scaling factor for font sizes. This is the ratio that is
4960 used to calculate the absolute font size, so any elements that
4961 heavily depend on that should use this to do calculations.
4962
4963 If a font scale is not set, this returns the device pixel ratio.
4964
4965 Currently this is only implemented on Android and reflects the user
4966 preference set in Settings > Display > Font size,
4967 on iOS it will always return the default pixel ratio.
4968 */
4969 getFontScale(): number
4970
4971 /**
4972 * Converts a layout size (dp) to pixel size (px).
4973 * Guaranteed to return an integer number.
4974 * @param layoutSize
4975 */
4976 getPixelSizeForLayoutSize(layoutSize: number): number
4977
4978 /**
4979 * Rounds a layout size (dp) to the nearest layout size that
4980 * corresponds to an integer number of pixels. For example,
4981 * on a device with a PixelRatio of 3,
4982 * PixelRatio.roundToNearestPixel(8.4) = 8.33,
4983 * which corresponds to exactly (8.33 * 3) = 25 pixels.
4984 * @param layoutSize
4985 */
4986 roundToNearestPixel(layoutSize: number): number
4987
4988 /**
4989 * No-op for iOS, but used on the web. Should not be documented. [sic]
4990 */
4991 startDetecting(): void
4992 }
4993
4994 /**
4995 * @see https://facebook.github.io/react-native/docs/platform-specific-code.html#content
4996 */
4997 type PlatformOSType = 'ios' | 'android'
4998
4999 interface PlatformStatic {
5000 OS: PlatformOSType
5001 Version?: number
5002
5003 /**
5004 * @see https://facebook.github.io/react-native/docs/platform-specific-code.html#content
5005 */
5006 select<T>( specifics: { ios?: T, android?: T} ): T;
5007 }
5008
5009 /**
5010 * Deprecated - subclass NativeEventEmitter to create granular event modules instead of
5011 * adding all event listeners directly to RCTDeviceEventEmitter.
5012 */
5013 interface RCTDeviceEventEmitter extends EventEmitter {
5014 sharedSubscriber: EventSubscriptionVendor
5015 new(): RCTDeviceEventEmitter;
5016 addListener<T>( type: string, listener: ( data: T ) => void, context?: any ): EmitterSubscription;
5017 }
5018
5019 // Used by Dimensions below
5020 export interface ScaledSize {
5021 width: number;
5022 height: number;
5023 scale: number;
5024 fontScale: number;
5025 }
5026
5027 /**
5028 * Initial dimensions are set before `runApplication` is called so they should
5029 * be available before any other require's are run, but may be updated later.
5030 *
5031 * Note: Although dimensions are available immediately, they may change (e.g
5032 * due to device rotation) so any rendering logic or styles that depend on
5033 * these constants should try to call this function on every render, rather
5034 * than caching the value (for example, using inline styles rather than
5035 * setting a value in a `StyleSheet`).
5036 *
5037 * Example: `var {height, width} = Dimensions.get('window');`
5038 *
5039 * @param {string} dim Name of dimension as defined when calling `set`.
5040 * @returns {Object?} Value for the dimension.
5041 * @see https://facebook.github.io/react-native/docs/dimensions.html#content
5042 */
5043 export interface Dimensions {
5044 /**
5045 * Initial dimensions are set before runApplication is called so they
5046 * should be available before any other require's are run, but may be
5047 * updated later.
5048 * Note: Although dimensions are available immediately, they may
5049 * change (e.g due to device rotation) so any rendering logic or
5050 * styles that depend on these constants should try to call this
5051 * function on every render, rather than caching the value (for
5052 * example, using inline styles rather than setting a value in a
5053 * StyleSheet).
5054 * Example: var {height, width} = Dimensions.get('window');
5055 @param {string} dim Name of dimension as defined when calling set.
5056 @returns {Object?} Value for the dimension.
5057 */
5058 get( dim: "window" | "screen" ): ScaledSize;
5059
5060 /**
5061 * This should only be called from native code by sending the didUpdateDimensions event.
5062 * @param {object} dims Simple string-keyed object of dimensions to set
5063 */
5064 set( dims: {[key: string]: any} ): void
5065 }
5066
5067 export type SimpleTask = {
5068 name: string
5069 gen: () => void
5070 }
5071 export type PromiseTask = {
5072 name: string
5073 gen: () => Promise<any>
5074 }
5075
5076 export type Handle = number
5077
5078 /**
5079 * EmitterSubscription represents a subscription with listener and context data.
5080 */
5081 export class EmitterSubscription {
5082 constructor(
5083 emitter: EventEmitter,
5084 subscriber: EventSubscriptionVendor,
5085 listener: Function,
5086 context?: Object
5087 )
5088 }
5089
5090 export interface InteractionManagerStatic {
5091 Events: {
5092 interactionStart: string
5093 interactionComplete: string
5094 }
5095
5096 addListener(
5097 eventType: string, listener: Function, context?: Object): EmitterSubscription
5098
5099 /**
5100 * Schedule a function to run after all interactions have completed.
5101 * Returns a cancellable
5102 * @param fn
5103 */
5104 runAfterInteractions( task: Function | SimpleTask | PromiseTask):
5105 {then: Function, done: Function, cancel: Function}
5106
5107 /**
5108 * Notify manager that an interaction has started.
5109 */
5110 createInteractionHandle(): Handle
5111
5112 /**
5113 * Notify manager that an interaction has completed.
5114 */
5115 clearInteractionHandle(handle: Handle): void
5116
5117 /**
5118 * A positive number will use setTimeout to schedule any tasks after
5119 * the eventLoopRunningTime hits the deadline value, otherwise all
5120 * tasks will be executed in one setImmediate batch (default).
5121 */
5122 setDeadline(deadline: number): void
5123 }
5124
5125 export interface ScrollViewStyle extends FlexStyle, TransformsStyle {
5126
5127 backfaceVisibility?: "visible" | "hidden"
5128 backgroundColor?: string
5129 borderColor?: string
5130 borderTopColor?: string
5131 borderRightColor?: string
5132 borderBottomColor?: string
5133 borderLeftColor?: string
5134 borderRadius?: number
5135 borderTopLeftRadius?: number
5136 borderTopRightRadius?: number
5137 borderBottomLeftRadius?: number
5138 borderBottomRightRadius?: number
5139 borderStyle?: "solid" | "dotted" | "dashed"
5140 borderWidth?: number
5141 borderTopWidth?: number
5142 borderRightWidth?: number
5143 borderBottomWidth?: number
5144 borderLeftWidth?: number
5145 opacity?: number
5146 overflow?: "visible" | "hidden"
5147 shadowColor?: string
5148 shadowOffset?: {width: number; height: number}
5149 shadowOpacity?: number
5150 shadowRadius?: number
5151 elevation?: number
5152 }
5153
5154
5155 interface ScrollResponderMixin extends SubscribableMixin {
5156 /**
5157 * Invoke this from an `onScroll` event.
5158 */
5159 scrollResponderHandleScrollShouldSetResponder(): boolean
5160
5161 /**
5162 * Merely touch starting is not sufficient for a scroll view to become the
5163 * responder. Being the "responder" means that the very next touch move/end
5164 * event will result in an action/movement.
5165 *
5166 * Invoke this from an `onStartShouldSetResponder` event.
5167 *
5168 * `onStartShouldSetResponder` is used when the next move/end will trigger
5169 * some UI movement/action, but when you want to yield priority to views
5170 * nested inside of the view.
5171 *
5172 * There may be some cases where scroll views actually should return `true`
5173 * from `onStartShouldSetResponder`: Any time we are detecting a standard tap
5174 * that gives priority to nested views.
5175 *
5176 * - If a single tap on the scroll view triggers an action such as
5177 * recentering a map style view yet wants to give priority to interaction
5178 * views inside (such as dropped pins or labels), then we would return true
5179 * from this method when there is a single touch.
5180 *
5181 * - Similar to the previous case, if a two finger "tap" should trigger a
5182 * zoom, we would check the `touches` count, and if `>= 2`, we would return
5183 * true.
5184 *
5185 */
5186 scrollResponderHandleStartShouldSetResponder(): boolean
5187
5188 /**
5189 * There are times when the scroll view wants to become the responder
5190 * (meaning respond to the next immediate `touchStart/touchEnd`), in a way
5191 * that *doesn't* give priority to nested views (hence the capture phase):
5192 *
5193 * - Currently animating.
5194 * - Tapping anywhere that is not the focused input, while the keyboard is
5195 * up (which should dismiss the keyboard).
5196 *
5197 * Invoke this from an `onStartShouldSetResponderCapture` event.
5198 */
5199 scrollResponderHandleStartShouldSetResponderCapture(e: Event): boolean
5200
5201 /**
5202 * Invoke this from an `onResponderReject` event.
5203 *
5204 * Some other element is not yielding its role as responder. Normally, we'd
5205 * just disable the `UIScrollView`, but a touch has already began on it, the
5206 * `UIScrollView` will not accept being disabled after that. The easiest
5207 * solution for now is to accept the limitation of disallowing this
5208 * altogether. To improve this, find a way to disable the `UIScrollView` after
5209 * a touch has already started.
5210 */
5211 scrollResponderHandleResponderReject(): any
5212
5213 /**
5214 * We will allow the scroll view to give up its lock iff it acquired the lock
5215 * during an animation. This is a very useful default that happens to satisfy
5216 * many common user experiences.
5217 *
5218 * - Stop a scroll on the left edge, then turn that into an outer view's
5219 * backswipe.
5220 * - Stop a scroll mid-bounce at the top, continue pulling to have the outer
5221 * view dismiss.
5222 * - However, without catching the scroll view mid-bounce (while it is
5223 * motionless), if you drag far enough for the scroll view to become
5224 * responder (and therefore drag the scroll view a bit), any backswipe
5225 * navigation of a swipe gesture higher in the view hierarchy, should be
5226 * rejected.
5227 */
5228 scrollResponderHandleTerminationRequest(): boolean
5229
5230 /**
5231 * Invoke this from an `onTouchEnd` event.
5232 *
5233 * @param {SyntheticEvent} e Event.
5234 */
5235 scrollResponderHandleTouchEnd(e: Event): void
5236
5237 /**
5238 * Invoke this from an `onResponderRelease` event.
5239 */
5240 scrollResponderHandleResponderRelease(e: Event): void
5241
5242 scrollResponderHandleScroll(e: Event): void
5243
5244 /**
5245 * Invoke this from an `onResponderGrant` event.
5246 */
5247 scrollResponderHandleResponderGrant(e: Event): void
5248
5249 /**
5250 * Unfortunately, `onScrollBeginDrag` also fires when *stopping* the scroll
5251 * animation, and there's not an easy way to distinguish a drag vs. stopping
5252 * momentum.
5253 *
5254 * Invoke this from an `onScrollBeginDrag` event.
5255 */
5256 scrollResponderHandleScrollBeginDrag(e: Event): void
5257
5258 /**
5259 * Invoke this from an `onScrollEndDrag` event.
5260 */
5261 scrollResponderHandleScrollEndDrag(e: Event): void
5262
5263 /**
5264 * Invoke this from an `onMomentumScrollBegin` event.
5265 */
5266 scrollResponderHandleMomentumScrollBegin(e: Event): void
5267
5268 /**
5269 * Invoke this from an `onMomentumScrollEnd` event.
5270 */
5271 scrollResponderHandleMomentumScrollEnd(e: Event): void
5272
5273 /**
5274 * Invoke this from an `onTouchStart` event.
5275 *
5276 * Since we know that the `SimpleEventPlugin` occurs later in the plugin
5277 * order, after `ResponderEventPlugin`, we can detect that we were *not*
5278 * permitted to be the responder (presumably because a contained view became
5279 * responder). The `onResponderReject` won't fire in that case - it only
5280 * fires when a *current* responder rejects our request.
5281 *
5282 * @param {SyntheticEvent} e Touch Start event.
5283 */
5284 scrollResponderHandleTouchStart(e: Event): void
5285
5286 /**
5287 * Invoke this from an `onTouchMove` event.
5288 *
5289 * Since we know that the `SimpleEventPlugin` occurs later in the plugin
5290 * order, after `ResponderEventPlugin`, we can detect that we were *not*
5291 * permitted to be the responder (presumably because a contained view became
5292 * responder). The `onResponderReject` won't fire in that case - it only
5293 * fires when a *current* responder rejects our request.
5294 *
5295 * @param {SyntheticEvent} e Touch Start event.
5296 */
5297 scrollResponderHandleTouchMove(e: Event): void
5298
5299 /**
5300 * A helper function for this class that lets us quickly determine if the
5301 * view is currently animating. This is particularly useful to know when
5302 * a touch has just started or ended.
5303 */
5304 scrollResponderIsAnimating(): boolean
5305
5306 /**
5307 * Returns the node that represents native view that can be scrolled.
5308 * Components can pass what node to use by defining a `getScrollableNode`
5309 * function otherwise `this` is used.
5310 */
5311 scrollResponderGetScrollableNode(): any
5312
5313 /**
5314 * A helper function to scroll to a specific point in the scrollview.
5315 * This is currently used to help focus on child textviews, but can also
5316 * be used to quickly scroll to any element we want to focus. Syntax:
5317 *
5318 * scrollResponderScrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
5319 *
5320 * Note: The weird argument signature is due to the fact that, for historical reasons,
5321 * the function also accepts separate arguments as as alternative to the options object.
5322 * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
5323 */
5324 scrollResponderScrollTo( x?: number | { x?: number, y?: number, animated?: boolean }, y?: number, animated?: boolean ): void,
5325
5326 /**
5327 * A helper function to zoom to a specific rect in the scrollview. The argument has the shape
5328 * {x: number; y: number; width: number; height: number; animated: boolean = true}
5329 *
5330 * @platform ios
5331 */
5332 scrollResponderZoomTo(
5333 rect: { x: number, y: number, width: number, height: number, animated?: boolean },
5334 animated?: boolean // deprecated, put this inside the rect argument instead
5335 ): void
5336
5337 /**
5338 * This method should be used as the callback to onFocus in a TextInputs'
5339 * parent view. Note that any module using this mixin needs to return
5340 * the parent view's ref in getScrollViewRef() in order to use this method.
5341 * @param {any} nodeHandle The TextInput node handle
5342 * @param {number} additionalOffset The scroll view's top "contentInset".
5343 * Default is 0.
5344 * @param {bool} preventNegativeScrolling Whether to allow pulling the content
5345 * down to make it meet the keyboard's top. Default is false.
5346 */
5347 scrollResponderScrollNativeHandleToKeyboard(nodeHandle: any, additionalOffset?: number, preventNegativeScrollOffset?: boolean): void
5348
5349 /**
5350 * The calculations performed here assume the scroll view takes up the entire
5351 * screen - even if has some content inset. We then measure the offsets of the
5352 * keyboard, and compensate both for the scroll view's "contentInset".
5353 *
5354 * @param {number} left Position of input w.r.t. table view.
5355 * @param {number} top Position of input w.r.t. table view.
5356 * @param {number} width Width of the text input.
5357 * @param {number} height Height of the text input.
5358 */
5359 scrollResponderInputMeasureAndScrollToKeyboard(left: number, top: number, width: number, height: number): void
5360
5361 scrollResponderTextInputFocusError(e: Event): void
5362
5363 /**
5364 * `componentWillMount` is the closest thing to a standard "constructor" for
5365 * React components.
5366 *
5367 * The `keyboardWillShow` is called before input focus.
5368 */
5369 componentWillMount(): void
5370
5371 /**
5372 * Warning, this may be called several times for a single keyboard opening.
5373 * It's best to store the information in this method and then take any action
5374 * at a later point (either in `keyboardDidShow` or other).
5375 *
5376 * Here's the order that events occur in:
5377 * - focus
5378 * - willShow {startCoordinates, endCoordinates} several times
5379 * - didShow several times
5380 * - blur
5381 * - willHide {startCoordinates, endCoordinates} several times
5382 * - didHide several times
5383 *
5384 * The `ScrollResponder` providesModule callbacks for each of these events.
5385 * Even though any user could have easily listened to keyboard events
5386 * themselves, using these `props` callbacks ensures that ordering of events
5387 * is consistent - and not dependent on the order that the keyboard events are
5388 * subscribed to. This matters when telling the scroll view to scroll to where
5389 * the keyboard is headed - the scroll responder better have been notified of
5390 * the keyboard destination before being instructed to scroll to where the
5391 * keyboard will be. Stick to the `ScrollResponder` callbacks, and everything
5392 * will work.
5393 *
5394 * WARNING: These callbacks will fire even if a keyboard is displayed in a
5395 * different navigation pane. Filter out the events to determine if they are
5396 * relevant to you. (For example, only if you receive these callbacks after
5397 * you had explicitly focused a node etc).
5398 */
5399 scrollResponderKeyboardWillShow(e: Event): void
5400
5401 scrollResponderKeyboardWillHide(e: Event): void
5402
5403 scrollResponderKeyboardDidShow(e: Event): void
5404
5405 scrollResponderKeyboardDidHide(e: Event): void
5406 }
5407
5408 export interface ScrollViewPropertiesIOS {
5409
5410 /**
5411 * When true the scroll view bounces horizontally when it reaches the end
5412 * even if the content is smaller than the scroll view itself. The default
5413 * value is true when `horizontal={true}` and false otherwise.
5414 */
5415 alwaysBounceHorizontal?: boolean
5416 /**
5417 * When true the scroll view bounces vertically when it reaches the end
5418 * even if the content is smaller than the scroll view itself. The default
5419 * value is false when `horizontal={true}` and true otherwise.
5420 */
5421 alwaysBounceVertical?: boolean
5422
5423 /**
5424 * Controls whether iOS should automatically adjust the content inset for scroll views that are placed behind a navigation bar or tab bar/ toolbar.
5425 * The default value is true.
5426 */
5427 automaticallyAdjustContentInsets?: boolean // true
5428
5429 /**
5430 * When true the scroll view bounces when it reaches the end of the
5431 * content if the content is larger then the scroll view along the axis of
5432 * the scroll direction. When false it disables all bouncing even if
5433 * the `alwaysBounce*` props are true. The default value is true.
5434 */
5435 bounces?: boolean
5436 /**
5437 * When true gestures can drive zoom past min/max and the zoom will animate
5438 * to the min/max value at gesture end otherwise the zoom will not exceed
5439 * the limits.
5440 */
5441 bouncesZoom?: boolean
5442
5443 /**
5444 * When false once tracking starts won't try to drag if the touch moves.
5445 * The default value is true.
5446 */
5447 canCancelContentTouches?: boolean
5448
5449 /**
5450 * When true the scroll view automatically centers the content when the
5451 * content is smaller than the scroll view bounds; when the content is
5452 * larger than the scroll view this property has no effect. The default
5453 * value is false.
5454 */
5455 centerContent?: boolean
5456
5457 /**
5458 * The amount by which the scroll view content is inset from the edges of the scroll view.
5459 * Defaults to {0, 0, 0, 0}.
5460 */
5461 contentInset?: Insets // zeros
5462
5463 /**
5464 * Used to manually set the starting scroll offset.
5465 * The default value is {x: 0, y: 0}
5466 */
5467 contentOffset?: PointProperties // zeros
5468
5469 /**
5470 * A floating-point number that determines how quickly the scroll view
5471 * decelerates after the user lifts their finger. Reasonable choices include
5472 * - Normal: 0.998 (the default)
5473 * - Fast: 0.9
5474 */
5475 decelerationRate?: "fast" | "normal" | number
5476
5477 /**
5478 * When true the ScrollView will try to lock to only vertical or horizontal
5479 * scrolling while dragging. The default value is false.
5480 */
5481 directionalLockEnabled?: boolean
5482
5483 /**
5484 * The style of the scroll indicators.
5485 * - default (the default), same as black.
5486 * - black, scroll indicator is black. This style is good against
5487 * a white content background.
5488 * - white, scroll indicator is white. This style is good against
5489 * a black content background.
5490 */
5491 indicatorStyle?: "default" | "black" | "white"
5492
5493 /**
5494 * The maximum allowed zoom scale. The default value is 1.0.
5495 */
5496 maximumZoomScale?: number
5497
5498 /**
5499 * The minimum allowed zoom scale. The default value is 1.0.
5500 */
5501 minimumZoomScale?: number
5502
5503 /**
5504 * Called when a scrolling animation ends.
5505 */
5506 onScrollAnimationEnd?: () => void
5507
5508 /**
5509 * When false, the content does not scroll. The default value is true
5510 */
5511 scrollEnabled?: boolean // true
5512
5513 /**
5514 * This controls how often the scroll event will be fired while scrolling (in events per seconds).
5515 * A higher number yields better accuracy for code that is tracking the scroll position,
5516 * but can lead to scroll performance problems due to the volume of information being send over the bridge.
5517 * The default value is zero, which means the scroll event will be sent only once each time the view is scrolled.
5518 */
5519 scrollEventThrottle?: number // null
5520
5521 /**
5522 * The amount by which the scroll view indicators are inset from the edges of the scroll view.
5523 * This should normally be set to the same value as the contentInset.
5524 * Defaults to {0, 0, 0, 0}.
5525 */
5526 scrollIndicatorInsets?: Insets //zeroes
5527
5528 /**
5529 * When true the scroll view scrolls to top when the status bar is tapped.
5530 * The default value is true.
5531 */
5532 scrollsToTop?: boolean
5533
5534 /**
5535 * When snapToInterval is set, snapToAlignment will define the relationship of the the snapping to the scroll view.
5536 * - start (the default) will align the snap at the left (horizontal) or top (vertical)
5537 * - center will align the snap in the center
5538 * - end will align the snap at the right (horizontal) or bottom (vertical)
5539 */
5540 snapToAlignment?: "start" | "center" | "end"
5541
5542 /**
5543 * When set, causes the scroll view to stop at multiples of the value of snapToInterval.
5544 * This can be used for paginating through children that have lengths smaller than the scroll view.
5545 * Used in combination with snapToAlignment.
5546 */
5547 snapToInterval?: number
5548
5549 /**
5550 * An array of child indices determining which children get docked to the
5551 * top of the screen when scrolling. For example passing
5552 * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the
5553 * top of the scroll view. This property is not supported in conjunction
5554 * with `horizontal={true}`.
5555 */
5556 stickyHeaderIndices?: number[]
5557
5558 /**
5559 * The current scale of the scroll view content. The default value is 1.0.
5560 */
5561 zoomScale?: number
5562 }
5563
5564 export interface ScrollViewPropertiesAndroid {
5565
5566 /**
5567 * Sometimes a scrollview takes up more space than its content fills.
5568 * When this is the case, this prop will fill the rest of the
5569 * scrollview with a color to avoid setting a background and creating
5570 * unnecessary overdraw. This is an advanced optimization that is not
5571 * needed in the general case.
5572 */
5573 endFillColor?: string
5574
5575 /**
5576 * Tag used to log scroll performance on this scroll view. Will force
5577 * momentum events to be turned on (see sendMomentumEvents). This doesn't do
5578 * anything out of the box and you need to implement a custom native
5579 * FpsListener for it to be useful.
5580 * @platform android
5581 */
5582 scrollPerfTag?: string
5583
5584 }
5585
5586 export interface ScrollViewProperties extends ViewProperties, ScrollViewPropertiesIOS, ScrollViewPropertiesAndroid, Touchable, React.Props<ScrollViewStatic> {
5587
5588 /**
5589 * These styles will be applied to the scroll view content container which
5590 * wraps all of the child views. Example:
5591 *
5592 * return (
5593 * <ScrollView contentContainerStyle={styles.contentContainer}>
5594 * </ScrollView>
5595 * );
5596 * ...
5597 * var styles = StyleSheet.create({
5598 * contentContainer: {
5599 * paddingVertical: 20
5600 * }
5601 * });
5602 */
5603 contentContainerStyle?: ViewStyle
5604
5605 /**
5606 * When true the scroll view's children are arranged horizontally in a row
5607 * instead of vertically in a column. The default value is false.
5608 */
5609 horizontal?: boolean
5610
5611 /**
5612 * Determines whether the keyboard gets dismissed in response to a drag.
5613 * - 'none' (the default) drags do not dismiss the keyboard.
5614 * - 'onDrag' the keyboard is dismissed when a drag begins.
5615 * - 'interactive' the keyboard is dismissed interactively with the drag
5616 * and moves in synchrony with the touch; dragging upwards cancels the
5617 * dismissal.
5618 */
5619 keyboardDismissMode?: string
5620
5621 /**
5622 * When false tapping outside of the focused text input when the keyboard
5623 * is up dismisses the keyboard. When true the scroll view will not catch
5624 * taps and the keyboard will not dismiss automatically. The default value
5625 * is false.
5626 */
5627 keyboardShouldPersistTaps?: boolean
5628
5629 /**
5630 * Fires at most once per frame during scrolling.
5631 * The frequency of the events can be contolled using the scrollEventThrottle prop.
5632 */
5633 onScroll?: (event?: { nativeEvent: NativeScrollEvent }) => void
5634
5635 /**
5636 * When true the scroll view stops on multiples of the scroll view's size
5637 * when scrolling. This can be used for horizontal pagination. The default
5638 * value is false.
5639 */
5640 pagingEnabled?: boolean
5641
5642 /**
5643 * Experimental: When true offscreen child views (whose `overflow` value is
5644 * `hidden`) are removed from their native backing superview when offscreen.
5645 * This canimprove scrolling performance on long lists. The default value is
5646 * false.
5647 */
5648 removeClippedSubviews?: boolean
5649
5650 /**
5651 * When true, shows a horizontal scroll indicator.
5652 */
5653 showsHorizontalScrollIndicator?: boolean
5654
5655 /**
5656 * When true, shows a vertical scroll indicator.
5657 */
5658 showsVerticalScrollIndicator?: boolean
5659
5660 /**
5661 * Style
5662 */
5663 style?: ScrollViewStyle
5664
5665 /**
5666 * A RefreshControl component, used to provide pull-to-refresh
5667 * functionality for the ScrollView.
5668 */
5669 refreshControl?: React.ReactElement<RefreshControlProperties>
5670
5671 ref?: Ref<ScrollViewStatic & ViewStatic>
5672 }
5673
5674 export interface ScrollViewProps extends ScrollViewProperties, React.Props<ScrollViewStatic> {
5675 ref?: Ref<ScrollViewStatic>
5676 }
5677
5678 interface ScrollViewStatic extends ScrollResponderMixin, React.ComponentClass<ScrollViewProps> {
5679
5680 /**
5681 * Scrolls to a given x, y offset, either immediately or with a smooth animation.
5682 * Syntax:
5683 *
5684 * scrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
5685 *
5686 * Note: The weird argument signature is due to the fact that, for historical reasons,
5687 * the function also accepts separate arguments as as alternative to the options object.
5688 * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
5689 */
5690 scrollTo(
5691 y?: number | { x?: number, y?: number, animated?: boolean },
5692 x?: number,
5693 animated?: boolean
5694 ): void;
5695
5696 /**
5697 * Returns a reference to the underlying scroll responder, which supports
5698 * operations like `scrollTo`. All ScrollView-like components should
5699 * implement this method so that they can be composed while providing access
5700 * to the underlying scroll responder's methods.
5701 */
5702 getScrollResponder(): JSX.Element;
5703
5704 getScrollableNode(): any;
5705
5706 // Undocumented
5707 getInnerViewNode(): any;
5708
5709 // Deprecated, do not use.
5710 scrollWithoutAnimationTo?(y: number, x: number): void
5711 }
5712
5713 export interface NativeScrollRectangle {
5714 left: number;
5715 top: number;
5716 bottom: number;
5717 right: number;
5718 }
5719
5720 export interface NativeScrollPoint {
5721 x: number;
5722 y: number;
5723 }
5724
5725 export interface NativeScrollSize {
5726 height: number;
5727 width: number;
5728 }
5729
5730 export interface NativeScrollEvent {
5731 contentInset: NativeScrollRectangle;
5732 contentOffset: NativeScrollPoint;
5733 contentSize: NativeScrollSize;
5734 layoutMeasurement: NativeScrollSize;
5735 zoomScale: number;
5736 }
5737
5738 export interface SnapshotViewIOSProperties extends ViewProperties, React.Props<SnapshotViewIOSStatic> {
5739
5740 // A callback when the Snapshot view is ready to be compared
5741 onSnapshotReady(): any,
5742
5743 // A name to identify the individual instance to the SnapshotView
5744 testIdentifier : string,
5745
5746 ref?: Ref<ViewStatic & SnapshotViewIOSStatic>
5747 }
5748
5749 export interface SnapshotViewIOSStatic extends NativeMethodsMixin, React.ComponentClass<SnapshotViewIOSProperties> {}
5750
5751 // Deduced from
5752 // https://github.com/facebook/react-native/commit/052cd7eb8afa7a805ef13e940251be080499919c
5753
5754 /**
5755 * Data source wrapper around ListViewDataSource to allow for tracking of
5756 * which row is swiped open and close opened row(s) when another row is swiped
5757 * open.
5758 *
5759 * See https://github.com/facebook/react-native/pull/5602 for why
5760 * ListViewDataSource is not subclassed.
5761 */
5762 export interface SwipeableListViewDataSource {
5763 cloneWithRowsAndSections(dataBlob: any,
5764 sectionIdentities?: Array<string>,
5765 rowIdentities?: Array<Array<string>>): SwipeableListViewDataSource
5766 getDataSource(): ListViewDataSource
5767 getOpenRowID(): string
5768 getFirstRowID(): string
5769 setOpenRowID(rowID: string): SwipeableListViewDataSource
5770 }
5771
5772 export interface SwipeableListViewProps extends React.Props<SwipeableListViewStatic> {
5773
5774 /**
5775 * To alert the user that swiping is possible, the first row can bounce
5776 * on component mount.
5777 */
5778 bounceFirstRowOnMount: boolean
5779
5780 /**
5781 * Use `SwipeableListView.getNewDataSource()` to get a data source to use,
5782 * then use it just like you would a normal ListView data source
5783 */
5784 dataSource: SwipeableListViewDataSource
5785
5786 // Maximum distance to open to after a swipe
5787 maxSwipeDistance: number
5788
5789 // Callback method to render the swipeable view
5790 renderRow: ( rowData: any, sectionID: string | number, rowID: string | number, highlightRow?: boolean ) => React.ReactElement<any>
5791
5792 // Callback method to render the view that will be unveiled on swipe
5793 renderQuickActions: (rowData: any, sectionID: string | number, rowID: string | number) => React.ReactElement<any>
5794 }
5795
5796 /**
5797 * A container component that renders multiple SwipeableRow's in a ListView
5798 * implementation. This is designed to be a drop-in replacement for the
5799 * standard React Native `ListView`, so use it as if it were a ListView, but
5800 * with extra props, i.e.
5801 *
5802 * let ds = SwipeableListView.getNewDataSource();
5803 * ds.cloneWithRowsAndSections(dataBlob, ?sectionIDs, ?rowIDs);
5804 * // ..
5805 * <SwipeableListView renderRow={..} renderQuickActions={..} {..ListView props} />
5806 *
5807 * SwipeableRow can be used independently of this component, but the main
5808 * benefit of using this component is
5809 *
5810 * - It ensures that at most 1 row is swiped open (auto closes others)
5811 * - It can bounce the 1st row of the list so users know it's swipeable
5812 * - More to come
5813 */
5814 export interface SwipeableListViewStatic extends React.ComponentClass<SwipeableListViewProps> {
5815 getNewDataSource(): SwipeableListViewDataSource
5816 }
5817
5818
5819 //////////////////////////////////////////////////////////////////////////
5820 //
5821 // A P I s
5822 //
5823 //////////////////////////////////////////////////////////////////////////
5824
5825 /**
5826 * @see: http://facebook.github.io/react-native/docs/actionsheetios.html#content
5827 */
5828 export interface ActionSheetIOSOptions {
5829 options: string[]
5830 cancelButtonIndex?: number
5831 destructiveButtonIndex?: number
5832 title?: string
5833 message?: string
5834 }
5835
5836 export interface ShareActionSheetIOSOptions {
5837 message?: string
5838 url?: string
5839 subject?: string
5840 /** The activities to exclude from the ActionSheet.
5841 * For example: ['com.apple.UIKit.activity.PostToTwitter']
5842 */
5843 excludedActivityTypes?: string[]
5844 }
5845
5846 /**
5847 * @see https://facebook.github.io/react-native/docs/actionsheetios.html#content
5848 */
5849 export interface ActionSheetIOSStatic {
5850 /**
5851 * Display an iOS action sheet. The `options` object must contain one or more
5852 * of:
5853 * - `options` (array of strings) - a list of button titles (required)
5854 * - `cancelButtonIndex` (int) - index of cancel button in `options`
5855 * - `destructiveButtonIndex` (int) - index of destructive button in `options`
5856 * - `title` (string) - a title to show above the action sheet
5857 * - `message` (string) - a message to show below the title
5858 */
5859 showActionSheetWithOptions: ( options: ActionSheetIOSOptions, callback: ( buttonIndex: number ) => void ) => void
5860
5861 /**
5862 * Display the iOS share sheet. The `options` object should contain
5863 * one or both of `message` and `url` and can additionally have
5864 * a `subject` or `excludedActivityTypes`:
5865 *
5866 * - `url` (string) - a URL to share
5867 * - `message` (string) - a message to share
5868 * - `subject` (string) - a subject for the message
5869 * - `excludedActivityTypes` (array) - the activities to exclude from the ActionSheet
5870 *
5871 * NOTE: if `url` points to a local file, or is a base64-encoded
5872 * uri, the file it points to will be loaded and shared directly.
5873 * In this way, you can share images, videos, PDF files, etc.
5874 */
5875 showShareActionSheetWithOptions: ( options: ShareActionSheetIOSOptions, failureCallback: ( error: Error ) => void, successCallback: ( success: boolean, method: string ) => void ) => void
5876 }
5877
5878 export type ShareContent = {
5879 title?: string
5880 message: string
5881 } | {
5882 title?: string
5883 url: string
5884 }
5885
5886 export type ShareOptions = {
5887 dialogTitle?: string
5888 excludeActivityTypes?: Array<string>
5889 tintColor?: string
5890 }
5891
5892 export interface ShareStatic {
5893 /**
5894 * Open a dialog to share text content.
5895 *
5896 * In iOS, Returns a Promise which will be invoked an object containing `action`, `activityType`.
5897 * If the user dismissed the dialog, the Promise will still be resolved with action being `Share.dismissedAction`
5898 * and all the other keys being undefined.
5899 *
5900 * In Android, Returns a Promise which always be resolved with action being `Share.sharedAction`.
5901 *
5902 * ### Content
5903 *
5904 * - `message` - a message to share
5905 * - `title` - title of the message
5906 *
5907 * #### iOS
5908 *
5909 * - `url` - an URL to share
5910 *
5911 * At least one of URL and message is required.
5912 *
5913 * ### Options
5914 *
5915 * #### iOS
5916 *
5917 * - `excludedActivityTypes`
5918 * - `tintColor`
5919 *
5920 * #### Android
5921 *
5922 * - `dialogTitle`
5923 *
5924 */
5925 share(content: ShareContent, options: ShareOptions): Promise<Object>
5926 sharedAction: string
5927 dismissedAction: string
5928 }
5929
5930 /**
5931 * @see https://facebook.github.io/react-native/docs/alert.html#content
5932 */
5933 export interface AlertButton {
5934 text?: string
5935 onPress?: () => void
5936 style?: "default" | "cancel" | "destructive"
5937 }
5938
5939 interface AlertOptions {
5940 /** @platform android */
5941 cancelable?: boolean;
5942 }
5943
5944 /**
5945 * Launches an alert dialog with the specified title and message.
5946 *
5947 * Optionally provide a list of buttons. Tapping any button will fire the
5948 * respective onPress callback and dismiss the alert. By default, the only
5949 * button will be an 'OK' button.
5950 *
5951 * This is an API that works both on iOS and Android and can show static
5952 * alerts. To show an alert that prompts the user to enter some information,
5953 * see `AlertIOS`; entering text in an alert is common on iOS only.
5954 *
5955 * ## iOS
5956 *
5957 * On iOS you can specify any number of buttons. Each button can optionally
5958 * specify a style, which is one of 'default', 'cancel' or 'destructive'.
5959 *
5960 * ## Android
5961 *
5962 * On Android at most three buttons can be specified. Android has a concept
5963 * of a neutral, negative and a positive button:
5964 *
5965 * - If you specify one button, it will be the 'positive' one (such as 'OK')
5966 * - Two buttons mean 'negative', 'positive' (such as 'Cancel', 'OK')
5967 * - Three buttons mean 'neutral', 'negative', 'positive' (such as 'Later', 'Cancel', 'OK')
5968 *
5969 * ```
5970 * // Works on both iOS and Android
5971 * Alert.alert(
5972 * 'Alert Title',
5973 * 'My Alert Msg',
5974 * [
5975 * {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
5976 * {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
5977 * {text: 'OK', onPress: () => console.log('OK Pressed')},
5978 * ]
5979 * )
5980 * ```
5981 */
5982 export interface AlertStatic {
5983 alert: (title: string, message?: string, buttons?: AlertButton[], options?: AlertOptions, type?: string) => void
5984 }
5985
5986 /**
5987 * Wrapper around the Android native module.
5988 */
5989 export interface AlertAndroidStatic {
5990 alert: (title: string, message?: string, buttons?: AlertButton[], options?: AlertOptions) => void
5991 }
5992
5993 /**
5994 * //FIXME: No documentation - inferred from RCTAdSupport.m
5995 */
5996 export interface AdSupportIOSStatic {
5997 getAdvertisingId: ( onSuccess: ( deviceId: string ) => void, onFailure: ( err: Error ) => void ) => void
5998 getAdvertisingTrackingEnabled: ( onSuccess: ( hasTracking: boolean ) => void, onFailure: ( err: Error ) => void ) => void
5999 }
6000
6001 interface AlertIOSButton {
6002 text: string
6003 onPress?: () => void
6004 style?: "default" | "cancel" | "destructive"
6005 }
6006
6007 export type AlertType = "default" | "plain-text" | "secure-text" | "login-password"
6008
6009 /**
6010 * @description
6011 * `AlertIOS` provides functionality to create an iOS alert dialog with a
6012 * message or create a prompt for user input.
6013 *
6014 * Creating an iOS alert:
6015 *
6016 * ```
6017 * AlertIOS.alert(
6018 * 'Sync Complete',
6019 * 'All your data are belong to us.'
6020 * );
6021 * ```
6022 *
6023 * Creating an iOS prompt:
6024 *
6025 * ```
6026 * AlertIOS.prompt(
6027 * 'Enter a value',
6028 * null,
6029 * text => console.log("You entered "+text)
6030 * );
6031 * ```
6032 *
6033 * We recommend using the [`Alert.alert`](/docs/alert.html) method for
6034 * cross-platform support if you don't need to create iOS-only prompts.
6035 *
6036 * @see https://facebook.github.io/react-native/docs/alertios.html#content
6037 */
6038 export interface AlertIOSStatic {
6039
6040 /**
6041 * Create and display a popup alert.
6042 * @static
6043 * @method alert
6044 * @param title The dialog's title.
6045 * @param message An optional message that appears below
6046 * the dialog's title.
6047 * @param callbackOrButtons This optional argument should
6048 * be either a single-argument function or an array of buttons. If passed
6049 * a function, it will be called when the user taps 'OK'.
6050 *
6051 * If passed an array of button configurations, each button should include
6052 * a `text` key, as well as optional `onPress` and `style` keys. `style`
6053 * should be one of 'default', 'cancel' or 'destructive'.
6054 * @param type Deprecated, do not use.
6055 *
6056 * @example <caption>Example with custom buttons</caption>
6057 *
6058 * AlertIOS.alert(
6059 * 'Update available',
6060 * 'Keep your app up to date to enjoy the latest features',
6061 * [
6062 * {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
6063 * {text: 'Install', onPress: () => console.log('Install Pressed')},
6064 * ],
6065 * );
6066 */
6067 alert: ( title: string, message?: string, callbackOrButtons?: (() => void) | Array<AlertIOSButton>, type?: AlertType ) => void
6068
6069 /**
6070 * Create and display a prompt to enter some text.
6071 * @static
6072 * @method prompt
6073 * @param title The dialog's title.
6074 * @param message An optional message that appears above the text
6075 * input.
6076 * @param callbackOrButtons This optional argument should
6077 * be either a single-argument function or an array of buttons. If passed
6078 * a function, it will be called with the prompt's value when the user
6079 * taps 'OK'.
6080 *
6081 * If passed an array of button configurations, each button should include
6082 * a `text` key, as well as optional `onPress` and `style` keys (see
6083 * example). `style` should be one of 'default', 'cancel' or 'destructive'.
6084 * @param type This configures the text input. One of 'plain-text',
6085 * 'secure-text' or 'login-password'.
6086 * @param defaultValue The default text in text input.
6087 *
6088 * @example <caption>Example with custom buttons</caption>
6089 *
6090 * AlertIOS.prompt(
6091 * 'Enter password',
6092 * 'Enter your password to claim your $1.5B in lottery winnings',
6093 * [
6094 * {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
6095 * {text: 'OK', onPress: password => console.log('OK Pressed, password: ' + password)},
6096 * ],
6097 * 'secure-text'
6098 * );
6099 *
6100 * @example <caption>Example with the default button and a custom callback</caption>
6101 *
6102 * AlertIOS.prompt(
6103 * 'Update username',
6104 * null,
6105 * text => console.log("Your username is "+text),
6106 * null,
6107 * 'default'
6108 * );
6109 */
6110 prompt: ( title: string, message?: string, callbackOrButtons?: ((value: string) => void) | Array<AlertIOSButton>, type?: AlertType, defaultValue?: string ) => void
6111 }
6112
6113 /**
6114 * AppStateIOS can tell you if the app is in the foreground or background,
6115 * and notify you when the state changes.
6116 *
6117 * AppStateIOS is frequently used to determine the intent and proper behavior
6118 * when handling push notifications.
6119 *
6120 * iOS App States
6121 * active - The app is running in the foreground
6122 * background - The app is running in the background. The user is either in another app or on the home screen
6123 * inactive - This is a transition state that currently never happens for typical React Native apps.
6124 *
6125 * For more information, see Apple's documentation: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html
6126 *
6127 * @see https://facebook.github.io/react-native/docs/appstateios.html#content
6128 */
6129 export type AppStateEvent = "change" | "memoryWarning"
6130 export type AppStateStatus = "active" | "background" | "inactive"
6131
6132 export interface AppStateStatic {
6133
6134 currentState: string
6135
6136 /**
6137 * Add a handler to AppState changes by listening to the change event
6138 * type and providing the handler
6139 */
6140 addEventListener( type: AppStateEvent, listener: ( state: AppStateStatus ) => void ): void
6141
6142 /**
6143 * Remove a handler by passing the change event type and the handler
6144 */
6145 removeEventListener( type: AppStateEvent, listener: ( state: AppStateStatus ) => void ): void
6146 }
6147
6148 /**
6149 * @class
6150 * @description
6151 * `AsyncStorage` is a simple, unencrypted, asynchronous, persistent, key-value storage
6152 * system that is global to the app. It should be used instead of LocalStorage.
6153 *
6154 * It is recommended that you use an abstraction on top of `AsyncStorage`
6155 * instead of `AsyncStorage` directly for anything more than light usage since
6156 * it operates globally.
6157 *
6158 * On iOS, `AsyncStorage` is backed by native code that stores small values in a
6159 * serialized dictionary and larger values in separate files. On Android,
6160 * `AsyncStorage` will use either [RocksDB](http://rocksdb.org/) or SQLite
6161 * based on what is available.
6162 *
6163 * The `AsyncStorage` JavaScript code is a simple facade that provides a clear
6164 * JavaScript API, real `Error` objects, and simple non-multi functions. Each
6165 * method in the API returns a `Promise` object.
6166 *
6167 * Persisting data:
6168 * ```
6169 * try {
6170 * await AsyncStorage.setItem('@MySuperStore:key', 'I like to save it.');
6171 * } catch (error) {
6172 * // Error saving data
6173 * }
6174 * ```
6175 *
6176 * Fetching data:
6177 * ```
6178 * try {
6179 * const value = await AsyncStorage.getItem('@MySuperStore:key');
6180 * if (value !== null){
6181 * // We have data!!
6182 * console.log(value);
6183 * }
6184 * } catch (error) {
6185 * // Error retrieving data
6186 * }
6187 * ```
6188 * @see https://facebook.github.io/react-native/docs/asyncstorage.html#content
6189 */
6190 export interface AsyncStorageStatic {
6191
6192 /**
6193 * Fetches key and passes the result to callback, along with an Error if there is any.
6194 */
6195 getItem( key: string, callback?: ( error?: Error, result?: string ) => void ): Promise<string>
6196
6197 /**
6198 * Sets value for key and calls callback on completion, along with an Error if there is any
6199 */
6200 setItem( key: string, value: string, callback?: ( error?: Error ) => void ): Promise<string>
6201
6202 removeItem( key: string, callback?: ( error?: Error ) => void ): Promise<string>
6203
6204 /**
6205 * Merges existing value with input value, assuming they are stringified json. Returns a Promise object.
6206 * Not supported by all native implementation
6207 */
6208 mergeItem( key: string, value: string, callback?: ( error?: Error ) => void ): Promise<string>
6209
6210 /**
6211 * Erases all AsyncStorage for all clients, libraries, etc. You probably don't want to call this.
6212 * Use removeItem or multiRemove to clear only your own keys instead.
6213 */
6214 clear( callback?: ( error?: Error ) => void ): Promise<string>
6215
6216 /**
6217 * Gets all keys known to the app, for all callers, libraries, etc
6218 */
6219 getAllKeys( callback?: ( error?: Error, keys?: string[] ) => void ): Promise<string>
6220
6221 /**
6222 * multiGet invokes callback with an array of key-value pair arrays that matches the input format of multiSet
6223 */
6224 multiGet( keys: string[], callback?: ( errors?: Error[], result?: string[][] ) => void ): Promise<string>
6225
6226 /**
6227 * multiSet and multiMerge take arrays of key-value array pairs that match the output of multiGet,
6228 *
6229 * multiSet([['k1', 'val1'], ['k2', 'val2']], cb);
6230 */
6231 multiSet( keyValuePairs: string[][], callback?: ( errors?: Error[] ) => void ): Promise<string>
6232
6233 /**
6234 * Delete all the keys in the keys array.
6235 */
6236 multiRemove( keys: string[], callback?: ( errors?: Error[] ) => void ): Promise<string>
6237
6238 /**
6239 * Merges existing values with input values, assuming they are stringified json.
6240 * Returns a Promise object.
6241 *
6242 * Not supported by all native implementations.
6243 */
6244 multiMerge( keyValuePairs: string[][], callback?: ( errors?: Error[] ) => void ): Promise<string>
6245 }
6246
6247 export type BackPressEventName = "hardwareBackPress"
6248
6249 /**
6250 * Detect hardware back button presses, and programmatically invoke the
6251 * default back button functionality to exit the app if there are no
6252 * listeners or if none of the listeners return true.
6253 * Methods don't have more detailed documentation as of 0.25.
6254 */
6255 export interface BackAndroidStatic {
6256 exitApp(): void;
6257 addEventListener(eventName: BackPressEventName, handler: () => void): void;
6258 removeEventListener(eventName: BackPressEventName, handler: () => void): void;
6259 }
6260
6261 export type CameraRollGroupType = "Album" | "All" | "Event" | "Faces" | "Library" | "PhotoStream" | "SavedPhotos";
6262 export type CameraRollAssetType = "All" | "Videos" | "Photos";
6263
6264 export interface CameraRollFetchParams {
6265 first: number;
6266 after?: string;
6267 groupTypes?: CameraRollGroupType
6268 groupName?: string
6269 assetType?: CameraRollAssetType
6270 }
6271
6272 export interface CameraRollNodeInfo {
6273 image: Image;
6274 group_name: string;
6275 timestamp: number;
6276 location: any;
6277 }
6278
6279 export interface CameraRollEdgeInfo {
6280 node: CameraRollNodeInfo;
6281 }
6282
6283 export interface CameraRollAssetInfo {
6284 edges: CameraRollEdgeInfo[];
6285 page_info: {
6286 has_next_page: boolean;
6287 end_cursor: string;
6288 };
6289 }
6290
6291 export interface GetPhotosParamType {
6292 first: number
6293 after?: string
6294 groupTypes?: CameraRollGroupType
6295 groupName?: string
6296 assetType?: CameraRollAssetType
6297 mimeTypes?: string[]
6298 }
6299
6300 export interface GetPhotosReturnType {
6301 edges: {
6302 node: {
6303 type: string
6304 group_name: string
6305 image: {
6306 uri: string
6307 height: number
6308 width: number
6309 isStored?: boolean
6310 }
6311 timestamp: number
6312 location: {
6313 latitude: number
6314 longitude: number
6315 altitude: number
6316 heading: number
6317 speed: number
6318 }
6319 }
6320 }[]
6321
6322 page_info: {
6323 has_next_page: boolean
6324 start_cursor?: string
6325 end_cursor?: string
6326 }
6327 }
6328
6329 /**
6330 * CameraRoll provides access to the local camera roll / gallery.
6331 * Before using this you must link the RCTCameraRoll library.
6332 * You can refer to (Linking)[https://facebook.github.io/react-native/docs/linking-libraries-ios.html] for help.
6333 */
6334 export interface CameraRollStatic {
6335
6336 GroupTypesOptions: CameraRollGroupType[] //'Album','All','Event','Faces','Library','PhotoStream','SavedPhotos'
6337 AssetTypeOptions: CameraRollAssetType[] // "All", "Videos", "Photos"
6338
6339 /**
6340 * Saves the image to the camera roll / gallery.
6341 *
6342 * @tag On Android, this is a local URI, such as "file:///sdcard/img.png".
6343 * On iOS, the tag can be one of the following:
6344 * local URI
6345 * assets-library tag
6346 * 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)
6347 *
6348 * @deprecated use saveToCameraRoll instead
6349 */
6350 saveImageWithTag( tag: string ): Promise<string>
6351
6352 /**
6353 * Saves the photo or video to the camera roll / gallery.
6354 *
6355 * On Android, the tag must be a local image or video URI, such as `"file:///sdcard/img.png"`.
6356 *
6357 * On iOS, the tag can be any image URI (including local, remote asset-library and base64 data URIs)
6358 * or a local video file URI (remote or data URIs are not supported for saving video at this time).
6359 *
6360 * If the tag has a file extension of .mov or .mp4, it will be inferred as a video. Otherwise
6361 * it will be treated as a photo. To override the automatic choice, you can pass an optional
6362 * `type` parameter that must be one of 'photo' or 'video'.
6363 *
6364 * Returns a Promise which will resolve with the new URI.
6365 */
6366 saveToCameraRoll(tag: string, type?: 'photo' | 'video'): Promise<string>
6367
6368 /**
6369 * Invokes callback with photo identifier objects from the local camera roll of the device matching shape defined by getPhotosReturnChecker.
6370 *
6371 * @param {object} params See getPhotosParamChecker.
6372 */
6373 getPhotos(params: GetPhotosParamType): Promise<GetPhotosReturnType>;
6374 }
6375
6376 /** Clipboard gives you an interface for setting and getting content from Clipboard on both iOS and Android */
6377 export interface ClipboardStatic {
6378 getString(): Promise<string>;
6379 setString(content: string): void;
6380 }
6381
6382 export interface DatePickerAndroidOpenOption {
6383 date?: Date | number
6384 minDate?: Date | number
6385 maxDate?: Date | number
6386 }
6387
6388 // Deduced from DatePickerAndroid.android.js
6389 export interface DatePickerAndroidOpenReturn {
6390 action: string // "dateSetAction" | "dismissedAction"
6391 year?: number
6392 month?: number
6393 day?: number
6394 }
6395
6396 export interface DatePickerAndroidStatic {
6397 /*
6398 Opens the standard Android date picker dialog.
6399
6400 The available keys for the options object are:
6401 * date (Date object or timestamp in milliseconds) - date to show by default
6402 * minDate (Date object or timestamp in milliseconds) - minimum date that can be selected
6403 * maxDate (Date object or timestamp in milliseconds) - maximum date that can be selected
6404
6405 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.
6406
6407 Note the native date picker dialog has some UI glitches on Android 4 and lower when using the minDate and maxDate options.
6408 */
6409 open(options?: DatePickerAndroidOpenOption): Promise<DatePickerAndroidOpenReturn>
6410
6411 /**
6412 * A date has been selected.
6413 */
6414 dateSetAction: string
6415
6416 /**
6417 * The dialog has been dismissed.
6418 */
6419 dismissedAction: string
6420 }
6421
6422 export interface FetchableListenable<T> {
6423 fetch: () => Promise<T>
6424
6425 /**
6426 * eventName is expected to be `change`
6427 * //FIXME: No doc - inferred from NetInfo.js
6428 */
6429 addEventListener: ( eventName: string, listener: ( result: T ) => void ) => void
6430
6431 /**
6432 * eventName is expected to be `change`
6433 * //FIXME: No doc - inferred from NetInfo.js
6434 */
6435 removeEventListener: ( eventName: string, listener: ( result: T ) => void ) => void
6436 }
6437
6438 export interface IntentAndroidStatic {
6439 /**
6440 * Starts a corresponding external activity for the given URL.
6441
6442 For example, if the URL is "https://www.facebook.com", the system browser will be opened, or the "choose application" dialog will be shown.
6443
6444 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}.
6445
6446 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.
6447
6448 NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
6449
6450 @deprecated
6451 */
6452 openURL(url: string): void
6453
6454 /**
6455 * Determine whether or not an installed app can handle a given URL.
6456
6457 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}.
6458
6459 NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
6460
6461 @param URL the URL to open
6462
6463 @deprecated
6464 */
6465 canOpenURL(url: string, callback: (supported: boolean) => void): void
6466
6467 /**
6468 * 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
6469
6470 Refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents
6471
6472 @deprecated
6473 */
6474 getInitialURL(callback: (url: string) => void):void
6475 }
6476
6477 export class LinkingStatic extends NativeEventEmitter {
6478 /**
6479 * Add a handler to Linking changes by listening to the `url` event type
6480 * and providing the handler
6481 */
6482 addEventListener(type: string, handler: (event: {url: string}) => void): void
6483
6484 /**
6485 * Remove a handler by passing the `url` event type and the handler
6486 */
6487 removeEventListener(type: string, handler: (event: {url: string}) => void): void
6488
6489 /**
6490 * Try to open the given url with any of the installed apps.
6491 * 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.
6492 * 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.
6493 * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
6494 */
6495 openURL(url: string): Promise<any>
6496
6497 /**
6498 * Determine whether or not an installed app can handle a given URL.
6499 * NOTE: For web URLs, the protocol ("http://", "https://") must be set accordingly!
6500 * NOTE: As of iOS 9, your app needs to provide the LSApplicationQueriesSchemes key inside Info.plist.
6501 * @param URL the URL to open
6502 */
6503 canOpenURL(url: string): Promise<boolean>
6504
6505 /**
6506 * If the app launch was triggered by an app link with, it will give the link url, otherwise it will give null
6507 * NOTE: To support deep linking on Android, refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents
6508 */
6509 getInitialURL(): Promise<string>
6510 }
6511
6512 export interface LinkingIOSStatic {
6513 /**
6514 * Add a handler to LinkingIOS changes by listening to the url event type and providing the handler
6515 @deprecated
6516 */
6517 addEventListener(type: string, handler: (event: {url: string}) => void): void
6518
6519 /**
6520 * Remove a handler by passing the url event type and the handler
6521 @deprecated
6522 */
6523 removeEventListener(type: string, handler: (event: {url: string}) => void): void
6524
6525 /**
6526 * Try to open the given url with any of the installed apps.
6527 @deprecated
6528 */
6529 openURL(url: string): void
6530
6531 /**
6532 * 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
6533 NOTE: As of iOS 9, your app needs to provide the LSApplicationQueriesSchemes key inside Info.plist.
6534 @deprecated
6535 */
6536 canOpenURL(url: string, callback: (supported: boolean) => void): void
6537
6538 /**
6539 * If the app launch was triggered by an app link, it will pop the link url, otherwise it will return null
6540 @deprecated
6541 */
6542 popInitialURL(): string;
6543 }
6544
6545 /**
6546 * NetInfo exposes info about online/offline status
6547 *
6548 * Asynchronously determine if the device is online and on a cellular network.
6549 *
6550 * - `none` - device is offline
6551 * - `wifi` - device is online and connected via wifi, or is the iOS simulator
6552 * - `cell` - device is connected via Edge, 3G, WiMax, or LTE
6553 * - `unknown` - error case and the network status is unknown
6554 * @see https://facebook.github.io/react-native/docs/netinfo.html#content
6555 */
6556 // This is from code, a few items more than documentation@0.25
6557 export type NetInfoReturnType = "none" | "wifi" | "cell" | "unknown" |
6558 "NONE" | "MOBILE" | "WIFI" | "MOBILE_MMS" | "MOBILE_SUPL" | "MOBILE_DUN" |
6559 "MOBILE_HIPRI" | "WIMAX" | "BLUETOOTH" | "DUMMY" | "ETHERNET" | "MOBILE_FOTA" |
6560 "MOBILE_IMS" | "MOBILE_CBS" | "WIFI_P2P" | "MOBILE_IA" | "MOBILE_EMERGENCY" |
6561 "PROXY" | "VPN" | "UNKNOWN"
6562
6563 export interface NetInfoStatic extends FetchableListenable<NetInfoReturnType> {
6564
6565 /**
6566 *
6567 * Available on all platforms.
6568 * Asynchronously fetch a boolean to determine internet connectivity.
6569 */
6570 isConnected: FetchableListenable<boolean>
6571
6572 /**
6573 * Available on Android. Detect if the current active connection is
6574 * metered or not. A network is classified as metered when the user is
6575 * sensitive to heavy data usage on that connection due to monetary
6576 * costs, data limitations or battery/performance issues.
6577 */
6578 isConnectionExpensive: Promise<boolean>
6579 }
6580
6581
6582 export interface PanResponderGestureState {
6583
6584 /**
6585 * ID of the gestureState- persisted as long as there at least one touch on
6586 */
6587 stateID: number
6588
6589 /**
6590 * the latest screen coordinates of the recently-moved touch
6591 */
6592 moveX: number
6593
6594 /**
6595 * the latest screen coordinates of the recently-moved touch
6596 */
6597 moveY: number
6598
6599 /**
6600 * the screen coordinates of the responder grant
6601 */
6602 x0: number
6603
6604 /**
6605 * the screen coordinates of the responder grant
6606 */
6607 y0: number
6608
6609 /**
6610 * accumulated distance of the gesture since the touch started
6611 */
6612 dx: number
6613
6614 /**
6615 * accumulated distance of the gesture since the touch started
6616 */
6617 dy: number
6618
6619 /**
6620 * current velocity of the gesture
6621 */
6622 vx: number
6623
6624 /**
6625 * current velocity of the gesture
6626 */
6627 vy: number
6628
6629 /**
6630 * Number of touches currently on screen
6631 */
6632 numberActiveTouches: number
6633
6634
6635 // All `gestureState` accounts for timeStamps up until:
6636 _accountsForMovesUpTo: number
6637 }
6638
6639
6640 /**
6641 * @see documentation of GestureResponderHandlers
6642 */
6643 export interface PanResponderCallbacks {
6644 onMoveShouldSetPanResponder?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean
6645 onStartShouldSetPanResponder?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
6646 onPanResponderGrant?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
6647 onPanResponderMove?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
6648 onPanResponderRelease?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
6649 onPanResponderTerminate?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
6650
6651 onMoveShouldSetPanResponderCapture?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean
6652 onStartShouldSetPanResponderCapture?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean
6653 onPanResponderReject?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
6654 onPanResponderStart?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
6655 onPanResponderEnd?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
6656 onPanResponderTerminationRequest?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean
6657 }
6658
6659 export interface PanResponderInstance {
6660 panHandlers: GestureResponderHandlers
6661 }
6662
6663 /**
6664 * PanResponder reconciles several touches into a single gesture.
6665 * It makes single-touch gestures resilient to extra touches,
6666 * and can be used to recognize simple multi-touch gestures.
6667 *
6668 * It provides a predictable wrapper of the responder handlers provided by the gesture responder system.
6669 * For each handler, it provides a new gestureState object alongside the normal event.
6670 */
6671 export interface PanResponderStatic {
6672 /**
6673 * @param config Enhanced versions of all of the responder callbacks
6674 * that provide not only the typical `ResponderSyntheticEvent`, but also the
6675 * `PanResponder` gesture state. Simply replace the word `Responder` with
6676 * `PanResponder` in each of the typical `onResponder*` callbacks. For
6677 * example, the `config` object would look like:
6678 *
6679 * - `onMoveShouldSetPanResponder: (e, gestureState) => {...}`
6680 * - `onMoveShouldSetPanResponderCapture: (e, gestureState) => {...}`
6681 * - `onStartShouldSetPanResponder: (e, gestureState) => {...}`
6682 * - `onStartShouldSetPanResponderCapture: (e, gestureState) => {...}`
6683 * - `onPanResponderReject: (e, gestureState) => {...}`
6684 * - `onPanResponderGrant: (e, gestureState) => {...}`
6685 * - `onPanResponderStart: (e, gestureState) => {...}`
6686 * - `onPanResponderEnd: (e, gestureState) => {...}`
6687 * - `onPanResponderRelease: (e, gestureState) => {...}`
6688 * - `onPanResponderMove: (e, gestureState) => {...}`
6689 * - `onPanResponderTerminate: (e, gestureState) => {...}`
6690 * - `onPanResponderTerminationRequest: (e, gestureState) => {...}`
6691 *
6692 * In general, for events that have capture equivalents, we update the
6693 * gestureState once in the capture phase and can use it in the bubble phase
6694 * as well.
6695 *
6696 * Be careful with onStartShould* callbacks. They only reflect updated
6697 * `gestureState` for start/end events that bubble/capture to the Node.
6698 * Once the node is the responder, you can rely on every start/end event
6699 * being processed by the gesture and `gestureState` being updated
6700 * accordingly. (numberActiveTouches) may not be totally accurate unless you
6701 * are the responder.
6702 */
6703 create( config: PanResponderCallbacks ): PanResponderInstance
6704 }
6705
6706 export type Rationale = {
6707 title: string
6708 message: string
6709 }
6710
6711 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"
6712
6713 export class PermissionsAndroidStatic {
6714 /**
6715 * A list of specified "dangerous" permissions that require prompting the user
6716 */
6717 PERMISSIONS: {[key: string]: Permission}
6718 constructor()
6719 /**
6720 * Returns a promise resolving to a boolean value as to whether the specified
6721 * permissions has been granted
6722 */
6723 checkPermission(permission: Permission): Promise<boolean>
6724 /**
6725 * Prompts the user to enable a permission and returns a promise resolving to a
6726 * boolean value indicating whether the user allowed or denied the request
6727 *
6728 * If the optional rationale argument is included (which is an object with a
6729 * `title` and `message`), this function checks with the OS whether it is
6730 * necessary to show a dialog explaining why the permission is needed
6731 * (https://developer.android.com/training/permissions/requesting.html#explain)
6732 * and then shows the system permission dialog
6733 */
6734 requestPermission(permission: Permission, rationale?: Rationale): Promise<boolean>
6735 }
6736
6737 export interface PushNotificationPermissions {
6738 alert?: boolean
6739 badge?: boolean
6740 sound?: boolean
6741 }
6742
6743 export interface PushNotification {
6744
6745 /**
6746 * An alias for `getAlert` to get the notification's main message string
6747 */
6748 getMessage(): string | Object
6749
6750 /**
6751 * Gets the sound string from the `aps` object
6752 */
6753 getSound(): string
6754
6755 /**
6756 * Gets the notification's main message from the `aps` object
6757 */
6758 getAlert(): string | Object
6759
6760 /**
6761 * Gets the badge count number from the `aps` object
6762 */
6763 getBadgeCount(): number
6764
6765 /**
6766 * Gets the data object on the notif
6767 */
6768 getData(): Object
6769
6770 }
6771
6772
6773 type PresentLocalNotificationDetails = {
6774 alertBody: string
6775 alertAction: string
6776 soundName?: string
6777 category?: string
6778 userInfo?: Object
6779 applicationIconBadgeNumber?: number
6780 }
6781
6782 type ScheduleLocalNotificationDetails = {
6783 fireDate: Date
6784 alertBody: string
6785 alertAction: string
6786 soundName?: string
6787 category?: string
6788 userInfo?: Object
6789 applicationIconBadgeNumber?: number
6790 }
6791
6792 export type PushNotificationEventName = "notification" | "localNotification" | "register" | "registrationError"
6793
6794 /**
6795 * Handle push notifications for your app, including permission handling and icon badge number.
6796 * @see https://facebook.github.io/react-native/docs/pushnotificationios.html#content
6797 *
6798 * //FIXME: BGR: The documentation seems completely off compared to the actual js implementation. I could never get the example to run
6799 */
6800 export interface PushNotificationIOSStatic {
6801
6802 /**
6803 * Schedules the localNotification for immediate presentation.
6804 * details is an object containing:
6805 * alertBody : The message displayed in the notification alert.
6806 * alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
6807 * soundName : The sound played when the notification is fired (optional).
6808 * category : The category of this notification, required for actionable notifications (optional).
6809 * userInfo : An optional object containing additional notification data.
6810 * 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.
6811 */
6812 presentLocalNotification(details: PresentLocalNotificationDetails): void
6813
6814 /**
6815 * Schedules the localNotification for future presentation.
6816 * details is an object containing:
6817 * fireDate : The date and time when the system should deliver the notification.
6818 * alertBody : The message displayed in the notification alert.
6819 * alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
6820 * soundName : The sound played when the notification is fired (optional).
6821 * category : The category of this notification, required for actionable notifications (optional).
6822 * userInfo : An optional object containing additional notification data.
6823 * applicationIconBadgeNumber (optional) : The number to display as the app's icon badge. Setting the number to 0 removes the icon badge.
6824 */
6825 scheduleLocalNotification(details: ScheduleLocalNotificationDetails): void
6826
6827 /**
6828 * Cancels all scheduled localNotifications
6829 */
6830 cancelAllLocalNotifications(): void
6831
6832 /**
6833 * Sets the badge number for the app icon on the home screen
6834 */
6835 setApplicationIconBadgeNumber( number: number ): void
6836
6837 /**
6838 * Gets the current badge number for the app icon on the home screen
6839 */
6840 getApplicationIconBadgeNumber( callback: ( badge: number ) => void ): void
6841
6842 /**
6843 * Cancel local notifications.
6844 * Optionally restricts the set of canceled notifications to those notifications whose userInfo fields match the corresponding fields in the userInfo argument.
6845 */
6846 cancelLocalNotifications(userInfo: Object): void
6847
6848 /**
6849 * Gets the local notifications that are currently scheduled.
6850 */
6851 getScheduledLocalNotifications(callback: (notifications: ScheduleLocalNotificationDetails[]) => void): void
6852
6853 /**
6854 * Attaches a listener to remote notifications while the app is running in the
6855 * foreground or the background.
6856 *
6857 * The handler will get be invoked with an instance of `PushNotificationIOS`
6858 *
6859 * The type MUST be 'notification'
6860 */
6861 addEventListener( type: PushNotificationEventName, handler: ( notification: PushNotification ) => void ):void
6862
6863 /**
6864 * Removes the event listener. Do this in `componentWillUnmount` to prevent
6865 * memory leaks
6866 */
6867 removeEventListener( type: PushNotificationEventName, handler: ( notification: PushNotification ) => void ): void
6868
6869 /**
6870 * Requests all notification permissions from iOS, prompting the user's
6871 * dialog box.
6872 */
6873 requestPermissions( permissions?: PushNotificationPermissions ): Promise<PushNotificationPermissions>
6874
6875 /**
6876 * Unregister for all remote notifications received via Apple Push
6877 * Notification service.
6878 * You should call this method in rare circumstances only, such as when
6879 * a new version of the app removes support for all types of remote
6880 * notifications. Users can temporarily prevent apps from receiving
6881 * remote notifications through the Notifications section of the
6882 * Settings app. Apps unregistered through this method can always
6883 * re-register.
6884 */
6885 abandonPermissions(): void
6886
6887 /**
6888 * See what push permissions are currently enabled. `callback` will be
6889 * invoked with a `permissions` object:
6890 *
6891 * - `alert` :boolean
6892 * - `badge` :boolean
6893 * - `sound` :boolean
6894 */
6895 checkPermissions( callback: ( permissions: PushNotificationPermissions ) => void ): void
6896
6897 /**
6898 * This method returns a promise that resolves to either the notification
6899 * object if the app was launched by a push notification, or `null` otherwise.
6900 */
6901 getInitialNotification(): PushNotification
6902 }
6903
6904 export interface SettingsStatic {
6905 get(key: string): any
6906 set(settings: Object): void
6907 watchKeys(keys: string | Array<string>, callback: (() => void)): number
6908 clearWatch(watchId: number): void
6909 }
6910
6911 /**
6912 * @enum('default', 'light-content')
6913 */
6914 export type StatusBarStyle = "default" | "light-content"
6915
6916 /**
6917 * @enum('fade', 'slide')
6918 */
6919 export type StatusBarAnimation = "none" | "fade" | "slide"
6920
6921 export interface StatusBarPropertiesIOS extends React.Props<StatusBarStatic> {
6922 /**
6923 * Sets the color of the status bar text.
6924 */
6925 barStyle?: StatusBarStyle
6926
6927 /**
6928 * If the network activity indicator should be visible.
6929 */
6930 networkActivityIndicatorVisible?: boolean
6931
6932 /**
6933 * The transition effect when showing and hiding the status bar using
6934 * the hidden prop. Defaults to 'fade'.
6935 */
6936 showHideTransition?: "fade" | "slide"
6937 }
6938
6939 export interface StatusBarPropertiesAndroid extends React.Props<StatusBarStatic> {
6940 /**
6941 * The background color of the status bar.
6942 */
6943 backgroundColor?: string
6944
6945 /**
6946 * If the status bar is translucent. When translucent is set to true,
6947 * the app will draw under the status bar. This is useful when using a
6948 * semi transparent status bar color.
6949 */
6950 translucent?: boolean
6951 }
6952
6953 export interface StatusBarProperties extends StatusBarPropertiesIOS, StatusBarPropertiesAndroid, React.Props<StatusBarStatic> {
6954
6955 /**
6956 * If the transition between status bar property changes should be
6957 * animated. Supported for backgroundColor, barStyle and hidden.
6958 */
6959 animated?: boolean
6960
6961 /**
6962 * If the status bar is hidden.
6963 */
6964 hidden?: boolean
6965 }
6966
6967 export interface StatusBarStatic extends React.ComponentClass<StatusBarProperties> {
6968
6969 /**
6970 * The current height of the status bar on the device.
6971 * @platform android
6972 */
6973 currentHeight?: number
6974
6975 /**
6976 * Show or hide the status bar
6977 * @param hidden The dialog's title.
6978 * @param animation Optional animation when
6979 * changing the status bar hidden property.
6980 */
6981 setHidden: (hidden: boolean, animation?: StatusBarAnimation) => void
6982
6983 /**
6984 * Set the status bar style
6985 * @param style Status bar style to set
6986 * @param animated Animate the style change.
6987 */
6988 setBarStyle: (style: StatusBarStyle, animated?: boolean) => void
6989
6990 /**
6991 * Control the visibility of the network activity indicator
6992 * @param visible Show the indicator.
6993 */
6994 setNetworkActivityIndicatorVisible: (visible: boolean) => void
6995
6996 /**
6997 * Set the background color for the status bar
6998 * @param color Background color.
6999 * @param animated Animate the style change.
7000 */
7001 setBackgroundColor: (color: string, animated?: boolean) => void
7002
7003 /**
7004 * Control the translucency of the status bar
7005 * @param translucent Set as translucent.
7006 */
7007 setTranslucent: (translucent: boolean) => void
7008 }
7009
7010 /**
7011 * StatusBarIOS is deprecated.
7012 * Use `StatusBar` for mutating the status bar.
7013 */
7014 export class StatusBarIOSStatic extends NativeEventEmitter {
7015 }
7016
7017 type TimePickerAndroidOpenOptions = {
7018 hour?: number
7019 minute?: number
7020 is24Hour?: boolean
7021 }
7022
7023 /**
7024 * Opens the standard Android time picker dialog.
7025 *
7026 * ### Example
7027 *
7028 * ```
7029 * try {
7030 * const {action, hour, minute} = await TimePickerAndroid.open({
7031 * hour: 14,
7032 * minute: 0,
7033 * is24Hour: false, // Will display '2 PM'
7034 * });
7035 * if (action !== TimePickerAndroid.dismissedAction) {
7036 * // Selected hour (0-23), minute (0-59)
7037 * }
7038 * } catch ({code, message}) {
7039 * console.warn('Cannot open time picker', message);
7040 * }
7041 * ```
7042 */
7043 export interface TimePickerAndroidStatic {
7044
7045 /**
7046 * Opens the standard Android time picker dialog.
7047 *
7048 * The available keys for the `options` object are:
7049 * * `hour` (0-23) - the hour to show, defaults to the current time
7050 * * `minute` (0-59) - the minute to show, defaults to the current time
7051 * * `is24Hour` (boolean) - If `true`, the picker uses the 24-hour format. If `false`,
7052 * the picker shows an AM/PM chooser. If undefined, the default for the current locale
7053 * is used.
7054 *
7055 * Returns a Promise which will be invoked an object containing `action`, `hour` (0-23),
7056 * `minute` (0-59) if the user picked a time. If the user dismissed the dialog, the Promise will
7057 * still be resolved with action being `TimePickerAndroid.dismissedAction` and all the other keys
7058 * being undefined. **Always** check whether the `action` before reading the values.
7059 */
7060 open(options: TimePickerAndroidOpenOptions): Promise<{action: string, hour: number, minute: number}>
7061
7062 /**
7063 * A time has been selected.
7064 */
7065 timeSetAction: string
7066
7067 /**
7068 * The dialog has been dismissed.
7069 */
7070 dismissedAction: string
7071 }
7072
7073 /**
7074 * This exposes the native ToastAndroid module as a JS module. This has a function 'show'
7075 * which takes the following parameters:
7076 *
7077 * 1. String message: A string with the text to toast
7078 * 2. int duration: The duration of the toast. May be ToastAndroid.SHORT or ToastAndroid.LONG
7079 *
7080 * There is also a function `showWithGravity` to specify the layout gravity. May be
7081 * ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER
7082 */
7083 export interface ToastAndroidStatic {
7084 /**
7085 * String message: A string with the text to toast
7086 * int duration: The duration of the toast.
7087 * May be ToastAndroid.SHORT or ToastAndroid.LONG
7088 */
7089 show(message: string, duration: number): void
7090 /** `gravity` may be ToastAndroid.TOP, ToastAndroid.BOTTOM, ToastAndroid.CENTER */
7091 showWithGravity(
7092 message: string,
7093 duration: number,
7094 gravity: number
7095 ): void
7096 // Toast duration constants
7097 SHORT: number
7098 LONG: number
7099 // Toast gravity constants
7100 TOP: number
7101 BOTTOM: number
7102 CENTER: number
7103 }
7104
7105 export interface UIManagerStatic {
7106 /**
7107 * Capture an image of the screen, window or an individual view. The image
7108 * will be stored in a temporary file that will only exist for as long as the
7109 * app is running.
7110 *
7111 * The `view` argument can be the literal string `window` if you want to
7112 * capture the entire window, or it can be a reference to a specific
7113 * React Native component.
7114 *
7115 * The `options` argument may include:
7116 * - width/height (number) - the width and height of the image to capture.
7117 * - format (string) - either 'png' or 'jpeg'. Defaults to 'png'.
7118 * - quality (number) - the quality when using jpeg. 0.0 - 1.0 (default).
7119 *
7120 * Returns a Promise<string> (tempFilePath)
7121 * @platform ios
7122 */
7123 takeSnapshot: (
7124 view ?: 'window' | ReactElement<any> | number,
7125 options ?: {
7126 width ?: number,
7127 height ?: number,
7128 format ?: 'png' | 'jpeg',
7129 quality ?: number,
7130 }
7131 ) => Promise<string>
7132 }
7133
7134 export interface SwitchPropertiesIOS extends ViewProperties, React.Props<SwitchStatic> {
7135
7136 /**
7137 * Background color when the switch is turned on.
7138 */
7139 onTintColor?: string
7140
7141 /**
7142 * Color of the foreground switch grip.
7143 */
7144 thumbTintColor?: string
7145
7146 /**
7147 * Background color when the switch is turned off.
7148 */
7149 tintColor?: string
7150
7151 ref?: Ref<SwitchStatic>
7152 }
7153
7154 export interface SwitchProperties extends SwitchPropertiesIOS, React.Props<SwitchStatic> {
7155
7156 /**
7157 * If true the user won't be able to toggle the switch.
7158 * Default value is false.
7159 */
7160 disabled?: boolean
7161
7162 /**
7163 * Invoked with the new value when the value changes.
7164 */
7165 onValueChange?: (value: boolean) => void
7166
7167 /**
7168 * Used to locate this view in end-to-end tests.
7169 */
7170 testID?: string
7171
7172 /**
7173 * The value of the switch. If true the switch will be turned on.
7174 * Default value is false.
7175 */
7176 value?: boolean
7177
7178 style?: ViewStyle
7179 }
7180
7181 /**
7182 * Renders a boolean input.
7183 *
7184 * This is a controlled component that requires an `onValueChange` callback that
7185 * updates the `value` prop in order for the component to reflect user actions.
7186 * If the `value` prop is not updated, the component will continue to render
7187 * the supplied `value` prop instead of the expected result of any user actions.
7188 */
7189 export interface SwitchStatic extends NativeMethodsMixin, React.ClassicComponentClass<SwitchProperties> {}
7190
7191 /**
7192 * NOTE: `VibrationIOS` is being deprecated. Use `Vibration` instead.
7193 *
7194 * The Vibration API is exposed at VibrationIOS.vibrate().
7195 * On iOS, calling this function will trigger a one second vibration.
7196 * The vibration is asynchronous so this method will return immediately.
7197 *
7198 * There will be no effect on devices that do not support Vibration, eg. the iOS simulator.
7199 *
7200 * Vibration patterns are currently unsupported.
7201 *
7202 * @see https://facebook.github.io/react-native/docs/vibrationios.html#content
7203 */
7204 export interface VibrationIOSStatic {
7205 /**
7206 * @deprecated
7207 */
7208 vibrate(): void
7209 }
7210
7211 /**
7212 * The Vibration API is exposed at `Vibration.vibrate()`.
7213 * The vibration is asynchronous so this method will return immediately.
7214 *
7215 * There will be no effect on devices that do not support Vibration, eg. the simulator.
7216 *
7217 * **Note for android**
7218 * add `<uses-permission android:name="android.permission.VIBRATE"/>` to `AndroidManifest.xml`
7219 *
7220 * **Android Usage:**
7221 *
7222 * [0, 500, 200, 500]
7223 * V(0.5s) --wait(0.2s)--> V(0.5s)
7224 *
7225 * [300, 500, 200, 500]
7226 * --wait(0.3s)--> V(0.5s) --wait(0.2s)--> V(0.5s)
7227 *
7228 * **iOS Usage:**
7229 * if first argument is 0, it will not be included in pattern array.
7230 *
7231 * [0, 1000, 2000, 3000]
7232 * V(fixed) --wait(1s)--> V(fixed) --wait(2s)--> V(fixed) --wait(3s)--> V(fixed)
7233 */
7234 export interface VibrationStatic {
7235 vibrate(pattern: number | number[], repeat: boolean): void
7236
7237 /**
7238 * Stop vibration
7239 */
7240 cancel(): void
7241 }
7242
7243 /**
7244 * This class implements common easing functions. The math is pretty obscure,
7245 * but this cool website has nice visual illustrations of what they represent:
7246 * http://xaedes.de/dev/transitions/
7247 */
7248 export type EasingFunction = (value: number) => number;
7249 export interface EasingStatic {
7250 step0: EasingFunction;
7251 step1: EasingFunction;
7252 linear: EasingFunction;
7253 ease: EasingFunction;
7254 quad: EasingFunction;
7255 cubic: EasingFunction;
7256 poly: EasingFunction;
7257 sin: EasingFunction;
7258 circle: EasingFunction;
7259 exp: EasingFunction;
7260 elastic: EasingFunction;
7261 back(s: number): EasingFunction;
7262 bounce: EasingFunction;
7263 bezier( x1: number,
7264 y1: number,
7265 x2: number,
7266 y2: number): EasingFunction;
7267 in(easing: EasingFunction): EasingFunction;
7268 out(easing: EasingFunction): EasingFunction;
7269 inOut(easing: EasingFunction): EasingFunction;
7270 }
7271
7272 export module Animated {
7273 // Most (all?) functions where AnimatedValue is used any subclass of Animated can be used as well.
7274 type AnimatedValue = Animated;
7275 type AnimatedValueXY = ValueXY;
7276
7277 type Base = Animated;
7278
7279 class Animated {
7280 // Internal class, no public API.
7281 }
7282
7283 class AnimatedWithChildren extends Animated {
7284 // Internal class, no public API.
7285 }
7286
7287 class AnimatedInterpolation extends AnimatedWithChildren {
7288 interpolate(config: InterpolationConfigType): AnimatedInterpolation;
7289 }
7290
7291 type ExtrapolateType = 'extend' | 'identity' | 'clamp';
7292
7293 type InterpolationConfigType = {
7294 inputRange: number[];
7295 outputRange: (number[] | string[]);
7296 easing?: ((input: number) => number);
7297 extrapolate?: ExtrapolateType;
7298 extrapolateLeft?: ExtrapolateType;
7299 extrapolateRight?: ExtrapolateType;
7300 };
7301
7302 type ValueListenerCallback = (state: {value: number}) => void;
7303
7304 /**
7305 * Standard value for driving animations. One `Animated.Value` can drive
7306 * multiple properties in a synchronized fashion, but can only be driven by one
7307 * mechanism at a time. Using a new mechanism (e.g. starting a new animation,
7308 * or calling `setValue`) will stop any previous ones.
7309 */
7310 export class Value extends AnimatedWithChildren {
7311 constructor(value: number);
7312
7313 /**
7314 * Directly set the value. This will stop any animations running on the value
7315 * and update all the bound properties.
7316 */
7317 setValue(value: number): void;
7318
7319 /**
7320 * Sets an offset that is applied on top of whatever value is set, whether via
7321 * `setValue`, an animation, or `Animated.event`. Useful for compensating
7322 * things like the start of a pan gesture.
7323 */
7324 setOffset(offset: number): void;
7325
7326 /**
7327 * Merges the offset value into the base value and resets the offset to zero.
7328 * The final output of the value is unchanged.
7329 */
7330 flattenOffset(): void;
7331
7332 /**
7333 * Adds an asynchronous listener to the value so you can observe updates from
7334 * animations. This is useful because there is no way to
7335 * synchronously read the value because it might be driven natively.
7336 */
7337 addListener(callback: ValueListenerCallback): string;
7338
7339 removeListener(id: string): void;
7340
7341 removeAllListeners(): void;
7342
7343 /**
7344 * Stops any running animation or tracking. `callback` is invoked with the
7345 * final value after stopping the animation, which is useful for updating
7346 * state to match the animation position with layout.
7347 */
7348 stopAnimation(callback?: (value: number) => void): void;
7349
7350 /**
7351 * Interpolates the value before updating the property, e.g. mapping 0-1 to
7352 * 0-10.
7353 */
7354 interpolate(config: InterpolationConfigType): AnimatedInterpolation;
7355 }
7356
7357 type ValueXYListenerCallback = (value: {x: number; y: number}) => void;
7358
7359 /**
7360 * 2D Value for driving 2D animations, such as pan gestures. Almost identical
7361 * API to normal `Animated.Value`, but multiplexed. Contains two regular
7362 * `Animated.Value`s under the hood.
7363 */
7364 export class ValueXY extends AnimatedWithChildren {
7365 x: AnimatedValue;
7366 y: AnimatedValue;
7367
7368 constructor(valueIn?: {x: number | AnimatedValue; y: number | AnimatedValue});
7369
7370 setValue(value: {x: number; y: number}): void;
7371
7372 setOffset(offset: {x: number; y: number}): void;
7373
7374 flattenOffset(): void
7375
7376 stopAnimation(callback?: (value: {x: number, y: number}) => void): void;
7377
7378 addListener(callback: ValueXYListenerCallback): string;
7379
7380 removeListener(id: string): void;
7381
7382 /**
7383 * Converts `{x, y}` into `{left, top}` for use in style, e.g.
7384 *
7385 *```javascript
7386 * style={this.state.anim.getLayout()}
7387 *```
7388 */
7389 getLayout(): { [key: string]: AnimatedValue };
7390
7391 /**
7392 * Converts `{x, y}` into a useable translation transform, e.g.
7393 *
7394 *```javascript
7395 * style={{
7396 * transform: this.state.anim.getTranslateTransform()
7397 * }}
7398 *```
7399 */
7400 getTranslateTransform(): {[key: string]: AnimatedValue}[];
7401
7402 }
7403
7404 type EndResult = {finished: boolean};
7405 type EndCallback = (result: EndResult) => void;
7406
7407 interface CompositeAnimation {
7408 start: (callback?: EndCallback) => void;
7409 stop: () => void;
7410 }
7411
7412 interface AnimationConfig {
7413 isInteraction?: boolean;
7414 useNativeDriver?: boolean;
7415 }
7416
7417 /**
7418 * Animates a value from an initial velocity to zero based on a decay
7419 * coefficient.
7420 */
7421 export function decay(
7422 value: AnimatedValue | AnimatedValueXY,
7423 config: DecayAnimationConfig
7424 ): CompositeAnimation;
7425
7426 interface DecayAnimationConfig extends AnimationConfig {
7427 velocity: number | {x: number, y: number};
7428 deceleration?: number;
7429 }
7430
7431 /**
7432 * Animates a value along a timed easing curve. The `Easing` module has tons
7433 * of pre-defined curves, or you can use your own function.
7434 */
7435 export var timing: (
7436 value: AnimatedValue | AnimatedValueXY,
7437 config: TimingAnimationConfig
7438 ) => CompositeAnimation;
7439
7440 interface TimingAnimationConfig extends AnimationConfig {
7441 toValue: number | AnimatedValue | {x: number, y: number} | AnimatedValueXY;
7442 easing?: (value: number) => number;
7443 duration?: number;
7444 delay?: number;
7445 }
7446
7447 interface SpringAnimationConfig extends AnimationConfig {
7448 toValue: number | AnimatedValue | {x: number, y: number} | AnimatedValueXY;
7449 overshootClamping?: boolean;
7450 restDisplacementThreshold?: number;
7451 restSpeedThreshold?: number;
7452 velocity?: number | {x: number, y: number};
7453 bounciness?: number;
7454 speed?: number;
7455 tension?: number;
7456 friction?: number;
7457 }
7458
7459 /**
7460 * Creates a new Animated value composed from two Animated values added
7461 * together.
7462 */
7463 export function add(
7464 a: Animated,
7465 b: Animated
7466 ): AnimatedAddition;
7467
7468 class AnimatedAddition extends AnimatedInterpolation {}
7469
7470 /**
7471 * Creates a new Animated value composed from two Animated values multiplied
7472 * together.
7473 */
7474 export function multiply(
7475 a: Animated,
7476 b: Animated
7477 ): AnimatedMultiplication;
7478
7479 class AnimatedMultiplication extends AnimatedInterpolation {}
7480
7481 /**
7482 * Creates a new Animated value that is the (non-negative) modulo of the
7483 * provided Animated value
7484 */
7485 export function modulo(
7486 a: Animated,
7487 modulus: number
7488 ): AnimatedModulo;
7489
7490 class AnimatedModulo extends AnimatedInterpolation {}
7491
7492 /**
7493 * Create a new Animated value that is limited between 2 values. It uses the
7494 * difference between the last value so even if the value is far from the bounds
7495 * it will start changing when the value starts getting closer again.
7496 * (`value = clamp(value + diff, min, max)`).
7497 *
7498 * This is useful with scroll events, for example, to show the navbar when
7499 * scrolling up and to hide it when scrolling down.
7500 */
7501 export function diffClamp(a: Animated, min: number, max: number): AnimatedDiffClamp;
7502
7503 class AnimatedDiffClamp extends AnimatedInterpolation {}
7504
7505 /**
7506 * Starts an animation after the given delay.
7507 */
7508 export function delay(time: number): CompositeAnimation;
7509
7510 /**
7511 * Starts an array of animations in order, waiting for each to complete
7512 * before starting the next. If the current running animation is stopped, no
7513 * following animations will be started.
7514 */
7515 export function sequence(
7516 animations: Array<CompositeAnimation>
7517 ): CompositeAnimation;
7518
7519 /**
7520 * Array of animations may run in parallel (overlap), but are started in
7521 * sequence with successive delays. Nice for doing trailing effects.
7522 */
7523
7524 export function stagger(
7525 time: number,
7526 animations: Array<CompositeAnimation>
7527 ): CompositeAnimation
7528
7529 /**
7530 * Spring animation based on Rebound and Origami. Tracks velocity state to
7531 * create fluid motions as the `toValue` updates, and can be chained together.
7532 */
7533 export function spring (
7534 value: AnimatedValue | AnimatedValueXY,
7535 config: SpringAnimationConfig
7536 ): CompositeAnimation;
7537
7538 type ParallelConfig = {
7539 stopTogether?: boolean; // If one is stopped, stop all. default: true
7540 }
7541
7542 /**
7543 * Starts an array of animations all at the same time. By default, if one
7544 * of the animations is stopped, they will all be stopped. You can override
7545 * this with the `stopTogether` flag.
7546 */
7547 export function parallel (
7548 animations: Array<CompositeAnimation>,
7549 config?: ParallelConfig
7550 ): CompositeAnimation;
7551
7552 type Mapping = {[key: string]: Mapping} | AnimatedValue;
7553 interface EventConfig {
7554 listener?: Function
7555 }
7556
7557 /**
7558 * Takes an array of mappings and extracts values from each arg accordingly,
7559 * then calls `setValue` on the mapped outputs. e.g.
7560 *
7561 *```javascript
7562 * onScroll={Animated.event(
7563 * [{nativeEvent: {contentOffset: {x: this._scrollX}}}]
7564 * {listener}, // Optional async listener
7565 * )
7566 * ...
7567 * onPanResponderMove: Animated.event([
7568 * null, // raw event arg ignored
7569 * {dx: this._panX}, // gestureState arg
7570 * ]),
7571 *```
7572 */
7573 export function event (
7574 argMapping: Mapping[],
7575 config?: EventConfig
7576 ): (...args: any[]) => void;
7577
7578 /**
7579 * Make any React component Animatable. Used to create `Animated.View`, etc.
7580 */
7581 export function createAnimatedComponent (component: any) : any;
7582
7583 /**
7584 * Animated variants of the basic native views. Accepts Animated.Value for
7585 * props and style.
7586 */
7587 export var View: any;
7588 export var Image: any;
7589 export var Text: any;
7590 }
7591
7592 export type I18nManagerStatus = {
7593 isRTL: boolean
7594 allowRTL: (allowRTL: boolean) => {}
7595 forceRTL: (forceRTL: boolean) => {}
7596 }
7597 export interface I18nManagerStatic {
7598 isRTL: boolean
7599 allowRTL: (allowRTL: boolean) => {}
7600 forceRTL: (forceRTL: boolean) => {}
7601 }
7602
7603 export interface GeolocationStatic {
7604 /*
7605 * Invokes the success callback once with the latest location info. Supported
7606 * options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool)
7607 * On Android, this can return almost immediately if the location is cached or
7608 * request an update, which might take a while.
7609 */
7610 getCurrentPosition(geo_success: (position: GeolocationReturnType) => void, geo_error?: (error: Error) => void, geo_options?: GetCurrentPositionOptions): void
7611
7612 /*
7613 * Invokes the success callback whenever the location changes. Supported
7614 * options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool), distanceFilter(m)
7615 */
7616 watchPosition(success: (position: Geolocation) => void, error?: (error: Error) => void, options?: WatchPositionOptions): void
7617
7618 clearWatch(watchID: number): void
7619
7620 stopObserving(): void
7621 }
7622
7623 export interface OpenCameraDialogOptions {
7624 /** Defaults to false */
7625 videoMode?: boolean
7626 }
7627
7628 export interface OpenSelectDialogOptions {
7629 /** Defaults to true */
7630 showImages?: boolean
7631 /** Defaults to false */
7632 showVideos?: boolean
7633 }
7634
7635 /** [imageURL|tempImageTag, height, width] */
7636 export type ImagePickerResult = [string, number, number]
7637
7638 export interface ImagePickerIOSStatic {
7639 canRecordVideos(callback: (value: boolean) => void): void
7640 canUseCamera(callback: (value: boolean) => void): void
7641 openCameraDialog(config: OpenCameraDialogOptions, successCallback: (args:ImagePickerResult) => void, cancelCallback: (args:any[]) => void): void
7642 openSelectDialog(config: OpenSelectDialogOptions, successCallback: (args:ImagePickerResult) => void, cancelCallback: (args:any[]) => void): void
7643 }
7644
7645 export interface ImageStoreStatic {
7646 /**
7647 * Check if the ImageStore contains image data for the specified URI.
7648 * @platform ios
7649 */
7650 hasImageForTag(uri: string, callback: (hasImage: boolean) => void): void
7651 /**
7652 * Delete an image from the ImageStore. Images are stored in memory and
7653 * must be manually removed when you are finished with them, otherwise they
7654 * will continue to use up RAM until the app is terminated. It is safe to
7655 * call `removeImageForTag()` without first calling `hasImageForTag()`, it
7656 * will simply fail silently.
7657 * @platform ios
7658 */
7659 removeImageForTag(uri: string): void
7660 /**
7661 * Stores a base64-encoded image in the ImageStore, and returns a URI that
7662 * can be used to access or display the image later. Images are stored in
7663 * memory only, and must be manually deleted when you are finished with
7664 * them by calling `removeImageForTag()`.
7665 *
7666 * Note that it is very inefficient to transfer large quantities of binary
7667 * data between JS and native code, so you should avoid calling this more
7668 * than necessary.
7669 * @platform ios
7670 */
7671 addImageFromBase64(
7672 base64ImageData: string,
7673 success: (uri: string) => void,
7674 failure: (error: any) => void
7675 ): void
7676 /**
7677 * Retrieves the base64-encoded data for an image in the ImageStore. If the
7678 * specified URI does not match an image in the store, the failure callback
7679 * will be called.
7680 *
7681 * Note that it is very inefficient to transfer large quantities of binary
7682 * data between JS and native code, so you should avoid calling this more
7683 * than necessary. To display an image in the ImageStore, you can just pass
7684 * the URI to an `<Image/>` component; there is no need to retrieve the
7685 * base64 data.
7686 */
7687 getBase64ForTag(
7688 uri: string,
7689 success: (base64ImageData: string) => void,
7690 failure: (error: any) => void
7691 ): void
7692 }
7693
7694 // Network Polyfill
7695 // TODO: Add proper support for fetch
7696 export type fetch = (url: string, options?: Object) => Promise<any>
7697
7698 // Timers polyfill
7699 export type timedScheduler = (fn: string | Function, time: number) => number
7700 export type untimedScheduler = (fn: string | Function) => number
7701 export type setTimeout = timedScheduler
7702 export type setInterval = timedScheduler
7703 export type setImmediate = untimedScheduler
7704 export type requestAnimationFrame = untimedScheduler
7705
7706 export type schedulerCanceller = (id: number) => void
7707 export type clearTimeout = schedulerCanceller
7708 export type clearInterval = schedulerCanceller
7709 export type clearImmediate = schedulerCanceller
7710 export type cancelAnimationFrame = schedulerCanceller
7711
7712
7713 export interface TabsReducerStatic {
7714 JumpToAction(index: number): any;
7715 }
7716
7717 export type TabsReducerFunction = (params:any) => any;
7718
7719 export interface NavigationTab
7720 {
7721 key: string;
7722 }
7723
7724 export interface NavigationAction
7725 {
7726 type: string;
7727 }
7728
7729 export interface NavigationRoute {
7730 key: string;
7731 }
7732
7733 export interface NavigationState extends NavigationRoute {
7734 index: number;
7735 routes: NavigationRoute[];
7736 }
7737
7738 export type NavigationRenderer = (
7739 route: NavigationState,
7740 onNavigate: (action: NavigationAction) => boolean
7741 ) => JSX.Element;
7742
7743 export interface NavigationHeaderProps {
7744 renderTitleComponent?(props: Object): JSX.Element
7745 onNavigateBack(): void
7746 }
7747
7748 export interface NavigationHeaderStatic extends React.ComponentClass<NavigationHeaderProps> {
7749 Title: JSX.Element
7750 HEIGHT: number
7751 }
7752
7753 export interface NavigationCardStackProps {
7754 /**
7755 * Custom style applied to the card.
7756 */
7757 cardStyle?: ViewStyle
7758 /**
7759 * Direction of the cards movement. Value could be `horizontal` or
7760 * `vertical`. Default value is `horizontal`.
7761 */
7762 direction?: 'horizontal' | 'vertical'
7763 /**
7764 * The distance from the edge of the card which gesture response can start
7765 * for. Defaults value is `30`.
7766 */
7767 gestureResponseDistance?: number
7768 /**
7769 * Enable gestures. Default value is true
7770 */
7771 enableGestures?: boolean,
7772 /**
7773 * The controlled navigation state. Typically, the navigation state
7774 * look like this:
7775 *
7776 * ```js
7777 * const navigationState = {
7778 * index: 0, // the index of the selected route.
7779 * routes: [ // A list of routes.
7780 * {key: 'page 1'}, // The 1st route.
7781 * {key: 'page 2'}, // The second route.
7782 * ],
7783 * };
7784 * ```
7785 */
7786 navigationState: NavigationState,
7787 /**
7788 * Callback that is called when the "back" action is performed.
7789 * This happens when the back button is pressed or the back gesture is
7790 * performed.
7791 */
7792 onNavigateBack?: Function,
7793 /**
7794 * Function that renders the header.
7795 */
7796 renderHeader?: Function,
7797
7798 /**
7799 * Function that renders the a scene for a route.
7800 */
7801 renderScene: Function,
7802
7803 /**
7804 * Custom style applied to the cards stack.
7805 */
7806 style?: ViewStyle,
7807 }
7808
7809 // Object Instances
7810
7811 export type NavigationAnimatedValue = Animated.Value;
7812
7813 // Value & Structs.
7814
7815 export type NavigationGestureDirection = 'horizontal' | 'vertical';
7816
7817 export type NavigationLayout = {
7818 height: NavigationAnimatedValue,
7819 initHeight: number,
7820 initWidth: number,
7821 isMeasured: boolean,
7822 width: NavigationAnimatedValue,
7823 };
7824
7825 export type NavigationScene = {
7826 index: number,
7827 isActive: boolean,
7828 isStale: boolean,
7829 key: string,
7830 route: NavigationRoute,
7831 };
7832
7833 export interface NavigationSceneRendererProps {
7834 // The layout of the transitioner of the scenes.
7835 layout: NavigationLayout,
7836
7837 // The navigation state of the transitioner.
7838 navigationState: NavigationState,
7839
7840 // The progressive index of the transitioner's navigation state.
7841 position: NavigationAnimatedValue,
7842
7843 // The value that represents the progress of the transition when navigation
7844 // state changes from one to another. Its numberic value will range from 0
7845 // to 1.
7846 // progress.__getAnimatedValue() < 1 : transtion is happening.
7847 // progress.__getAnimatedValue() == 1 : transtion completes.
7848 progress: NavigationAnimatedValue,
7849
7850 // All the scenes of the transitioner.
7851 scenes: Array<NavigationScene>,
7852
7853 // The active scene, corresponding to the route at
7854 // `navigationState.routes[navigationState.index]`.
7855 scene: NavigationScene,
7856
7857 // The gesture distance for `horizontal` and `vertical` transitions
7858 gestureResponseDistance?: number,
7859 }
7860
7861 export interface NavigationSceneRenderer extends React.ComponentClass<NavigationSceneRendererProps> {
7862 }
7863
7864 export interface NavigationPropTypes {
7865 // helpers
7866 extractSceneRendererProps(props: NavigationSceneRendererProps): NavigationSceneRendererProps
7867
7868 // Bundled propTypes.
7869 SceneRendererProps: {
7870 layout: string,
7871 navigationState: string,
7872 position: string,
7873 progress: string,
7874 scene: string,
7875 scenes: NavigationScene[],
7876 }
7877
7878 // propTypes
7879 SceneRenderer: any, // TODO: fix this
7880 action: NavigationAction,
7881 navigationState: NavigationState,
7882 navigationRoute: NavigationRoute,
7883 panHandlers: GestureResponderHandlers,
7884 }
7885
7886 export interface NavigationCardProps extends React.ComponentClass<NavigationSceneRendererProps> {
7887 onComponentRef: (ref: any) => void,
7888 onNavigateBack: Function,
7889 panHandlers: GestureResponderHandlers,
7890 pointerEvents: string,
7891 renderScene: NavigationSceneRenderer,
7892 style: any,
7893 }
7894
7895 export interface NavigationCardStackStatic extends React.ComponentClass<NavigationCardStackProps> {
7896 }
7897
7898 export interface NavigationCardStatic extends React.ComponentClass<NavigationCardProps> {
7899 }
7900
7901 /**
7902 * Utilities to perform atomic operation with navigate state and routes.
7903 *
7904 * ```javascript
7905 * const state1 = {key: 'page 1'};
7906 * const state2 = NavigationStateUtils.push(state1, {key: 'page 2'});
7907 * ```
7908 */
7909 export interface NavigationStateUtils {
7910 get(state: NavigationState, key: string): NavigationRoute
7911 indexOf(state: NavigationState, key: string): number
7912 has(state: NavigationState, key: string): boolean
7913 push(state: NavigationState, route: NavigationRoute): NavigationState
7914 pop(state: NavigationState): NavigationState
7915 jumpToIndex(state: NavigationState, index: number): NavigationState
7916 jumpTo(state: NavigationState, key: string): NavigationState
7917 back(state: NavigationState): NavigationState
7918 forward(state: NavigationState): NavigationState
7919 replaceAt(
7920 state: NavigationState,
7921 key: string,
7922 route: NavigationRoute
7923 ): NavigationState
7924 replaceAtIndex(
7925 state: NavigationState,
7926 index: number,
7927 route: NavigationRoute
7928 ): NavigationState
7929 reset(
7930 state: NavigationState,
7931 routes: Array<NavigationRoute>,
7932 index?: number
7933 ): NavigationState
7934 }
7935
7936 export type NavigationTransitionProps = {
7937 // The layout of the transitioner of the scenes.
7938 layout: NavigationLayout,
7939
7940 // The navigation state of the transitioner.
7941 navigationState: NavigationState,
7942
7943 // The progressive index of the transitioner's navigation state.
7944 position: NavigationAnimatedValue,
7945
7946 // The value that represents the progress of the transition when navigation
7947 // state changes from one to another. Its numberic value will range from 0
7948 // to 1.
7949 // progress.__getAnimatedValue() < 1 : transtion is happening.
7950 // progress.__getAnimatedValue() == 1 : transtion completes.
7951 progress: NavigationAnimatedValue,
7952
7953 // All the scenes of the transitioner.
7954 scenes: Array<NavigationScene>,
7955
7956 // The active scene, corresponding to the route at
7957 // `navigationState.routes[navigationState.index]`.
7958 scene: NavigationScene,
7959
7960 // The gesture distance for `horizontal` and `vertical` transitions
7961 gestureResponseDistance?: number,
7962 }
7963 export type NavigationTransitionSpec = {
7964 duration?: number,
7965 // An easing function from `Easing`.
7966 easing?: () => any,
7967 // A timing function such as `Animated.timing`.
7968 timing?: (value: NavigationAnimatedValue, config: any) => any,
7969 }
7970 export interface NavigationTransitionerProps {
7971 configureTransition: (
7972 a: NavigationTransitionProps,
7973 b?: NavigationTransitionProps
7974 ) => NavigationTransitionSpec,
7975 navigationState: NavigationState,
7976 onTransitionEnd: () => void,
7977 onTransitionStart: () => void,
7978 render: (a: NavigationTransitionProps, b?: NavigationTransitionProps) => any,
7979 style: any,
7980 }
7981
7982 export interface NavigationTransitioner extends React.ComponentClass<NavigationTransitionerProps> {
7983 }
7984
7985 export interface NavigationCard extends React.ComponentClass<NavigationCardProps> {
7986 }
7987
7988 export interface NavigationExperimentalStatic {
7989 // Core
7990 StateUtils: NavigationStateUtils
7991
7992 // Views
7993 Transitioner: NavigationTransitioner,
7994
7995 //AnimatedView: NavigationAnimatedViewStatic;
7996 // CustomComponents:
7997 Card: NavigationCard,
7998 CardStack: NavigationCardStackStatic;
7999 Header: NavigationHeaderStatic;
8000
8001 PropTypes: NavigationPropTypes,
8002 }
8003
8004 //
8005 // Interfacing with Native Modules
8006 // https://facebook.github.io/react-native/docs/native-modules-ios.html
8007 //
8008
8009 export interface NativeEventSubscription {
8010 /**
8011 * Call this method to un-subscribe from a native-event
8012 */
8013 remove(): void;
8014 }
8015
8016 /**
8017 * Receive events from native-code
8018 * Deprecated - subclass NativeEventEmitter to create granular event modules instead of
8019 * adding all event listeners directly to RCTNativeAppEventEmitter.
8020 * @see https://github.com/facebook/react-native/blob/0.34-stable\Libraries\EventEmitter\RCTNativeAppEventEmitter.js
8021 * @see https://facebook.github.io/react-native/docs/native-modules-ios.html#sending-events-to-javascript
8022 */
8023 type RCTNativeAppEventEmitter = RCTDeviceEventEmitter
8024
8025 interface ImageCropData {
8026 /**
8027 * The top-left corner of the cropped image, specified in the original
8028 * image's coordinate space.
8029 */
8030 offset: {
8031 x: number;
8032 y: number;
8033 }
8034
8035 /**
8036 * The size (dimensions) of the cropped image, specified in the original
8037 * image's coordinate space.
8038 */
8039 size: {
8040 width: number;
8041 height: number;
8042 }
8043
8044 /**
8045 * (Optional) size to scale the cropped image to.
8046 */
8047 displaySize?: { width: number, height: number }
8048
8049 /**
8050 * (Optional) the resizing mode to use when scaling the image. If the
8051 * `displaySize` param is not specified, this has no effect.
8052 */
8053 resizeMode?: 'contain' | 'cover' | 'stretch'
8054 }
8055
8056 interface ImageEditorStatic {
8057 /**
8058 * Crop the image specified by the URI param. If URI points to a remote
8059 * image, it will be downloaded automatically. If the image cannot be
8060 * loaded/downloaded, the failure callback will be called.
8061 *
8062 * If the cropping process is successful, the resultant cropped image
8063 * will be stored in the ImageStore, and the URI returned in the success
8064 * callback will point to the image in the store. Remember to delete the
8065 * cropped image from the ImageStore when you are done with it.
8066 */
8067 cropImage( uri: string, cropData: ImageCropData, success: (uri: string) => void, failure: (error: Object) => void ): void
8068 }
8069
8070 //////////////////////////////////////////////////////////////////////////
8071 //
8072 // R E - E X P O R T S
8073 //
8074 //////////////////////////////////////////////////////////////////////////
8075
8076 // TODO: The following components need to be added
8077 // - [ ] ART
8078
8079 export var ActivityIndicator: ActivityIndicatorStatic
8080 export type ActivityIndicator = ActivityIndicatorStatic
8081
8082 export var ActivityIndicatorIOS: ActivityIndicatorIOSStatic
8083 export type ActivityIndicatorIOS = ActivityIndicatorIOSStatic
8084
8085 export var DatePickerIOS: DatePickerIOSStatic
8086 export type DatePickerIOS = DatePickerIOSStatic
8087
8088 export var DrawerLayoutAndroid: DrawerLayoutAndroidStatic
8089 export type DrawerLayoutAndroid = DrawerLayoutAndroidStatic
8090
8091 export var Image: ImageStatic
8092 export type Image = ImageStatic
8093
8094 export var ImagePickerIOS: ImagePickerIOSStatic
8095 export type ImagePickerIOS = ImagePickerIOSStatic
8096
8097 export var LayoutAnimation: LayoutAnimationStatic
8098 export type LayoutAnimation = LayoutAnimationStatic
8099
8100 export var ListView: ListViewStatic
8101 export type ListView = ListViewStatic
8102
8103 export var MapView: MapViewStatic
8104 export type MapView = MapViewStatic
8105
8106 export var Modal: ModalStatic
8107 export type Modal = ModalStatic
8108
8109 export var Navigator: NavigatorStatic
8110 export type Navigator = NavigatorStatic
8111
8112 export var NavigatorIOS: NavigatorIOSStatic
8113 export type NavigatorIOS = NavigatorIOSStatic
8114
8115 export var Picker: PickerStatic
8116 export type Picker = PickerStatic
8117
8118 export var PickerIOS: PickerIOSStatic
8119 export type PickerIOS = PickerIOSStatic
8120
8121 export var ProgressBarAndroid: ProgressBarAndroidStatic
8122 export type ProgressBarAndroid = ProgressBarAndroidStatic
8123
8124 export var ProgressViewIOS: ProgressViewIOSStatic
8125 export type ProgressViewIOS = ProgressViewIOSStatic
8126
8127 export var RefreshControl: RefreshControlStatic
8128 export type RefreshControl = RefreshControlStatic
8129
8130 export var RecyclerViewBackedScrollView: RecyclerViewBackedScrollViewStatic
8131 export type RecyclerViewBackedScrollView = RecyclerViewBackedScrollViewStatic
8132
8133 export var SegmentedControlIOS: SegmentedControlIOSStatic
8134 export type SegmentedControlIOS = SegmentedControlIOSStatic
8135
8136 export var Slider: SliderStatic
8137 export type Slider = SliderStatic
8138
8139 export var SliderIOS: SliderStatic
8140 export type SliderIOS = SliderStatic
8141
8142 export var StatusBar: StatusBarStatic
8143 export type StatusBar = StatusBarStatic
8144
8145 export var ScrollView: ScrollViewStatic
8146 export type ScrollView = ScrollViewStatic
8147
8148 export var SnapshotViewIOS: SnapshotViewIOSStatic
8149 export type SnapshotViewIOS = SnapshotViewIOSStatic
8150
8151 export var Systrace: SystraceStatic
8152 export type Systrace = SystraceStatic
8153
8154 export var SwipeableListView: SwipeableListViewStatic
8155 export type SwipeableListView = SwipeableListViewStatic
8156
8157 export var Switch: SwitchStatic
8158 export type Switch = SwitchStatic
8159
8160 export var SwitchIOS: SwitchIOSStatic
8161 export type SwitchIOS = SwitchIOSStatic
8162
8163 export var TabBarIOS: TabBarIOSStatic
8164 export type TabBarIOS = TabBarIOSStatic
8165
8166 export var Text: TextStatic
8167 export type Text = TextStatic
8168
8169 export var TextInput: TextInputStatic
8170 export type TextInput = TextInputStatic
8171
8172 export var ToolbarAndroid: ToolbarAndroidStatic
8173 export type ToolbarAndroid = ToolbarAndroidStatic
8174
8175 export var TouchableHighlight: TouchableHighlightStatic
8176 export type TouchableHighlight = TouchableHighlightStatic
8177
8178 export var TouchableNativeFeedback: TouchableNativeFeedbackStatic
8179 export type TouchableNativeFeedback = TouchableNativeFeedbackStatic
8180
8181 export var TouchableOpacity: TouchableOpacityStatic
8182 export type TouchableOpacity = TouchableOpacityStatic
8183
8184 export var TouchableWithoutFeedback: TouchableWithoutFeedbackStatic
8185 export type TouchableWithoutFeedback= TouchableWithoutFeedbackStatic
8186
8187 export var View: ViewStatic
8188 export type View = ViewStatic
8189
8190 export var ViewPagerAndroid: ViewPagerAndroidStatic
8191 export type ViewPagerAndroid = ViewPagerAndroidStatic
8192
8193 export var WebView: WebViewStatic
8194 export type WebView = WebViewStatic
8195
8196
8197 //////////// APIS //////////////
8198 export var ActionSheetIOS: ActionSheetIOSStatic
8199 export type ActionSheetIOS = ActionSheetIOSStatic
8200
8201 export var Share: ShareStatic
8202 export type Share = ShareStatic
8203
8204 export var AdSupportIOS: AdSupportIOSStatic
8205 export type AdSupportIOS = AdSupportIOSStatic
8206
8207 export var Alert: AlertStatic
8208 export type Alert = AlertStatic
8209
8210 export var AlertAndroid: AlertAndroidStatic
8211 export type AlertAndroid = AlertAndroidStatic
8212
8213 export var AlertIOS: AlertIOSStatic
8214 export type AlertIOS = AlertIOSStatic
8215
8216 export var AppState : AppStateStatic;
8217 export type AppState = AppStateStatic;
8218
8219 export var AppStateIOS: AppStateStatic
8220 export type AppStateIOS = AppStateStatic
8221
8222 export var AsyncStorage: AsyncStorageStatic
8223 export type AsyncStorage = AsyncStorageStatic
8224
8225 export var BackAndroid: BackAndroidStatic
8226 export type BackAndroid = BackAndroidStatic
8227
8228 export var CameraRoll: CameraRollStatic
8229 export type CameraRoll = CameraRollStatic
8230
8231 export var Clipboard: ClipboardStatic
8232 export type Clipboard = ClipboardStatic
8233
8234 export var DatePickerAndroid: DatePickerAndroidStatic
8235 export type DatePickerAndroid = DatePickerAndroidStatic
8236
8237 export var Geolocation: GeolocationStatic
8238 export type Geolocation = GeolocationStatic
8239
8240 /** http://facebook.github.io/react-native/blog/2016/08/19/right-to-left-support-for-react-native-apps.html */
8241 export var I18nManager: I18nManagerStatic
8242 export type I18nManager = I18nManagerStatic
8243
8244 export var ImageEditor: ImageEditorStatic
8245 export type ImageEditor = ImageEditorStatic
8246
8247 export var ImageStore: ImageStoreStatic
8248 export type ImageStore = ImageStoreStatic
8249
8250 export var InteractionManager: InteractionManagerStatic
8251
8252 export var IntentAndroid: IntentAndroidStatic
8253 export type IntentAndroid = IntentAndroidStatic
8254
8255 export var Keyboard: NativeEventEmitter
8256
8257 export var KeyboardAvoidingView: KeyboardAvoidingViewStatic
8258 export type KeyboardAvoidingView = KeyboardAvoidingViewStatic
8259
8260 export var Linking: LinkingStatic
8261 export type Linking = LinkingStatic
8262
8263 export var LinkingIOS: LinkingIOSStatic
8264 export type LinkingIOS = LinkingIOSStatic
8265
8266 export var NativeMethodsMixin: NativeMethodsMixinStatic
8267 export type NativeMethodsMixin = NativeMethodsMixinStatic
8268
8269 export var NativeComponent: NativeMethodsMixinStatic
8270 export type NativeComponent = NativeMethodsMixinStatic
8271
8272 export var NetInfo: NetInfoStatic
8273 export type NetInfo = NetInfoStatic
8274
8275 export var PanResponder: PanResponderStatic
8276 export type PanResponder = PanResponderStatic
8277
8278 export var PermissionsAndroid: PermissionsAndroidStatic
8279 export type PermissionsAndroid = PermissionsAndroidStatic
8280
8281 export var PushNotificationIOS: PushNotificationIOSStatic
8282 export type PushNotificationIOS = PushNotificationIOSStatic
8283
8284 export var Settings: SettingsStatic
8285 export type Settings = SettingsStatic
8286
8287 export var StatusBarIOS: StatusBarIOSStatic
8288 export type StatusBarIOS = StatusBarIOSStatic
8289
8290 export var TimePickerAndroid: TimePickerAndroidStatic
8291 export type TimePickerAndroid = TimePickerAndroidStatic
8292
8293 export var ToastAndroid: ToastAndroidStatic
8294 export type ToastAndroid = ToastAndroidStatic
8295
8296 export var UIManager: UIManagerStatic
8297 export type UIManager = UIManagerStatic
8298
8299 export var VibrationIOS: VibrationIOSStatic
8300 export type VibrationIOS = VibrationIOSStatic
8301
8302 export var Vibration: VibrationStatic
8303 export type Vibration = VibrationStatic
8304
8305 export var Dimensions: Dimensions;
8306 export var ShadowPropTypesIOS: ShadowPropTypesIOSStatic;
8307
8308 export type NavigationExperimental = NavigationExperimentalStatic;
8309 export var NavigationExperimental: NavigationExperimentalStatic;
8310
8311 export type Easing = EasingStatic;
8312 export var Easing: EasingStatic;
8313
8314 //////////// Plugins //////////////
8315
8316 export var DeviceEventEmitter: RCTDeviceEventEmitter
8317 /**
8318 * Abstract base class for implementing event-emitting modules. This implements
8319 * a subset of the standard EventEmitter node module API.
8320 */
8321 export interface NativeEventEmitter extends EventEmitter {}
8322 export var NativeEventEmitter: NativeEventEmitter
8323 /**
8324 * Deprecated - subclass NativeEventEmitter to create granular event modules instead of
8325 * adding all event listeners directly to RCTNativeAppEventEmitter.
8326 */
8327 export var NativeAppEventEmitter: RCTNativeAppEventEmitter
8328 /**
8329 * Native Modules written in ObjectiveC/Swift/Java exposed via the RCTBridge
8330 * Define lazy getters for each module. These will return the module if already loaded, or load it if not.
8331 * See https://facebook.github.io/react-native/docs/native-modules-ios.html
8332 * Use:
8333 * <code>const MyModule = NativeModules.ModuleName</code>
8334 */
8335 export var NativeModules: any
8336 export var Platform: PlatformStatic
8337 export var PixelRatio: PixelRatioStatic
8338
8339 export interface ComponentInterface<P> {
8340 name?: string;
8341 displayName?: string;
8342 propTypes: P
8343 }
8344
8345 /**
8346 * Used to create React components that directly wrap native component
8347 * implementations. Config information is extracted from data exported from the
8348 * UIManager module. You should also wrap the native component in a
8349 * hand-written component with full propTypes definitions and other
8350 * documentation - pass the hand-written component in as `componentInterface` to
8351 * verify all the native props are documented via `propTypes`.
8352 *
8353 * If some native props shouldn't be exposed in the wrapper interface, you can
8354 * pass null for `componentInterface` and call `verifyPropTypes` directly
8355 * with `nativePropsToIgnore`;
8356 *
8357 * Common types are lined up with the appropriate prop differs with
8358 * `TypeToDifferMap`. Non-scalar types not in the map default to `deepDiffer`.
8359 */
8360 export function requireNativeComponent<P>(
8361 viewName: string,
8362 componentInterface?: ComponentInterface<P>,
8363 extraConfig?: {nativeOnly?: any}
8364 ): React.ComponentClass<P>;
8365
8366 export function processColor(color: any): number;
8367
8368 //////////////////////////////////////////////////////////////////////////
8369 //
8370 // Additional ( and controversial)
8371 //
8372 //////////////////////////////////////////////////////////////////////////
8373
8374 export function __spread( target: any, ...sources: any[] ): any;
8375
8376 export interface GlobalStatic {
8377
8378 /**
8379 * Accepts a function as its only argument and calls that function before the next repaint.
8380 * It is an essential building block for animations that underlies all of the JavaScript-based animation APIs.
8381 * In general, you shouldn't need to call this yourself - the animation API's will manage frame updates for you.
8382 * @see https://facebook.github.io/react-native/docs/animations.html#requestanimationframe
8383 */
8384 requestAnimationFrame( fn: () => void ) : void;
8385
8386 }
8387
8388 //
8389 // Add-Ons
8390 //
8391 namespace addons {
8392
8393 //FIXME: Documentation ?
8394 export interface TestModuleStatic {
8395
8396 verifySnapshot: ( done: ( indicator?: any ) => void ) => void
8397 markTestPassed: ( indicator: any ) => void
8398 markTestCompleted: () => void
8399 }
8400
8401 export var TestModule: TestModuleStatic
8402 export type TestModule = TestModuleStatic
8403 }
8404
8405 //
8406 // Prop Types
8407 //
8408 export var ColorPropType: Requireable<any>
8409 export var EdgeInsetsPropType: Requireable<any>
8410 export var PointPropType: Requireable<any>
8411}
8412
8413declare module "react-native" {
8414 import ReactNative = __React
8415 export = ReactNative
8416}
8417
8418declare var global: __React.GlobalStatic
8419
8420declare function require( name: string ): any
8421
8422/**
8423 * This variable is set to true when react-native is running in Dev mode
8424 * Typical usage:
8425 * <code> if (__DEV__) console.log('Running in dev mode')</code>
8426 */
8427declare var __DEV__: boolean