1+ // These types are derived from @types /react-native.
2+ // All credit goes to amazing people who made the react-native typings.
3+
4+ import * as React from 'react' ;
5+ import {
6+ ViewProps ,
7+ NativeSyntheticEvent ,
8+ NativeSegmentedControlIOSChangeEvent ,
9+ NativeMethodsMixin ,
10+ Constructor
11+ } from 'react-native'
12+
13+ export interface SegmentedControlIOSProps extends ViewProps {
14+ /**
15+ * If false the user won't be able to interact with the control. Default value is true.
16+ */
17+ enabled ?: boolean ;
18+
19+ /**
20+ * If true, then selecting a segment won't persist visually.
21+ * The onValueChange callback will still work as expected.
22+ */
23+ momentary ?: boolean ;
24+
25+ /**
26+ * Callback that is called when the user taps a segment;
27+ * passes the event as an argument
28+ */
29+ onChange ?: ( event : NativeSyntheticEvent < NativeSegmentedControlIOSChangeEvent > ) => void ;
30+
31+ /**
32+ * Callback that is called when the user taps a segment; passes the segment's value as an argument
33+ */
34+ onValueChange ?: ( value : string ) => void ;
35+
36+ /**
37+ * The index in props.values of the segment to be (pre)selected.
38+ */
39+ selectedIndex ?: number ;
40+
41+ /**
42+ * Accent color of the control.
43+ */
44+ tintColor ?: string ;
45+
46+ /**
47+ * The labels for the control's segment buttons, in order.
48+ */
49+ values ?: string [ ] ;
50+ }
51+
52+ /**
53+ * Use `SegmentedControlIOS` to render a UISegmentedControl iOS.
54+ *
55+ * #### Programmatically changing selected index
56+ *
57+ * The selected index can be changed on the fly by assigning the
58+ * selectIndex prop to a state variable, then changing that variable.
59+ * Note that the state variable would need to be updated as the user
60+ * selects a value and changes the index, as shown in the example below.
61+ *
62+ * ````
63+ * <SegmentedControlIOS
64+ * values={['One', 'Two']}
65+ * selectedIndex={this.state.selectedIndex}
66+ * onChange={(event) => {
67+ * this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex});
68+ * }}
69+ * />
70+ * ````
71+ */
72+ declare class SegmentedControlIOSComponent extends React . Component < SegmentedControlIOSProps > { }
73+ declare const SegmentedControlIOSBase : Constructor < NativeMethodsMixin > & typeof SegmentedControlIOSComponent ;
74+ export default class SegmentedControlIOS extends SegmentedControlIOSBase { }
0 commit comments