1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | import type * as React from 'react';
|
11 | import {Constructor} from '../../../types/private/Utilities';
|
12 | import {NativeMethods} from '../../../types/public/ReactNativeTypes';
|
13 | import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
|
14 | import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
|
15 | import {ViewProps} from '../View/ViewPropTypes';
|
16 | import {NativeSyntheticEvent, TargetedEvent} from '../../Types/CoreEventTypes';
|
17 |
|
18 | export interface SwitchPropsIOS extends ViewProps {
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 | onTintColor?: ColorValue | undefined;
|
25 |
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 | thumbTintColor?: ColorValue | undefined;
|
32 |
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 | tintColor?: ColorValue | undefined;
|
39 | }
|
40 |
|
41 | export interface SwitchChangeEventData extends TargetedEvent {
|
42 | value: boolean;
|
43 | }
|
44 |
|
45 | export interface SwitchChangeEvent
|
46 | extends NativeSyntheticEvent<SwitchChangeEventData> {}
|
47 |
|
48 | export interface SwitchProps extends SwitchPropsIOS {
|
49 | |
50 |
|
51 |
|
52 | thumbColor?: ColorValue | undefined;
|
53 |
|
54 | |
55 |
|
56 |
|
57 |
|
58 |
|
59 | trackColor?:
|
60 | | {
|
61 | false?: ColorValue | null | undefined;
|
62 | true?: ColorValue | null | undefined;
|
63 | }
|
64 | | undefined;
|
65 |
|
66 | |
67 |
|
68 |
|
69 |
|
70 | disabled?: boolean | undefined;
|
71 |
|
72 | |
73 |
|
74 |
|
75 | onChange?:
|
76 | | ((event: SwitchChangeEvent) => Promise<void> | void)
|
77 | | null
|
78 | | undefined;
|
79 |
|
80 | /**
|
81 | * Invoked with the new value when the value changes.
|
82 | */
|
83 | onValueChange?: ((value: boolean) => Promise<void> | void) | null | undefined;
|
84 |
|
85 | /**
|
86 | * Used to locate this view in end-to-end tests.
|
87 | */
|
88 | testID?: string | undefined;
|
89 |
|
90 | /**
|
91 | * The value of the switch. If true the switch will be turned on.
|
92 | * Default value is false.
|
93 | */
|
94 | value?: boolean | undefined;
|
95 |
|
96 | /**
|
97 | * On iOS, custom color for the background.
|
98 | * Can be seen when the switch value is false or when the switch is disabled.
|
99 | */
|
100 | ios_backgroundColor?: ColorValue | undefined;
|
101 |
|
102 | style?: StyleProp<ViewStyle> | undefined;
|
103 | }
|
104 |
|
105 | /**
|
106 | * Renders a boolean input.
|
107 | *
|
108 | * This is a controlled component that requires an `onValueChange` callback that
|
109 | * updates the `value` prop in order for the component to reflect user actions.
|
110 | * If the `value` prop is not updated, the component will continue to render
|
111 | * the supplied `value` prop instead of the expected result of any user actions.
|
112 | */
|
113 | declare class SwitchComponent extends React.Component<SwitchProps> {}
|
114 | declare const SwitchBase: Constructor<NativeMethods> & typeof SwitchComponent;
|
115 | export class Switch extends SwitchBase {}
|
116 |
|
\ | No newline at end of file |