UNPKG

6.66 kBTypeScriptView Raw
1import * as React from 'react';
2import { Animated, ColorValue, GestureResponderEvent, StyleProp, TextStyle, ViewStyle } from 'react-native';
3import type { ThemeProp } from '../../types';
4import type { IconSource } from '../Icon';
5export type Props = {
6 /**
7 * Action items to display in the form of a speed dial.
8 * An action item should contain the following properties:
9 * - `icon`: icon to display (required)
10 * - `label`: optional label text
11 * - `color`: custom icon color of the action item
12 * - `labelTextColor`: custom label text color of the action item
13 * - `accessibilityLabel`: accessibility label for the action, uses label by default if specified
14 * - `accessibilityHint`: accessibility hint for the action
15 * - `style`: pass additional styles for the fab item, for example, `backgroundColor`
16 * - `containerStyle`: pass additional styles for the fab item label container, for example, `backgroundColor` @supported Available in 5.x
17 * - `labelStyle`: pass additional styles for the fab item label, for example, `fontSize`
18 * - `labelMaxFontSizeMultiplier`: specifies the largest possible scale a title font can reach.
19 * - `onPress`: callback that is called when `FAB` is pressed (required)
20 * - `onLongPress`: callback that is called when `FAB` is long pressed
21 * - `toggleStackOnLongPress`: callback that is called when `FAB` is long pressed
22 * - `size`: size of action item. Defaults to `small`. @supported Available in v5.x
23 * - `testID`: testID to be used on tests
24 * - `rippleColor`: color of the ripple effect.
25 */
26 actions: Array<{
27 icon: IconSource;
28 label?: string;
29 color?: string;
30 labelTextColor?: string;
31 accessibilityLabel?: string;
32 accessibilityHint?: string;
33 style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
34 containerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
35 labelStyle?: StyleProp<TextStyle>;
36 labelMaxFontSizeMultiplier?: number;
37 onPress: (e: GestureResponderEvent) => void;
38 size?: 'small' | 'medium';
39 testID?: string;
40 rippleColor?: ColorValue;
41 }>;
42 /**
43 * Icon to display for the `FAB`.
44 * You can toggle it based on whether the speed dial is open to display a different icon.
45 */
46 icon: IconSource;
47 /**
48 * Accessibility label for the FAB. This is read by the screen reader when the user taps the FAB.
49 */
50 accessibilityLabel?: string;
51 /**
52 * Custom color for the `FAB`.
53 */
54 color?: string;
55 /**
56 * Custom backdrop color for opened speed dial background.
57 */
58 backdropColor?: string;
59 /**
60 * Color of the ripple effect.
61 */
62 rippleColor?: ColorValue;
63 /**
64 * Function to execute on pressing the `FAB`.
65 */
66 onPress?: (e: GestureResponderEvent) => void;
67 /**
68 * Function to execute on long pressing the `FAB`.
69 */
70 onLongPress?: (e: GestureResponderEvent) => void;
71 /**
72 * Makes actions stack appear on long press instead of on press.
73 */
74 toggleStackOnLongPress?: boolean;
75 /**
76 * Changes the delay for long press reaction.
77 */
78 delayLongPress?: number;
79 /**
80 * Allows for onLongPress when stack is opened.
81 */
82 enableLongPressWhenStackOpened?: boolean;
83 /**
84 * Whether the speed dial is open.
85 */
86 open: boolean;
87 /**
88 * Callback which is called on opening and closing the speed dial.
89 * The open state needs to be updated when it's called, otherwise the change is dropped.
90 */
91 onStateChange: (state: {
92 open: boolean;
93 }) => void;
94 /**
95 * Whether `FAB` is currently visible.
96 */
97 visible: boolean;
98 /**
99 * Style for the group. You can use it to pass additional styles if you need.
100 * For example, you can set an additional padding if you have a tab bar at the bottom.
101 */
102 style?: StyleProp<ViewStyle>;
103 /**
104 * Style for the FAB. It allows to pass the FAB button styles, such as backgroundColor.
105 */
106 fabStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
107 /**
108 * @supported Available in v5.x with theme version 3
109 *
110 * Color mappings variant for combinations of container and icon colors.
111 */
112 variant?: 'primary' | 'secondary' | 'tertiary' | 'surface';
113 /**
114 * @optional
115 */
116 theme?: ThemeProp;
117 /**
118 * Optional label for `FAB`.
119 */
120 label?: string;
121 /**
122 * Pass down testID from Group props to FAB.
123 */
124 testID?: string;
125};
126/**
127 * A component to display a stack of FABs with related actions in a speed dial.
128 * To render the group above other components, you'll need to wrap it with the [`Portal`](../Portal) component.
129 *
130 * ## Usage
131 * ```js
132 * import * as React from 'react';
133 * import { FAB, Portal, PaperProvider } from 'react-native-paper';
134 *
135 * const MyComponent = () => {
136 * const [state, setState] = React.useState({ open: false });
137 *
138 * const onStateChange = ({ open }) => setState({ open });
139 *
140 * const { open } = state;
141 *
142 * return (
143 * <PaperProvider>
144 * <Portal>
145 * <FAB.Group
146 * open={open}
147 * visible
148 * icon={open ? 'calendar-today' : 'plus'}
149 * actions={[
150 * { icon: 'plus', onPress: () => console.log('Pressed add') },
151 * {
152 * icon: 'star',
153 * label: 'Star',
154 * onPress: () => console.log('Pressed star'),
155 * },
156 * {
157 * icon: 'email',
158 * label: 'Email',
159 * onPress: () => console.log('Pressed email'),
160 * },
161 * {
162 * icon: 'bell',
163 * label: 'Remind',
164 * onPress: () => console.log('Pressed notifications'),
165 * },
166 * ]}
167 * onStateChange={onStateChange}
168 * onPress={() => {
169 * if (open) {
170 * // do something if the speed dial is open
171 * }
172 * }}
173 * />
174 * </Portal>
175 * </PaperProvider>
176 * );
177 * };
178 *
179 * export default MyComponent;
180 * ```
181 */
182declare const FABGroup: {
183 ({ actions, icon, open, onPress, onLongPress, toggleStackOnLongPress, accessibilityLabel, theme: themeOverrides, style, fabStyle, visible, label, testID, onStateChange, color: colorProp, delayLongPress, variant, enableLongPressWhenStackOpened, backdropColor: customBackdropColor, rippleColor, }: Props): React.JSX.Element;
184 displayName: string;
185};
186export default FABGroup;
187export { FABGroup };
188//# sourceMappingURL=FABGroup.d.ts.map
\No newline at end of file