-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathAppbarBackAction.tsx
More file actions
78 lines (71 loc) · 1.74 KB
/
AppbarBackAction.tsx
File metadata and controls
78 lines (71 loc) · 1.74 KB
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
import * as React from 'react';
import type {
Animated,
GestureResponderEvent,
StyleProp,
View,
ViewStyle,
} from 'react-native';
import type { $Omit } from '@/types';
import { forwardRef } from '@/utils/forwardRef';
import AppbarAction from './AppbarAction';
import AppbarBackIcon from './AppbarBackIcon';
export type Props = $Omit<
React.ComponentPropsWithoutRef<typeof AppbarAction>,
'icon'
> & {
/**
* Custom color for back icon.
*/
color?: string;
/**
* Optional icon size.
*/
size?: number;
/**
* Whether the button is disabled. A disabled button is greyed out and `onPress` is not called on touch.
*/
disabled?: boolean;
/**
* Accessibility label for the button. This is read by the screen reader when the user taps the button.
*/
accessibilityLabel?: string;
/**
* Function to execute on press.
*/
onPress?: (e: GestureResponderEvent) => void;
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
ref?: React.RefObject<View>;
};
/**
* A component used to display a back button in the appbar.
*
* ## Usage
* ```js
* import * as React from 'react';
* import { Appbar } from 'react-native-paper';
*
* const MyComponent = () => (
* <Appbar.Header>
* <Appbar.BackAction onPress={() => {}} />
* </Appbar.Header>
* );
*
* export default MyComponent;
* ```
*/
const AppbarBackAction = forwardRef<View, Props>(
({ accessibilityLabel = 'Back', ...rest }: Props, ref) => (
<AppbarAction
accessibilityLabel={accessibilityLabel}
{...rest}
icon={AppbarBackIcon}
isLeading
ref={ref}
/>
)
);
AppbarBackAction.displayName = 'Appbar.BackAction';
export default AppbarBackAction;
// @component-docs ignore-next-line
export { AppbarBackAction };