forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-native.d.ts
6092 lines (4991 loc) · 205 KB
/
react-native.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for react-native 0.29
// Project: https://github.com/facebook/react-native
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// USING: these definitions are meant to be used with the TSC compiler target set to ES6
//
// USAGE EXAMPLES: check the RNTSExplorer project at https://github.com/bgrieder/RNTSExplorer
// Warning: the project currently uses and older version of react-native
//
// CONTRIBUTING: please open pull requests
//
// CREDITS: This work is based on an original work made by Bernd Paradies: https://github.com/bparadie
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <reference path="../react/react.d.ts" />
//so we know what is "original" React
import React = __React;
//react-native "extends" react
declare namespace __React {
module NativeMethodsMixin {
type MeasureOnSuccessCallback = (
x: number,
y: number,
width: number,
height: number,
pageX: number,
pageY: number
) => void
type MeasureInWindowOnSuccessCallback = (
x: number,
y: number,
width: number,
height: number
) => void
type MeasureLayoutOnSuccessCallback = (
left: number,
top: number,
width: number,
height: number
) => void
}
/**
* @see https://github.com/facebook/react-native/blob/master/Libraries/ReactIOS/NativeMethodsMixin.js
*/
// export class Component<P, S> extends React.Component<P, S> {
export interface NativeComponent {
/**
* Determines the location on screen, width, and height of the given view and
* returns the values via an async callback. If successful, the callback will
* be called with the following arguments:
*
* - x
* - y
* - width
* - height
* - pageX
* - pageY
*
* Note that these measurements are not available until after the rendering
* has been completed in native. If you need the measurements as soon as
* possible, consider using the [`onLayout`
* prop](docs/view.html#onlayout) instead.
*/
measure(callback: NativeMethodsMixin.MeasureOnSuccessCallback): void;
/**
* Determines the location of the given view in the window and returns the
* values via an async callback. If the React root view is embedded in
* another native view, this will give you the absolute coordinates. If
* successful, the callback will be called with the following
* arguments:
*
* - x
* - y
* - width
* - height
*
* Note that these measurements are not available until after the rendering
* has been completed in native.
*/
measureInWindow(callback: NativeMethodsMixin.MeasureInWindowOnSuccessCallback): void;
/**
* Like [`measure()`](#measure), but measures the view relative an ancestor,
* specified as `relativeToNativeNode`. This means that the returned x, y
* are relative to the origin x, y of the ancestor view.
*
* As always, to obtain a native node handle for a component, you can use
* `React.findNodeHandle(component)`.
*/
measureLayout(
relativeToNativeNode: number,
onSuccess: NativeMethodsMixin.MeasureLayoutOnSuccessCallback,
onFail: () => void /* currently unused */
): void;
/**
* This function sends props straight to native. They will not participate in
* future diff process - this means that if you do not include them in the
* next render, they will remain active (see [Direct
* Manipulation](docs/direct-manipulation.html)).
*/
setNativeProps(nativeProps: Object): void;
/**
* Requests focus for the given input or view. The exact behavior triggered
* will depend on the platform and type of view.
*/
focus(): void;
/**
* Removes focus from an input or view. This is the opposite of `focus()`.
*/
blur(): void;
refs: {
[key: string]: Component<any, any>
};
}
//TODO: BGR: Replace with ComponentClass ?
// node_modules/react-tools/src/classic/class/ReactClass.js
export interface ReactClass<D, P, S> {
// TODO:
}
// see react-jsx.d.ts
export function createElement<P>( type: React.ReactType,
props?: P,
...children: React.ReactNode[] ): React.ReactElement<P>;
export type Runnable = ( appParameters: any ) => void;
// Similar to React.SyntheticEvent except for nativeEvent
interface NativeSyntheticEvent<T> {
bubbles: boolean
cancelable: boolean
currentTarget: EventTarget
defaultPrevented: boolean
eventPhase: number
isTrusted: boolean
nativeEvent: T
preventDefault(): void
stopPropagation(): void
target: EventTarget
timeStamp: Date
type: string
}
export interface NativeTouchEvent {
/**
* Array of all touch events that have changed since the last event
*/
changedTouches: NativeTouchEvent[]
/**
* The ID of the touch
*/
identifier: string
/**
* The X position of the touch, relative to the element
*/
locationX: number
/**
* The Y position of the touch, relative to the element
*/
locationY: number
/**
* The X position of the touch, relative to the screen
*/
pageX: number
/**
* The Y position of the touch, relative to the screen
*/
pageY: number
/**
* The node id of the element receiving the touch event
*/
target: string
/**
* A time identifier for the touch, useful for velocity calculation
*/
timestamp: number
/**
* Array of all current touches on the screen
*/
touches : NativeTouchEvent[]
}
export interface GestureResponderEvent extends NativeSyntheticEvent<NativeTouchEvent> {
}
export interface PointProperties {
x: number
y: number
}
export interface Insets {
top?: number
left?: number
bottom?: number
right?: number
}
/**
* //FIXME: need to find documentation on which compoenent is a native (i.e. non composite component)
*/
/*
export interface NativeComponent {
}
*/
/**
* //FIXME: need to find documentation on which component is a TTouchable and can implement that interface
* @see React.DOMAtributes
*/
export interface Touchable {
onTouchStart?: ( event: GestureResponderEvent ) => void
onTouchMove?: ( event: GestureResponderEvent ) => void
onTouchEnd?: ( event: GestureResponderEvent ) => void
onTouchCancel?: ( event: GestureResponderEvent ) => void
onTouchEndCapture?: ( event: GestureResponderEvent ) => void
}
export type AppConfig = {
appKey: string;
component: ReactClass<any, any, any>;
run?: Runnable;
}
// https://github.com/facebook/react-native/blob/master/Libraries/AppRegistry/AppRegistry.js
/**
* `AppRegistry` is the JS entry point to running all React Native apps. App
* root components should register themselves with
* `AppRegistry.registerComponent`, then the native system can load the bundle
* for the app and then actually run the app when it's ready by invoking
* `AppRegistry.runApplication`.
*
* To "stop" an application when a view should be destroyed, call
* `AppRegistry.unmountApplicationComponentAtRootTag` with the tag that was
* pass into `runApplication`. These should always be used as a pair.
*
* `AppRegistry` should be `require`d early in the `require` sequence to make
* sure the JS execution environment is setup before other modules are
* `require`d.
*/
export class AppRegistry {
static registerConfig( config: AppConfig[] ): void;
static registerComponent( appKey: string, getComponentFunc: () => React.ComponentClass<any> ): string;
static registerRunnable( appKey: string, func: Runnable ): string;
static getAppKeys(): string[];
static unmountApplicationComponentAtRootTag(rootTag: number): void;
static runApplication( appKey: string, appParameters: any ): void;
}
export interface LayoutAnimationTypes {
spring: string
linear: string
easeInEaseOut: string
easeIn: string
easeOut: string
}
export interface LayoutAnimationProperties {
opacity: string
scaleXY: string
}
export interface LayoutAnimationAnim {
duration?: number
delay?: number
springDamping?: number
initialVelocity?: number
type?: string //LayoutAnimationTypes
property?: string //LayoutAnimationProperties
}
export interface LayoutAnimationConfig {
duration: number
create?: LayoutAnimationAnim
update?: LayoutAnimationAnim
delete?: LayoutAnimationAnim
}
export interface LayoutAnimationStatic {
configureNext: ( config: LayoutAnimationConfig, onAnimationDidEnd?: () => void, onError?: ( error?: any ) => void ) => void
create: ( duration: number, type?: string, creationProp?: string ) => LayoutAnimationConfig
Types: LayoutAnimationTypes
Properties: LayoutAnimationProperties
configChecker: ( conf: {config: LayoutAnimationConfig}, name: string, next: string ) => void
Presets : {
easeInEaseOut: LayoutAnimationConfig
linear:LayoutAnimationConfig
spring: LayoutAnimationConfig
}
}
export type FlexAlignType = "flex-start" | "flex-end" | "center" | "stretch";
export type FlexJustifyType = "flex-start" | "flex-end" | "center" | "space-between" | "space-around";
/**
* Flex Prop Types
* @see https://facebook.github.io/react-native/docs/flexbox.html#proptypes
* @see LayoutPropTypes.js
*/
export interface FlexStyle {
alignItems?: FlexAlignType;
alignSelf?: "auto" | FlexAlignType;
borderBottomWidth?: number
borderLeftWidth?: number
borderRightWidth?: number
borderTopWidth?: number
borderWidth?: number
bottom?: number
flex?: number
flexDirection?: "row" | "column" | "row-reverse" | "column-reverse"
flexWrap?: "wrap" | "nowrap"
height?: number
justifyContent?: FlexJustifyType
left?: number
minWidth?: number
maxWidth?: number
minHeight?: number
maxHeight?: number
margin?: number
marginBottom?: number
marginHorizontal?: number
marginLeft?: number
marginRight?: number
marginTop?: number
marginVertical?: number
padding?: number
paddingBottom?: number
paddingHorizontal?: number
paddingLeft?: number
paddingRight?: number
paddingTop?: number
paddingVertical?: number
position?: "absolute" | "relative"
right?: number
top?: number
width?: number
/**
* @platform ios
*/
zIndex?: number
}
/**
* @see ShadowPropTypesIOS.js
*/
export interface ShadowPropTypesIOSStatic {
/**
* Sets the drop shadow color
* @platform ios
*/
shadowColor: string
/**
* Sets the drop shadow offset
* @platform ios
*/
shadowOffset: {width: number, height: number}
/**
* Sets the drop shadow opacity (multiplied by the color's alpha component)
* @platform ios
*/
shadowOpacity: number
/**
* Sets the drop shadow blur radius
* @platform ios
*/
shadowRadius: number
}
type GetCurrentPositionOptions = {
timeout: number
maximumAge: number
enableHighAccuracy: boolean
distanceFilter: number
}
type WatchPositionOptions = {
timeout: number
maximumAge: number
enableHighAccuracy: boolean
distanceFilter: number
}
type GeolocationReturnType = {
coords: {
latitude: number
longitude: number
}
}
export interface TransformsStyle {
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}]
transformMatrix?: Array<number>
rotation?: number
scaleX?: number
scaleY?: number
translateX?: number
translateY?: number
}
export interface StyleSheetProperties {
hairlineWidth: number
flatten<T extends string>(style: T): T
}
export interface LayoutRectangle {
x: number;
y: number;
width: number;
height: number;
}
// @see TextProperties.onLayout
export interface LayoutChangeEvent {
nativeEvent: {
layout: LayoutRectangle
}
}
export interface TextStyleIOS extends ViewStyle {
letterSpacing?: number
textDecorationColor?: string
textDecorationStyle?: "solid" | "double" | "dotted" | "dashed"
writingDirection?: "auto" | "ltr" | "rtl"
}
export interface TextStyleAndroid extends ViewStyle {
textAlignVertical?: "auto" | "top" | "bottom" | "center"
}
// @see https://facebook.github.io/react-native/docs/text.html#style
export interface TextStyle extends TextStyleIOS, TextStyleAndroid, ViewStyle {
color?: string
fontFamily?: string
fontSize?: number
fontStyle?: "normal" | "italic"
/**
* Specifies font weight. The values 'normal' and 'bold' are supported
* for most fonts. Not all fonts have a variant for each of the numeric
* values, in that case the closest one is chosen.
*/
fontWeight?: "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"
letterSpacing?: number
lineHeight?: number
/**
* Specifies text alignment.
* The value 'justify' is only supported on iOS.
*/
textAlign?: "auto" | "left" | "right" | "center"
textDecorationLine?: "none" | "underline" | "line-through" | "underline line-through"
textDecorationStyle?: "solid" | "double" | "dotted" | "dashed"
textDecorationColor?: string
textShadowColor?: string
textShadowOffset?: {width: number, height: number}
textShadowRadius?: number
testID?: string
}
export interface TextPropertiesIOS {
/**
* Specifies should fonts scale to respect Text Size accessibility
* setting on iOS.
*/
allowFontScaling: boolean
/**
* When true, no visual change is made when text is pressed down.
* By default, a gray oval highlights the text on press down.
*/
suppressHighlighting?: boolean
}
// https://facebook.github.io/react-native/docs/text.html#props
export interface TextProperties extends React.Props<TextProperties> {
/**
* Specifies should fonts scale to respect Text Size accessibility setting on iOS.
*/
allowFontScaling?: boolean
/**
* Line Break mode. Works only with numberOfLines.
* clip is working only for iOS
*/
lineBreakMode?: 'head' | 'middle' | 'tail' | 'clip'
/**
* 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.
*/
numberOfLines?: number
/**
* Invoked on mount and layout changes with
*
* {nativeEvent: { layout: {x, y, width, height}}}.
*/
onLayout?: ( event: LayoutChangeEvent ) => void
/**
* This function is called on press.
* Text intrinsically supports press handling with a default highlight state (which can be disabled with suppressHighlighting).
*/
onPress?: () => void
/**
* @see https://facebook.github.io/react-native/docs/text.html#style
*/
style?: TextStyle
/**
* Used to locate this view in end-to-end tests.
*/
testID?: string
}
/**
* A React component for displaying text which supports nesting, styling, and touch handling.
*/
export interface TextStatic extends React.ComponentClass<TextProperties> {
}
/**
* IOS Specific properties for TextInput
* @see https://facebook.github.io/react-native/docs/textinput.html#props
*/
export interface TextInputIOSProperties {
/**
* enum('never', 'while-editing', 'unless-editing', 'always')
* When the clear button should appear on the right side of the text view
*/
clearButtonMode?: string
/**
* If true, clears the text field automatically when editing begins
*/
clearTextOnFocus?: boolean
/**
* If true, the keyboard disables the return key when there is no text and automatically enables it when there is text.
* The default value is false.
*/
enablesReturnKeyAutomatically?: boolean
/**
* Callback that is called when a key is pressed.
* Pressed key value is passed as an argument to the callback handler.
* Fires before onChange callbacks.
*/
onKeyPress?: () => void
/**
* //FIXME: requires typing
* See DocumentSelectionState.js, some state that is responsible for maintaining selection information for a document
*/
selectionState?: any
}
/**
* Android Specific properties for TextInput
* @see https://facebook.github.io/react-native/docs/textinput.html#props
*/
export interface TextInputAndroidProperties {
/**
* Sets the number of lines for a TextInput.
* Use it with multiline set to true to be able to fill the lines.
*/
numberOfLines?: number
/**
* Sets the return key to the label. Use it instead of `returnKeyType`.
* @platform android
*/
returnKeyLabel?: string
/**
* enum('start', 'center', 'end')
* Set the position of the cursor from where editing will begin.
*/
textAlign?: string
/**
* enum('top', 'center', 'bottom')
* Aligns text vertically within the TextInput.
*/
textAlignVertical?: string
/**
* The color of the textInput underline.
*/
underlineColorAndroid?: string
}
/**
* @see https://facebook.github.io/react-native/docs/textinput.html#props
*/
export interface TextInputProperties extends TextInputIOSProperties, TextInputAndroidProperties, React.Props<TextInputStatic> {
/**
* Can tell TextInput to automatically capitalize certain characters.
* characters: all characters,
* words: first letter of each word
* sentences: first letter of each sentence (default)
* none: don't auto capitalize anything
*
* https://facebook.github.io/react-native/docs/textinput.html#autocapitalize
*/
autoCapitalize?: "none" | "sentences" | "words" | "characters"
/**
* If false, disables auto-correct.
* The default value is true.
*/
autoCorrect?: boolean
/**
* If true, focuses the input on componentDidMount.
* The default value is false.
*/
autoFocus?: boolean
/**
* If true, the text field will blur when submitted.
* The default value is true.
*/
blurOnSubmit?: boolean
/**
* Provides an initial value that will change when the user starts typing.
* Useful for simple use-cases where you don't want to deal with listening to events
* and updating the value prop to keep the controlled state in sync.
*/
defaultValue?: string
/**
* If false, text is not editable. The default value is true.
*/
editable?: boolean
/**
* enum("default", 'numeric', 'email-address', "ascii-capable", 'numbers-and-punctuation', 'url', 'number-pad', 'phone-pad', 'name-phone-pad', 'decimal-pad', 'twitter', 'web-search')
* Determines which keyboard to open, e.g.numeric.
* The following values work across platforms: - default - numeric - email-address
*/
keyboardType?: "default" | "email-address" | "numeric" | "phone-pad" | "ascii-capable" | "numbers-and-punctuation" | "url" | "number-pad" | "name-phone-pad" | "decimal-pad" | "twitter" | "web-search"
/**
* Limits the maximum number of characters that can be entered.
* Use this instead of implementing the logic in JS to avoid flicker.
*/
maxLength?: number
/**
* If true, the text input can be multiple lines. The default value is false.
*/
multiline?: boolean
/**
* Callback that is called when the text input is blurred
*/
onBlur?: () => void
/**
* Callback that is called when the text input's text changes.
*/
onChange?: ( event: {nativeEvent: {text: string}} ) => void
/**
* Callback that is called when the text input's text changes.
* Changed text is passed as an argument to the callback handler.
*/
onChangeText?: ( text: string ) => void
/**
* Callback that is called when text input ends.
*/
onEndEditing?: ( event: {nativeEvent: {text: string}} ) => void
/**
* Callback that is called when the text input is focused
*/
onFocus?: () => void
/**
* Invoked on mount and layout changes with {x, y, width, height}.
*/
onLayout?: ( event: {nativeEvent: {x: number, y: number, width: number, height: number}} ) => void
onSelectionChange?: () => void
/**
* Callback that is called when the text input's submit button is pressed.
*/
onSubmitEditing?: ( event: {nativeEvent: {text: string}} ) => void
/**
* //FIXME: Not part of the doc but found in examples
*/
password?: boolean
/**
* The string that will be rendered before text input has been entered
*/
placeholder?: string
/**
* The text color of the placeholder string
*/
placeholderTextColor?: string
/**
* enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call')
* Determines how the return key should look.
*/
returnKeyType?: "default" | "go" | "google" | "join" | "next" | "route" | "search" | "send" | "yahoo" | "done" | "emergency-call"
/**
* If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
* The default value is false.
*/
secureTextEntry?: boolean
/**
* If true, all text will automatically be selected on focus
*/
selectTextOnFocus?: boolean
/**
* The highlight (and cursor on ios) color of the text input
*/
selectionColor?: string
/**
* Styles
*/
style?: TextStyle
/**
* Used to locate this view in end-to-end tests
*/
testID?: string
/**
* The value to show for the text input. TextInput is a controlled component,
* which means the native value will be forced to match this value prop if provided.
* 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.
* In addition to simply setting the same value, either set editable={false},
* or set/update maxLength to prevent unwanted edits without flicker.
*/
value?: string
}
/**
* @see https://facebook.github.io/react-native/docs/textinput.html#methods
*/
export interface TextInputStatic extends NativeComponent, React.ComponentClass<TextInputProperties> {
/**
* Returns if the input is currently focused.
*/
isFocused: () => boolean
/**
* Removes all text from the input.
*/
clear: () => void
// The following methods are found only in implementation
blur: () => void
focus: () => void
}
export type ToolbarAndroidAction = {
/**
* title: required, the title of this action
*/
title: string
/**
* icon: the icon for this action, e.g. require('./some_icon.png')
*/
icon?: any
/**
* show: when to show this action as an icon or hide it in the overflow menu: always, ifRoom or never
*/
show?: "always" | "ifRoom" | "never"
/**
* showWithText: boolean, whether to show text alongside the icon or not
*/
showWithText?: boolean
}
export interface ToolbarAndroidProperties extends ViewProperties, React.Props<ToolbarAndroidStatic> {
actions?: ToolbarAndroidAction[]
/**
* Sets the content inset for the toolbar ending edge.
* The content inset affects the valid area for Toolbar content other
* than the navigation button and menu. Insets define the minimum
* margin for these components and can be used to effectively align
* Toolbar content along well-known gridlines.
*/
contentInsetEnd?: number
/**
* Sets the content inset for the toolbar starting edge.
* The content inset affects the valid area for Toolbar content
* other than the navigation button and menu. Insets define the
* minimum margin for these components and can be used to effectively
* align Toolbar content along well-known gridlines.
*/
contentInsetStart?: number
/**
* Sets the toolbar logo.
*/
logo?: any
/**
* Sets the navigation icon.
*/
navIcon?: any
/**
* Callback that is called when an action is selected. The only
* argument that is passed to the callback is the position of the
* action in the actions array.
*/
onActionSelected?: (position: number) => void
/**
* Callback called when the icon is selected.
*/
onIconClicked?: () => void
/**
* Sets the overflow icon.
*/
overflowIcon?: any
/**
* Used to set the toolbar direction to RTL.
* In addition to this property you need to add
* android:supportsRtl="true"
* to your application AndroidManifest.xml and then call
* setLayoutDirection(LayoutDirection.RTL) in your MainActivity
* onCreate method.
*/
rtl?: boolean
/**
* Sets the toolbar subtitle.
*/
subtitle?: string
/**
* Sets the toolbar subtitle color.
*/
subtitleColor?: string
/**
* Used to locate this view in end-to-end tests.
*/
testID?: string
/**
* Sets the toolbar title.
*/
title?: string
/**
* Sets the toolbar title color.
*/
titleColor?: string
ref?: Ref<ToolbarAndroidStatic>
}
export interface ToolbarAndroidStatic extends React.ComponentClass<ToolbarAndroidProperties> {
}
/**
* Gesture recognition on mobile devices is much more complicated than web.
* A touch can go through several phases as the app determines what the user's intention is.
* For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping.
* This can even change during the duration of a touch. There can also be multiple simultaneous touches.
*
* The touch responder system is needed to allow components to negotiate these touch interactions
* without any additional knowledge about their parent or child components.
* This system is implemented in ResponderEventPlugin.js, which contains further details and documentation.
*
* Best Practices
* Users can feel huge differences in the usability of web apps vs. native, and this is one of the big causes.
* Every action should have the following attributes:
* Feedback/highlighting- show the user what is handling their touch, and what will happen when they release the gesture
* Cancel-ability- when making an action, the user should be able to abort it mid-touch by dragging their finger away
*
* These features make users more comfortable while using an app,
* because it allows people to experiment and interact without fear of making mistakes.
*
* TouchableHighlight and Touchable*
* The responder system can be complicated to use.
* So we have provided an abstract Touchable implementation for things that should be "tappable".
* This uses the responder system and allows you to easily configure tap interactions declaratively.
* Use TouchableHighlight anywhere where you would use a button or link on web.
*/
export interface GestureResponderHandlers {
/**
* A view can become the touch responder by implementing the correct negotiation methods.
* There are two methods to ask the view if it wants to become responder:
*/
/**
* Does this view want to become responder on the start of a touch?
*/
onStartShouldSetResponder?: ( event: GestureResponderEvent ) => boolean
/**
* Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness?
*/
onMoveShouldSetResponder?: ( event: GestureResponderEvent ) => boolean
/**
* If the View returns true and attempts to become the responder, one of the following will happen:
*/
/**
* The View is now responding for touch events.
* This is the time to highlight and show the user what is happening
*/
onResponderGrant?: ( event: GestureResponderEvent ) => void
/**
* Something else is the responder right now and will not release it
*/
onResponderReject?: ( event: GestureResponderEvent ) => void
/**
* If the view is responding, the following handlers can be called:
*/
/**
* The user is moving their finger
*/
onResponderMove?: ( event: GestureResponderEvent ) => void
/**
* Fired at the end of the touch, ie "touchUp"
*/
onResponderRelease?: ( event: GestureResponderEvent ) => void