1 | import * as React from 'react';
|
2 | import { AccessibilityProps, ColorValue, StyleProp, ViewStyle } from 'react-native';
|
3 | import type { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler';
|
4 | export interface RawButtonProps extends NativeViewGestureHandlerProps, AccessibilityProps {
|
5 | /**
|
6 | * Defines if more than one button could be pressed simultaneously. By default
|
7 | * set true.
|
8 | */
|
9 | exclusive?: boolean;
|
10 | /**
|
11 | * Android only.
|
12 | *
|
13 | * Defines color of native ripple animation used since API level 21.
|
14 | */
|
15 | rippleColor?: number | ColorValue | null;
|
16 | /**
|
17 | * Android only.
|
18 | *
|
19 | * Defines radius of native ripple animation used since API level 21.
|
20 | */
|
21 | rippleRadius?: number | null;
|
22 | /**
|
23 | * Android only.
|
24 | *
|
25 | * Set this to true if you want the ripple animation to render outside the view bounds.
|
26 | */
|
27 | borderless?: boolean;
|
28 | /**
|
29 | * Android only.
|
30 | *
|
31 | * Defines whether the ripple animation should be drawn on the foreground of the view.
|
32 | */
|
33 | foreground?: boolean;
|
34 | /**
|
35 | * Android only.
|
36 | *
|
37 | * Set this to true if you don't want the system to play sound when the button is pressed.
|
38 | */
|
39 | touchSoundDisabled?: boolean;
|
40 | /**
|
41 | * Style object, use it to set additional styles.
|
42 | */
|
43 | style?: StyleProp<ViewStyle>;
|
44 | /**
|
45 | * Used for testing-library compatibility, not passed to the native component.
|
46 | */
|
47 | testOnly_onPress?: Function | null;
|
48 | /**
|
49 | * Used for testing-library compatibility, not passed to the native component.
|
50 | */
|
51 | testOnly_onPressIn?: Function | null;
|
52 | /**
|
53 | * Used for testing-library compatibility, not passed to the native component.
|
54 | */
|
55 | testOnly_onPressOut?: Function | null;
|
56 | /**
|
57 | * Used for testing-library compatibility, not passed to the native component.
|
58 | */
|
59 | testOnly_onLongPress?: Function | null;
|
60 | }
|
61 | interface ButtonWithRefProps {
|
62 | innerRef?: React.ForwardedRef<React.ComponentType<any>>;
|
63 | }
|
64 | export interface BaseButtonProps extends RawButtonProps {
|
65 | /**
|
66 | * Called when the button gets pressed (analogous to `onPress` in
|
67 | * `TouchableHighlight` from RN core).
|
68 | */
|
69 | onPress?: (pointerInside: boolean) => void;
|
70 | /**
|
71 | * Called when the button gets pressed and is held for `delayLongPress`
|
72 | * milliseconds.
|
73 | */
|
74 | onLongPress?: () => void;
|
75 | /**
|
76 | * Called when button changes from inactive to active and vice versa. It
|
77 | * passes active state as a boolean variable as a first parameter for that
|
78 | * method.
|
79 | */
|
80 | onActiveStateChange?: (active: boolean) => void;
|
81 | style?: StyleProp<ViewStyle>;
|
82 | testID?: string;
|
83 | /**
|
84 | * Delay, in milliseconds, after which the `onLongPress` callback gets called.
|
85 | * Defaults to 600.
|
86 | */
|
87 | delayLongPress?: number;
|
88 | }
|
89 | export interface BaseButtonWithRefProps extends BaseButtonProps, ButtonWithRefProps {
|
90 | }
|
91 | export interface RectButtonProps extends BaseButtonProps {
|
92 | /**
|
93 | * Background color that will be dimmed when button is in active state.
|
94 | */
|
95 | underlayColor?: string;
|
96 | /**
|
97 | * iOS only.
|
98 | *
|
99 | * Opacity applied to the underlay when button is in active state.
|
100 | */
|
101 | activeOpacity?: number;
|
102 | }
|
103 | export interface RectButtonWithRefProps extends RectButtonProps, ButtonWithRefProps {
|
104 | }
|
105 | export interface BorderlessButtonProps extends BaseButtonProps {
|
106 | /**
|
107 | * iOS only.
|
108 | *
|
109 | * Opacity applied to the button when it is in an active state.
|
110 | */
|
111 | activeOpacity?: number;
|
112 | }
|
113 | export interface BorderlessButtonWithRefProps extends BorderlessButtonProps, ButtonWithRefProps {
|
114 | }
|
115 | export {};
|