UNPKG

4.19 kBTypeScriptView Raw
1import * as React from 'react';
2import { Animated, StyleProp, View, ViewStyle } from 'react-native';
3import type { ThemeProp } from '../../types';
4export declare type Props = Omit<Partial<React.ComponentPropsWithRef<typeof View>>, 'style'> & {
5 /**
6 * Whether the background color is a dark color. A dark appbar will render light text and vice-versa.
7 */
8 dark?: boolean;
9 /**
10 * Content of the `Appbar`.
11 */
12 children: React.ReactNode;
13 /**
14 * @supported Available in v5.x with theme version 3
15 *
16 * Mode of the Appbar.
17 * - `small` - Appbar with default height (64).
18 * - `medium` - Appbar with medium height (112).
19 * - `large` - Appbar with large height (152).
20 * - `center-aligned` - Appbar with default height and center-aligned title.
21 */
22 mode?: 'small' | 'medium' | 'large' | 'center-aligned';
23 /**
24 * @supported Available in v5.x with theme version 3
25 * Whether Appbar background should have the elevation along with primary color pigment.
26 */
27 elevated?: boolean;
28 /**
29 * Safe area insets for the Appbar. This can be used to avoid elements like the navigation bar on Android and bottom safe area on iOS.
30 */
31 safeAreaInsets?: {
32 bottom?: number;
33 top?: number;
34 left?: number;
35 right?: number;
36 };
37 /**
38 * @optional
39 */
40 theme?: ThemeProp;
41 style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
42};
43/**
44 * A component to display action items in a bar. It can be placed at the top or bottom.
45 * The top bar usually contains the screen title, controls such as navigation buttons, menu button etc.
46 * The bottom bar usually provides access to a drawer and up to four actions.
47 *
48 * By default Appbar uses primary color as a background, in dark theme with `adaptive` mode it will use surface colour instead.
49 * See [Dark Theme](https://callstack.github.io/react-native-paper/docs/guides/theming#dark-theme) for more informations
50 *
51 * ## Usage
52 * ### Top bar
53 * ```js
54 * import * as React from 'react';
55 * import { Appbar } from 'react-native-paper';
56 *
57 * const MyComponent = () => (
58 * <Appbar.Header>
59 * <Appbar.BackAction onPress={() => {}} />
60 * <Appbar.Content title="Title" />
61 * <Appbar.Action icon="calendar" onPress={() => {}} />
62 * <Appbar.Action icon="magnify" onPress={() => {}} />
63 * </Appbar.Header>
64 * );
65 *
66 * export default MyComponent;
67 * ```
68 *
69 * ### Bottom bar
70 * ```js
71 * import * as React from 'react';
72 * import { StyleSheet } from 'react-native';
73 * import { Appbar, FAB, useTheme } from 'react-native-paper';
74 * import { useSafeAreaInsets } from 'react-native-safe-area-context';
75 *
76 * const BOTTOM_APPBAR_HEIGHT = 80;
77 * const MEDIUM_FAB_HEIGHT = 56;
78 *
79 * const MyComponent = () => {
80 * const { bottom } = useSafeAreaInsets();
81 * const theme = useTheme();
82 *
83 * return (
84 * <Appbar
85 * style={[
86 * styles.bottom,
87 * {
88 * height: BOTTOM_APPBAR_HEIGHT + bottom,
89 * backgroundColor: theme.colors.elevation.level2,
90 * },
91 * ]}
92 * safeAreaInsets={{ bottom }}
93 * >
94 * <Appbar.Action icon="archive" onPress={() => {}} />
95 * <Appbar.Action icon="email" onPress={() => {}} />
96 * <Appbar.Action icon="label" onPress={() => {}} />
97 * <Appbar.Action icon="delete" onPress={() => {}} />
98 * <FAB
99 * mode="flat"
100 * size="medium"
101 * icon="plus"
102 * onPress={() => {}}
103 * style={[
104 * styles.fab,
105 * { top: (BOTTOM_APPBAR_HEIGHT - MEDIUM_FAB_HEIGHT) / 2 },
106 * ]}
107 * />
108 * </Appbar>
109 * );
110 * };
111 *
112 * const styles = StyleSheet.create({
113 * bottom: {
114 * backgroundColor: 'aquamarine',
115 * position: 'absolute',
116 * left: 0,
117 * right: 0,
118 * bottom: 0,
119 * },
120 * fab: {
121 * position: 'absolute',
122 * right: 16,
123 * },
124 * });
125 *
126 * export default MyComponent;
127 * ```
128 */
129declare const Appbar: ({ children, dark, style, mode, elevated, safeAreaInsets, theme: themeOverrides, ...rest }: Props) => React.JSX.Element;
130export default Appbar;
131export { Appbar };
132//# sourceMappingURL=Appbar.d.ts.map
\No newline at end of file