@react-navigation/elements 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/lib/commonjs/Background.js +34 -0
- package/lib/commonjs/Background.js.map +1 -0
- package/lib/commonjs/Header/Header.js +250 -0
- package/lib/commonjs/Header/Header.js.map +1 -0
- package/lib/commonjs/Header/HeaderBackButton.js +222 -0
- package/lib/commonjs/Header/HeaderBackButton.js.map +1 -0
- package/lib/commonjs/Header/HeaderBackContext.js +15 -0
- package/lib/commonjs/Header/HeaderBackContext.js.map +1 -0
- package/lib/commonjs/Header/HeaderBackground.js +57 -0
- package/lib/commonjs/Header/HeaderBackground.js.map +1 -0
- package/lib/commonjs/Header/HeaderHeightContext.js +15 -0
- package/lib/commonjs/Header/HeaderHeightContext.js.map +1 -0
- package/lib/commonjs/Header/HeaderShownContext.js +15 -0
- package/lib/commonjs/Header/HeaderShownContext.js.map +1 -0
- package/lib/commonjs/Header/HeaderTitle.js +56 -0
- package/lib/commonjs/Header/HeaderTitle.js.map +1 -0
- package/lib/commonjs/Header/getDefaultHeaderHeight.js +40 -0
- package/lib/commonjs/Header/getDefaultHeaderHeight.js.map +1 -0
- package/lib/commonjs/Header/getHeaderTitle.js +11 -0
- package/lib/commonjs/Header/getHeaderTitle.js.map +1 -0
- package/lib/commonjs/Header/useHeaderHeight.js +27 -0
- package/lib/commonjs/Header/useHeaderHeight.js.map +1 -0
- package/lib/commonjs/MaskedView.android.js +16 -0
- package/lib/commonjs/MaskedView.android.js.map +1 -0
- package/lib/commonjs/MaskedView.ios.js +16 -0
- package/lib/commonjs/MaskedView.ios.js.map +1 -0
- package/lib/commonjs/MaskedView.js +16 -0
- package/lib/commonjs/MaskedView.js.map +1 -0
- package/lib/commonjs/MaskedViewNative.js +40 -0
- package/lib/commonjs/MaskedViewNative.js.map +1 -0
- package/lib/commonjs/MissingIcon.js +34 -0
- package/lib/commonjs/MissingIcon.js.map +1 -0
- package/lib/commonjs/PlatformPressable.js +77 -0
- package/lib/commonjs/PlatformPressable.js.map +1 -0
- package/lib/commonjs/ResourceSavingView.js +64 -0
- package/lib/commonjs/ResourceSavingView.js.map +1 -0
- package/lib/commonjs/SafeAreaProviderCompat.js +69 -0
- package/lib/commonjs/SafeAreaProviderCompat.js.map +1 -0
- package/lib/commonjs/Screen.js +89 -0
- package/lib/commonjs/Screen.js.map +1 -0
- package/lib/commonjs/assets/back-icon-mask.png +0 -0
- package/lib/commonjs/assets/back-icon.png +0 -0
- package/lib/commonjs/assets/back-icon@1.5x.android.png +0 -0
- package/lib/commonjs/assets/back-icon@1.5x.ios.png +0 -0
- package/lib/commonjs/assets/back-icon@1x.android.png +0 -0
- package/lib/commonjs/assets/back-icon@1x.ios.png +0 -0
- package/lib/commonjs/assets/back-icon@2x.android.png +0 -0
- package/lib/commonjs/assets/back-icon@2x.ios.png +0 -0
- package/lib/commonjs/assets/back-icon@3x.android.png +0 -0
- package/lib/commonjs/assets/back-icon@3x.ios.png +0 -0
- package/lib/commonjs/assets/back-icon@4x.android.png +0 -0
- package/lib/commonjs/assets/back-icon@4x.ios.png +0 -0
- package/lib/commonjs/getNamedContext.js +32 -0
- package/lib/commonjs/getNamedContext.js.map +1 -0
- package/lib/commonjs/index.js +175 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/Background.js +20 -0
- package/lib/module/Background.js.map +1 -0
- package/lib/module/Header/Header.js +229 -0
- package/lib/module/Header/Header.js.map +1 -0
- package/lib/module/Header/HeaderBackButton.js +203 -0
- package/lib/module/Header/HeaderBackButton.js.map +1 -0
- package/lib/module/Header/HeaderBackContext.js +4 -0
- package/lib/module/Header/HeaderBackContext.js.map +1 -0
- package/lib/module/Header/HeaderBackground.js +42 -0
- package/lib/module/Header/HeaderBackground.js.map +1 -0
- package/lib/module/Header/HeaderHeightContext.js +4 -0
- package/lib/module/Header/HeaderHeightContext.js.map +1 -0
- package/lib/module/Header/HeaderShownContext.js +4 -0
- package/lib/module/Header/HeaderShownContext.js.map +1 -0
- package/lib/module/Header/HeaderTitle.js +41 -0
- package/lib/module/Header/HeaderTitle.js.map +1 -0
- package/lib/module/Header/getDefaultHeaderHeight.js +32 -0
- package/lib/module/Header/getDefaultHeaderHeight.js.map +1 -0
- package/lib/module/Header/getHeaderTitle.js +4 -0
- package/lib/module/Header/getHeaderTitle.js.map +1 -0
- package/lib/module/Header/useHeaderHeight.js +12 -0
- package/lib/module/Header/useHeaderHeight.js.map +1 -0
- package/lib/module/MaskedView.android.js +2 -0
- package/lib/module/MaskedView.android.js.map +1 -0
- package/lib/module/MaskedView.ios.js +2 -0
- package/lib/module/MaskedView.ios.js.map +1 -0
- package/lib/module/MaskedView.js +9 -0
- package/lib/module/MaskedView.js.map +1 -0
- package/lib/module/MaskedViewNative.js +26 -0
- package/lib/module/MaskedViewNative.js.map +1 -0
- package/lib/module/MissingIcon.js +20 -0
- package/lib/module/MissingIcon.js.map +1 -0
- package/lib/module/PlatformPressable.js +62 -0
- package/lib/module/PlatformPressable.js.map +1 -0
- package/lib/module/ResourceSavingView.js +50 -0
- package/lib/module/ResourceSavingView.js.map +1 -0
- package/lib/module/SafeAreaProviderCompat.js +51 -0
- package/lib/module/SafeAreaProviderCompat.js.map +1 -0
- package/lib/module/Screen.js +67 -0
- package/lib/module/Screen.js.map +1 -0
- package/lib/module/assets/back-icon-mask.png +0 -0
- package/lib/module/assets/back-icon.png +0 -0
- package/lib/module/assets/back-icon@1.5x.android.png +0 -0
- package/lib/module/assets/back-icon@1.5x.ios.png +0 -0
- package/lib/module/assets/back-icon@1x.android.png +0 -0
- package/lib/module/assets/back-icon@1x.ios.png +0 -0
- package/lib/module/assets/back-icon@2x.android.png +0 -0
- package/lib/module/assets/back-icon@2x.ios.png +0 -0
- package/lib/module/assets/back-icon@3x.android.png +0 -0
- package/lib/module/assets/back-icon@3x.ios.png +0 -0
- package/lib/module/assets/back-icon@4x.android.png +0 -0
- package/lib/module/assets/back-icon@4x.ios.png +0 -0
- package/lib/module/getNamedContext.js +19 -0
- package/lib/module/getNamedContext.js.map +1 -0
- package/lib/module/index.js +21 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/src/Background.d.ts +7 -0
- package/lib/typescript/src/Header/Header.d.ts +18 -0
- package/lib/typescript/src/Header/HeaderBackButton.d.ts +3 -0
- package/lib/typescript/src/Header/HeaderBackContext.d.ts +5 -0
- package/lib/typescript/src/Header/HeaderBackground.d.ts +8 -0
- package/lib/typescript/src/Header/HeaderHeightContext.d.ts +3 -0
- package/lib/typescript/src/Header/HeaderShownContext.d.ts +3 -0
- package/lib/typescript/src/Header/HeaderTitle.d.ts +9 -0
- package/lib/typescript/src/Header/getDefaultHeaderHeight.d.ts +2 -0
- package/lib/typescript/src/Header/getHeaderTitle.d.ts +5 -0
- package/lib/typescript/src/Header/useHeaderHeight.d.ts +1 -0
- package/lib/typescript/src/MaskedView.android.d.ts +1 -0
- package/lib/typescript/src/MaskedView.d.ts +10 -0
- package/lib/typescript/src/MaskedView.ios.d.ts +1 -0
- package/lib/typescript/src/MaskedViewNative.d.ts +10 -0
- package/lib/typescript/src/MissingIcon.d.ts +9 -0
- package/lib/typescript/src/PlatformPressable.d.ts +12 -0
- package/lib/typescript/src/ResourceSavingView.d.ts +9 -0
- package/lib/typescript/src/SafeAreaProviderCompat.d.ts +11 -0
- package/lib/typescript/src/Screen.d.ts +17 -0
- package/lib/typescript/src/getNamedContext.d.ts +5 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/types.d.ts +202 -0
- package/package.json +72 -0
- package/src/Background.tsx +18 -0
- package/src/Header/Header.tsx +306 -0
- package/src/Header/HeaderBackButton.tsx +240 -0
- package/src/Header/HeaderBackContext.tsx +8 -0
- package/src/Header/HeaderBackground.tsx +56 -0
- package/src/Header/HeaderHeightContext.tsx +8 -0
- package/src/Header/HeaderShownContext.tsx +5 -0
- package/src/Header/HeaderTitle.tsx +52 -0
- package/src/Header/getDefaultHeaderHeight.tsx +39 -0
- package/src/Header/getHeaderTitle.tsx +12 -0
- package/src/Header/useHeaderHeight.tsx +15 -0
- package/src/MaskedView.android.tsx +1 -0
- package/src/MaskedView.ios.tsx +1 -0
- package/src/MaskedView.tsx +13 -0
- package/src/MaskedViewNative.tsx +33 -0
- package/src/MissingIcon.tsx +18 -0
- package/src/PlatformPressable.tsx +86 -0
- package/src/ResourceSavingView.tsx +70 -0
- package/src/SafeAreaProviderCompat.tsx +61 -0
- package/src/Screen.tsx +109 -0
- package/src/assets/back-icon-mask.png +0 -0
- package/src/assets/back-icon.png +0 -0
- package/src/assets/back-icon@1.5x.android.png +0 -0
- package/src/assets/back-icon@1.5x.ios.png +0 -0
- package/src/assets/back-icon@1x.android.png +0 -0
- package/src/assets/back-icon@1x.ios.png +0 -0
- package/src/assets/back-icon@2x.android.png +0 -0
- package/src/assets/back-icon@2x.ios.png +0 -0
- package/src/assets/back-icon@3x.android.png +0 -0
- package/src/assets/back-icon@3x.ios.png +0 -0
- package/src/assets/back-icon@4x.android.png +0 -0
- package/src/assets/back-icon@4x.ios.png +0 -0
- package/src/getNamedContext.tsx +28 -0
- package/src/index.tsx +25 -0
- package/src/types.tsx +208 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Dimensions,
|
|
4
|
+
Platform,
|
|
5
|
+
StyleProp,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
View,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import {
|
|
11
|
+
initialWindowMetrics,
|
|
12
|
+
SafeAreaInsetsContext,
|
|
13
|
+
SafeAreaProvider,
|
|
14
|
+
} from 'react-native-safe-area-context';
|
|
15
|
+
|
|
16
|
+
type Props = {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const { width = 0, height = 0 } = Dimensions.get('window');
|
|
22
|
+
|
|
23
|
+
// To support SSR on web, we need to have empty insets for initial values
|
|
24
|
+
// Otherwise there can be mismatch between SSR and client output
|
|
25
|
+
// We also need to specify empty values to support tests environments
|
|
26
|
+
const initialMetrics =
|
|
27
|
+
Platform.OS === 'web' || initialWindowMetrics == null
|
|
28
|
+
? {
|
|
29
|
+
frame: { x: 0, y: 0, width, height },
|
|
30
|
+
insets: { top: 0, left: 0, right: 0, bottom: 0 },
|
|
31
|
+
}
|
|
32
|
+
: initialWindowMetrics;
|
|
33
|
+
|
|
34
|
+
export default function SafeAreaProviderCompat({ children, style }: Props) {
|
|
35
|
+
return (
|
|
36
|
+
<SafeAreaInsetsContext.Consumer>
|
|
37
|
+
{(insets) => {
|
|
38
|
+
if (insets) {
|
|
39
|
+
// If we already have insets, don't wrap the stack in another safe area provider
|
|
40
|
+
// This avoids an issue with updates at the cost of potentially incorrect values
|
|
41
|
+
// https://github.com/react-navigation/react-navigation/issues/174
|
|
42
|
+
return <View style={[styles.container, style]}>{children}</View>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<SafeAreaProvider initialMetrics={initialMetrics} style={style}>
|
|
47
|
+
{children}
|
|
48
|
+
</SafeAreaProvider>
|
|
49
|
+
);
|
|
50
|
+
}}
|
|
51
|
+
</SafeAreaInsetsContext.Consumer>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
SafeAreaProviderCompat.initialMetrics = initialMetrics;
|
|
56
|
+
|
|
57
|
+
const styles = StyleSheet.create({
|
|
58
|
+
container: {
|
|
59
|
+
flex: 1,
|
|
60
|
+
},
|
|
61
|
+
});
|
package/src/Screen.tsx
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NavigationContext,
|
|
3
|
+
NavigationProp,
|
|
4
|
+
NavigationRouteContext,
|
|
5
|
+
ParamListBase,
|
|
6
|
+
RouteProp,
|
|
7
|
+
} from '@react-navigation/native';
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
|
|
10
|
+
import {
|
|
11
|
+
useSafeAreaFrame,
|
|
12
|
+
useSafeAreaInsets,
|
|
13
|
+
} from 'react-native-safe-area-context';
|
|
14
|
+
|
|
15
|
+
import Background from './Background';
|
|
16
|
+
import getDefaultHeaderHeight from './Header/getDefaultHeaderHeight';
|
|
17
|
+
import HeaderHeightContext from './Header/HeaderHeightContext';
|
|
18
|
+
import HeaderShownContext from './Header/HeaderShownContext';
|
|
19
|
+
|
|
20
|
+
type Props = {
|
|
21
|
+
focused: boolean;
|
|
22
|
+
modal?: boolean;
|
|
23
|
+
navigation: NavigationProp<ParamListBase>;
|
|
24
|
+
route: RouteProp<ParamListBase>;
|
|
25
|
+
header: React.ReactNode;
|
|
26
|
+
headerShown?: boolean;
|
|
27
|
+
headerStatusBarHeight?: number;
|
|
28
|
+
headerTransparent?: boolean;
|
|
29
|
+
style?: StyleProp<ViewStyle>;
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default function Screen(props: Props) {
|
|
34
|
+
const dimensions = useSafeAreaFrame();
|
|
35
|
+
const insets = useSafeAreaInsets();
|
|
36
|
+
|
|
37
|
+
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
|
38
|
+
const parentHeaderHeight = React.useContext(HeaderHeightContext);
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
focused,
|
|
42
|
+
modal = false,
|
|
43
|
+
header,
|
|
44
|
+
headerShown = true,
|
|
45
|
+
headerTransparent,
|
|
46
|
+
headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,
|
|
47
|
+
navigation,
|
|
48
|
+
route,
|
|
49
|
+
children,
|
|
50
|
+
style,
|
|
51
|
+
} = props;
|
|
52
|
+
|
|
53
|
+
const [headerHeight, setHeaderHeight] = React.useState(() =>
|
|
54
|
+
getDefaultHeaderHeight(dimensions, modal, headerStatusBarHeight)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Background
|
|
59
|
+
accessibilityElementsHidden={!focused}
|
|
60
|
+
importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}
|
|
61
|
+
style={[styles.container, style]}
|
|
62
|
+
>
|
|
63
|
+
<View style={styles.content}>
|
|
64
|
+
<HeaderShownContext.Provider
|
|
65
|
+
value={isParentHeaderShown || headerShown !== false}
|
|
66
|
+
>
|
|
67
|
+
<HeaderHeightContext.Provider
|
|
68
|
+
value={headerShown ? headerHeight : parentHeaderHeight ?? 0}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</HeaderHeightContext.Provider>
|
|
72
|
+
</HeaderShownContext.Provider>
|
|
73
|
+
</View>
|
|
74
|
+
{headerShown ? (
|
|
75
|
+
<NavigationContext.Provider value={navigation}>
|
|
76
|
+
<NavigationRouteContext.Provider value={route}>
|
|
77
|
+
<View
|
|
78
|
+
onLayout={(e) => {
|
|
79
|
+
const { height } = e.nativeEvent.layout;
|
|
80
|
+
|
|
81
|
+
setHeaderHeight(height);
|
|
82
|
+
}}
|
|
83
|
+
style={headerTransparent ? styles.absolute : null}
|
|
84
|
+
>
|
|
85
|
+
{header}
|
|
86
|
+
</View>
|
|
87
|
+
</NavigationRouteContext.Provider>
|
|
88
|
+
</NavigationContext.Provider>
|
|
89
|
+
) : null}
|
|
90
|
+
</Background>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const styles = StyleSheet.create({
|
|
95
|
+
container: {
|
|
96
|
+
flex: 1,
|
|
97
|
+
flexDirection: 'column-reverse',
|
|
98
|
+
},
|
|
99
|
+
// This is necessary to avoid applying 'column-reverse' to screen content
|
|
100
|
+
content: {
|
|
101
|
+
flex: 1,
|
|
102
|
+
},
|
|
103
|
+
absolute: {
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
top: 0,
|
|
106
|
+
left: 0,
|
|
107
|
+
right: 0,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
const contexts = '__react_navigation__elements_contexts';
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
var __react_navigation__elements_contexts: Map<string, React.Context<any>>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// We use a global variable to keep our contexts so that we can reuse same contexts across packages
|
|
10
|
+
global[contexts] = global[contexts] ?? new Map<string, React.Context<any>>();
|
|
11
|
+
|
|
12
|
+
export default function getNamedContext<T>(
|
|
13
|
+
name: string,
|
|
14
|
+
initialValue: T
|
|
15
|
+
): React.Context<T> {
|
|
16
|
+
let context = global[contexts].get(name);
|
|
17
|
+
|
|
18
|
+
if (context) {
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
context = React.createContext<T>(initialValue);
|
|
23
|
+
context.displayName = name;
|
|
24
|
+
|
|
25
|
+
global[contexts].set(name, context);
|
|
26
|
+
|
|
27
|
+
return context;
|
|
28
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { default as Background } from './Background';
|
|
2
|
+
export { default as getDefaultHeaderHeight } from './Header/getDefaultHeaderHeight';
|
|
3
|
+
export { default as getHeaderTitle } from './Header/getHeaderTitle';
|
|
4
|
+
export { default as Header } from './Header/Header';
|
|
5
|
+
export { default as HeaderBackButton } from './Header/HeaderBackButton';
|
|
6
|
+
export { default as HeaderBackContext } from './Header/HeaderBackContext';
|
|
7
|
+
export { default as HeaderBackground } from './Header/HeaderBackground';
|
|
8
|
+
export { default as HeaderHeightContext } from './Header/HeaderHeightContext';
|
|
9
|
+
export { default as HeaderShownContext } from './Header/HeaderShownContext';
|
|
10
|
+
export { default as HeaderTitle } from './Header/HeaderTitle';
|
|
11
|
+
export { default as useHeaderHeight } from './Header/useHeaderHeight';
|
|
12
|
+
export { default as MissingIcon } from './MissingIcon';
|
|
13
|
+
export { default as PlatformPressable } from './PlatformPressable';
|
|
14
|
+
export { default as ResourceSavingView } from './ResourceSavingView';
|
|
15
|
+
export { default as SafeAreaProviderCompat } from './SafeAreaProviderCompat';
|
|
16
|
+
export { default as Screen } from './Screen';
|
|
17
|
+
|
|
18
|
+
export const Assets = [
|
|
19
|
+
// eslint-disable-next-line import/no-commonjs
|
|
20
|
+
require('./assets/back-icon.png'),
|
|
21
|
+
// eslint-disable-next-line import/no-commonjs
|
|
22
|
+
require('./assets/back-icon-mask.png'),
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export * from './types';
|
package/src/types.tsx
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Animated,
|
|
3
|
+
LayoutChangeEvent,
|
|
4
|
+
StyleProp,
|
|
5
|
+
TextStyle,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
export type Layout = { width: number; height: number };
|
|
10
|
+
|
|
11
|
+
export type HeaderOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* String or a function that returns a React Element to be used by the header.
|
|
14
|
+
* Defaults to screen `title` or route name.
|
|
15
|
+
*
|
|
16
|
+
* It receives `allowFontScaling`, `tintColor`, `style` and `children` in the options object as an argument.
|
|
17
|
+
* The title string is passed in `children`.
|
|
18
|
+
*/
|
|
19
|
+
headerTitle?: string | ((props: HeaderTitleProps) => React.ReactNode);
|
|
20
|
+
/**
|
|
21
|
+
* How to align the the header title.
|
|
22
|
+
* Defaults to `center` on iOS and `left` on Android.
|
|
23
|
+
*/
|
|
24
|
+
headerTitleAlign?: 'left' | 'center';
|
|
25
|
+
/**
|
|
26
|
+
* Style object for the title component.
|
|
27
|
+
*/
|
|
28
|
+
headerTitleStyle?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
|
|
29
|
+
/**
|
|
30
|
+
* Style object for the container of the `headerTitle` element.
|
|
31
|
+
*/
|
|
32
|
+
headerTitleContainerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
33
|
+
/**
|
|
34
|
+
* Whether header title font should scale to respect Text Size accessibility settings. Defaults to `false`.
|
|
35
|
+
*/
|
|
36
|
+
headerTitleAllowFontScaling?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Function which returns a React Element to display on the left side of the header.
|
|
39
|
+
*/
|
|
40
|
+
headerLeft?: (props: {
|
|
41
|
+
tintColor?: string;
|
|
42
|
+
pressColor?: string;
|
|
43
|
+
pressOpacity?: number;
|
|
44
|
+
labelVisible?: boolean;
|
|
45
|
+
}) => React.ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Whether a label is visible in the left button. Used to add extra padding.
|
|
48
|
+
*/
|
|
49
|
+
headerLeftLabelVisible?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Style object for the container of the `headerLeft` element`.
|
|
52
|
+
*/
|
|
53
|
+
headerLeftContainerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
54
|
+
/**
|
|
55
|
+
* Function which returns a React Element to display on the right side of the header.
|
|
56
|
+
*/
|
|
57
|
+
headerRight?: (props: {
|
|
58
|
+
tintColor?: string;
|
|
59
|
+
pressColor?: string;
|
|
60
|
+
pressOpacity?: number;
|
|
61
|
+
}) => React.ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* Style object for the container of the `headerRight` element.
|
|
64
|
+
*/
|
|
65
|
+
headerRightContainerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
66
|
+
/**
|
|
67
|
+
* Color for material ripple (Android >= 5.0 only).
|
|
68
|
+
*/
|
|
69
|
+
headerPressColor?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Color for material ripple (Android >= 5.0 only).
|
|
72
|
+
*/
|
|
73
|
+
headerPressOpacity?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Tint color for the header.
|
|
76
|
+
*/
|
|
77
|
+
headerTintColor?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Function which returns a React Element to render as the background of the header.
|
|
80
|
+
* This is useful for using backgrounds such as an image or a gradient.
|
|
81
|
+
* You can use this with `headerTransparent` to render a blur view, for example, to create a translucent header.
|
|
82
|
+
*/
|
|
83
|
+
headerBackground?: (props: {
|
|
84
|
+
style: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
85
|
+
}) => React.ReactNode;
|
|
86
|
+
/**
|
|
87
|
+
* Style object for the container of the `headerBackground` element.
|
|
88
|
+
*/
|
|
89
|
+
headerBackgroundContainerStyle?: Animated.WithAnimatedValue<
|
|
90
|
+
StyleProp<ViewStyle>
|
|
91
|
+
>;
|
|
92
|
+
/**
|
|
93
|
+
* Defaults to `false`. If `true`, the header will not have a background unless you explicitly provide it with `headerBackground`.
|
|
94
|
+
* The header will also float over the screen so that it overlaps the content underneath.
|
|
95
|
+
* This is useful if you want to render a semi-transparent header or a blurred background.
|
|
96
|
+
*/
|
|
97
|
+
headerTransparent?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Style object for the header. You can specify a custom background color here, for example.
|
|
100
|
+
*/
|
|
101
|
+
headerStyle?: StyleProp<ViewStyle>;
|
|
102
|
+
/**
|
|
103
|
+
* Extra padding to add at the top of header to account for translucent status bar.
|
|
104
|
+
* By default, it uses the top value from the safe area insets of the device.
|
|
105
|
+
* Pass 0 or a custom value to disable the default behaviour, and customize the height.
|
|
106
|
+
*/
|
|
107
|
+
headerStatusBarHeight?: number;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type HeaderTitleProps = {
|
|
111
|
+
/**
|
|
112
|
+
* The title text of the header.
|
|
113
|
+
*/
|
|
114
|
+
children: string;
|
|
115
|
+
/**
|
|
116
|
+
* Whether title font should scale to respect Text Size accessibility settings.
|
|
117
|
+
*/
|
|
118
|
+
allowFontScaling?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Tint color for the header.
|
|
121
|
+
*/
|
|
122
|
+
tintColor?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Callback to trigger when the size of the title element changes.
|
|
125
|
+
*/
|
|
126
|
+
onLayout?: (e: LayoutChangeEvent) => void;
|
|
127
|
+
/**
|
|
128
|
+
* Style object for the title element.
|
|
129
|
+
*/
|
|
130
|
+
style?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export type HeaderBackButtonProps = {
|
|
134
|
+
/**
|
|
135
|
+
* Whether the button is disabled.
|
|
136
|
+
*/
|
|
137
|
+
disabled?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Callback to call when the button is pressed.
|
|
140
|
+
*/
|
|
141
|
+
onPress?: () => void;
|
|
142
|
+
/**
|
|
143
|
+
* Color for material ripple (Android >= 5.0 only).
|
|
144
|
+
*/
|
|
145
|
+
pressColor?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Opacity when the button is pressed, used when ripple is not supported.
|
|
148
|
+
*/
|
|
149
|
+
pressOpacity?: number;
|
|
150
|
+
/**
|
|
151
|
+
* Function which returns a React Element to display custom image in header's back button.
|
|
152
|
+
*/
|
|
153
|
+
backImage?: (props: { tintColor: string }) => React.ReactNode;
|
|
154
|
+
/**
|
|
155
|
+
* Tint color for the header.
|
|
156
|
+
*/
|
|
157
|
+
tintColor?: string;
|
|
158
|
+
/**
|
|
159
|
+
* Label text for the button. Usually the title of the previous screen.
|
|
160
|
+
* By default, this is only shown on iOS.
|
|
161
|
+
*/
|
|
162
|
+
label?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Label text to show when there isn't enough space for the full label.
|
|
165
|
+
*/
|
|
166
|
+
truncatedLabel?: string;
|
|
167
|
+
/**
|
|
168
|
+
* Whether the label text is visible.
|
|
169
|
+
* Defaults to `true` on iOS and `false` on Android.
|
|
170
|
+
*/
|
|
171
|
+
labelVisible?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Style object for the label.
|
|
174
|
+
*/
|
|
175
|
+
labelStyle?: Animated.WithAnimatedValue<StyleProp<TextStyle>>;
|
|
176
|
+
/**
|
|
177
|
+
* Whether label font should scale to respect Text Size accessibility settings.
|
|
178
|
+
*/
|
|
179
|
+
allowFontScaling?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Callback to trigger when the size of the label changes.
|
|
182
|
+
*/
|
|
183
|
+
onLabelLayout?: (e: LayoutChangeEvent) => void;
|
|
184
|
+
/**
|
|
185
|
+
* Layout of the screen.
|
|
186
|
+
*/
|
|
187
|
+
screenLayout?: Layout;
|
|
188
|
+
/**
|
|
189
|
+
* Layout of the title element in the header.
|
|
190
|
+
*/
|
|
191
|
+
titleLayout?: Layout;
|
|
192
|
+
/**
|
|
193
|
+
* Whether it's possible to navigate back in stack.
|
|
194
|
+
*/
|
|
195
|
+
canGoBack?: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Accessibility label for the button for screen readers.
|
|
198
|
+
*/
|
|
199
|
+
accessibilityLabel?: string;
|
|
200
|
+
/**
|
|
201
|
+
* ID to locate this button in tests.
|
|
202
|
+
*/
|
|
203
|
+
testID?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Style object for the button.
|
|
206
|
+
*/
|
|
207
|
+
style?: StyleProp<ViewStyle>;
|
|
208
|
+
};
|