microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
147d9cc549da9c4c4297f65e799484b78fe8de80

Branches

Tags

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

Clone

HTTPS

Download ZIP

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

3480lines · modecode

1// Type definitions for react-native 0.14
2// Project: https://github.com/facebook/react-native
3// Definitions by: Bruno Grieder <https://github.com/bgrieder>
4// Definitions: https://github.com/borisyankov/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// CONTRIBUTING: please open pull requests and make sure that the changes do not break RNTSExplorer (they should not)
13// Do not hesitate to open a pull request against RNTSExplorer to provide an example for a case not covered by the current App
14//
15// CREDITS: This work is based on an original work made by Bernd Paradies: https://github.com/bparadie
16//
17///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
18
19/// <reference path="../react/react.d.ts" />
20
21//so we know what is "original" React
22import React = __React;
23
24//react-native "extends" react
25declare namespace __React {
26
27
28 /**
29 * Represents the completion of an asynchronous operation
30 * @see lib.es6.d.ts
31 */
32 export interface Promise<T> {
33 /**
34 * Attaches callbacks for the resolution and/or rejection of the Promise.
35 * @param onfulfilled The callback to execute when the Promise is resolved.
36 * @param onrejected The callback to execute when the Promise is rejected.
37 * @returns A Promise for the completion of which ever callback is executed.
38 */
39 then<TResult>( onfulfilled?: ( value: T ) => TResult | Promise<TResult>, onrejected?: ( reason: any ) => TResult | Promise<TResult> ): Promise<TResult>;
40
41 /**
42 * Attaches a callback for only the rejection of the Promise.
43 * @param onrejected The callback to execute when the Promise is rejected.
44 * @returns A Promise for the completion of the callback.
45 */
46 catch( onrejected?: ( reason: any ) => T | Promise<T> ): Promise<T>;
47
48
49 // not in lib.es6.d.ts but called by react-native
50 done( callback?: ( value: T ) => void ): void;
51 }
52
53 export interface PromiseConstructor {
54 /**
55 * A reference to the prototype.
56 */
57 prototype: Promise<any>;
58
59 /**
60 * Creates a new Promise.
61 * @param init A callback used to initialize the promise. This callback is passed two arguments:
62 * a resolve callback used resolve the promise with a value or the result of another promise,
63 * and a reject callback used to reject the promise with a provided reason or error.
64 */
65 new <T>( init: ( resolve: ( value?: T | Promise<T> ) => void, reject: ( reason?: any ) => void ) => void ): Promise<T>;
66
67 <T>( init: ( resolve: ( value?: T | Promise<T> ) => void, reject: ( reason?: any ) => void ) => void ): Promise<T>;
68
69 /**
70 * Creates a Promise that is resolved with an array of results when all of the provided Promises
71 * resolve, or rejected when any Promise is rejected.
72 * @param values An array of Promises.
73 * @returns A new Promise.
74 */
75 all<T>( values: (T | Promise<T>)[] ): Promise<T[]>;
76
77 /**
78 * Creates a Promise that is resolved with an array of results when all of the provided Promises
79 * resolve, or rejected when any Promise is rejected.
80 * @param values An array of values.
81 * @returns A new Promise.
82 */
83 all( values: Promise<void>[] ): Promise<void>;
84
85 /**
86 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
87 * or rejected.
88 * @param values An array of Promises.
89 * @returns A new Promise.
90 */
91 race<T>( values: (T | Promise<T>)[] ): Promise<T>;
92
93 /**
94 * Creates a new rejected promise for the provided reason.
95 * @param reason The reason the promise was rejected.
96 * @returns A new rejected Promise.
97 */
98 reject( reason: any ): Promise<void>;
99
100 /**
101 * Creates a new rejected promise for the provided reason.
102 * @param reason The reason the promise was rejected.
103 * @returns A new rejected Promise.
104 */
105 reject<T>( reason: any ): Promise<T>;
106
107 /**
108 * Creates a new resolved promise for the provided value.
109 * @param value A promise.
110 * @returns A promise whose internal state matches the provided promise.
111 */
112 resolve<T>( value: T | Promise<T> ): Promise<T>;
113
114 /**
115 * Creates a new resolved promise .
116 * @returns A resolved promise.
117 */
118 resolve(): Promise<void>;
119 }
120
121 // @see lib.es6.d.ts
122 export var Promise: PromiseConstructor;
123
124 //TODO: BGR: Replace with ComponentClass ?
125 // node_modules/react-tools/src/classic/class/ReactClass.js
126 export interface ReactClass<D, P, S> {
127 // TODO:
128 }
129
130 // see react-jsx.d.ts
131 export function createElement<P>( type: React.ReactType,
132 props?: P,
133 ...children: React.ReactNode[] ): React.ReactElement<P>;
134
135
136 export type Runnable = ( appParameters: any ) => void;
137
138
139 // Similar to React.SyntheticEvent except for nativeEvent
140 interface NativeSyntheticEvent<T> {
141 bubbles: boolean
142 cancelable: boolean
143 currentTarget: EventTarget
144 defaultPrevented: boolean
145 eventPhase: number
146 isTrusted: boolean
147 nativeEvent: T
148 preventDefault(): void
149 stopPropagation(): void
150 target: EventTarget
151 timeStamp: Date
152 type: string
153 }
154
155 export interface NativeTouchEvent {
156 /**
157 * Array of all touch events that have changed since the last event
158 */
159 changedTouches: NativeTouchEvent[]
160
161 /**
162 * The ID of the touch
163 */
164 identifier: string
165
166 /**
167 * The X position of the touch, relative to the element
168 */
169 locationX: number
170
171 /**
172 * The Y position of the touch, relative to the element
173 */
174 locationY: number
175
176 /**
177 * The X position of the touch, relative to the screen
178 */
179 pageX: number
180
181 /**
182 * The Y position of the touch, relative to the screen
183 */
184 pageY: number
185
186 /**
187 * The node id of the element receiving the touch event
188 */
189 target: string
190
191 /**
192 * A time identifier for the touch, useful for velocity calculation
193 */
194 timestamp: number
195
196 /**
197 * Array of all current touches on the screen
198 */
199 touches : NativeTouchEvent[]
200 }
201
202 export interface GestureResponderEvent extends NativeSyntheticEvent<NativeTouchEvent> {
203 }
204
205
206 export interface PointProperties {
207 x: number
208 y: number
209 }
210
211 export interface Insets {
212 top?: number
213 left?: number
214 bottom?: number
215 right?: number
216 }
217
218 /**
219 * //FIXME: need to find documentation on which compoenent is a native (i.e. non composite component)
220 */
221 export interface NativeComponent {
222 setNativeProps: ( props: Object ) => void
223 }
224
225 /**
226 * //FIXME: need to find documentation on which component is a TTouchable and can implement that interface
227 * @see React.DOMAtributes
228 */
229 export interface Touchable {
230 onTouchStart?: ( event: GestureResponderEvent ) => void
231 onTouchMove?: ( event: GestureResponderEvent ) => void
232 onTouchEnd?: ( event: GestureResponderEvent ) => void
233 onTouchCancel?: ( event: GestureResponderEvent ) => void
234 onTouchEndCapture?: ( event: GestureResponderEvent ) => void
235 }
236
237 export type AppConfig = {
238 appKey: string;
239 component: ReactClass<any, any, any>;
240 run?: Runnable;
241 }
242
243 // https://github.com/facebook/react-native/blob/master/Libraries/AppRegistry/AppRegistry.js
244 export class AppRegistry {
245 static registerConfig( config: AppConfig[] ): void;
246
247 static registerComponent( appKey: string, getComponentFunc: () => React.ComponentClass<any> ): string;
248
249 static registerRunnable( appKey: string, func: Runnable ): string;
250
251 static runApplication( appKey: string, appParameters: any ): void;
252 }
253
254 export interface LayoutAnimationTypes {
255 spring: string
256 linear: string
257 easeInEaseOut: string
258 easeIn: string
259 easeOut: string
260 }
261
262 export interface LayoutAnimationProperties {
263 opacity: string
264 scaleXY: string
265 }
266
267 export interface LayoutAnimationAnim {
268 duration?: number
269 delay?: number
270 springDamping?: number
271 initialVelocity?: number
272 type?: string //LayoutAnimationTypes
273 property?: string //LayoutAnimationProperties
274 }
275
276 export interface LayoutAnimationConfig {
277 duration: number
278 create?: LayoutAnimationAnim
279 update?: LayoutAnimationAnim
280 delete?: LayoutAnimationAnim
281 }
282
283 export interface LayoutAnimationStatic {
284
285 configureNext: ( config: LayoutAnimationConfig, onAnimationDidEnd?: () => void, onError?: ( error?: any ) => void ) => void
286 create: ( duration: number, type?: string, creationProp?: string ) => LayoutAnimationConfig
287 Types: LayoutAnimationTypes
288 Properties: LayoutAnimationProperties
289 configChecker: ( conf: {config: LayoutAnimationConfig}, name: string, next: string ) => void
290 Presets : {
291 easeInEaseOut: LayoutAnimationConfig
292 linear:LayoutAnimationConfig
293 spring: LayoutAnimationConfig
294 }
295 }
296
297
298 /**
299 * Flex Prop Types
300 * @see https://facebook.github.io/react-native/docs/flexbox.html#proptypes
301 * @see LayoutPropTypes.js
302 */
303 export interface FlexStyle {
304
305 alignItems?: string; //enum('flex-start', 'flex-end', 'center', 'stretch')
306 alignSelf?: string// enum('auto', 'flex-start', 'flex-end', 'center', 'stretch')
307 borderBottomWidth?: number
308 borderLeftWidth?: number
309 borderRightWidth?: number
310 borderTopWidth?: number
311 borderWidth?: number
312 bottom?: number
313 flex?: number
314 flexDirection?: string // enum('row', 'column')
315 flexWrap?: string // enum('wrap', 'nowrap')
316 height?: number
317 justifyContent?: string // enum('flex-start', 'flex-end', 'center', 'space-between', 'space-around')
318 left?: number
319 margin?: number
320 marginBottom?: number
321 marginHorizontal?: number
322 marginLeft?: number
323 marginRight?: number
324 marginTop?: number
325 marginVertical?: number
326 padding?: number
327 paddingBottom?: number
328 paddingHorizontal?: number
329 paddingLeft?: number
330 paddingRight?: number
331 paddingTop?: number
332 paddingVertical?: number
333 position?: string // enum('absolute', 'relative')
334 right?: number
335 top?: number
336 width?: number
337 }
338
339
340 export interface TransformsStyle {
341
342 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}]
343 transformMatrix?: Array<number>
344 rotation?: number
345 scaleX?: number
346 scaleY?: number
347 translateX?: number
348 translateY?: number
349 }
350
351
352 export interface StyleSheetProperties {
353 // TODO:
354 }
355
356 export interface LayoutRectangle {
357 x: number;
358 y: number;
359 width: number;
360 height: number;
361 }
362
363 // @see TextProperties.onLayout
364 export interface LayoutChangeEvent {
365 nativeEvent: {
366 layout: LayoutRectangle
367 }
368 }
369
370 // @see https://facebook.github.io/react-native/docs/text.html#style
371 export interface TextStyle extends ViewStyle {
372 color?: string
373 fontFamily?: string
374 fontSize?: number
375 fontStyle?: string // 'normal' | 'italic';
376 fontWeight?: string // enum("normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900')
377 letterSpacing?: number
378 lineHeight?: number
379 textAlign?: string // enum("auto", 'left', 'right', 'center')
380 textDecorationLine?: string // enum("none", 'underline', 'line-through', 'underline line-through')
381 textDecorationStyle?: string // enum("solid", 'double', 'dotted', 'dashed')
382 textDecorationColor?: string
383 writingDirection?: string; //enum("auto", 'ltr', 'rtl')
384 //containerBackgroundColor?: string
385 }
386
387 export interface TextPropertiesIOS {
388
389 /**
390 * When true, no visual change is made when text is pressed down.
391 * By default, a gray oval highlights the text on press down.
392 */
393 suppressHighlighting?: boolean
394 }
395
396 // https://facebook.github.io/react-native/docs/text.html#props
397 export interface TextProperties extends React.Props<TextProperties> {
398
399 /**
400 * Specifies should fonts scale to respect Text Size accessibility setting on iOS.
401 */
402 allowFontScaling?: boolean
403
404 /**
405 * Used to truncate the text with an elipsis after computing the text layout, including line wrapping, such that the total number of lines does not exceed this number.
406 */
407 numberOfLines?: number
408
409 /**
410 * Invoked on mount and layout changes with
411 *
412 * {nativeEvent: { layout: {x, y, width, height}}}.
413 */
414 onLayout?: ( event: LayoutChangeEvent ) => void
415
416 /**
417 * This function is called on press.
418 * Text intrinsically supports press handling with a default highlight state (which can be disabled with suppressHighlighting).
419 */
420 onPress?: () => void
421
422 /**
423 * @see https://facebook.github.io/react-native/docs/text.html#style
424 */
425 style?: TextStyle
426
427 /**
428 * Used to locate this view in end-to-end tests.
429 */
430 testID?: string
431 }
432
433 /**
434 * A React component for displaying text which supports nesting, styling, and touch handling.
435 */
436 export interface TextStatic extends React.ComponentClass<TextProperties> {
437
438 }
439
440
441 /**
442 * IOS Specific properties for TextInput
443 * @see https://facebook.github.io/react-native/docs/textinput.html#props
444 */
445 export interface TextInputIOSProperties {
446
447 /**
448 * If true, the text field will blur when submitted.
449 * The default value is true.
450 */
451 blurOnSubmit?: boolean
452
453 /**
454 * enum('never', 'while-editing', 'unless-editing', 'always')
455 * When the clear button should appear on the right side of the text view
456 */
457 clearButtonMode?: string
458
459 /**
460 * If true, clears the text field automatically when editing begins
461 */
462 clearTextOnFocus?: boolean
463
464 /**
465 * If true, the keyboard disables the return key when there is no text and automatically enables it when there is text.
466 * The default value is false.
467 */
468 enablesReturnKeyAutomatically?: boolean
469
470 /**
471 * Callback that is called when a key is pressed.
472 * Pressed key value is passed as an argument to the callback handler.
473 * Fires before onChange callbacks.
474 */
475 onKeyPress?: () => void
476
477 /**
478 * enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call')
479 * Determines how the return key should look.
480 */
481 returnKeyType?: string
482
483 /**
484 * If true, all text will automatically be selected on focus
485 */
486 selectTextOnFocus?: boolean
487
488 /**
489 * //FIXME: requires typing
490 * See DocumentSelectionState.js, some state that is responsible for maintaining selection information for a document
491 */
492 selectionState?: any
493
494
495 }
496
497 /**
498 * Android Specific properties for TextInput
499 * @see https://facebook.github.io/react-native/docs/textinput.html#props
500 */
501 export interface TextInputAndroidProperties {
502
503 /**
504 * Sets the number of lines for a TextInput.
505 * Use it with multiline set to true to be able to fill the lines.
506 */
507 numberOfLines?: number
508
509 /**
510 * enum('start', 'center', 'end')
511 * Set the position of the cursor from where editing will begin.
512 */
513 textAlign?: string
514
515 /**
516 * enum('top', 'center', 'bottom')
517 * Aligns text vertically within the TextInput.
518 */
519 textAlignVertical?: string
520
521 /**
522 * The color of the textInput underline.
523 */
524 underlineColorAndroid?: string
525 }
526
527
528 /**
529 * @see https://facebook.github.io/react-native/docs/textinput.html#props
530 */
531 export interface TextInputProperties extends TextInputIOSProperties, TextInputAndroidProperties, React.Props<TextInputStatic> {
532
533 /**
534 * Can tell TextInput to automatically capitalize certain characters.
535 * characters: all characters,
536 * words: first letter of each word
537 * sentences: first letter of each sentence (default)
538 * none: don't auto capitalize anything
539 *
540 * https://facebook.github.io/react-native/docs/textinput.html#autocapitalize
541 */
542 autoCapitalize?: string
543
544 /**
545 * If false, disables auto-correct.
546 * The default value is true.
547 */
548 autoCorrect?: boolean
549
550 /**
551 * If true, focuses the input on componentDidMount.
552 * The default value is false.
553 */
554 autoFocus?: boolean
555
556 /**
557 * Provides an initial value that will change when the user starts typing.
558 * Useful for simple use-cases where you don't want to deal with listening to events
559 * and updating the value prop to keep the controlled state in sync.
560 */
561 defaultValue?: string
562
563 /**
564 * If false, text is not editable. The default value is true.
565 */
566 editable?: boolean
567
568 /**
569 * enum("default", 'numeric', 'email-address', "ascii-capable", 'numbers-and-punctuation', 'url', 'number-pad', 'phone-pad', 'name-phone-pad', 'decimal-pad', 'twitter', 'web-search')
570 * Determines which keyboard to open, e.g.numeric.
571 * The following values work across platforms: - default - numeric - email-address
572 */
573 keyboardType?: string
574
575 /**
576 * Limits the maximum number of characters that can be entered.
577 * Use this instead of implementing the logic in JS to avoid flicker.
578 */
579 maxLength?: number
580
581 /**
582 * If true, the text input can be multiple lines. The default value is false.
583 */
584 multiline?: boolean
585
586 /**
587 * Callback that is called when the text input is blurred
588 */
589 onBlur?: () => void
590
591 /**
592 * Callback that is called when the text input's text changes.
593 */
594 onChange?: ( event: {nativeEvent: {text: string}} ) => void
595
596 /**
597 * Callback that is called when the text input's text changes.
598 * Changed text is passed as an argument to the callback handler.
599 */
600 onChangeText?: ( text: string ) => void
601
602 /**
603 * Callback that is called when text input ends.
604 */
605 onEndEditing?: ( event: {nativeEvent: {text: string}} ) => void
606
607 /**
608 * Callback that is called when the text input is focused
609 */
610 onFocus?: () => void
611
612 /**
613 * Invoked on mount and layout changes with {x, y, width, height}.
614 */
615 onLayout?: ( event: {nativeEvent: {x: number, y: number, width: number, height: number}} ) => void
616
617 /**
618 * Callback that is called when the text input's submit button is pressed.
619 */
620 onSubmitEditing?: ( event: {nativeEvent: {text: string}} ) => void
621
622 /**
623 * //FIXME: Not part of the doc but found in examples
624 */
625 password?: boolean
626
627 /**
628 * The string that will be rendered before text input has been entered
629 */
630 placeholder?: string
631
632 /**
633 * The text color of the placeholder string
634 */
635 placeholderTextColor?: string
636
637 /**
638 * If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
639 * The default value is false.
640 */
641 secureTextEntry?: boolean
642
643 /**
644 * Styles
645 */
646 style?: TextStyle
647
648 /**
649 * Used to locate this view in end-to-end tests
650 */
651 testID?: string
652
653 /**
654 * The value to show for the text input. TextInput is a controlled component,
655 * which means the native value will be forced to match this value prop if provided.
656 * 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.
657 * In addition to simply setting the same value, either set editable={false},
658 * or set/update maxLength to prevent unwanted edits without flicker.
659 */
660 value?: string
661 }
662
663 export interface TextInputStatic extends NativeComponent, React.ComponentClass<TextInputProperties> {
664 blur: () => void
665 focus: () => void
666 }
667
668
669 /**
670 * Gesture recognition on mobile devices is much more complicated than web.
671 * A touch can go through several phases as the app determines what the user's intention is.
672 * For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping.
673 * This can even change during the duration of a touch. There can also be multiple simultaneous touches.
674 *
675 * The touch responder system is needed to allow components to negotiate these touch interactions
676 * without any additional knowledge about their parent or child components.
677 * This system is implemented in ResponderEventPlugin.js, which contains further details and documentation.
678 *
679 * Best Practices
680 * Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes.
681 * Every action should have the following attributes:
682 * Feedback/highlighting- show the user what is handling their touch, and what will happen when they release the gesture
683 * Cancel-ability- when making an action, the user should be able to abort it mid-touch by dragging their finger away
684 *
685 * These features make users more comfortable while using an app,
686 * because it allows people to experiment and interact without fear of making mistakes.
687 *
688 * TouchableHighlight and Touchable*
689 * The responder system can be complicated to use.
690 * So we have provided an abstract Touchable implementation for things that should be "tappable".
691 * This uses the responder system and allows you to easily configure tap interactions declaratively.
692 * Use TouchableHighlight anywhere where you would use a button or link on web.
693 */
694 export interface GestureResponderHandlers {
695
696 /**
697 * A view can become the touch responder by implementing the correct negotiation methods.
698 * There are two methods to ask the view if it wants to become responder:
699 */
700
701 /**
702 * Does this view want to become responder on the start of a touch?
703 */
704 onStartShouldSetResponder?: ( event: GestureResponderEvent ) => boolean
705
706 /**
707 * Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness?
708 */
709 onMoveShouldSetResponder?: ( event: GestureResponderEvent ) => boolean
710
711 /**
712 * If the View returns true and attempts to become the responder, one of the following will happen:
713 */
714
715 /**
716 * The View is now responding for touch events.
717 * This is the time to highlight and show the user what is happening
718 */
719 onResponderGrant?: ( event: GestureResponderEvent ) => void
720
721 /**
722 * Something else is the responder right now and will not release it
723 */
724 onResponderReject?: ( event: GestureResponderEvent ) => void
725
726 /**
727 * If the view is responding, the following handlers can be called:
728 */
729
730 /**
731 * The user is moving their finger
732 */
733 onResponderMove?: ( event: GestureResponderEvent ) => void
734
735 /**
736 * Fired at the end of the touch, ie "touchUp"
737 */
738 onResponderRelease?: ( event: GestureResponderEvent ) => void
739
740 /**
741 * Something else wants to become responder.
742 * Should this view release the responder? Returning true allows release
743 */
744 onResponderTerminationRequest?: ( event: GestureResponderEvent ) => boolean
745
746 /**
747 * The responder has been taken from the View.
748 * Might be taken by other views after a call to onResponderTerminationRequest,
749 * or might be taken by the OS without asking (happens with control center/ notification center on iOS)
750 */
751 onResponderTerminate?: ( event: GestureResponderEvent ) => void
752
753 /**
754 * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern,
755 * where the deepest node is called first.
756 * That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers.
757 * This is desirable in most cases, because it makes sure all controls and buttons are usable.
758 *
759 * However, sometimes a parent will want to make sure that it becomes responder.
760 * This can be handled by using the capture phase.
761 * Before the responder system bubbles up from the deepest component,
762 * it will do a capture phase, firing on*ShouldSetResponderCapture.
763 * So if a parent View wants to prevent the child from becoming responder on a touch start,
764 * it should have a onStartShouldSetResponderCapture handler which returns true.
765 */
766 onStartShouldSetResponderCapture?: ( event: GestureResponderEvent ) => boolean
767
768 /**
769 * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern,
770 * where the deepest node is called first.
771 * That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers.
772 * This is desirable in most cases, because it makes sure all controls and buttons are usable.
773 *
774 * However, sometimes a parent will want to make sure that it becomes responder.
775 * This can be handled by using the capture phase.
776 * Before the responder system bubbles up from the deepest component,
777 * it will do a capture phase, firing on*ShouldSetResponderCapture.
778 * So if a parent View wants to prevent the child from becoming responder on a touch start,
779 * it should have a onStartShouldSetResponderCapture handler which returns true.
780 */
781 onMoveShouldSetResponderCapture?: () => void;
782
783 }
784
785 // @see https://facebook.github.io/react-native/docs/view.html#style
786 export interface ViewStyle extends FlexStyle, TransformsStyle {
787 backgroundColor?: string;
788 borderBottomColor?: string;
789 borderBottomLeftRadius?: number;
790 borderBottomRightRadius?: number;
791 borderColor?: string;
792 borderLeftColor?: string;
793 borderRadius?: number;
794 borderRightColor?: string;
795 borderTopColor?: string;
796 borderTopLeftRadius?: number;
797 borderTopRightRadius?: number;
798 opacity?: number;
799 overflow?: string; // enum('visible', 'hidden')
800 shadowColor?: string;
801 shadowOffset?: {width: number, height: number};
802 shadowOpacity?: number;
803 shadowRadius?: number;
804 }
805
806
807 export interface ViewPropertiesIOS {
808
809 /**
810 * Provides additional traits to screen reader.
811 * By default no traits are provided unless specified otherwise in element
812 *
813 * @enum('none', 'button', 'link', 'header', 'search', 'image', 'selected', 'plays', 'key', 'text','summary', 'disabled', 'frequentUpdates', 'startsMedia', 'adjustable', 'allowsDirectInteraction', 'pageTurn')
814 */
815 accessibilityTraits?: string | string[];
816
817 /**
818 * Whether this view should be rendered as a bitmap before compositing.
819 *
820 * On iOS, this is useful for animations and interactions that do not modify this component's dimensions nor its children;
821 * for example, when translating the position of a static view, rasterization allows the renderer to reuse a cached bitmap of a static view
822 * and quickly composite it during each frame.
823 *
824 * Rasterization incurs an off-screen drawing pass and the bitmap consumes memory.
825 * Test and measure when using this property.
826 */
827 shouldRasterizeIOS?: boolean
828 }
829
830 export interface ViewPropertiesAndroid {
831
832 /**
833 * Indicates to accessibility services to treat UI component like a native one.
834 * Works for Android only.
835 *
836 * @enum('none', 'button', 'radiobutton_checked', 'radiobutton_unchecked' )
837 */
838 accessibilityComponentType?: string
839
840
841 /**
842 * Indicates to accessibility services whether the user should be notified when this view changes.
843 * Works for Android API >= 19 only.
844 * See http://developer.android.com/reference/android/view/View.html#attr_android:accessibilityLiveRegion for references.
845 */
846 accessibilityLiveRegion?: string
847
848 /**
849 * Views that are only used to layout their children or otherwise don't draw anything
850 * may be automatically removed from the native hierarchy as an optimization.
851 * Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy.
852 */
853 collapsable?: boolean
854
855
856 /**
857 * Controls how view is important for accessibility which is if it fires accessibility events
858 * and if it is reported to accessibility services that query the screen.
859 * Works for Android only. See http://developer.android.com/reference/android/R.attr.html#importantForAccessibility for references.
860 *
861 * Possible values:
862 * 'auto' - The system determines whether the view is important for accessibility - default (recommended).
863 * 'yes' - The view is important for accessibility.
864 * 'no' - The view is not important for accessibility.
865 * 'no-hide-descendants' - The view is not important for accessibility, nor are any of its descendant views.
866 */
867 importantForAccessibility?: string
868
869
870 /**
871 * Whether this view needs to rendered offscreen and composited with an alpha in order to preserve 100% correct colors and blending behavior.
872 * The default (false) falls back to drawing the component and its children
873 * 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.
874 * This default may be noticeable and undesired in the case where the View you are setting an opacity on
875 * has multiple overlapping elements (e.g. multiple overlapping Views, or text and a background).
876 *
877 * Rendering offscreen to preserve correct alpha behavior is extremely expensive
878 * and hard to debug for non-native developers, which is why it is not turned on by default.
879 * If you do need to enable this property for an animation,
880 * consider combining it with renderToHardwareTextureAndroid if the view contents are static (i.e. it doesn't need to be redrawn each frame).
881 * If that property is enabled, this View will be rendered off-screen once,
882 * 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.
883 */
884 needsOffscreenAlphaCompositing?: boolean
885
886
887 /**
888 * Whether this view should render itself (and all of its children) into a single hardware texture on the GPU.
889 *
890 * On Android, this is useful for animations and interactions that only modify opacity, rotation, translation, and/or scale:
891 * 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
892 * 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.
893 */
894 renderToHardwareTextureAndroid?: boolean;
895
896 }
897
898 /**
899 * @see https://facebook.github.io/react-native/docs/view.html#props
900 */
901 export interface ViewProperties extends ViewPropertiesAndroid, ViewPropertiesIOS, GestureResponderHandlers, Touchable, React.Props<ViewStatic> {
902
903 /**
904 * 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.
905 */
906 accessibilityLabel?: string;
907
908 /**
909 * When true, indicates that the view is an accessibility element.
910 * By default, all the touchable elements are accessible.
911 */
912 accessible?: boolean;
913
914 /**
915 * When `accessible` is true, the system will try to invoke this function when the user performs accessibility tap gesture.
916 */
917 onAcccessibilityTap?: () => void;
918
919 /**
920 * Invoked on mount and layout changes with
921 *
922 * {nativeEvent: { layout: {x, y, width, height}}}.
923 */
924 onLayout?: ( event: LayoutChangeEvent ) => void;
925
926 /**
927 * When accessible is true, the system will invoke this function when the user performs the magic tap gesture.
928 */
929 onMagicTap?: () => void;
930
931 /**
932 *
933 * 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:
934 *
935 * .box-none {
936 * pointer-events: none;
937 * }
938 * .box-none * {
939 * pointer-events: all;
940 * }
941 *
942 * box-only is the equivalent of
943 *
944 * .box-only {
945 * pointer-events: all;
946 * }
947 * .box-only * {
948 * pointer-events: none;
949 * }
950 *
951 * But since pointerEvents does not affect layout/appearance, and we are already deviating from the spec by adding additional modes,
952 * 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.
953 */
954 pointerEvents?: string;
955
956 /**
957 *
958 * This is a special performance property exposed by RCTView and is useful for scrolling content when there are many subviews,
959 * 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.
960 * The subviews must also have overflow: hidden, as should the containing view (or one of its superviews).
961 */
962 removeClippedSubviews?: boolean
963
964 style?: ViewStyle;
965
966 /**
967 * Used to locate this view in end-to-end tests.
968 */
969 testID?: string;
970 }
971
972 /**
973 * The most fundamental component for building UI, View is a container that supports layout with flexbox, style, some touch handling,
974 * and accessibility controls, and is designed to be nested inside other views and to have 0 to many children of any type.
975 * View maps directly to the native view equivalent on whatever platform React is running on,
976 * whether that is a UIView, <div>, android.view, etc.
977 */
978 export interface ViewStatic extends NativeComponent, React.ComponentClass<ViewProperties> {
979
980 }
981
982 /**
983 * //FIXME: No documentation extracted from code comment on WebView.ios.js
984 */
985 export interface NavState {
986
987 url?: string
988 title?: string
989 loading?: boolean
990 canGoBack?: boolean
991 canGoForward?: boolean;
992
993 [key: string]: any
994 }
995
996 export interface WebViewPropertiesAndroid {
997
998 /**
999 * Used for android only, JS is enabled by default for WebView on iOS
1000 */
1001 javaScriptEnabledAndroid?: boolean
1002 }
1003
1004 export interface WebViewPropertiesIOS {
1005
1006 /**
1007 * Used for iOS only, sets whether the webpage scales to fit the view and the user can change the scale
1008 */
1009 scalesPageToFit?: boolean
1010 }
1011
1012 /**
1013 * @see https://facebook.github.io/react-native/docs/webview.html#props
1014 */
1015 export interface WebViewProperties extends WebViewPropertiesAndroid, WebViewPropertiesIOS, React.Props<WebViewStatic> {
1016
1017 automaticallyAdjustContentInsets?: boolean
1018
1019 bounces?: boolean
1020
1021 contentInset?: Insets
1022
1023 html?: string
1024
1025 /**
1026 * Sets the JS to be injected when the webpage loads.
1027 */
1028 injectedJavaScript?: string
1029
1030 onNavigationStateChange?: ( event: NavState ) => void
1031
1032 /**
1033 * Allows custom handling of any webview requests by a JS handler.
1034 * Return true or false from this method to continue loading the request.
1035 */
1036 onShouldStartLoadWithRequest?: () => boolean
1037
1038 /**
1039 * view to show if there's an error
1040 */
1041 renderError?: () => ViewStatic
1042
1043 /**
1044 * loading indicator to show
1045 */
1046 renderLoading?: () => ViewStatic
1047
1048 scrollEnabled?: boolean
1049
1050 startInLoadingState?: boolean
1051
1052 style?: ViewStyle
1053
1054 url: string
1055 }
1056
1057
1058 export interface WebViewStatic extends React.ComponentClass<WebViewProperties> {
1059
1060 goBack: () => void
1061 goForward: () => void
1062 reload: () => void
1063 }
1064
1065
1066 /**
1067 * @see
1068 */
1069 export interface SegmentedControlIOSProperties {
1070 /// TODO
1071 }
1072
1073
1074 export interface NavigatorIOSProperties extends React.Props<NavigatorIOSStatic> {
1075
1076 /**
1077 * NavigatorIOS uses "route" objects to identify child views, their props, and navigation bar configuration.
1078 * "push" and all the other navigation operations expect routes to be like this
1079 */
1080 initialRoute?: Route
1081
1082 /**
1083 * The default wrapper style for components in the navigator.
1084 * A common use case is to set the backgroundColor for every page
1085 */
1086 itemWrapperStyle?: ViewStyle
1087
1088 /**
1089 * A Boolean value that indicates whether the navigation bar is hidden
1090 */
1091 navigationBarHidden?: boolean
1092
1093 /**
1094 * A Boolean value that indicates whether to hide the 1px hairline shadow
1095 */
1096 shadowHidden?: boolean
1097
1098 /**
1099 * The color used for buttons in the navigation bar
1100 */
1101 tintColor?: string
1102
1103 /**
1104 * The text color of the navigation bar title
1105 */
1106 titleTextColor?: string
1107
1108 /**
1109 * A Boolean value that indicates whether the navigation bar is translucent
1110 */
1111 translucent?: boolean
1112
1113 /**
1114 * NOT IN THE DOC BUT IN THE EXAMPLES
1115 */
1116 style?: ViewStyle
1117 }
1118
1119 /**
1120 * A navigator is an object of navigation functions that a view can call.
1121 * It is passed as a prop to any component rendered by NavigatorIOS.
1122 *
1123 * Navigator functions are also available on the NavigatorIOS component:
1124 *
1125 * @see https://facebook.github.io/react-native/docs/navigatorios.html#navigator
1126 */
1127 export interface NavigationIOS {
1128 /**
1129 * Navigate forward to a new route
1130 */
1131 push: ( route: Route ) => void
1132
1133 /**
1134 * Go back one page
1135 */
1136 pop: () => void
1137
1138 /**
1139 * Go back N pages at once. When N=1, behavior matches pop()
1140 */
1141 popN: ( n: number ) => void
1142
1143 /**
1144 * Replace the route for the current page and immediately load the view for the new route
1145 */
1146 replace: ( route: Route ) => void
1147
1148 /**
1149 * Replace the route/view for the previous page
1150 */
1151 replacePrevious: ( route: Route ) => void
1152
1153 /**
1154 * Replaces the previous route/view and transitions back to it
1155 */
1156 replacePreviousAndPop: ( route: Route ) => void
1157
1158 /**
1159 * Replaces the top item and popToTop
1160 */
1161 resetTo: ( route: Route ) => void
1162
1163 /**
1164 * Go back to the item for a particular route object
1165 */
1166 popToRoute( route: Route ): void
1167
1168 /**
1169 * Go back to the top item
1170 */
1171 popToTop(): void
1172 }
1173
1174 export interface NavigatorIOSStatic extends NavigationIOS, React.ComponentClass<NavigatorIOSProperties> {
1175 }
1176
1177
1178 /**
1179 * @see https://facebook.github.io/react-native/docs/activityindicatorios.html#props
1180 */
1181 export interface ActivityIndicatorIOSProperties extends React.Props<ActivityIndicatorIOSStatic> {
1182
1183 /**
1184 * Whether to show the indicator (true, the default) or hide it (false).
1185 */
1186 animating?: boolean
1187
1188 /**
1189 * The foreground color of the spinner (default is gray).
1190 */
1191 color?: string
1192
1193 /**
1194 * Whether the indicator should hide when not animating (true by default).
1195 */
1196 hidesWhenStopped?: boolean
1197
1198 /**
1199 * Invoked on mount and layout changes with
1200 */
1201 onLayout?: ( event: {nativeEvent: { layout: {x: number, y: number , width: number, height: number}}} ) => void
1202
1203 /**
1204 * Size of the indicator.
1205 * Small has a height of 20, large has a height of 36.
1206 *
1207 * enum('small', 'large')
1208 */
1209 size?: string
1210
1211 style?: ViewStyle
1212 }
1213
1214 export interface ActivityIndicatorIOSStatic extends React.ComponentClass<ActivityIndicatorIOSProperties> {
1215 }
1216
1217
1218 export interface DatePickerIOSProperties extends React.Props<DatePickerIOSStatic> {
1219
1220 /**
1221 * The currently selected date.
1222 */
1223 date?: Date
1224
1225
1226 /**
1227 * Maximum date.
1228 * Restricts the range of possible date/time values.
1229 */
1230 maximumDate?: Date
1231
1232 /**
1233 * Maximum date.
1234 * Restricts the range of possible date/time values.
1235 */
1236 minimumDate?: Date
1237
1238 /**
1239 * enum(1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30)
1240 * The interval at which minutes can be selected.
1241 */
1242 minuteInterval?: number
1243
1244 /**
1245 * enum('date', 'time', 'datetime')
1246 * The date picker mode.
1247 */
1248 mode?: string
1249
1250 /**
1251 * Date change handler.
1252 * This is called when the user changes the date or time in the UI.
1253 * The first and only argument is a Date object representing the new date and time.
1254 */
1255 onDateChange?: ( newDate: Date ) => void
1256
1257 /**
1258 * Timezone offset in minutes.
1259 * By default, the date picker will use the device's timezone. With this parameter, it is possible to force a certain timezone offset.
1260 * For instance, to show times in Pacific Standard Time, pass -7 * 60.
1261 */
1262 timeZoneOffsetInMinutes?: number
1263
1264 }
1265
1266 export interface DatePickerIOSStatic extends React.ComponentClass<DatePickerIOSProperties> {
1267 }
1268
1269
1270 /**
1271 * @see PickerIOS.ios.js
1272 */
1273 export interface PickerIOSItemProperties extends React.Props<PickerIOSItemStatic> {
1274 value?: string | number
1275 label?: string
1276 }
1277
1278 /**
1279 * @see PickerIOS.ios.js
1280 */
1281 export interface PickerIOSItemStatic extends React.ComponentClass<PickerIOSItemProperties> {
1282 }
1283
1284
1285 /**
1286 * @see https://facebook.github.io/react-native/docs/pickerios.html
1287 * @see PickerIOS.ios.js
1288 */
1289 export interface PickerIOSProperties extends React.Props<PickerIOSStatic> {
1290
1291 onValueChange?: ( value: string | number ) => void
1292
1293 selectedValue?: string | number
1294
1295 style?: ViewStyle
1296 }
1297
1298 /**
1299 * @see https://facebook.github.io/react-native/docs/pickerios.html
1300 * @see PickerIOS.ios.js
1301 */
1302 export interface PickerIOSStatic extends React.ComponentClass<PickerIOSProperties> {
1303
1304 Item: PickerIOSItemStatic
1305 }
1306
1307
1308 /**
1309 * @see https://facebook.github.io/react-native/docs/sliderios.html
1310 */
1311 export interface SliderIOSProperties extends React.Props<SliderIOSStatic> {
1312
1313 /**
1314 * If true the user won't be able to move the slider. Default value is false.
1315 */
1316 disabled?: boolean
1317
1318 /**
1319 * Initial maximum value of the slider. Default value is 1.
1320 */
1321 maximumValue?: number
1322
1323 /**
1324 * The color used for the track to the right of the button. Overrides the default blue gradient image.
1325 */
1326 maximumTrackTintColor?: string
1327
1328 /**
1329 * Initial minimum value of the slider. Default value is 0.
1330 */
1331 minimumValue?: number
1332
1333 /**
1334 * The color used for the track to the left of the button. Overrides the default blue gradient image.
1335 */
1336 minimumTrackTintColor?: string
1337
1338 /**
1339 * Callback called when the user finishes changing the value (e.g. when the slider is released).
1340 */
1341 onSlidingComplete?: () => void
1342
1343 /**
1344 * Callback continuously called while the user is dragging the slider.
1345 */
1346 onValueChange?: ( value: number ) => void
1347
1348 /**
1349 * Step value of the slider.
1350 * The value should be between 0 and (maximumValue - minimumValue).
1351 * Default value is 0.
1352 */
1353 step?: number
1354
1355 /**
1356 * Used to style and layout the Slider.
1357 * @see StyleSheet.js and ViewStylePropTypes.js for more info.
1358 */
1359 style?: ViewStyle
1360
1361 /**
1362 * Initial value of the slider.
1363 * The value should be between minimumValue and maximumValue, which default to 0 and 1 respectively.
1364 * Default value is 0.
1365 *
1366 * This is not a controlled component, e.g. if you don't update the value, the component won't be reset to its inital value.
1367 */
1368 value?: number
1369 }
1370
1371 export interface SliderIOSStatic extends React.ComponentClass<SliderIOSProperties> {
1372
1373 }
1374
1375 /**
1376 * //FIXME: no dcumentation, inferred
1377 * @see SwitchIOS.ios.js
1378 */
1379 export interface SwitchIOSStyle extends ViewStyle {
1380 height?: number
1381 width?: number
1382 }
1383
1384
1385 /**
1386 * https://facebook.github.io/react-native/docs/switchios.html#props
1387 */
1388 export interface SwitchIOSProperties extends React.Props<SwitchIOSStatic> {
1389
1390 /**
1391 * If true the user won't be able to toggle the switch. Default value is false.
1392 */
1393 disabled?: boolean
1394
1395 /**
1396 * Background color when the switch is turned on.
1397 */
1398 onTintColor?: string
1399
1400 /**
1401 * Callback that is called when the user toggles the switch.
1402 */
1403 onValueChange?: ( value: boolean ) => void
1404
1405 /**
1406 * Background color for the switch round button.
1407 */
1408 thumbTintColor?: string
1409
1410 /**
1411 * Background color when the switch is turned off.
1412 */
1413 tintColor?: string
1414
1415 /**
1416 * The value of the switch, if true the switch will be turned on. Default value is false.
1417 */
1418 value?: boolean
1419
1420 style?: SwitchIOSStyle
1421 }
1422
1423 /**
1424 *
1425 * Use SwitchIOS to render a boolean input on iOS.
1426 *
1427 * 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,
1428 * otherwise the user's change will be reverted immediately to reflect props.value as the source of truth.
1429 *
1430 * @see https://facebook.github.io/react-native/docs/switchios.html
1431 */
1432 export interface SwitchIOSStatic extends React.ComponentClass<SwitchIOSProperties> {
1433
1434 }
1435
1436
1437 /**
1438 * @see ImageResizeMode.js
1439 */
1440 export interface ImageResizeModeStatic {
1441 /**
1442 * contain - The image will be resized such that it will be completely
1443 * visible, contained within the frame of the View.
1444 */
1445 contain: string
1446 /**
1447 * cover - The image will be resized such that the entire area of the view
1448 * is covered by the image, potentially clipping parts of the image.
1449 */
1450 cover: string
1451 /**
1452 * stretch - The image will be stretched to fill the entire frame of the
1453 * view without clipping. This may change the aspect ratio of the image,
1454 * distoring it. Only supported on iOS.
1455 */
1456 stretch: string
1457 }
1458
1459 /**
1460 * Image style
1461 * @see https://facebook.github.io/react-native/docs/image.html#style
1462 */
1463 export interface ImageStyle extends FlexStyle, TransformsStyle {
1464 resizeMode?: string //Object.keys(ImageResizeMode)
1465 backgroundColor?: string
1466 borderColor?: string
1467 borderWidth?: number
1468 borderRadius?: number
1469 overflow?: string // enum('visible', 'hidden')
1470 tintColor?: string
1471 opacity?: number
1472 }
1473
1474 export interface ImagePropertiesIOS {
1475 /**
1476 * The text that's read by the screen reader when the user interacts with the image.
1477 */
1478 accessibilityLabel?: string;
1479
1480 /**
1481 * When true, indicates the image is an accessibility element.
1482 */
1483 accessible?: boolean;
1484
1485 /**
1486 * When the image is resized, the corners of the size specified by capInsets will stay a fixed size,
1487 * but the center content and borders of the image will be stretched.
1488 * This is useful for creating resizable rounded buttons, shadows, and other resizable assets.
1489 * More info on Apple documentation
1490 */
1491 capInsets?: Insets
1492
1493 /**
1494 * A static image to display while downloading the final image off the network.
1495 */
1496 defaultSource?: {uri: string}
1497
1498 /**
1499 * Invoked on load error with {nativeEvent: {error}}
1500 */
1501 onError?: ( error: {nativeEvent: any} ) => void
1502
1503 /**
1504 * Invoked when load completes successfully
1505 */
1506 onLoad?: () => void
1507
1508 /**
1509 * Invoked when load either succeeds or fails
1510 */
1511 onLoadEnd?: () => void
1512
1513 /**
1514 * Invoked on load start
1515 */
1516 onLoadStart?: () => void
1517
1518 /**
1519 * Invoked on download progress with {nativeEvent: {loaded, total}}
1520 */
1521 onProgress?: ()=> void
1522 }
1523
1524 /**
1525 * @see https://facebook.github.io/react-native/docs/image.html
1526 */
1527 export interface ImageProperties extends ImagePropertiesIOS, React.Props<Image> {
1528 /**
1529 * onLayout function
1530 *
1531 * Invoked on mount and layout changes with
1532 *
1533 * {nativeEvent: { layout: {x, y, width, height}}}.
1534 */
1535 onLayout?: ( event: LayoutChangeEvent ) => void;
1536
1537
1538 /**
1539 * Determines how to resize the image when the frame doesn't match the raw image dimensions.
1540 *
1541 * enum('cover', 'contain', 'stretch')
1542 */
1543 resizeMode?: string;
1544
1545 /**
1546 * uri is a string representing the resource identifier for the image,
1547 * which could be an http address, a local file path,
1548 * or the name of a static image resource (which should be wrapped in the require('image!name') function).
1549 */
1550 source: {uri: string} | string;
1551
1552 /**
1553 *
1554 * Style
1555 */
1556 style?: ImageStyle;
1557
1558 /**
1559 * A unique identifier for this element to be used in UI Automation testing scripts.
1560 */
1561 testID?: string;
1562
1563 }
1564
1565 export interface ImageStatic extends React.ComponentClass<ImageProperties> {
1566 uri: string;
1567 resizeMode: ImageResizeModeStatic
1568 }
1569
1570
1571 /**
1572 * @see https://facebook.github.io/react-native/docs/listview.html#props
1573 */
1574 export interface ListViewProperties extends ScrollViewProperties, React.Props<ListViewStatic> {
1575
1576 dataSource?: ListViewDataSource
1577
1578 /**
1579 * How many rows to render on initial component mount. Use this to make
1580 * it so that the first screen worth of data apears at one time instead of
1581 * over the course of multiple frames.
1582 */
1583 initialListSize?: number
1584
1585 /**
1586 * (visibleRows, changedRows) => void
1587 *
1588 * Called when the set of visible rows changes. `visibleRows` maps
1589 * { sectionID: { rowID: true }} for all the visible rows, and
1590 * `changedRows` maps { sectionID: { rowID: true | false }} for the rows
1591 * that have changed their visibility, with true indicating visible, and
1592 * false indicating the view has moved out of view.
1593 */
1594 onChangeVisibleRows?: ( visibleRows: Array<{[sectionId: string]: {[rowID: string]: boolean}}>, changedRows: Array<{[sectionId: string]: {[rowID: string]: boolean}}> ) => void
1595
1596 /**
1597 * Called when all rows have been rendered and the list has been scrolled
1598 * to within onEndReachedThreshold of the bottom. The native scroll
1599 * event is provided.
1600 */
1601 onEndReached?: () => void
1602
1603 /**
1604 * Threshold in pixels for onEndReached.
1605 */
1606 onEndReachedThreshold?: number
1607
1608 /**
1609 * Number of rows to render per event loop.
1610 */
1611 pageSize?: number
1612
1613 /**
1614 * An experimental performance optimization for improving scroll perf of
1615 * large lists, used in conjunction with overflow: 'hidden' on the row
1616 * containers. Use at your own risk.
1617 */
1618 removeClippedSubviews?: boolean
1619
1620 /**
1621 * () => renderable
1622 *
1623 * The header and footer are always rendered (if these props are provided)
1624 * on every render pass. If they are expensive to re-render, wrap them
1625 * in StaticContainer or other mechanism as appropriate. Footer is always
1626 * at the bottom of the list, and header at the top, on every render pass.
1627 */
1628 renderFooter?: () => React.ReactElement<any>
1629
1630 /**
1631 * () => renderable
1632 *
1633 * The header and footer are always rendered (if these props are provided)
1634 * on every render pass. If they are expensive to re-render, wrap them
1635 * in StaticContainer or other mechanism as appropriate. Footer is always
1636 * at the bottom of the list, and header at the top, on every render pass.
1637 */
1638 renderHeader?: () => React.ReactElement<any>
1639
1640 /**
1641 * (rowData, sectionID, rowID) => renderable
1642 * Takes a data entry from the data source and its ids and should return
1643 * a renderable component to be rendered as the row. By default the data
1644 * is exactly what was put into the data source, but it's also possible to
1645 * provide custom extractors.
1646 */
1647 renderRow?: ( rowData: any, sectionID: string | number, rowID: string | number, highlightRow?: boolean ) => React.ReactElement<any>
1648
1649
1650 /**
1651 * A function that returns the scrollable component in which the list rows are rendered.
1652 * Defaults to returning a ScrollView with the given props.
1653 */
1654 renderScrollComponent?: ( props: ScrollViewProperties ) => React.ReactElement<ScrollViewProperties>
1655
1656 /**
1657 * (sectionData, sectionID) => renderable
1658 *
1659 * If provided, a sticky header is rendered for this section. The sticky
1660 * behavior means that it will scroll with the content at the top of the
1661 * section until it reaches the top of the screen, at which point it will
1662 * stick to the top until it is pushed off the screen by the next section
1663 * header.
1664 */
1665 renderSectionHeader?: ( sectionData: any, sectionId: string | number ) => React.ReactElement<any>
1666
1667
1668 /**
1669 * (sectionID, rowID, adjacentRowHighlighted) => renderable
1670 * If provided, a renderable component to be rendered as the separator below each row
1671 * but not the last row if there is a section header below.
1672 * Take a sectionID and rowID of the row above and whether its adjacent row is highlighted.
1673 */
1674 renderSeparator?: ( sectionID: string | number, rowID: string | number, adjacentRowHighlighted?: boolean ) => React.ReactElement<any>
1675
1676 /**
1677 * How early to start rendering rows before they come on screen, in
1678 * pixels.
1679 */
1680 scrollRenderAheadDistance?: number
1681 }
1682
1683 export interface ListViewStatic extends React.ComponentClass<ListViewProperties> {
1684 DataSource: ListViewDataSource;
1685 }
1686
1687
1688 export interface MapViewAnnotation {
1689 latitude?: number
1690 longitude?: number
1691 animateDrop?: boolean
1692 title?: string
1693 subtitle?: string
1694 hasLeftCallout?: boolean
1695 hasRightCallout?: boolean
1696 onLeftCalloutPress?: () => void
1697 onRightCalloutPress?: () => void
1698 id?: string
1699 }
1700
1701 export interface MapViewRegion {
1702 latitude: number
1703 longitude: number
1704 latitudeDelta: number
1705 longitudeDelta: number
1706 }
1707
1708 export interface MapViewPropertiesIOS {
1709
1710 /**
1711 * If false points of interest won't be displayed on the map.
1712 * Default value is true.
1713 */
1714 showsPointsOfInterest?: boolean
1715 }
1716
1717 export interface MapViewProperties extends MapViewPropertiesIOS, Touchable, React.Props<MapViewStatic> {
1718
1719 /**
1720 * Map annotations with title/subtitle.
1721 */
1722 annotations?: MapViewAnnotation[]
1723
1724 /**
1725 * Insets for the map's legal label, originally at bottom left of the map. See EdgeInsetsPropType.js for more information.
1726 */
1727 legalLabelInsets?: Insets
1728
1729 /**
1730 * The map type to be displayed.
1731 * standard: standard road map (default)
1732 * satellite: satellite view
1733 * hybrid: satellite view with roads and points of interest overlayed
1734 *
1735 * enum('standard', 'satellite', 'hybrid')
1736 */
1737 mapType?: string
1738
1739 /**
1740 * Maximum size of area that can be displayed.
1741 */
1742 maxDelta?: number
1743
1744 /**
1745 * Minimum size of area that can be displayed.
1746 */
1747 minDelta?: number
1748
1749 /**
1750 * Callback that is called once, when the user taps an annotation.
1751 */
1752 onAnnotationPress?: () => void
1753
1754 /**
1755 * Callback that is called continuously when the user is dragging the map.
1756 */
1757 onRegionChange?: ( region: MapViewRegion ) => void
1758
1759 /**
1760 * Callback that is called once, when the user is done moving the map.
1761 */
1762 onRegionChangeComplete?: ( region: MapViewRegion ) => void
1763
1764 /**
1765 * When this property is set to true and a valid camera is associated with the map,
1766 * the camera’s pitch angle is used to tilt the plane of the map.
1767 *
1768 * When this property is set to false, the camera’s pitch angle is ignored and
1769 * the map is always displayed as if the user is looking straight down onto it.
1770 */
1771 pitchEnabled?: boolean
1772
1773 /**
1774 * The region to be displayed by the map.
1775 * The region is defined by the center coordinates and the span of coordinates to display.
1776 */
1777 region?: MapViewRegion
1778
1779 /**
1780 * When this property is set to true and a valid camera is associated with the map,
1781 * the camera’s heading angle is used to rotate the plane of the map around its center point.
1782 *
1783 * When this property is set to false, the camera’s heading angle is ignored and the map is always oriented
1784 * so that true north is situated at the top of the map view
1785 */
1786 rotateEnabled?: boolean
1787
1788 /**
1789 * If false the user won't be able to change the map region being displayed.
1790 * Default value is true.
1791 */
1792 scrollEnabled?: boolean
1793
1794 /**
1795 * If true the app will ask for the user's location and focus on it.
1796 * Default value is false.
1797 *
1798 * NOTE: You need to add NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation,
1799 * otherwise it is going to fail silently!
1800 */
1801 showsUserLocation?: boolean
1802
1803 /**
1804 * Used to style and layout the MapView.
1805 * See StyleSheet.js and ViewStylePropTypes.js for more info.
1806 */
1807 style?: ViewStyle
1808
1809 /**
1810 * If false the user won't be able to pinch/zoom the map.
1811 * Default value is true.
1812 */
1813 zoomEnabled?: boolean
1814 }
1815
1816 /**
1817 * @see https://facebook.github.io/react-native/docs/mapview.html#content
1818 */
1819 export interface MapViewStatic extends React.ComponentClass<MapViewProperties> {
1820 }
1821
1822
1823 export interface TouchableWithoutFeedbackAndroidProperties {
1824
1825 /**
1826 * Indicates to accessibility services to treat UI component like a native one.
1827 * Works for Android only.
1828 *
1829 * @enum('none', 'button', 'radiobutton_checked', 'radiobutton_unchecked' )
1830 */
1831 accessibilityComponentType?: string
1832 }
1833
1834 export interface TouchableWithoutFeedbackIOSProperties {
1835
1836 /**
1837 * Provides additional traits to screen reader.
1838 * By default no traits are provided unless specified otherwise in element
1839 *
1840 * @enum('none', 'button', 'link', 'header', 'search', 'image', 'selected', 'plays', 'key', 'text','summary', 'disabled', 'frequentUpdates', 'startsMedia', 'adjustable', 'allowsDirectInteraction', 'pageTurn')
1841 */
1842 accessibilityTraits?: string | string[];
1843
1844 }
1845
1846 /**
1847 * @see https://facebook.github.io/react-native/docs/touchablewithoutfeedback.html#props
1848 */
1849 export interface TouchableWithoutFeedbackProperties extends TouchableWithoutFeedbackAndroidProperties, TouchableWithoutFeedbackIOSProperties {
1850
1851
1852 /**
1853 * Called when the touch is released, but not if cancelled (e.g. by a scroll that steals the responder lock).
1854 */
1855 accessible?: boolean
1856
1857 /**
1858 * Delay in ms, from onPressIn, before onLongPress is called.
1859 */
1860 delayLongPress?: number;
1861
1862 /**
1863 * Delay in ms, from the start of the touch, before onPressIn is called.
1864 */
1865 delayPressIn?: number;
1866
1867 /**
1868 * Delay in ms, from the release of the touch, before onPressOut is called.
1869 */
1870 delayPressOut?: number;
1871
1872 /**
1873 * Invoked on mount and layout changes with
1874 * {nativeEvent: {layout: {x, y, width, height}}}
1875 */
1876 onLayout?: ( event: LayoutChangeEvent ) => void
1877
1878 onLongPress?: () => void;
1879
1880 /**
1881 * Called when the touch is released,
1882 * but not if cancelled (e.g. by a scroll that steals the responder lock).
1883 */
1884 onPress?: () => void;
1885
1886 onPressIn?: () => void;
1887
1888 onPressOut?: () => void;
1889
1890 /**
1891 * //FIXME: not in doc but available in exmaples
1892 */
1893 style?: ViewStyle
1894 }
1895
1896
1897 export interface TouchableWithoutFeedbackProps extends TouchableWithoutFeedbackProperties, React.Props<TouchableWithoutFeedbackStatic> {
1898
1899 }
1900
1901 /**
1902 * Do not use unless you have a very good reason.
1903 * All the elements that respond to press should have a visual feedback when touched.
1904 * This is one of the primary reason a "web" app doesn't feel "native".
1905 *
1906 * @see https://facebook.github.io/react-native/docs/touchablewithoutfeedback.html
1907 */
1908 export interface TouchableWithoutFeedbackStatic extends React.ComponentClass<TouchableWithoutFeedbackProps> {
1909
1910 }
1911
1912
1913 /**
1914 * @see https://facebook.github.io/react-native/docs/touchablehighlight.html#props
1915 */
1916 export interface TouchableHighlightProperties extends TouchableWithoutFeedbackProperties, React.Props<TouchableHighlightStatic> {
1917
1918 /**
1919 * Determines what the opacity of the wrapped view should be when touch is active.
1920 */
1921 activeOpacity?: number
1922
1923 /**
1924 *
1925 * Called immediately after the underlay is hidden
1926 */
1927 onHideUnderlay?: () => void
1928
1929 /**
1930 * Called immediately after the underlay is shown
1931 */
1932 onShowUnderlay?: () => void
1933
1934 /**
1935 * @see https://facebook.github.io/react-native/docs/view.html#style
1936 */
1937 style?: ViewStyle
1938
1939
1940 /**
1941 * The color of the underlay that will show through when the touch is active.
1942 */
1943 underlayColor?: string
1944 }
1945
1946 /**
1947 * A wrapper for making views respond properly to touches.
1948 * On press down, the opacity of the wrapped view is decreased,
1949 * which allows the underlay color to show through, darkening or tinting the view.
1950 * The underlay comes from adding a view to the view hierarchy,
1951 * which can sometimes cause unwanted visual artifacts if not used correctly,
1952 * for example if the backgroundColor of the wrapped view isn't explicitly set to an opaque color.
1953 *
1954 * NOTE: TouchableHighlight supports only one child
1955 * If you wish to have several child components, wrap them in a View.
1956 *
1957 * @see https://facebook.github.io/react-native/docs/touchablehighlight.html
1958 */
1959 export interface TouchableHighlightStatic extends React.ComponentClass<TouchableHighlightProperties> {
1960 }
1961
1962
1963 /**
1964 * @see https://facebook.github.io/react-native/docs/touchableopacity.html#props
1965 */
1966 export interface TouchableOpacityProperties extends TouchableWithoutFeedbackProperties, React.Props<TouchableOpacityStatic> {
1967 /**
1968 * Determines what the opacity of the wrapped view should be when touch is active.
1969 * Defaults to 0.2
1970 */
1971 activeOpacity?: number
1972 }
1973
1974 /**
1975 * A wrapper for making views respond properly to touches.
1976 * On press down, the opacity of the wrapped view is decreased, dimming it.
1977 * This is done without actually changing the view hierarchy,
1978 * and in general is easy to add to an app without weird side-effects.
1979 *
1980 * @see https://facebook.github.io/react-native/docs/touchableopacity.html
1981 */
1982 export interface TouchableOpacityStatic extends React.ComponentClass<TouchableOpacityProperties> {
1983 }
1984
1985
1986 /**
1987 * @see https://facebook.github.io/react-native/docs/touchableopacity.html#props
1988 */
1989 export interface TouchableNativeFeedbackProperties extends TouchableWithoutFeedbackProperties, React.Props<TouchableNativeFeedbackStatic> {
1990 /**
1991 * Determines the type of background drawable that's going to be used to display feedback.
1992 * It takes an object with type property and extra data depending on the type.
1993 * It's recommended to use one of the following static methods to generate that dictionary:
1994 * 1) TouchableNativeFeedback.SelectableBackground() - will create object that represents android theme's default background for selectable elements (?android:attr/selectableItemBackground)
1995 * 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+
1996 * 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+
1997 */
1998 background?: any
1999 }
2000
2001 /**
2002 * A wrapper for making views respond properly to touches (Android only).
2003 * On Android this component uses native state drawable to display touch feedback.
2004 * At the moment it only supports having a single View instance as a child node,
2005 * as it's implemented by replacing that View with another instance of RCTView node with some additional properties set.
2006 *
2007 * Background drawable of native feedback touchable can be customized with background property.
2008 *
2009 * @see https://facebook.github.io/react-native/docs/touchablenativefeedback.html#content
2010 */
2011 export interface TouchableNativeFeedbackStatic extends React.ComponentClass<TouchableNativeFeedbackProperties> {
2012 SelectableBackground: () => TouchableNativeFeedbackStatic
2013 SelectableBackgroundBorderless: () => TouchableNativeFeedbackStatic
2014 Ripple: ( color: string, borderless?: boolean ) => TouchableNativeFeedbackStatic
2015 }
2016
2017
2018 export interface LeftToRightGesture {
2019 //TODO:
2020 }
2021
2022 export interface AnimationInterpolator {
2023 //TODO:
2024 }
2025
2026 // see /NavigatorSceneConfigs.js
2027 export interface SceneConfig {
2028 // A list of all gestures that are enabled on this scene
2029 gestures: {
2030 pop: LeftToRightGesture,
2031 },
2032
2033 // Rebound spring parameters when transitioning FROM this scene
2034 springFriction: number;
2035 springTension: number;
2036
2037 // Velocity to start at when transitioning without gesture
2038 defaultTransitionVelocity: number;
2039
2040 // Animation interpolators for horizontal transitioning:
2041 animationInterpolators: {
2042 into: AnimationInterpolator,
2043 out: AnimationInterpolator
2044 };
2045
2046 }
2047
2048 // see /NavigatorSceneConfigs.js
2049 export interface SceneConfigs {
2050 FloatFromBottom: SceneConfig;
2051 FloatFromRight: SceneConfig;
2052 PushFromRight: SceneConfig;
2053 FloatFromLeft: SceneConfig;
2054 HorizontalSwipeJump: SceneConfig;
2055 }
2056
2057 export interface Route {
2058 component?: ComponentClass<ViewProperties>
2059 id?: string
2060 title?: string
2061 passProps?: Object;
2062
2063 //anything else
2064 [key: string]: any
2065
2066 //Commonly found properties
2067 backButtonTitle?: string
2068 content?: string
2069 message?: string;
2070 index?: number
2071 onRightButtonPress?: () => void
2072 rightButtonTitle?: string
2073 sceneConfig?: SceneConfig
2074 wrapperStyle?: any
2075 }
2076
2077
2078 /**
2079 * @see https://facebook.github.io/react-native/docs/navigator.html#content
2080 */
2081 export interface NavigatorProperties extends React.Props<Navigator> {
2082 /**
2083 * Optional function that allows configuration about scene animations and gestures.
2084 * Will be invoked with the route and should return a scene configuration object
2085 * @param route
2086 */
2087 configureScene?: ( route: Route ) => SceneConfig
2088 /**
2089 * Specify a route to start on.
2090 * A route is an object that the navigator will use to identify each scene to render.
2091 * initialRoute must be a route in the initialRouteStack if both props are provided.
2092 * The initialRoute will default to the last item in the initialRouteStack.
2093 */
2094 initialRoute?: Route
2095 /**
2096 * Provide a set of routes to initially mount.
2097 * Required if no initialRoute is provided.
2098 * Otherwise, it will default to an array containing only the initialRoute
2099 */
2100 initialRouteStack?: Route[]
2101
2102 /**
2103 * Optionally provide a navigation bar that persists across scene transitions
2104 */
2105 navigationBar?: React.ReactElement<NavigatorStatic.NavigationBarProperties>
2106
2107 /**
2108 * Optionally provide the navigator object from a parent Navigator
2109 */
2110 navigator?: Navigator
2111
2112 /**
2113 * @deprecated Use navigationContext.addListener('willfocus', callback) instead.
2114 */
2115 onDidFocus?: Function
2116
2117 /**
2118 * @deprecated Use navigationContext.addListener('willfocus', callback) instead.
2119 */
2120 onWillFocus?: Function
2121
2122 /**
2123 * Required function which renders the scene for a given route.
2124 * Will be invoked with the route and the navigator object
2125 * @param route
2126 * @param navigator
2127 */
2128 renderScene?: ( route: Route, navigator: Navigator ) => React.ReactElement<ViewProperties>
2129
2130 /**
2131 * Styles to apply to the container of each scene
2132 */
2133 sceneStyle?: ViewStyle
2134
2135 /**
2136 * //FIXME: not found in doc but found in examples
2137 */
2138 debugOverlay?: boolean
2139
2140 }
2141
2142 /**
2143 * Use Navigator to transition between different scenes in your app.
2144 * To accomplish this, provide route objects to the navigator to identify each scene,
2145 * and also a renderScene function that the navigator can use to render the scene for a given route.
2146 *
2147 * To change the animation or gesture properties of the scene, provide a configureScene prop to get the config object for a given route.
2148 * See Navigator.SceneConfigs for default animations and more info on scene config options.
2149 * @see https://facebook.github.io/react-native/docs/navigator.html
2150 */
2151 export interface NavigatorStatic extends React.ComponentClass<NavigatorProperties> {
2152 SceneConfigs: SceneConfigs;
2153 NavigationBar: NavigatorStatic.NavigationBarStatic;
2154 BreadcrumbNavigationBar: NavigatorStatic.BreadcrumbNavigationBarStatic
2155
2156 getContext( self: any ): NavigatorStatic;
2157
2158 /**
2159 * returns the current list of routes
2160 */
2161 getCurrentRoutes(): Route[];
2162
2163 /**
2164 * Jump backward without unmounting the current scen
2165 */
2166 jumpBack(): void;
2167
2168 /**
2169 * Jump forward to the next scene in the route stack
2170 */
2171 jumpForward(): void;
2172
2173 /**
2174 * Transition to an existing scene without unmounting
2175 */
2176 jumpTo( route: Route ): void;
2177
2178 /**
2179 * Navigate forward to a new scene, squashing any scenes that you could jumpForward to
2180 */
2181 push( route: Route ): void;
2182
2183 /**
2184 * Transition back and unmount the current scene
2185 */
2186 pop(): void;
2187
2188 /**
2189 * Replace the current scene with a new route
2190 */
2191 replace( route: Route ): void;
2192
2193 /**
2194 * Replace a scene as specified by an index
2195 */
2196 replaceAtIndex( route: Route, index: number ): void;
2197
2198 /**
2199 * Replace the previous scene
2200 */
2201 replacePrevious( route: Route ): void;
2202
2203 /**
2204 * Reset every scene with an array of routes
2205 */
2206 immediatelyResetRouteStack( routes: Route[] ): void;
2207
2208 /**
2209 * Pop to a particular scene, as specified by its route. All scenes after it will be unmounted
2210 */
2211 popToRoute( route: Route ): void;
2212
2213 /**
2214 * Pop to the first scene in the stack, unmounting every other scene
2215 */
2216 popToTop(): void;
2217
2218 }
2219
2220 namespace NavigatorStatic {
2221
2222
2223 export interface NavState {
2224 routeStack: Route[]
2225 idStack: number[]
2226 presentedIndex: number
2227 }
2228
2229 export interface NavigationBarStyle {
2230 //TODO @see NavigationBarStyle.ios.js
2231 }
2232
2233
2234 export interface NavigationBarRouteMapper {
2235 Title: ( route: Route, nav: Navigator, index: number, navState: NavState ) => React.ReactElement<any>;
2236 LeftButton: ( route: Route, nav: Navigator, index: number, navState: NavState )=> React.ReactElement<any>;
2237 RightButton: ( route: Route, nav: Navigator, index: number, navState: NavState )=> React.ReactElement<any>;
2238 }
2239
2240 /**
2241 * @see NavigatorNavigationBar.js
2242 */
2243 export interface NavigationBarProperties extends React.Props<NavigationBarStatic> {
2244 navigator?: Navigator
2245 routeMapper?: NavigationBarRouteMapper
2246 navState?: NavState
2247 style?: ViewStyle
2248 }
2249
2250 export interface NavigationBarStatic extends React.ComponentClass<NavigationBarProperties> {
2251 Styles: NavigationBarStyle
2252
2253 }
2254
2255 export type NavigationBar = NavigationBarStatic
2256 export var NavigationBar: NavigationBarStatic
2257
2258
2259 export interface BreadcrumbNavigationBarStyle {
2260 //TODO &see NavigatorBreadcrumbNavigationBar.js
2261 }
2262
2263 export interface BreadcrumbNavigationBarRouteMapper {
2264 rightContentForRoute: ( route: Route, navigator: Navigator ) => React.ReactElement<any>
2265 titleContentForRoute: ( route: Route, navigator: Navigator ) => React.ReactElement<any>
2266 iconForRoute: ( route: Route, navigator: Navigator ) => React.ReactElement<any>
2267 //in samples...
2268 separatorForRoute: ( route: Route, navigator: Navigator ) => React.ReactElement<any>
2269 }
2270
2271 /**
2272 * @see NavigatorNavigationBar.js
2273 */
2274 export interface BreadcrumbNavigationBarProperties extends React.Props<BreadcrumbNavigationBarStatic> {
2275 navigator?: Navigator
2276 routeMapper?: BreadcrumbNavigationBarRouteMapper
2277 navState?: NavState
2278 style?: ViewStyle
2279 }
2280
2281 export interface BreadcrumbNavigationBarStatic extends React.ComponentClass<BreadcrumbNavigationBarProperties> {
2282 Styles: BreadcrumbNavigationBarStyle
2283 }
2284
2285 export type BreadcrumbNavigationBar = BreadcrumbNavigationBarStatic
2286 var BreadcrumbNavigationBar: BreadcrumbNavigationBarStatic
2287
2288 }
2289
2290
2291 export interface StyleSheetStatic extends React.ComponentClass<StyleSheetProperties> {
2292 create<T>( styles: T ): T;
2293 }
2294
2295 /**
2296 * //FIXME: Could not find docs. Inferred from examples and jscode : ListViewDataSource.js
2297 */
2298 export interface DataSourceAssetCallback {
2299 rowHasChanged?: ( r1: any, r2: any ) => boolean
2300 sectionHeaderHasChanged?: ( h1: any, h2: any ) => boolean
2301 getRowData?: <T>( dataBlob: any, sectionID: number | string, rowID: number | string ) => T
2302 getSectionHeaderData?: <T>( dataBlob: any, sectionID: number | string ) => T
2303 }
2304
2305 /**
2306 * //FIXME: Could not find docs. Inferred from examples and js code: ListViewDataSource.js
2307 */
2308 export interface ListViewDataSource {
2309 new( onAsset: DataSourceAssetCallback ): ListViewDataSource;
2310 /**
2311 * Clones this `ListViewDataSource` with the specified `dataBlob` and
2312 * `rowIdentities`. The `dataBlob` is just an aribitrary blob of data. At
2313 * construction an extractor to get the interesting informatoin was defined
2314 * (or the default was used).
2315 *
2316 * The `rowIdentities` is is a 2D array of identifiers for rows.
2317 * ie. [['a1', 'a2'], ['b1', 'b2', 'b3'], ...]. If not provided, it's
2318 * assumed that the keys of the section data are the row identities.
2319 *
2320 * Note: This function does NOT clone the data in this data source. It simply
2321 * passes the functions defined at construction to a new data source with
2322 * the data specified. If you wish to maintain the existing data you must
2323 * handle merging of old and new data separately and then pass that into
2324 * this function as the `dataBlob`.
2325 */
2326 cloneWithRows<T>( dataBlob: Array<any> | {[key: string ]: any}, rowIdentities?: Array<string | number> ): ListViewDataSource
2327
2328 /**
2329 * This performs the same function as the `cloneWithRows` function but here
2330 * you also specify what your `sectionIdentities` are. If you don't care
2331 * about sections you should safely be able to use `cloneWithRows`.
2332 *
2333 * `sectionIdentities` is an array of identifiers for sections.
2334 * ie. ['s1', 's2', ...]. If not provided, it's assumed that the
2335 * keys of dataBlob are the section identities.
2336 *
2337 * Note: this returns a new object!
2338 */
2339 cloneWithRowsAndSections( dataBlob: Array<any> | {[key: string]: any}, sectionIdentities?: Array<string | number>, rowIdentities?: Array<Array<string | number>> ): ListViewDataSource
2340
2341 getRowCount(): number
2342
2343 /**
2344 * Gets the data required to render the row.
2345 */
2346 getRowData( sectionIndex: number, rowIndex: number ): any
2347
2348 /**
2349 * Gets the rowID at index provided if the dataSource arrays were flattened,
2350 * or null of out of range indexes.
2351 */
2352 getRowIDForFlatIndex( index: number ): string
2353
2354 /**
2355 * Gets the sectionID at index provided if the dataSource arrays were flattened,
2356 * or null for out of range indexes.
2357 */
2358 getSectionIDForFlatIndex( index: number ): string
2359
2360 /**
2361 * Returns an array containing the number of rows in each section
2362 */
2363 getSectionLengths(): Array<number>
2364
2365 /**
2366 * Returns if the section header is dirtied and needs to be rerendered
2367 */
2368 sectionHeaderShouldUpdate( sectionIndex: number ): boolean
2369
2370 /**
2371 * Gets the data required to render the section header
2372 */
2373 getSectionHeaderData( sectionIndex: number ): any
2374 }
2375
2376
2377 /**
2378 * @see https://facebook.github.io/react-native/docs/tabbarios-item.html#props
2379 */
2380 export interface TabBarItemProperties extends React.Props<TabBarItemStatic> {
2381
2382 /**
2383 * Little red bubble that sits at the top right of the icon.
2384 */
2385 badge?: string | number
2386
2387 /**
2388 * A custom icon for the tab. It is ignored when a system icon is defined.
2389 */
2390 icon?: {uri: string} | string
2391
2392 /**
2393 * Callback when this tab is being selected,
2394 * you should change the state of your component to set selected={true}.
2395 */
2396 onPress?: () => void
2397
2398 /**
2399 * It specifies whether the children are visible or not. If you see a blank content, you probably forgot to add a selected one.
2400 */
2401 selected?: boolean
2402
2403 /**
2404 * A custom icon when the tab is selected.
2405 * It is ignored when a system icon is defined. If left empty, the icon will be tinted in blue.
2406 */
2407 selectedIcon?: {uri: string} | string;
2408
2409 /**
2410 * React style object.
2411 */
2412 style?: ViewStyle
2413
2414 /**
2415 * Items comes with a few predefined system icons.
2416 * Note that if you are using them, the title and selectedIcon will be overriden with the system ones.
2417 *
2418 * enum('bookmarks', 'contacts', 'downloads', 'favorites', 'featured', 'history', 'more', 'most-recent', 'most-viewed', 'recents', 'search', 'top-rated')
2419 */
2420 systemIcon: string
2421
2422 /**
2423 * Text that appears under the icon. It is ignored when a system icon is defined.
2424 */
2425 title?: string
2426
2427 }
2428
2429 export interface TabBarItemStatic extends React.ComponentClass<TabBarItemProperties> {
2430 }
2431
2432 /**
2433 * @see https://facebook.github.io/react-native/docs/tabbarios.html#props
2434 */
2435 export interface TabBarIOSProperties extends React.Props<TabBarIOSStatic> {
2436
2437 /**
2438 * Background color of the tab bar
2439 */
2440 barTintColor?: string
2441
2442 style?: ViewStyle
2443
2444 /**
2445 * Color of the currently selected tab icon
2446 */
2447 tintColor?: string
2448
2449 /**
2450 * A Boolean value that indicates whether the tab bar is translucent
2451 */
2452 translucent?: boolean
2453 }
2454
2455 export interface TabBarIOSStatic extends React.ComponentClass<TabBarIOSProperties> {
2456 Item: TabBarItemStatic;
2457 }
2458
2459
2460 export interface PixelRatioStatic {
2461 get(): number;
2462 }
2463
2464 export interface DeviceEventSubscriptionStatic {
2465 remove(): void;
2466 }
2467
2468 export interface DeviceEventEmitterStatic {
2469 addListener<T>( type: string, onReceived: ( data: T ) => void ): DeviceEventSubscription;
2470 }
2471
2472 // Used by Dimensions below
2473 export interface ScaledSize {
2474 width: number;
2475 height: number;
2476 scale: number;
2477 }
2478
2479
2480 export interface InteractionManagerStatic {
2481 runAfterInteractions( fn: () => void ): void;
2482 }
2483
2484
2485 export interface ScrollViewStyle extends FlexStyle, TransformsStyle {
2486
2487 backfaceVisibility?:string //enum('visible', 'hidden')
2488 backgroundColor?: string
2489 borderColor?: string
2490 borderTopColor?: string
2491 borderRightColor?: string
2492 borderBottomColor?: string
2493 borderLeftColor?: string
2494 borderRadius?: number
2495 borderTopLeftRadius?: number
2496 borderTopRightRadius?: number
2497 borderBottomLeftRadius?: number
2498 borderBottomRightRadius?: number
2499 borderStyle?: string //enum('solid', 'dotted', 'dashed')
2500 borderWidth?: number
2501 borderTopWidth?: number
2502 borderRightWidth?: number
2503 borderBottomWidth?: number
2504 borderLeftWidth?: number
2505 opacity?: number
2506 overflow?: string //enum('visible', 'hidden')
2507 shadowColor?: string
2508 shadowOffset?: {width: number; height: number}
2509 shadowOpacity?: number
2510 shadowRadius?: number
2511 }
2512
2513
2514 export interface ScrollViewIOSProperties {
2515
2516 /**
2517 * When true the scroll view bounces horizontally when it reaches the end
2518 * even if the content is smaller than the scroll view itself. The default
2519 * value is true when `horizontal={true}` and false otherwise.
2520 */
2521 alwaysBounceHorizontal?: boolean
2522 /**
2523 * When true the scroll view bounces vertically when it reaches the end
2524 * even if the content is smaller than the scroll view itself. The default
2525 * value is false when `horizontal={true}` and true otherwise.
2526 */
2527 alwaysBounceVertical?: boolean
2528
2529 /**
2530 * Controls whether iOS should automatically adjust the content inset for scroll views that are placed behind a navigation bar or tab bar/ toolbar.
2531 * The default value is true.
2532 */
2533 automaticallyAdjustContentInsets?: boolean // true
2534
2535 /**
2536 * When true the scroll view bounces when it reaches the end of the
2537 * content if the content is larger then the scroll view along the axis of
2538 * the scroll direction. When false it disables all bouncing even if
2539 * the `alwaysBounce*` props are true. The default value is true.
2540 */
2541 bounces?: boolean
2542 /**
2543 * When true gestures can drive zoom past min/max and the zoom will animate
2544 * to the min/max value at gesture end otherwise the zoom will not exceed
2545 * the limits.
2546 */
2547 bouncesZoom?: boolean
2548
2549 /**
2550 * When false once tracking starts won't try to drag if the touch moves.
2551 * The default value is true.
2552 */
2553 canCancelContentTouches?: boolean
2554
2555 /**
2556 * When true the scroll view automatically centers the content when the
2557 * content is smaller than the scroll view bounds; when the content is
2558 * larger than the scroll view this property has no effect. The default
2559 * value is false.
2560 */
2561 centerContent?: boolean
2562
2563
2564 /**
2565 * The amount by which the scroll view content is inset from the edges of the scroll view.
2566 * Defaults to {0, 0, 0, 0}.
2567 */
2568 contentInset?: Insets // zeros
2569
2570 /**
2571 * Used to manually set the starting scroll offset.
2572 * The default value is {x: 0, y: 0}
2573 */
2574 contentOffset?: PointProperties // zeros
2575
2576 /**
2577 * A floating-point number that determines how quickly the scroll view
2578 * decelerates after the user lifts their finger. Reasonable choices include
2579 * - Normal: 0.998 (the default)
2580 * - Fast: 0.9
2581 */
2582 decelerationRate?: number
2583
2584 /**
2585 * When true the ScrollView will try to lock to only vertical or horizontal
2586 * scrolling while dragging. The default value is false.
2587 */
2588 directionalLockEnabled?: boolean
2589
2590 /**
2591 * The maximum allowed zoom scale. The default value is 1.0.
2592 */
2593 maximumZoomScale?: number
2594
2595 /**
2596 * The minimum allowed zoom scale. The default value is 1.0.
2597 */
2598 minimumZoomScale?: number
2599
2600 /**
2601 * Called when a scrolling animation ends.
2602 */
2603 onScrollAnimationEnd?: () => void
2604
2605 /**
2606 * When true the scroll view stops on multiples of the scroll view's size
2607 * when scrolling. This can be used for horizontal pagination. The default
2608 * value is false.
2609 */
2610 pagingEnabled?: boolean
2611
2612 /**
2613 * When false, the content does not scroll. The default value is true
2614 */
2615 scrollEnabled?: boolean // true
2616
2617 /**
2618 * This controls how often the scroll event will be fired while scrolling (in events per seconds).
2619 * A higher number yields better accuracy for code that is tracking the scroll position,
2620 * but can lead to scroll performance problems due to the volume of information being send over the bridge.
2621 * The default value is zero, which means the scroll event will be sent only once each time the view is scrolled.
2622 */
2623 scrollEventThrottle?: number // null
2624
2625 /**
2626 * The amount by which the scroll view indicators are inset from the edges of the scroll view.
2627 * This should normally be set to the same value as the contentInset.
2628 * Defaults to {0, 0, 0, 0}.
2629 */
2630 scrollIndicatorInsets?: Insets //zeroes
2631
2632 /**
2633 * When true the scroll view scrolls to top when the status bar is tapped.
2634 * The default value is true.
2635 */
2636 scrollsToTop?: boolean
2637
2638 /**
2639 * When snapToInterval is set, snapToAlignment will define the relationship of the the snapping to the scroll view.
2640 * - start (the default) will align the snap at the left (horizontal) or top (vertical)
2641 * - center will align the snap in the center
2642 * - end will align the snap at the right (horizontal) or bottom (vertical)
2643 */
2644 snapToAlignment?: string
2645
2646 /**
2647 * When set, causes the scroll view to stop at multiples of the value of snapToInterval.
2648 * This can be used for paginating through children that have lengths smaller than the scroll view.
2649 * Used in combination with snapToAlignment.
2650 */
2651 snapToInterval?: number
2652
2653 /**
2654 * An array of child indices determining which children get docked to the
2655 * top of the screen when scrolling. For example passing
2656 * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the
2657 * top of the scroll view. This property is not supported in conjunction
2658 * with `horizontal={true}`.
2659 */
2660 stickyHeaderIndices?: number[]
2661
2662 /**
2663 * The current scale of the scroll view content. The default value is 1.0.
2664 */
2665 zoomScale?: number
2666 }
2667
2668 export interface ScrollViewProperties extends ScrollViewIOSProperties, Touchable {
2669
2670 /**
2671 * These styles will be applied to the scroll view content container which
2672 * wraps all of the child views. Example:
2673 *
2674 * return (
2675 * <ScrollView contentContainerStyle={styles.contentContainer}>
2676 * </ScrollView>
2677 * );
2678 * ...
2679 * var styles = StyleSheet.create({
2680 * contentContainer: {
2681 * paddingVertical: 20
2682 * }
2683 * });
2684 */
2685 contentContainerStyle?: ViewStyle
2686
2687 /**
2688 * When true the scroll view's children are arranged horizontally in a row
2689 * instead of vertically in a column. The default value is false.
2690 */
2691 horizontal?: boolean
2692
2693 /**
2694 * Determines whether the keyboard gets dismissed in response to a drag.
2695 * - 'none' (the default) drags do not dismiss the keyboard.
2696 * - 'onDrag' the keyboard is dismissed when a drag begins.
2697 * - 'interactive' the keyboard is dismissed interactively with the drag
2698 * and moves in synchrony with the touch; dragging upwards cancels the
2699 * dismissal.
2700 */
2701 keyboardDismissMode?: string
2702
2703 /**
2704 * When false tapping outside of the focused text input when the keyboard
2705 * is up dismisses the keyboard. When true the scroll view will not catch
2706 * taps and the keyboard will not dismiss automatically. The default value
2707 * is false.
2708 */
2709 keyboardShouldPersistTaps?: boolean
2710
2711 /**
2712 * Fires at most once per frame during scrolling.
2713 * The frequency of the events can be contolled using the scrollEventThrottle prop.
2714 */
2715 onScroll?: (event?: { nativeEvent: NativeScrollEvent }) => void
2716
2717 /**
2718 * Experimental: When true offscreen child views (whose `overflow` value is
2719 * `hidden`) are removed from their native backing superview when offscreen.
2720 * This canimprove scrolling performance on long lists. The default value is
2721 * false.
2722 */
2723 removeClippedSubviews?: boolean
2724
2725 /**
2726 * When true, shows a horizontal scroll indicator.
2727 */
2728 showsHorizontalScrollIndicator?: boolean
2729
2730 /**
2731 * When true, shows a vertical scroll indicator.
2732 */
2733 showsVerticalScrollIndicator?: boolean
2734
2735 /**
2736 * Style
2737 */
2738 style?: ScrollViewStyle
2739 }
2740
2741 export interface ScrollViewProps extends ScrollViewProperties, React.Props<ScrollViewStatic> {
2742
2743 }
2744
2745 interface ScrollViewStatic extends React.ComponentClass<ScrollViewProps> {
2746
2747 }
2748
2749
2750 export interface NativeScrollRectangle {
2751 left: number;
2752 top: number;
2753 bottom: number;
2754 right: number;
2755 }
2756
2757 export interface NativeScrollPoint {
2758 x: number;
2759 y: number;
2760 }
2761
2762 export interface NativeScrollSize {
2763 height: number;
2764 width: number;
2765 }
2766
2767 export interface NativeScrollEvent {
2768 contentInset: NativeScrollRectangle;
2769 contentOffset: NativeScrollPoint;
2770 contentSize: NativeScrollSize;
2771 layoutMeasurement: NativeScrollSize;
2772 zoomScale: number;
2773 }
2774
2775
2776 //////////////////////////////////////////////////////////////////////////
2777 //
2778 // A P I s
2779 //
2780 //////////////////////////////////////////////////////////////////////////
2781
2782 /**
2783 * //FIXME: no documentation - inferred from RCTACtionSheetManager.m
2784 */
2785 export interface ActionSheetIOSOptions {
2786 title?: string
2787 options?: string[]
2788 cancelButtonIndex?: number
2789 destructiveButtonIndex?: number
2790 }
2791
2792 /**
2793 * //FIXME: no documentation - inferred from RCTACtionSheetManager.m
2794 */
2795 export interface ShareActionSheetIOSOptions {
2796 message?: string
2797 url?: string
2798 }
2799
2800 /**
2801 * @see https://facebook.github.io/react-native/docs/actionsheetios.html#content
2802 * //FIXME: no documentation - inferred from RCTACtionSheetManager.m
2803 */
2804 export interface ActionSheetIOSStatic {
2805 showActionSheetWithOptions: ( options: ActionSheetIOSOptions, callback: ( buttonIndex: number ) => void ) => void
2806 showShareActionSheetWithOptions: ( options: ShareActionSheetIOSOptions, failureCallback: ( error: Error ) => void, successCallback: ( success: boolean, method: string ) => void ) => void
2807 }
2808
2809
2810 /**
2811 * //FIXME: No documentation - inferred from RCTAdSupport.m
2812 */
2813 export interface AdSupportIOSStatic {
2814 getAdvertisingId: ( onSuccess: ( deviceId: string ) => void, onFailure: ( err: Error ) => void ) => void
2815 getAdvertisingTrackingEnabled: ( onSuccess: ( hasTracking: boolean ) => void, onFailure: ( err: Error ) => void ) => void
2816 }
2817
2818 interface AlertIOSButton {
2819 text: string
2820 onPress?: () => void
2821 }
2822
2823 /**
2824 * Launches an alert dialog with the specified title and message.
2825 *
2826 * Optionally provide a list of buttons.
2827 * Tapping any button will fire the respective onPress callback and dismiss the alert.
2828 * By default, the only button will be an 'OK' button
2829 *
2830 * The last button in the list will be considered the 'Primary' button and it will appear bold.
2831 *
2832 * @see https://facebook.github.io/react-native/docs/alertios.html#content
2833 */
2834 export interface AlertIOSStatic {
2835 alert: ( title: string, message?: string, buttons?: Array<AlertIOSButton>, type?: string ) => void
2836 prompt: ( title: string, value?: string, buttons?: Array<AlertIOSButton>, callback?: ( value?: string ) => void ) => void
2837 }
2838
2839
2840 /**
2841 * AppStateIOS can tell you if the app is in the foreground or background,
2842 * and notify you when the state changes.
2843 *
2844 * AppStateIOS is frequently used to determine the intent and proper behavior
2845 * when handling push notifications.
2846 *
2847 * iOS App States
2848 * active - The app is running in the foreground
2849 * background - The app is running in the background. The user is either in another app or on the home screen
2850 * inactive - This is a transition state that currently never happens for typical React Native apps.
2851 *
2852 * For more information, see Apple's documentation: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html
2853 *
2854 * @see https://facebook.github.io/react-native/docs/appstateios.html#content
2855 */
2856 export interface AppStateIOSStatic {
2857 currentState: string
2858 addEventListener( type: string, listener: ( state: string ) => void ): void
2859 removeEventListener( type: string, listener: ( state: string ) => void ): void
2860 }
2861
2862 /**
2863 * AsyncStorage is a simple, asynchronous, persistent, key-value storage system that is global to the app.
2864 * It should be used instead of LocalStorage.
2865 *
2866 * It is recommended that you use an abstraction on top of AsyncStorage
2867 * instead of AsyncStorage directly for anything more than light usage since it operates globally.
2868 *
2869 * @see https://facebook.github.io/react-native/docs/asyncstorage.html#content
2870 */
2871 export interface AsyncStorageStatic {
2872
2873 /**
2874 * Fetches key and passes the result to callback, along with an Error if there is any.
2875 */
2876 getItem( key: string, callback?: ( error?: Error, result?: string ) => void ): Promise<string>
2877
2878 /**
2879 * Sets value for key and calls callback on completion, along with an Error if there is any
2880 */
2881 setItem( key: string, value: string, callback?: ( error?: Error ) => void ): Promise<string>
2882
2883 removeItem( key: string, callback?: ( error?: Error ) => void ): Promise<string>
2884
2885 /**
2886 * Merges existing value with input value, assuming they are stringified json. Returns a Promise object.
2887 * Not supported by all native implementation
2888 */
2889 mergeItem( key: string, value: string, callback?: ( error?: Error ) => void ): Promise<string>
2890
2891 /**
2892 * Erases all AsyncStorage for all clients, libraries, etc. You probably don't want to call this.
2893 * Use removeItem or multiRemove to clear only your own keys instead.
2894 */
2895 clear( callback?: ( error?: Error ) => void ): Promise<string>
2896
2897 /**
2898 * Gets all keys known to the app, for all callers, libraries, etc
2899 */
2900 getAllKeys( callback?: ( error?: Error, keys?: string[] ) => void ): Promise<string>
2901
2902 /**
2903 * multiGet invokes callback with an array of key-value pair arrays that matches the input format of multiSet
2904 */
2905 multiGet( keys: string[], callback?: ( errors?: Error[], result?: string[][] ) => void ): Promise<string>
2906
2907 /**
2908 * multiSet and multiMerge take arrays of key-value array pairs that match the output of multiGet,
2909 *
2910 * multiSet([['k1', 'val1'], ['k2', 'val2']], cb);
2911 */
2912 multiSet( keyValuePairs: string[][], callback?: ( errors?: Error[] ) => void ): Promise<string>
2913
2914 /**
2915 * Delete all the keys in the keys array.
2916 */
2917 multiRemove( keys: string[], callback?: ( errors?: Error[] ) => void ): Promise<string>
2918
2919 /**
2920 * Merges existing values with input values, assuming they are stringified json.
2921 * Returns a Promise object.
2922 *
2923 * Not supported by all native implementations.
2924 */
2925 multiMerge( keyValuePairs: string[][], callback?: ( errors?: Error[] ) => void ): Promise<string>
2926 }
2927
2928
2929 export interface CameraRollFetchParams {
2930 first: number;
2931 after?: string;
2932 groupTypes: string; // 'Album','All','Event','Faces','Library','PhotoStream','SavedPhotos'
2933 groupName?: string
2934 assetType?: string
2935 }
2936
2937 export interface CameraRollNodeInfo {
2938 image: Image;
2939 group_name: string;
2940 timestamp: number;
2941 location: any;
2942 }
2943
2944 export interface CameraRollEdgeInfo {
2945 node: CameraRollNodeInfo;
2946 }
2947
2948 export interface CameraRollAssetInfo {
2949 edges: CameraRollEdgeInfo[];
2950 page_info: {
2951 has_next_page: boolean;
2952 end_cursor: string;
2953 };
2954 }
2955
2956 /**
2957 * CameraRoll provides access to the local camera roll / gallery.
2958 */
2959 export interface CameraRollStatic {
2960
2961 GroupTypesOptions: string[] //'Album','All','Event','Faces','Library','PhotoStream','SavedPhotos'
2962
2963 /**
2964 * Saves the image to the camera roll / gallery.
2965 *
2966 * The CameraRoll API is not yet implemented for Android.
2967 *
2968 * @tag On Android, this is a local URI, such as "file:///sdcard/img.png".
2969 * On iOS, the tag can be one of the following:
2970 * local URI
2971 * assets-library tag
2972 * 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)
2973 *
2974 * @param successCallback Invoked with the value of tag on success.
2975 * @param errorCallback Invoked with error message on error.
2976 */
2977 saveImageWithTag( tag: string, successCallback: ( tag?: string ) => void, errorCallback: ( error: Error ) => void ): void
2978
2979 /**
2980 * Invokes callback with photo identifier objects from the local camera roll of the device matching shape defined by getPhotosReturnChecker.
2981 *
2982 * @param {object} params See getPhotosParamChecker.
2983 * @param {function} callback Invoked with arg of shape defined by getPhotosReturnChecker on success.
2984 * @param {function} errorCallback Invoked with error message on error.
2985 */
2986 getPhotos( fetch: CameraRollFetchParams,
2987 callback: ( assetInfo: CameraRollAssetInfo ) => void,
2988 errorCallback: ( error: Error )=> void ): void;
2989 }
2990
2991 export interface FetchableListenable<T> {
2992 fetch: () => Promise<T>
2993
2994 /**
2995 * eventName is expected to be `change`
2996 * //FIXME: No doc - inferred from NetInfo.js
2997 */
2998 addEventListener: ( eventName: string, listener: ( result: T ) => void ) => void
2999
3000 /**
3001 * eventName is expected to be `change`
3002 * //FIXME: No doc - inferred from NetInfo.js
3003 */
3004 removeEventListener: ( eventName: string, listener: ( result: T ) => void ) => void
3005 }
3006
3007 /**
3008 * NetInfo exposes info about online/offline status
3009 *
3010 * Asynchronously determine if the device is online and on a cellular network.
3011 *
3012 * - `none` - device is offline
3013 * - `wifi` - device is online and connected via wifi, or is the iOS simulator
3014 * - `cell` - device is connected via Edge, 3G, WiMax, or LTE
3015 * - `unknown` - error case and the network status is unknown
3016
3017 * @see https://facebook.github.io/react-native/docs/netinfo.html#content
3018 */
3019 export interface NetInfoStatic extends FetchableListenable<string> {
3020
3021 /**
3022 *
3023 * Available on all platforms.
3024 * Asynchronously fetch a boolean to determine internet connectivity.
3025 */
3026 isConnected: FetchableListenable<boolean>
3027
3028 //FIXME: Documentation missing
3029 isConnectionMetered: any
3030 }
3031
3032
3033 export interface PanResponderGestureState {
3034
3035 /**
3036 * ID of the gestureState- persisted as long as there at least one touch on
3037 */
3038 stateID: number
3039
3040 /**
3041 * the latest screen coordinates of the recently-moved touch
3042 */
3043 moveX: number
3044
3045 /**
3046 * the latest screen coordinates of the recently-moved touch
3047 */
3048 moveY: number
3049
3050 /**
3051 * the screen coordinates of the responder grant
3052 */
3053 x0: number
3054
3055 /**
3056 * the screen coordinates of the responder grant
3057 */
3058 y0: number
3059
3060 /**
3061 * accumulated distance of the gesture since the touch started
3062 */
3063 dx: number
3064
3065 /**
3066 * accumulated distance of the gesture since the touch started
3067 */
3068 dy: number
3069
3070 /**
3071 * current velocity of the gesture
3072 */
3073 vx: number
3074
3075 /**
3076 * current velocity of the gesture
3077 */
3078 vy: number
3079
3080 /**
3081 * Number of touches currently on screeen
3082 */
3083 numberActiveTouches: number
3084
3085
3086 // All `gestureState` accounts for timeStamps up until:
3087 _accountsForMovesUpTo: number
3088 }
3089
3090
3091 /**
3092 * @see documentation of GestureResponderHandlers
3093 */
3094 export interface PanResponderCallbacks {
3095 onMoveShouldSetPanResponder?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean
3096 onStartShouldSetPanResponder?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
3097 onPanResponderGrant?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
3098 onPanResponderMove?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
3099 onPanResponderRelease?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
3100 onPanResponderTerminate?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
3101
3102 onMoveShouldSetPanResponderCapture?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean
3103 onStartShouldSetPanResponderCapture?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean
3104 onPanResponderReject?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
3105 onPanResponderStart?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
3106 onPanResponderEnd?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void
3107 onPanResponderTerminationRequest?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean
3108 }
3109
3110 export interface PanResponderInstance {
3111 panHandlers: GestureResponderHandlers
3112 }
3113
3114 /**
3115 * PanResponder reconciles several touches into a single gesture.
3116 * It makes single-touch gestures resilient to extra touches,
3117 * and can be used to recognize simple multi-touch gestures.
3118 *
3119 * It provides a predictable wrapper of the responder handlers provided by the gesture responder system.
3120 * For each handler, it provides a new gestureState object alongside the normal event.
3121 */
3122 export interface PanResponderStatic {
3123 /**
3124 * @param config Enhanced versions of all of the responder callbacks
3125 * that provide not only the typical `ResponderSyntheticEvent`, but also the
3126 * `PanResponder` gesture state. Simply replace the word `Responder` with
3127 * `PanResponder` in each of the typical `onResponder*` callbacks. For
3128 * example, the `config` object would look like:
3129 *
3130 * - `onMoveShouldSetPanResponder: (e, gestureState) => {...}`
3131 * - `onMoveShouldSetPanResponderCapture: (e, gestureState) => {...}`
3132 * - `onStartShouldSetPanResponder: (e, gestureState) => {...}`
3133 * - `onStartShouldSetPanResponderCapture: (e, gestureState) => {...}`
3134 * - `onPanResponderReject: (e, gestureState) => {...}`
3135 * - `onPanResponderGrant: (e, gestureState) => {...}`
3136 * - `onPanResponderStart: (e, gestureState) => {...}`
3137 * - `onPanResponderEnd: (e, gestureState) => {...}`
3138 * - `onPanResponderRelease: (e, gestureState) => {...}`
3139 * - `onPanResponderMove: (e, gestureState) => {...}`
3140 * - `onPanResponderTerminate: (e, gestureState) => {...}`
3141 * - `onPanResponderTerminationRequest: (e, gestureState) => {...}`
3142 *
3143 * In general, for events that have capture equivalents, we update the
3144 * gestureState once in the capture phase and can use it in the bubble phase
3145 * as well.
3146 *
3147 * Be careful with onStartShould* callbacks. They only reflect updated
3148 * `gestureState` for start/end events that bubble/capture to the Node.
3149 * Once the node is the responder, you can rely on every start/end event
3150 * being processed by the gesture and `gestureState` being updated
3151 * accordingly. (numberActiveTouches) may not be totally accurate unless you
3152 * are the responder.
3153 */
3154 create( config: PanResponderCallbacks ): PanResponderInstance
3155 }
3156
3157 export interface PushNotificationPermissions {
3158 alert?: boolean
3159 badge?: boolean
3160 sound?: boolean
3161 }
3162
3163 export interface PushNotification {
3164
3165
3166 /**
3167 * An alias for `getAlert` to get the notification's main message string
3168 */
3169 getMessage(): string | Object
3170
3171 /**
3172 * Gets the sound string from the `aps` object
3173 */
3174 getSound(): string
3175
3176 /**
3177 * Gets the notification's main message from the `aps` object
3178 */
3179 getAlert(): string | Object
3180
3181 /**
3182 * Gets the badge count number from the `aps` object
3183 */
3184 getBadgeCount(): number
3185
3186 /**
3187 * Gets the data object on the notif
3188 */
3189 getData(): Object
3190
3191 }
3192
3193
3194 /**
3195 * Handle push notifications for your app, including permission handling and icon badge number.
3196 * @see https://facebook.github.io/react-native/docs/pushnotificationios.html#content
3197 *
3198 * //FIXME: BGR: The documentation seems completely off compared to the actual js implementation. I could never get the example to run
3199 */
3200 export interface PushNotificationIOSStatic {
3201
3202 /**
3203 * Sets the badge number for the app icon on the home screen
3204 */
3205 setApplicationIconBadgeNumber( number: number ): void
3206
3207 /**
3208 * Gets the current badge number for the app icon on the home screen
3209 */
3210 getApplicationIconBadgeNumber( callback: ( badge: number ) => void ): void
3211
3212 /**
3213 * Attaches a listener to remote notifications while the app is running in the
3214 * foreground or the background.
3215 *
3216 * The handler will get be invoked with an instance of `PushNotificationIOS`
3217 *
3218 * The type MUST be 'notification'
3219 */
3220 addEventListener( type: string, handler: ( notification: PushNotification ) => void ):void
3221
3222 /**
3223 * Requests all notification permissions from iOS, prompting the user's
3224 * dialog box.
3225 */
3226 requestPermissions(): void
3227
3228 /**
3229 * See what push permissions are currently enabled. `callback` will be
3230 * invoked with a `permissions` object:
3231 *
3232 * - `alert` :boolean
3233 * - `badge` :boolean
3234 * - `sound` :boolean
3235 */
3236 checkPermissions( callback: ( permissions: PushNotificationPermissions ) => void ): void
3237
3238 /**
3239 * Removes the event listener. Do this in `componentWillUnmount` to prevent
3240 * memory leaks
3241 */
3242 removeEventListener( type: string, handler: ( notification: PushNotification ) => void ): void
3243
3244 /**
3245 * An initial notification will be available if the app was cold-launched
3246 * from a notification.
3247 *
3248 * The first caller of `popInitialNotification` will get the initial
3249 * notification object, or `null`. Subsequent invocations will return null.
3250 */
3251 popInitialNotification(): PushNotification
3252 }
3253
3254
3255 /**
3256 * @enum('default', 'light-content')
3257 */
3258 export type StatusBarStyle = string
3259
3260 /**
3261 * @enum('none','fade', 'slide')
3262 */
3263 type StatusBarAnimation = string
3264
3265
3266 /**
3267 * //FIXME: No documentation is available (although this is self explanatory)
3268 *
3269 * @see https://facebook.github.io/react-native/docs/statusbarios.html#content
3270 */
3271 export interface StatusBarIOSStatic {
3272
3273 setStyle(style: StatusBarStyle, animated?: boolean): void
3274
3275 setHidden(hidden: boolean, animation?: StatusBarAnimation): void
3276
3277 setNetworkActivityIndicatorVisible(visible: boolean): void
3278 }
3279
3280 /**
3281 * The Vibration API is exposed at VibrationIOS.vibrate().
3282 * On iOS, calling this function will trigger a one second vibration.
3283 * The vibration is asynchronous so this method will return immediately.
3284 *
3285 * There will be no effect on devices that do not support Vibration, eg. the iOS simulator.
3286 *
3287 * Vibration patterns are currently unsupported.
3288 *
3289 * @see https://facebook.github.io/react-native/docs/vibrationios.html#content
3290 */
3291 export interface VibrationIOSStatic {
3292 vibrate(): void
3293 }
3294
3295 //////////////////////////////////////////////////////////////////////////
3296 //
3297 // R E - E X P O R T S
3298 //
3299 //////////////////////////////////////////////////////////////////////////
3300
3301 // export var AppRegistry: AppRegistryStatic;
3302
3303
3304 export var ActivityIndicatorIOS: ActivityIndicatorIOSStatic
3305 export type ActivityIndicatorIOS = ActivityIndicatorIOSStatic
3306
3307 export var DatePickerIOS: DatePickerIOSStatic
3308 export type DatePickerIOS = DatePickerIOSStatic
3309
3310 export var Image: ImageStatic
3311 export type Image = ImageStatic
3312
3313 export var LayoutAnimation: LayoutAnimationStatic
3314 export type LayoutAnimation = LayoutAnimationStatic
3315
3316 export var ListView: ListViewStatic
3317 export type ListView = ListViewStatic
3318
3319 export var MapView: MapViewStatic
3320 export type MapView = MapViewStatic
3321
3322 export var Navigator: NavigatorStatic
3323 export type Navigator = NavigatorStatic
3324
3325 export var NavigatorIOS: NavigatorIOSStatic
3326 export type NavigatorIOS = NavigatorIOSStatic
3327
3328 export var PickerIOS: PickerIOSStatic
3329 export type PickerIOS = PickerIOSStatic
3330
3331 export var SliderIOS: SliderIOSStatic
3332 export type SliderIOS = SliderIOSStatic
3333
3334 export var ScrollView: ScrollViewStatic
3335 export type ScrollView = ScrollViewStatic
3336
3337 export var StyleSheet: StyleSheetStatic
3338 export type StyleSheet = StyleSheetStatic
3339
3340 export var SwitchIOS: SwitchIOSStatic
3341 export type SwitchIOS = SwitchIOSStatic
3342
3343 export var TabBarIOS: TabBarIOSStatic
3344 export type TabBarIOS = TabBarIOSStatic
3345
3346 export var Text: TextStatic
3347 export type Text = TextStatic
3348
3349 export var TextInput: TextInputStatic
3350 export type TextInput = TextInputStatic
3351
3352 export var TouchableHighlight: TouchableHighlightStatic
3353 export type TouchableHighlight = TouchableHighlightStatic
3354
3355 export var TouchableNativeFeedback: TouchableNativeFeedbackStatic
3356 export type TouchableNativeFeedback = TouchableNativeFeedbackStatic
3357
3358 export var TouchableOpacity: TouchableOpacityStatic
3359 export type TouchableOpacity = TouchableOpacityStatic
3360
3361 export var TouchableWithoutFeedback: TouchableWithoutFeedbackStatic
3362 export type TouchableWithoutFeedback= TouchableWithoutFeedbackStatic
3363
3364 export var View: ViewStatic
3365 export type View = ViewStatic
3366
3367 export var WebView: WebViewStatic
3368 export type WebView = WebViewStatic
3369
3370
3371 //////////// APIS //////////////
3372 export var ActionSheetIOS: ActionSheetIOSStatic
3373 export type ActionSheetIOS = ActionSheetIOSStatic
3374
3375 export var AdSupportIOS: AdSupportIOSStatic
3376 export type AdSupportIOS = AdSupportIOSStatic
3377
3378 export var AlertIOS: AlertIOSStatic
3379 export type AlertIOS = AlertIOSStatic
3380
3381 export var AppStateIOS: AppStateIOSStatic
3382 export type AppStateIOS = AppStateIOSStatic
3383
3384 export var AsyncStorage: AsyncStorageStatic
3385 export type AsyncStorage = AsyncStorageStatic
3386
3387 export var CameraRoll: CameraRollStatic
3388 export type CameraRoll = CameraRollStatic
3389
3390 export var NetInfo: NetInfoStatic
3391 export type NetInfo = NetInfoStatic
3392
3393 export var PanResponder: PanResponderStatic
3394 export type PanResponder = PanResponderStatic
3395
3396 export var PushNotificationIOS: PushNotificationIOSStatic
3397 export type PushNotificationIOS = PushNotificationIOSStatic
3398
3399 export var StatusBarIOS: StatusBarIOSStatic
3400 export type StatusBarIOS = StatusBarIOSStatic
3401
3402 export var VibrationIOS: VibrationIOSStatic
3403 export type VibrationIOS = VibrationIOSStatic
3404
3405
3406 //
3407 // /TODO: BGR: These are leftovers of the initial port that must be revisited
3408 //
3409
3410 export var SegmentedControlIOS: React.ComponentClass<SegmentedControlIOSProperties>
3411
3412 export var PixelRatio: PixelRatioStatic
3413 export var DeviceEventEmitter: DeviceEventEmitterStatic
3414 export var DeviceEventSubscription: DeviceEventSubscriptionStatic
3415 export type DeviceEventSubscription = DeviceEventSubscriptionStatic
3416 export var InteractionManager: InteractionManagerStatic
3417
3418 //////////////////////////////////////////////////////////////////////////
3419 //
3420 // Additional ( and controversial)
3421 //
3422 //////////////////////////////////////////////////////////////////////////
3423
3424 export function __spread( target: any, ...sources: any[] ): any;
3425
3426
3427 export interface GlobalStatic {
3428
3429 /**
3430 * Accepts a function as its only argument and calls that function before the next repaint.
3431 * It is an essential building block for animations that underlies all of the JavaScript-based animation APIs.
3432 * In general, you shouldn't need to call this yourself - the animation API's will manage frame updates for you.
3433 * @see https://facebook.github.io/react-native/docs/animations.html#requestanimationframe
3434 */
3435 requestAnimationFrame( fn: () => void ) : void;
3436
3437 }
3438
3439 //
3440 // Add-Ons
3441 //
3442 namespace addons {
3443
3444 //FIXME: Documentation ?
3445 export interface TestModuleStatic {
3446
3447 verifySnapshot: ( done: ( indicator?: any ) => void ) => void
3448 markTestPassed: ( indicator: any ) => void
3449 markTestCompleted: () => void
3450 }
3451
3452 export var TestModule: TestModuleStatic
3453 export type TestModule = TestModuleStatic
3454 }
3455
3456
3457}
3458
3459declare module "react-native" {
3460
3461 import ReactNative = __React
3462 export = ReactNative
3463}
3464
3465declare var global: __React.GlobalStatic
3466
3467declare function require( name: string ): any
3468
3469
3470//TODO: BGR: this is a left-over from the initial port. Not sure it makes any sense
3471declare module "Dimensions" {
3472 import * as React from 'react-native';
3473
3474 interface Dimensions {
3475 get( what: string ): React.ScaledSize;
3476 }
3477
3478 var ExportDimensions: Dimensions;
3479 export = ExportDimensions;
3480}
3481