@react-navigation/native-stack 6.2.0
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/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/navigators/createNativeStackNavigator.js +67 -0
- package/lib/commonjs/navigators/createNativeStackNavigator.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/views/DebugContainer.js +24 -0
- package/lib/commonjs/views/DebugContainer.js.map +1 -0
- package/lib/commonjs/views/DebugContainer.native.js +43 -0
- package/lib/commonjs/views/DebugContainer.native.js.map +1 -0
- package/lib/commonjs/views/FontProcessor.js +11 -0
- package/lib/commonjs/views/FontProcessor.js.map +1 -0
- package/lib/commonjs/views/FontProcessor.native.js +25 -0
- package/lib/commonjs/views/FontProcessor.native.js.map +1 -0
- package/lib/commonjs/views/HeaderConfig.js +157 -0
- package/lib/commonjs/views/HeaderConfig.js.map +1 -0
- package/lib/commonjs/views/NativeStackView.js +133 -0
- package/lib/commonjs/views/NativeStackView.js.map +1 -0
- package/lib/commonjs/views/NativeStackView.native.js +247 -0
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/navigators/createNativeStackNavigator.js +50 -0
- package/lib/module/navigators/createNativeStackNavigator.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/views/DebugContainer.js +11 -0
- package/lib/module/views/DebugContainer.js.map +1 -0
- package/lib/module/views/DebugContainer.native.js +26 -0
- package/lib/module/views/DebugContainer.native.js.map +1 -0
- package/lib/module/views/FontProcessor.js +4 -0
- package/lib/module/views/FontProcessor.js.map +1 -0
- package/lib/module/views/FontProcessor.native.js +15 -0
- package/lib/module/views/FontProcessor.native.js.map +1 -0
- package/lib/module/views/HeaderConfig.js +138 -0
- package/lib/module/views/HeaderConfig.js.map +1 -0
- package/lib/module/views/NativeStackView.js +118 -0
- package/lib/module/views/NativeStackView.js.map +1 -0
- package/lib/module/views/NativeStackView.native.js +224 -0
- package/lib/module/views/NativeStackView.native.js.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts +6 -0
- package/lib/typescript/src/types.d.ts +373 -0
- package/lib/typescript/src/views/DebugContainer.d.ts +9 -0
- package/lib/typescript/src/views/DebugContainer.native.d.ts +9 -0
- package/lib/typescript/src/views/FontProcessor.d.ts +1 -0
- package/lib/typescript/src/views/FontProcessor.native.d.ts +1 -0
- package/lib/typescript/src/views/HeaderConfig.d.ts +9 -0
- package/lib/typescript/src/views/NativeStackView.d.ts +10 -0
- package/lib/typescript/src/views/NativeStackView.native.d.ts +10 -0
- package/package.json +80 -0
- package/src/index.tsx +14 -0
- package/src/navigators/createNativeStackNavigator.tsx +81 -0
- package/src/types.tsx +425 -0
- package/src/views/DebugContainer.native.tsx +33 -0
- package/src/views/DebugContainer.tsx +14 -0
- package/src/views/FontProcessor.native.tsx +13 -0
- package/src/views/FontProcessor.tsx +5 -0
- package/src/views/HeaderConfig.tsx +234 -0
- package/src/views/NativeStackView.native.tsx +331 -0
- package/src/views/NativeStackView.tsx +173 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = NativeStackView;
|
|
7
|
+
|
|
8
|
+
var _elements = require("@react-navigation/elements");
|
|
9
|
+
|
|
10
|
+
var _native = require("@react-navigation/native");
|
|
11
|
+
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _reactNative = require("react-native");
|
|
15
|
+
|
|
16
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
17
|
+
|
|
18
|
+
var _reactNativeScreens = require("react-native-screens");
|
|
19
|
+
|
|
20
|
+
var _warnOnce = _interopRequireDefault(require("warn-once"));
|
|
21
|
+
|
|
22
|
+
var _DebugContainer = _interopRequireDefault(require("./DebugContainer"));
|
|
23
|
+
|
|
24
|
+
var _HeaderConfig = _interopRequireDefault(require("./HeaderConfig"));
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
+
|
|
32
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
33
|
+
|
|
34
|
+
const isAndroid = _reactNative.Platform.OS === 'android';
|
|
35
|
+
|
|
36
|
+
const MaybeNestedStack = ({
|
|
37
|
+
options,
|
|
38
|
+
route,
|
|
39
|
+
presentation,
|
|
40
|
+
children
|
|
41
|
+
}) => {
|
|
42
|
+
const {
|
|
43
|
+
colors
|
|
44
|
+
} = (0, _native.useTheme)();
|
|
45
|
+
const {
|
|
46
|
+
header,
|
|
47
|
+
headerShown = true,
|
|
48
|
+
contentStyle
|
|
49
|
+
} = options;
|
|
50
|
+
const isHeaderInModal = isAndroid ? false : presentation !== 'card' && headerShown === true && header === undefined;
|
|
51
|
+
const headerShownPreviousRef = React.useRef(headerShown);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
(0, _warnOnce.default)(!isAndroid && presentation !== 'card' && headerShownPreviousRef.current !== headerShown, `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`);
|
|
54
|
+
headerShownPreviousRef.current = headerShown;
|
|
55
|
+
}, [headerShown, presentation, route.name]);
|
|
56
|
+
const content = /*#__PURE__*/React.createElement(_DebugContainer.default, {
|
|
57
|
+
style: [styles.container, presentation !== 'transparentModal' && presentation !== 'containedTransparentModal' && {
|
|
58
|
+
backgroundColor: colors.background
|
|
59
|
+
}, contentStyle],
|
|
60
|
+
stackPresentation: presentation === 'card' ? 'push' : presentation
|
|
61
|
+
}, children);
|
|
62
|
+
const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
63
|
+
const dimensions = (0, _reactNativeSafeAreaContext.useSafeAreaFrame)(); // landscape is meaningful only for iPhone
|
|
64
|
+
|
|
65
|
+
const isLandscape = dimensions.width > dimensions.height && !_reactNative.Platform.isPad && !_reactNative.Platform.isTVOS; // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.
|
|
66
|
+
|
|
67
|
+
const isFullScreenModal = presentation !== 'modal' && presentation !== 'formSheet';
|
|
68
|
+
const topInset = isFullScreenModal && !isLandscape ? insets.top : 0;
|
|
69
|
+
const headerHeight = (0, _elements.getDefaultHeaderHeight)(dimensions, !isFullScreenModal, topInset);
|
|
70
|
+
|
|
71
|
+
if (isHeaderInModal) {
|
|
72
|
+
return /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStack, {
|
|
73
|
+
style: styles.container
|
|
74
|
+
}, /*#__PURE__*/React.createElement(_reactNativeScreens.Screen, {
|
|
75
|
+
enabled: true,
|
|
76
|
+
style: _reactNative.StyleSheet.absoluteFill
|
|
77
|
+
}, /*#__PURE__*/React.createElement(_elements.HeaderShownContext.Provider, {
|
|
78
|
+
value: true
|
|
79
|
+
}, /*#__PURE__*/React.createElement(_elements.HeaderHeightContext.Provider, {
|
|
80
|
+
value: headerHeight
|
|
81
|
+
}, /*#__PURE__*/React.createElement(_HeaderConfig.default, _extends({}, options, {
|
|
82
|
+
route: route,
|
|
83
|
+
canGoBack: true
|
|
84
|
+
})), content))));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return content;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const SceneView = ({
|
|
91
|
+
descriptor,
|
|
92
|
+
previousDescriptor,
|
|
93
|
+
index,
|
|
94
|
+
onWillDisappear,
|
|
95
|
+
onAppear,
|
|
96
|
+
onDisappear,
|
|
97
|
+
onDismissed
|
|
98
|
+
}) => {
|
|
99
|
+
const {
|
|
100
|
+
route,
|
|
101
|
+
navigation,
|
|
102
|
+
options,
|
|
103
|
+
render
|
|
104
|
+
} = descriptor;
|
|
105
|
+
const {
|
|
106
|
+
gestureEnabled,
|
|
107
|
+
header,
|
|
108
|
+
headerShown,
|
|
109
|
+
animationTypeForReplace = 'pop',
|
|
110
|
+
animation,
|
|
111
|
+
orientation,
|
|
112
|
+
statusBarAnimation,
|
|
113
|
+
statusBarHidden,
|
|
114
|
+
statusBarStyle
|
|
115
|
+
} = options;
|
|
116
|
+
let {
|
|
117
|
+
presentation = 'card'
|
|
118
|
+
} = options;
|
|
119
|
+
|
|
120
|
+
if (index === 0) {
|
|
121
|
+
// first screen should always be treated as `card`, it resolves problems with no header animation
|
|
122
|
+
// for navigator with first screen as `modal` and the next as `card`
|
|
123
|
+
presentation = 'card';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const isHeaderInPush = isAndroid ? headerShown : presentation === 'card' && headerShown !== false;
|
|
127
|
+
const isParentHeaderShown = React.useContext(_elements.HeaderShownContext);
|
|
128
|
+
const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
129
|
+
const parentHeaderHeight = React.useContext(_elements.HeaderHeightContext);
|
|
130
|
+
const headerHeight = (0, _elements.getDefaultHeaderHeight)((0, _reactNativeSafeAreaContext.useSafeAreaFrame)(), false, insets.top);
|
|
131
|
+
return /*#__PURE__*/React.createElement(_reactNativeScreens.Screen, {
|
|
132
|
+
key: route.key,
|
|
133
|
+
enabled: true,
|
|
134
|
+
style: _reactNative.StyleSheet.absoluteFill,
|
|
135
|
+
gestureEnabled: isAndroid ? // This prop enables handling of system back gestures on Android
|
|
136
|
+
// Since we handle them in JS side, we disable this
|
|
137
|
+
false : gestureEnabled,
|
|
138
|
+
replaceAnimation: animationTypeForReplace,
|
|
139
|
+
stackPresentation: presentation === 'card' ? 'push' : presentation,
|
|
140
|
+
stackAnimation: animation,
|
|
141
|
+
screenOrientation: orientation,
|
|
142
|
+
statusBarAnimation: statusBarAnimation,
|
|
143
|
+
statusBarHidden: statusBarHidden,
|
|
144
|
+
statusBarStyle: statusBarStyle,
|
|
145
|
+
onWillDisappear: onWillDisappear,
|
|
146
|
+
onAppear: onAppear,
|
|
147
|
+
onDisappear: onDisappear,
|
|
148
|
+
onDismissed: onDismissed
|
|
149
|
+
}, /*#__PURE__*/React.createElement(_elements.HeaderShownContext.Provider, {
|
|
150
|
+
value: isParentHeaderShown || isHeaderInPush !== false
|
|
151
|
+
}, /*#__PURE__*/React.createElement(_elements.HeaderHeightContext.Provider, {
|
|
152
|
+
value: isHeaderInPush !== false ? headerHeight : parentHeaderHeight !== null && parentHeaderHeight !== void 0 ? parentHeaderHeight : 0
|
|
153
|
+
}, header !== undefined && headerShown !== false ? // TODO: expose custom header height
|
|
154
|
+
header({
|
|
155
|
+
back: previousDescriptor ? {
|
|
156
|
+
title: (0, _elements.getHeaderTitle)(previousDescriptor.options, previousDescriptor.route.name)
|
|
157
|
+
} : undefined,
|
|
158
|
+
options,
|
|
159
|
+
route,
|
|
160
|
+
navigation
|
|
161
|
+
}) : /*#__PURE__*/React.createElement(_HeaderConfig.default, _extends({}, options, {
|
|
162
|
+
route: route,
|
|
163
|
+
headerShown: isHeaderInPush,
|
|
164
|
+
canGoBack: index !== 0
|
|
165
|
+
})), /*#__PURE__*/React.createElement(MaybeNestedStack, {
|
|
166
|
+
options: options,
|
|
167
|
+
route: route,
|
|
168
|
+
presentation: presentation
|
|
169
|
+
}, render()))));
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
function NativeStackViewInner({
|
|
173
|
+
state,
|
|
174
|
+
navigation,
|
|
175
|
+
descriptors
|
|
176
|
+
}) {
|
|
177
|
+
var _state$routes$find;
|
|
178
|
+
|
|
179
|
+
const [nextDismissedKey, setNextDismissedKey] = React.useState(null);
|
|
180
|
+
const dismissedRouteName = nextDismissedKey ? (_state$routes$find = state.routes.find(route => route.key === nextDismissedKey)) === null || _state$routes$find === void 0 ? void 0 : _state$routes$find.name : null;
|
|
181
|
+
React.useEffect(() => {
|
|
182
|
+
if (dismissedRouteName) {
|
|
183
|
+
const message = `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` + `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\n\n` + `Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;
|
|
184
|
+
console.error(message);
|
|
185
|
+
}
|
|
186
|
+
}, [dismissedRouteName]);
|
|
187
|
+
return /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStack, {
|
|
188
|
+
style: styles.container
|
|
189
|
+
}, state.routes.map((route, index) => {
|
|
190
|
+
var _state$routes;
|
|
191
|
+
|
|
192
|
+
const descriptor = descriptors[route.key];
|
|
193
|
+
const previousKey = (_state$routes = state.routes[index - 1]) === null || _state$routes === void 0 ? void 0 : _state$routes.key;
|
|
194
|
+
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
|
|
195
|
+
return /*#__PURE__*/React.createElement(SceneView, {
|
|
196
|
+
key: route.key,
|
|
197
|
+
index: index,
|
|
198
|
+
descriptor: descriptor,
|
|
199
|
+
previousDescriptor: previousDescriptor,
|
|
200
|
+
onWillDisappear: () => {
|
|
201
|
+
navigation.emit({
|
|
202
|
+
type: 'transitionStart',
|
|
203
|
+
data: {
|
|
204
|
+
closing: true
|
|
205
|
+
},
|
|
206
|
+
target: route.key
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
onAppear: () => {
|
|
210
|
+
navigation.emit({
|
|
211
|
+
type: 'transitionEnd',
|
|
212
|
+
data: {
|
|
213
|
+
closing: false
|
|
214
|
+
},
|
|
215
|
+
target: route.key
|
|
216
|
+
});
|
|
217
|
+
},
|
|
218
|
+
onDisappear: () => {
|
|
219
|
+
navigation.emit({
|
|
220
|
+
type: 'transitionEnd',
|
|
221
|
+
data: {
|
|
222
|
+
closing: true
|
|
223
|
+
},
|
|
224
|
+
target: route.key
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
onDismissed: () => {
|
|
228
|
+
navigation.dispatch({ ..._native.StackActions.pop(),
|
|
229
|
+
source: route.key,
|
|
230
|
+
target: state.key
|
|
231
|
+
});
|
|
232
|
+
setNextDismissedKey(route.key);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function NativeStackView(props) {
|
|
239
|
+
return /*#__PURE__*/React.createElement(_elements.SafeAreaProviderCompat, null, /*#__PURE__*/React.createElement(NativeStackViewInner, props));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const styles = _reactNative.StyleSheet.create({
|
|
243
|
+
container: {
|
|
244
|
+
flex: 1
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
//# sourceMappingURL=NativeStackView.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["NativeStackView.native.tsx"],"names":["isAndroid","Platform","OS","MaybeNestedStack","options","route","presentation","children","colors","header","headerShown","contentStyle","isHeaderInModal","undefined","headerShownPreviousRef","React","useRef","useEffect","current","name","content","styles","container","backgroundColor","background","insets","dimensions","isLandscape","width","height","isPad","isTVOS","isFullScreenModal","topInset","top","headerHeight","StyleSheet","absoluteFill","SceneView","descriptor","previousDescriptor","index","onWillDisappear","onAppear","onDisappear","onDismissed","navigation","render","gestureEnabled","animationTypeForReplace","animation","orientation","statusBarAnimation","statusBarHidden","statusBarStyle","isHeaderInPush","isParentHeaderShown","useContext","HeaderShownContext","parentHeaderHeight","HeaderHeightContext","key","back","title","NativeStackViewInner","state","descriptors","nextDismissedKey","setNextDismissedKey","useState","dismissedRouteName","routes","find","message","console","error","map","previousKey","emit","type","data","closing","target","dispatch","StackActions","pop","source","NativeStackView","props","create","flex"],"mappings":";;;;;;;AAAA;;AAOA;;AAOA;;AACA;;AACA;;AAIA;;AAKA;;AAQA;;AACA;;;;;;;;;;AAEA,MAAMA,SAAS,GAAGC,sBAASC,EAAT,KAAgB,SAAlC;;AAEA,MAAMC,gBAAgB,GAAG,CAAC;AACxBC,EAAAA,OADwB;AAExBC,EAAAA,KAFwB;AAGxBC,EAAAA,YAHwB;AAIxBC,EAAAA;AAJwB,CAAD,KAUnB;AACJ,QAAM;AAAEC,IAAAA;AAAF,MAAa,uBAAnB;AACA,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,WAAW,GAAG,IAAxB;AAA8BC,IAAAA;AAA9B,MAA+CP,OAArD;AAEA,QAAMQ,eAAe,GAAGZ,SAAS,GAC7B,KAD6B,GAE7BM,YAAY,KAAK,MAAjB,IAA2BI,WAAW,KAAK,IAA3C,IAAmDD,MAAM,KAAKI,SAFlE;AAIA,QAAMC,sBAAsB,GAAGC,KAAK,CAACC,MAAN,CAAaN,WAA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AU,CAACqC,QAAX,CAAoB,EAClB,GAAGC,qBAAaC,GAAb,EADe;AAElBC,UAAAA,MAAM,EAAEjF,KAAK,CAACwD,GAFI;AAGlBqB,UAAAA,MAAM,EAAEjB,KAAK,CAACJ;AAHI,SAApB;AAMAO,QAAAA,mBAAmB,CAAC/D,KAAK,CAACwD,GAAP,CAAnB;AACD;AAlCH,MADF;AAsCD,GA7CA,CADH,CADF;AAkDD;;AAEc,SAAS0B,eAAT,CAAyBC,KAAzB,EAAuC;AACpD,sBACE,oBAAC,gCAAD,qBACE,oBAAC,oBAAD,EAA0BA,KAA1B,CADF,CADF;AAKD;;AAED,MAAMnE,MAAM,GAAGe,wBAAWqD,MAAX,CAAkB;AAC/BnE,EAAAA,SAAS,EAAE;AACToE,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import {\n getDefaultHeaderHeight,\n getHeaderTitle,\n HeaderHeightContext,\n HeaderShownContext,\n SafeAreaProviderCompat,\n} from '@react-navigation/elements';\nimport {\n ParamListBase,\n Route,\n StackActions,\n StackNavigationState,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Platform, PlatformIOSStatic, StyleSheet } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport {\n Screen,\n ScreenStack,\n StackPresentationTypes,\n} from 'react-native-screens';\nimport warnOnce from 'warn-once';\n\nimport type {\n NativeStackDescriptor,\n NativeStackDescriptorMap,\n NativeStackNavigationHelpers,\n NativeStackNavigationOptions,\n} from '../types';\nimport DebugContainer from './DebugContainer';\nimport HeaderConfig from './HeaderConfig';\n\nconst isAndroid = Platform.OS === 'android';\n\nconst MaybeNestedStack = ({\n options,\n route,\n presentation,\n children,\n}: {\n options: NativeStackNavigationOptions;\n route: Route<string>;\n presentation: Exclude<StackPresentationTypes, 'push'> | 'card';\n children: React.ReactNode;\n}) => {\n const { colors } = useTheme();\n const { header, headerShown = true, contentStyle } = options;\n\n const isHeaderInModal = isAndroid\n ? false\n : presentation !== 'card' && headerShown === true && header === undefined;\n\n const headerShownPreviousRef = React.useRef(headerShown);\n\n React.useEffect(() => {\n warnOnce(\n !isAndroid &&\n presentation !== 'card' &&\n headerShownPreviousRef.current !== headerShown,\n `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`\n );\n\n headerShownPreviousRef.current = headerShown;\n }, [headerShown, presentation, route.name]);\n\n const content = (\n <DebugContainer\n style={[\n styles.container,\n presentation !== 'transparentModal' &&\n presentation !== 'containedTransparentModal' && {\n backgroundColor: colors.background,\n },\n contentStyle,\n ]}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n >\n {children}\n </DebugContainer>\n );\n\n const insets = useSafeAreaInsets();\n const dimensions = useSafeAreaFrame();\n // landscape is meaningful only for iPhone\n const isLandscape =\n dimensions.width > dimensions.height &&\n !(Platform as PlatformIOSStatic).isPad &&\n !(Platform as PlatformIOSStatic).isTVOS;\n // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.\n const isFullScreenModal =\n presentation !== 'modal' && presentation !== 'formSheet';\n const topInset = isFullScreenModal && !isLandscape ? insets.top : 0;\n const headerHeight = getDefaultHeaderHeight(\n dimensions,\n !isFullScreenModal,\n topInset\n );\n\n if (isHeaderInModal) {\n return (\n <ScreenStack style={styles.container}>\n <Screen enabled style={StyleSheet.absoluteFill}>\n <HeaderShownContext.Provider value>\n <HeaderHeightContext.Provider value={headerHeight}>\n <HeaderConfig {...options} route={route} canGoBack />\n {content}\n </HeaderHeightContext.Provider>\n </HeaderShownContext.Provider>\n </Screen>\n </ScreenStack>\n );\n }\n\n return content;\n};\n\ntype SceneViewProps = {\n index: number;\n descriptor: NativeStackDescriptor;\n previousDescriptor?: NativeStackDescriptor;\n onWillDisappear: () => void;\n onAppear: () => void;\n onDisappear: () => void;\n onDismissed: () => void;\n};\n\nconst SceneView = ({\n descriptor,\n previousDescriptor,\n index,\n onWillDisappear,\n onAppear,\n onDisappear,\n onDismissed,\n}: SceneViewProps) => {\n const { route, navigation, options, render } = descriptor;\n const {\n gestureEnabled,\n header,\n headerShown,\n animationTypeForReplace = 'pop',\n animation,\n orientation,\n statusBarAnimation,\n statusBarHidden,\n statusBarStyle,\n } = options;\n\n let { presentation = 'card' } = options;\n\n if (index === 0) {\n // first screen should always be treated as `card`, it resolves problems with no header animation\n // for navigator with first screen as `modal` and the next as `card`\n presentation = 'card';\n }\n\n const isHeaderInPush = isAndroid\n ? headerShown\n : presentation === 'card' && headerShown !== false;\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n const insets = useSafeAreaInsets();\n const parentHeaderHeight = React.useContext(HeaderHeightContext);\n const headerHeight = getDefaultHeaderHeight(\n useSafeAreaFrame(),\n false,\n insets.top\n );\n\n return (\n <Screen\n key={route.key}\n enabled\n style={StyleSheet.absoluteFill}\n gestureEnabled={\n isAndroid\n ? // This prop enables handling of system back gestures on Android\n // Since we handle them in JS side, we disable this\n false\n : gestureEnabled\n }\n replaceAnimation={animationTypeForReplace}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n stackAnimation={animation}\n screenOrientation={orientation}\n statusBarAnimation={statusBarAnimation}\n statusBarHidden={statusBarHidden}\n statusBarStyle={statusBarStyle}\n onWillDisappear={onWillDisappear}\n onAppear={onAppear}\n onDisappear={onDisappear}\n onDismissed={onDismissed}\n >\n <HeaderShownContext.Provider\n value={isParentHeaderShown || isHeaderInPush !== false}\n >\n <HeaderHeightContext.Provider\n value={\n isHeaderInPush !== false ? headerHeight : parentHeaderHeight ?? 0\n }\n >\n {header !== undefined && headerShown !== false ? (\n // TODO: expose custom header height\n header({\n back: previousDescriptor\n ? {\n title: getHeaderTitle(\n previousDescriptor.options,\n previousDescriptor.route.name\n ),\n }\n : undefined,\n options,\n route,\n navigation,\n })\n ) : (\n <HeaderConfig\n {...options}\n route={route}\n headerShown={isHeaderInPush}\n canGoBack={index !== 0}\n />\n )}\n <MaybeNestedStack\n options={options}\n route={route}\n presentation={presentation}\n >\n {render()}\n </MaybeNestedStack>\n </HeaderHeightContext.Provider>\n </HeaderShownContext.Provider>\n </Screen>\n );\n};\n\ntype Props = {\n state: StackNavigationState<ParamListBase>;\n navigation: NativeStackNavigationHelpers;\n descriptors: NativeStackDescriptorMap;\n};\n\nfunction NativeStackViewInner({ state, navigation, descriptors }: Props) {\n const [nextDismissedKey, setNextDismissedKey] =\n React.useState<string | null>(null);\n\n const dismissedRouteName = nextDismissedKey\n ? state.routes.find((route) => route.key === nextDismissedKey)?.name\n : null;\n\n React.useEffect(() => {\n if (dismissedRouteName) {\n const message =\n `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` +\n `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\\n\\n` +\n `Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;\n\n console.error(message);\n }\n }, [dismissedRouteName]);\n\n return (\n <ScreenStack style={styles.container}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const previousKey = state.routes[index - 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n\n return (\n <SceneView\n key={route.key}\n index={index}\n descriptor={descriptor}\n previousDescriptor={previousDescriptor}\n onWillDisappear={() => {\n navigation.emit({\n type: 'transitionStart',\n data: { closing: true },\n target: route.key,\n });\n }}\n onAppear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: false },\n target: route.key,\n });\n }}\n onDisappear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: true },\n target: route.key,\n });\n }}\n onDismissed={() => {\n navigation.dispatch({\n ...StackActions.pop(),\n source: route.key,\n target: state.key,\n });\n\n setNextDismissedKey(route.key);\n }}\n />\n );\n })}\n </ScreenStack>\n );\n}\n\nexport default function NativeStackView(props: Props) {\n return (\n <SafeAreaProviderCompat>\n <NativeStackViewInner {...props} />\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["default","createNativeStackNavigator"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,IAAIC,0BAApB,QAAsD,yCAAtD;AAEA;AACA;AACA","sourcesContent":["/**\n * Navigators\n */\nexport { default as createNativeStackNavigator } from './navigators/createNativeStackNavigator';\n\n/**\n * Types\n */\nexport type {\n NativeStackHeaderProps,\n NativeStackNavigationOptions,\n NativeStackNavigationProp,\n NativeStackScreenProps,\n} from './types';\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import { createNavigatorFactory, StackActions, StackRouter, useNavigationBuilder } from '@react-navigation/native';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import NativeStackView from '../views/NativeStackView';
|
|
6
|
+
|
|
7
|
+
function NativeStackNavigator({
|
|
8
|
+
initialRouteName,
|
|
9
|
+
children,
|
|
10
|
+
screenListeners,
|
|
11
|
+
screenOptions,
|
|
12
|
+
...rest
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
state,
|
|
16
|
+
descriptors,
|
|
17
|
+
navigation
|
|
18
|
+
} = useNavigationBuilder(StackRouter, {
|
|
19
|
+
initialRouteName,
|
|
20
|
+
children,
|
|
21
|
+
screenListeners,
|
|
22
|
+
screenOptions
|
|
23
|
+
});
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
var _navigation$addListen;
|
|
26
|
+
|
|
27
|
+
return navigation === null || navigation === void 0 ? void 0 : (_navigation$addListen = navigation.addListener) === null || _navigation$addListen === void 0 ? void 0 : _navigation$addListen.call(navigation, 'tabPress', e => {
|
|
28
|
+
const isFocused = navigation.isFocused(); // Run the operation in the next frame so we're sure all listeners have been run
|
|
29
|
+
// This is necessary to know if preventDefault() has been called
|
|
30
|
+
|
|
31
|
+
requestAnimationFrame(() => {
|
|
32
|
+
if (state.index > 0 && isFocused && !e.defaultPrevented) {
|
|
33
|
+
// When user taps on already focused tab and we're inside the tab,
|
|
34
|
+
// reset the stack to replicate native behaviour
|
|
35
|
+
navigation.dispatch({ ...StackActions.popToTop(),
|
|
36
|
+
target: state.key
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}, [navigation, state.index, state.key]);
|
|
42
|
+
return /*#__PURE__*/React.createElement(NativeStackView, _extends({}, rest, {
|
|
43
|
+
state: state,
|
|
44
|
+
navigation: navigation,
|
|
45
|
+
descriptors: descriptors
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default createNavigatorFactory(NativeStackNavigator);
|
|
50
|
+
//# sourceMappingURL=createNativeStackNavigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["createNativeStackNavigator.tsx"],"names":["createNavigatorFactory","StackActions","StackRouter","useNavigationBuilder","React","NativeStackView","NativeStackNavigator","initialRouteName","children","screenListeners","screenOptions","rest","state","descriptors","navigation","useEffect","addListener","e","isFocused","requestAnimationFrame","index","defaultPrevented","dispatch","popToTop","target","key"],"mappings":";;AAAA,SACEA,sBADF,EAKEC,YALF,EAOEC,WAPF,EASEC,oBATF,QAUO,0BAVP;AAWA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAOA,OAAOC,eAAP,MAA4B,0BAA5B;;AAEA,SAASC,oBAAT,CAA8B;AAC5BC,EAAAA,gBAD4B;AAE5BC,EAAAA,QAF4B;AAG5BC,EAAAA,eAH4B;AAI5BC,EAAAA,aAJ4B;AAK5B,KAAGC;AALyB,CAA9B,EAM8B;AAC5B,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA,WAAT;AAAsBC,IAAAA;AAAtB,MAAqCX,oBAAoB,CAM7DD,WAN6D,EAMhD;AACbK,IAAAA,gBADa;AAEbC,IAAAA,QAFa;AAGbC,IAAAA,eAHa;AAIbC,IAAAA;AAJa,GANgD,CAA/D;AAaAN,EAAAA,KAAK,CAACW,SAAN,CACE;AAAA;;AAAA,WACED,UADF,aACEA,UADF,gDACEA,UAAU,CAAEE,WADd,0DACE,2BAAAF,UAAU,EAAgB,UAAhB,EAA6BG,CAAD,IAAY;AAChD,YAAMC,SAAS,GAAGJ,UAAU,CAACI,SAAX,EAAlB,CADgD,CAGhD;AACA;;AACAC,MAAAA,qBAAqB,CAAC,MAAM;AAC1B,YACEP,KAAK,CAACQ,KAAN,GAAc,CAAd,IACAF,SADA,IAEA,CAAED,CAAD,CAAkCI,gBAHrC,EAIE;AACA;AACA;AACAP,UAAAA,UAAU,CAACQ,QAAX,CAAoB,EAClB,GAAGrB,YAAY,CAACsB,QAAb,EADe;AAElBC,YAAAA,MAAM,EAAEZ,KAAK,CAACa;AAFI,WAApB;AAID;AACF,OAboB,CAArB;AAcD,KAnBS,CADZ;AAAA,GADF,EAsBE,CAACX,UAAD,EAAaF,KAAK,CAACQ,KAAnB,EAA0BR,KAAK,CAACa,GAAhC,CAtBF;AAyBA,sBACE,oBAAC,eAAD,eACMd,IADN;AAEE,IAAA,KAAK,EAAEC,KAFT;AAGE,IAAA,UAAU,EAAEE,UAHd;AAIE,IAAA,WAAW,EAAED;AAJf,KADF;AAQD;;AAED,eAAeb,sBAAsB,CAKnCM,oBALmC,CAArC","sourcesContent":["import {\n createNavigatorFactory,\n EventArg,\n ParamListBase,\n StackActionHelpers,\n StackActions,\n StackNavigationState,\n StackRouter,\n StackRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport * as React from 'react';\n\nimport type {\n NativeStackNavigationEventMap,\n NativeStackNavigationOptions,\n NativeStackNavigatorProps,\n} from '../types';\nimport NativeStackView from '../views/NativeStackView';\n\nfunction NativeStackNavigator({\n initialRouteName,\n children,\n screenListeners,\n screenOptions,\n ...rest\n}: NativeStackNavigatorProps) {\n const { state, descriptors, navigation } = useNavigationBuilder<\n StackNavigationState<ParamListBase>,\n StackRouterOptions,\n StackActionHelpers<ParamListBase>,\n NativeStackNavigationOptions,\n NativeStackNavigationEventMap\n >(StackRouter, {\n initialRouteName,\n children,\n screenListeners,\n screenOptions,\n });\n\n React.useEffect(\n () =>\n navigation?.addListener?.('tabPress', (e: any) => {\n const isFocused = navigation.isFocused();\n\n // Run the operation in the next frame so we're sure all listeners have been run\n // This is necessary to know if preventDefault() has been called\n requestAnimationFrame(() => {\n if (\n state.index > 0 &&\n isFocused &&\n !(e as EventArg<'tabPress', true>).defaultPrevented\n ) {\n // When user taps on already focused tab and we're inside the tab,\n // reset the stack to replicate native behaviour\n navigation.dispatch({\n ...StackActions.popToTop(),\n target: state.key,\n });\n }\n });\n }),\n [navigation, state.index, state.key]\n );\n\n return (\n <NativeStackView\n {...rest}\n state={state}\n navigation={navigation}\n descriptors={descriptors}\n />\n );\n}\n\nexport default createNavigatorFactory<\n StackNavigationState<ParamListBase>,\n NativeStackNavigationOptions,\n NativeStackNavigationEventMap,\n typeof NativeStackNavigator\n>(NativeStackNavigator);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
export default function Container(props) {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
const {
|
|
6
|
+
stackPresentation: _,
|
|
7
|
+
...rest
|
|
8
|
+
} = props;
|
|
9
|
+
return /*#__PURE__*/React.createElement(View, rest);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=DebugContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["DebugContainer.tsx"],"names":["React","View","Container","props","stackPresentation","_","rest"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAAgC,cAAhC;AAQA,eAAe,SAASC,SAAT,CAAmBC,KAAnB,EAA0C;AACvD;AACA,QAAM;AAAEC,IAAAA,iBAAiB,EAAEC,CAArB;AAAwB,OAAGC;AAA3B,MAAoCH,KAA1C;AACA,sBAAO,oBAAC,IAAD,EAAUG,IAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { View, ViewProps } from 'react-native';\nimport type { StackPresentationTypes } from 'react-native-screens';\n\ntype ContainerProps = ViewProps & {\n stackPresentation: StackPresentationTypes;\n children: React.ReactNode;\n};\n\nexport default function Container(props: ContainerProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { stackPresentation: _, ...rest } = props;\n return <View {...rest} />;\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Platform, View } from 'react-native'; // @ts-ignore Getting private component
|
|
3
|
+
|
|
4
|
+
import AppContainer from 'react-native/Libraries/ReactNative/AppContainer';
|
|
5
|
+
let Container = View;
|
|
6
|
+
|
|
7
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8
|
+
const DebugContainer = props => {
|
|
9
|
+
const {
|
|
10
|
+
stackPresentation,
|
|
11
|
+
...rest
|
|
12
|
+
} = props;
|
|
13
|
+
|
|
14
|
+
if (Platform.OS === 'ios' && stackPresentation !== 'push') {
|
|
15
|
+
// This is necessary for LogBox
|
|
16
|
+
return /*#__PURE__*/React.createElement(AppContainer, null, /*#__PURE__*/React.createElement(View, rest));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return /*#__PURE__*/React.createElement(View, rest);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Container = DebugContainer;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default Container;
|
|
26
|
+
//# sourceMappingURL=DebugContainer.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["DebugContainer.native.tsx"],"names":["React","Platform","View","AppContainer","Container","process","env","NODE_ENV","DebugContainer","props","stackPresentation","rest","OS"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA0C,cAA1C,C,CACA;;AACA,OAAOC,YAAP,MAAyB,iDAAzB;AAQA,IAAIC,SAAS,GAAGF,IAAhB;;AAEA,IAAIG,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,QAAMC,cAAc,GAAIC,KAAD,IAA2B;AAChD,UAAM;AAAEC,MAAAA,iBAAF;AAAqB,SAAGC;AAAxB,QAAiCF,KAAvC;;AAEA,QAAIR,QAAQ,CAACW,EAAT,KAAgB,KAAhB,IAAyBF,iBAAiB,KAAK,MAAnD,EAA2D;AACzD;AACA,0BACE,oBAAC,YAAD,qBACE,oBAAC,IAAD,EAAUC,IAAV,CADF,CADF;AAKD;;AAED,wBAAO,oBAAC,IAAD,EAAUA,IAAV,CAAP;AACD,GAbD;;AAeAP,EAAAA,SAAS,GAAGI,cAAZ;AACD;;AAED,eAAeJ,SAAf","sourcesContent":["import * as React from 'react';\nimport { Platform, View, ViewProps } from 'react-native';\n// @ts-ignore Getting private component\nimport AppContainer from 'react-native/Libraries/ReactNative/AppContainer';\nimport type { StackPresentationTypes } from 'react-native-screens';\n\ntype ContainerProps = ViewProps & {\n stackPresentation: StackPresentationTypes;\n children: React.ReactNode;\n};\n\nlet Container = View as unknown as React.ComponentType<ContainerProps>;\n\nif (process.env.NODE_ENV !== 'production') {\n const DebugContainer = (props: ContainerProps) => {\n const { stackPresentation, ...rest } = props;\n\n if (Platform.OS === 'ios' && stackPresentation !== 'push') {\n // This is necessary for LogBox\n return (\n <AppContainer>\n <View {...rest} />\n </AppContainer>\n );\n }\n\n return <View {...rest} />;\n };\n\n Container = DebugContainer;\n}\n\nexport default Container;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["FontProcessor.tsx"],"names":["processFonts","_","Error"],"mappings":"AAAA,OAAO,SAASA,YAAT,CACLC,CADK,EAEmB;AACxB,QAAM,IAAIC,KAAJ,CAAU,sBAAV,CAAN;AACD","sourcesContent":["export function processFonts(\n _: (string | undefined)[]\n): (string | undefined)[] {\n throw new Error('Not supported on Web');\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @ts-ignore: No declaration available
|
|
2
|
+
import ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
|
|
3
|
+
export function processFonts(fontFamilies) {
|
|
4
|
+
var _ReactNativeStyleAttr;
|
|
5
|
+
|
|
6
|
+
// @ts-ignore: React Native types are incorrect here and don't consider fontFamily a style value
|
|
7
|
+
const fontFamilyProcessor = (_ReactNativeStyleAttr = ReactNativeStyleAttributes.fontFamily) === null || _ReactNativeStyleAttr === void 0 ? void 0 : _ReactNativeStyleAttr.process;
|
|
8
|
+
|
|
9
|
+
if (typeof fontFamilyProcessor === 'function') {
|
|
10
|
+
return fontFamilies.map(fontFamilyProcessor);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return fontFamilies;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=FontProcessor.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["FontProcessor.native.tsx"],"names":["ReactNativeStyleAttributes","processFonts","fontFamilies","fontFamilyProcessor","fontFamily","process","map"],"mappings":"AAAA;AACA,OAAOA,0BAAP,MAAuC,mEAAvC;AAEA,OAAO,SAASC,YAAT,CACLC,YADK,EAEmB;AAAA;;AACxB;AACA,QAAMC,mBAAmB,4BAAGH,0BAA0B,CAACI,UAA9B,0DAAG,sBAAuCC,OAAnE;;AACA,MAAI,OAAOF,mBAAP,KAA+B,UAAnC,EAA+C;AAC7C,WAAOD,YAAY,CAACI,GAAb,CAAiBH,mBAAjB,CAAP;AACD;;AACD,SAAOD,YAAP;AACD","sourcesContent":["// @ts-ignore: No declaration available\nimport ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';\n\nexport function processFonts(\n fontFamilies: (string | undefined)[]\n): (string | undefined)[] {\n // @ts-ignore: React Native types are incorrect here and don't consider fontFamily a style value\n const fontFamilyProcessor = ReactNativeStyleAttributes.fontFamily?.process;\n if (typeof fontFamilyProcessor === 'function') {\n return fontFamilies.map(fontFamilyProcessor);\n }\n return fontFamilies;\n}\n"]}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { HeaderTitle } from '@react-navigation/elements';
|
|
2
|
+
import { useTheme } from '@react-navigation/native';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { I18nManager, Platform, StyleSheet, View } from 'react-native';
|
|
5
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
6
|
+
import { ScreenStackHeaderBackButtonImage, ScreenStackHeaderCenterView, ScreenStackHeaderConfig, ScreenStackHeaderLeftView, ScreenStackHeaderRightView, ScreenStackHeaderSearchBarView, SearchBar } from 'react-native-screens';
|
|
7
|
+
import { processFonts } from './FontProcessor';
|
|
8
|
+
export default function HeaderConfig({
|
|
9
|
+
headerBackImageSource,
|
|
10
|
+
headerBackButtonMenuEnabled,
|
|
11
|
+
headerBackTitle,
|
|
12
|
+
headerBackTitleStyle,
|
|
13
|
+
headerBackTitleVisible = true,
|
|
14
|
+
headerBackVisible,
|
|
15
|
+
headerShadowVisible,
|
|
16
|
+
headerLargeStyle,
|
|
17
|
+
headerLargeTitle,
|
|
18
|
+
headerLargeTitleShadowVisible,
|
|
19
|
+
headerLargeTitleStyle,
|
|
20
|
+
headerLeft,
|
|
21
|
+
headerRight,
|
|
22
|
+
headerShown,
|
|
23
|
+
headerStyle,
|
|
24
|
+
headerBlurEffect,
|
|
25
|
+
headerTintColor,
|
|
26
|
+
headerTitle,
|
|
27
|
+
headerTitleAlign,
|
|
28
|
+
headerTitleStyle,
|
|
29
|
+
headerTransparent,
|
|
30
|
+
headerSearchBarOptions,
|
|
31
|
+
route,
|
|
32
|
+
title,
|
|
33
|
+
canGoBack
|
|
34
|
+
}) {
|
|
35
|
+
var _ref, _headerTitleStyleFlat, _headerStyleFlattened;
|
|
36
|
+
|
|
37
|
+
const insets = useSafeAreaInsets();
|
|
38
|
+
const {
|
|
39
|
+
colors
|
|
40
|
+
} = useTheme();
|
|
41
|
+
const tintColor = (headerTintColor !== null && headerTintColor !== void 0 ? headerTintColor : Platform.OS === 'ios') ? colors.primary : colors.text;
|
|
42
|
+
const headerBackTitleStyleFlattened = StyleSheet.flatten(headerBackTitleStyle) || {};
|
|
43
|
+
const headerLargeTitleStyleFlattened = StyleSheet.flatten(headerLargeTitleStyle) || {};
|
|
44
|
+
const headerTitleStyleFlattened = StyleSheet.flatten(headerTitleStyle) || {};
|
|
45
|
+
const headerStyleFlattened = StyleSheet.flatten(headerStyle) || {};
|
|
46
|
+
const headerLargeStyleFlattened = StyleSheet.flatten(headerLargeStyle) || {};
|
|
47
|
+
const [backTitleFontFamily, largeTitleFontFamily, titleFontFamily] = processFonts([headerBackTitleStyleFlattened.fontFamily, headerLargeTitleStyleFlattened.fontFamily, headerTitleStyleFlattened.fontFamily]);
|
|
48
|
+
const titleText = title !== undefined ? title : route.name;
|
|
49
|
+
const titleColor = (_ref = (_headerTitleStyleFlat = headerTitleStyleFlattened.color) !== null && _headerTitleStyleFlat !== void 0 ? _headerTitleStyleFlat : headerTintColor) !== null && _ref !== void 0 ? _ref : colors.text;
|
|
50
|
+
const titleFontSize = headerTitleStyleFlattened.fontSize;
|
|
51
|
+
const titleFontWeight = headerTitleStyleFlattened.fontWeight;
|
|
52
|
+
const headerTitleStyleSupported = {
|
|
53
|
+
color: titleColor
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
if (headerTitleStyleFlattened.fontFamily != null) {
|
|
57
|
+
headerTitleStyleSupported.fontFamily = headerTitleStyleFlattened.fontFamily;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (titleFontSize != null) {
|
|
61
|
+
headerTitleStyleSupported.fontSize = titleFontSize;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (titleFontWeight != null) {
|
|
65
|
+
headerTitleStyleSupported.fontWeight = titleFontWeight;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const headerLeftElement = headerLeft === null || headerLeft === void 0 ? void 0 : headerLeft({
|
|
69
|
+
tintColor,
|
|
70
|
+
label: headerBackTitle,
|
|
71
|
+
canGoBack
|
|
72
|
+
});
|
|
73
|
+
const headerRightElement = headerRight === null || headerRight === void 0 ? void 0 : headerRight({
|
|
74
|
+
tintColor
|
|
75
|
+
});
|
|
76
|
+
const headerTitleElement = typeof headerTitle === 'function' ? headerTitle({
|
|
77
|
+
tintColor,
|
|
78
|
+
children: titleText
|
|
79
|
+
}) : null;
|
|
80
|
+
|
|
81
|
+
if (Platform.OS === 'ios' && headerSearchBarOptions != null && SearchBar == null) {
|
|
82
|
+
throw new Error(`The current version of 'react-native-screens' doesn't support SearchBar in the header. Please update to the latest version to use this option.`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* We need to set this in if:
|
|
86
|
+
* - Back button should stay visible when `headerLeft` is specified
|
|
87
|
+
* - If `headerTitle` for Android is specified, so we only need to remove the title and keep the back button
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
const backButtonInCustomView = headerBackVisible ? headerLeftElement != null : Platform.OS === 'android' && headerTitleElement != null;
|
|
92
|
+
return /*#__PURE__*/React.createElement(ScreenStackHeaderConfig, {
|
|
93
|
+
backButtonInCustomView: backButtonInCustomView,
|
|
94
|
+
backgroundColor: (_headerStyleFlattened = headerStyleFlattened.backgroundColor) !== null && _headerStyleFlattened !== void 0 ? _headerStyleFlattened : headerTransparent ? 'transparent' : colors.card,
|
|
95
|
+
backTitle: headerBackTitleVisible ? headerBackTitle : ' ',
|
|
96
|
+
backTitleFontFamily: backTitleFontFamily,
|
|
97
|
+
backTitleFontSize: headerBackTitleStyleFlattened.fontSize,
|
|
98
|
+
blurEffect: headerBlurEffect,
|
|
99
|
+
color: tintColor,
|
|
100
|
+
direction: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
101
|
+
disableBackButtonMenu: headerBackButtonMenuEnabled === false,
|
|
102
|
+
hidden: headerShown === false,
|
|
103
|
+
hideBackButton: headerBackVisible === false,
|
|
104
|
+
hideShadow: headerShadowVisible === false,
|
|
105
|
+
largeTitle: headerLargeTitle,
|
|
106
|
+
largeTitleBackgroundColor: headerLargeStyleFlattened.backgroundColor,
|
|
107
|
+
largeTitleColor: headerLargeTitleStyleFlattened.color,
|
|
108
|
+
largeTitleFontFamily: largeTitleFontFamily,
|
|
109
|
+
largeTitleFontSize: headerLargeTitleStyleFlattened.fontSize,
|
|
110
|
+
largeTitleFontWeight: headerLargeTitleStyleFlattened.fontWeight,
|
|
111
|
+
largeTitleHideShadow: headerLargeTitleShadowVisible === false,
|
|
112
|
+
title: typeof headerTitle === 'string' ? headerTitle : titleText,
|
|
113
|
+
titleColor: titleColor,
|
|
114
|
+
titleFontFamily: titleFontFamily,
|
|
115
|
+
titleFontSize: titleFontSize,
|
|
116
|
+
titleFontWeight: titleFontWeight,
|
|
117
|
+
topInsetEnabled: insets.top !== 0,
|
|
118
|
+
translucent: // This defaults to `true`, so we can't pass `undefined`
|
|
119
|
+
headerTransparent === true
|
|
120
|
+
}, Platform.OS === 'ios' ? /*#__PURE__*/React.createElement(React.Fragment, null, headerLeftElement != null ? /*#__PURE__*/React.createElement(ScreenStackHeaderLeftView, null, headerLeftElement) : null, headerTitleElement != null ? /*#__PURE__*/React.createElement(ScreenStackHeaderCenterView, null, headerTitleElement) : null) : /*#__PURE__*/React.createElement(React.Fragment, null, headerLeftElement != null || typeof headerTitle === 'function' ? /*#__PURE__*/React.createElement(ScreenStackHeaderLeftView, null, /*#__PURE__*/React.createElement(View, {
|
|
121
|
+
style: styles.row
|
|
122
|
+
}, headerLeftElement, headerTitleAlign !== 'center' ? typeof headerTitle === 'function' ? headerTitleElement : /*#__PURE__*/React.createElement(HeaderTitle, {
|
|
123
|
+
tintColor: tintColor,
|
|
124
|
+
style: headerTitleStyleSupported
|
|
125
|
+
}, titleText) : null)) : null, headerTitleAlign === 'center' ? /*#__PURE__*/React.createElement(ScreenStackHeaderCenterView, null, typeof headerTitle === 'function' ? headerTitleElement : /*#__PURE__*/React.createElement(HeaderTitle, {
|
|
126
|
+
tintColor: tintColor,
|
|
127
|
+
style: headerTitleStyleSupported
|
|
128
|
+
}, titleText)) : null), headerBackImageSource !== undefined ? /*#__PURE__*/React.createElement(ScreenStackHeaderBackButtonImage, {
|
|
129
|
+
source: headerBackImageSource
|
|
130
|
+
}) : null, headerRightElement != null ? /*#__PURE__*/React.createElement(ScreenStackHeaderRightView, null, headerRightElement) : null, Platform.OS === 'ios' && headerSearchBarOptions != null ? /*#__PURE__*/React.createElement(ScreenStackHeaderSearchBarView, null, /*#__PURE__*/React.createElement(SearchBar, headerSearchBarOptions)) : null);
|
|
131
|
+
}
|
|
132
|
+
const styles = StyleSheet.create({
|
|
133
|
+
row: {
|
|
134
|
+
flexDirection: 'row',
|
|
135
|
+
alignItems: 'center'
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
//# sourceMappingURL=HeaderConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["HeaderConfig.tsx"],"names":["HeaderTitle","useTheme","React","I18nManager","Platform","StyleSheet","View","useSafeAreaInsets","ScreenStackHeaderBackButtonImage","ScreenStackHeaderCenterView","ScreenStackHeaderConfig","ScreenStackHeaderLeftView","ScreenStackHeaderRightView","ScreenStackHeaderSearchBarView","SearchBar","processFonts","HeaderConfig","headerBackImageSource","headerBackButtonMenuEnabled","headerBackTitle","headerBackTitleStyle","headerBackTitleVisible","headerBackVisible","headerShadowVisible","headerLargeStyle","headerLargeTitle","headerLargeTitleShadowVisible","headerLargeTitleStyle","headerLeft","headerRight","headerShown","headerStyle","headerBlurEffect","headerTintColor","headerTitle","headerTitleAlign","headerTitleStyle","headerTransparent","headerSearchBarOptions","route","title","canGoBack","insets","colors","tintColor","OS","primary","text","headerBackTitleStyleFlattened","flatten","headerLargeTitleStyleFlattened","headerTitleStyleFlattened","headerStyleFlattened","headerLargeStyleFlattened","backTitleFontFamily","largeTitleFontFamily","titleFontFamily","fontFamily","titleText","undefined","name","titleColor","color","titleFontSize","fontSize","titleFontWeight","fontWeight","headerTitleStyleSupported","headerLeftElement","label","headerRightElement","headerTitleElement","children","Error","backButtonInCustomView","backgroundColor","card","isRTL","top","styles","row","create","flexDirection","alignItems"],"mappings":"AAAA,SAASA,WAAT,QAA4B,4BAA5B;AACA,SAAgBC,QAAhB,QAAgC,0BAAhC;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SACEC,WADF,EAEEC,QAFF,EAGEC,UAHF,EAKEC,IALF,QAMO,cANP;AAOA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,SACEC,gCADF,EAEEC,2BAFF,EAGEC,uBAHF,EAIEC,yBAJF,EAKEC,0BALF,EAMEC,8BANF,EAOEC,SAPF,QAQO,sBARP;AAWA,SAASC,YAAT,QAA6B,iBAA7B;AAOA,eAAe,SAASC,YAAT,CAAsB;AACnCC,EAAAA,qBADmC;AAEnCC,EAAAA,2BAFmC;AAGnCC,EAAAA,eAHmC;AAInCC,EAAAA,oBAJmC;AAKnCC,EAAAA,sBAAsB,GAAG,IALU;AAMnCC,EAAAA,iBANmC;AAOnCC,EAAAA,mBAPmC;AAQnCC,EAAAA,gBARmC;AASnCC,EAAAA,gBATmC;AAUnCC,EAAAA,6BAVmC;AAWnCC,EAAAA,qBAXmC;AAYnCC,EAAAA,UAZmC;AAanCC,EAAAA,WAbmC;AAcnCC,EAAAA,WAdmC;AAenCC,EAAAA,WAfmC;AAgBnCC,EAAAA,gBAhBmC;AAiBn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gBACC,oBAAC,8BAAD,qBACE,oBAAC,SAAD,EAAeA,sBAAf,CADF,CADD,GAIG,IAhGN,CADF;AAoGD;AAED,MAAMyC,MAAM,GAAG1E,UAAU,CAAC4E,MAAX,CAAkB;AAC/BD,EAAAA,GAAG,EAAE;AACHE,IAAAA,aAAa,EAAE,KADZ;AAEHC,IAAAA,UAAU,EAAE;AAFT;AAD0B,CAAlB,CAAf","sourcesContent":["import { HeaderTitle } from '@react-navigation/elements';\nimport { Route, useTheme } from '@react-navigation/native';\nimport * as React from 'react';\nimport {\n I18nManager,\n Platform,\n StyleSheet,\n TextStyle,\n View,\n} from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport {\n ScreenStackHeaderBackButtonImage,\n ScreenStackHeaderCenterView,\n ScreenStackHeaderConfig,\n ScreenStackHeaderLeftView,\n ScreenStackHeaderRightView,\n ScreenStackHeaderSearchBarView,\n SearchBar,\n} from 'react-native-screens';\n\nimport type { NativeStackNavigationOptions } from '../types';\nimport { processFonts } from './FontProcessor';\n\ntype Props = NativeStackNavigationOptions & {\n route: Route<string>;\n canGoBack: boolean;\n};\n\nexport default function HeaderConfig({\n headerBackImageSource,\n headerBackButtonMenuEnabled,\n headerBackTitle,\n headerBackTitleStyle,\n headerBackTitleVisible = true,\n headerBackVisible,\n headerShadowVisible,\n headerLargeStyle,\n headerLargeTitle,\n headerLargeTitleShadowVisible,\n headerLargeTitleStyle,\n headerLeft,\n headerRight,\n headerShown,\n headerStyle,\n headerBlurEffect,\n headerTintColor,\n headerTitle,\n headerTitleAlign,\n headerTitleStyle,\n headerTransparent,\n headerSearchBarOptions,\n route,\n title,\n canGoBack,\n}: Props): JSX.Element {\n const insets = useSafeAreaInsets();\n const { colors } = useTheme();\n const tintColor =\n headerTintColor ?? Platform.OS === 'ios' ? colors.primary : colors.text;\n\n const headerBackTitleStyleFlattened =\n StyleSheet.flatten(headerBackTitleStyle) || {};\n const headerLargeTitleStyleFlattened =\n StyleSheet.flatten(headerLargeTitleStyle) || {};\n const headerTitleStyleFlattened = StyleSheet.flatten(headerTitleStyle) || {};\n const headerStyleFlattened = StyleSheet.flatten(headerStyle) || {};\n const headerLargeStyleFlattened = StyleSheet.flatten(headerLargeStyle) || {};\n\n const [backTitleFontFamily, largeTitleFontFamily, titleFontFamily] =\n processFonts([\n headerBackTitleStyleFlattened.fontFamily,\n headerLargeTitleStyleFlattened.fontFamily,\n headerTitleStyleFlattened.fontFamily,\n ]);\n\n const titleText = title !== undefined ? title : route.name;\n const titleColor =\n headerTitleStyleFlattened.color ?? headerTintColor ?? colors.text;\n const titleFontSize = headerTitleStyleFlattened.fontSize;\n const titleFontWeight = headerTitleStyleFlattened.fontWeight;\n\n const headerTitleStyleSupported: TextStyle = { color: titleColor };\n\n if (headerTitleStyleFlattened.fontFamily != null) {\n headerTitleStyleSupported.fontFamily = headerTitleStyleFlattened.fontFamily;\n }\n\n if (titleFontSize != null) {\n headerTitleStyleSupported.fontSize = titleFontSize;\n }\n\n if (titleFontWeight != null) {\n headerTitleStyleSupported.fontWeight = titleFontWeight;\n }\n\n const headerLeftElement = headerLeft?.({\n tintColor,\n label: headerBackTitle,\n canGoBack,\n });\n const headerRightElement = headerRight?.({ tintColor });\n const headerTitleElement =\n typeof headerTitle === 'function'\n ? headerTitle({ tintColor, children: titleText })\n : null;\n\n if (\n Platform.OS === 'ios' &&\n headerSearchBarOptions != null &&\n SearchBar == null\n ) {\n throw new Error(\n `The current version of 'react-native-screens' doesn't support SearchBar in the header. Please update to the latest version to use this option.`\n );\n }\n\n /**\n * We need to set this in if:\n * - Back button should stay visible when `headerLeft` is specified\n * - If `headerTitle` for Android is specified, so we only need to remove the title and keep the back button\n */\n const backButtonInCustomView = headerBackVisible\n ? headerLeftElement != null\n : Platform.OS === 'android' && headerTitleElement != null;\n\n return (\n <ScreenStackHeaderConfig\n backButtonInCustomView={backButtonInCustomView}\n backgroundColor={\n headerStyleFlattened.backgroundColor ??\n (headerTransparent ? 'transparent' : colors.card)\n }\n backTitle={headerBackTitleVisible ? headerBackTitle : ' '}\n backTitleFontFamily={backTitleFontFamily}\n backTitleFontSize={headerBackTitleStyleFlattened.fontSize}\n blurEffect={headerBlurEffect}\n color={tintColor}\n direction={I18nManager.isRTL ? 'rtl' : 'ltr'}\n disableBackButtonMenu={headerBackButtonMenuEnabled === false}\n hidden={headerShown === false}\n hideBackButton={headerBackVisible === false}\n hideShadow={headerShadowVisible === false}\n largeTitle={headerLargeTitle}\n largeTitleBackgroundColor={headerLargeStyleFlattened.backgroundColor}\n largeTitleColor={headerLargeTitleStyleFlattened.color}\n largeTitleFontFamily={largeTitleFontFamily}\n largeTitleFontSize={headerLargeTitleStyleFlattened.fontSize}\n largeTitleFontWeight={headerLargeTitleStyleFlattened.fontWeight}\n largeTitleHideShadow={headerLargeTitleShadowVisible === false}\n title={typeof headerTitle === 'string' ? headerTitle : titleText}\n titleColor={titleColor}\n titleFontFamily={titleFontFamily}\n titleFontSize={titleFontSize}\n titleFontWeight={titleFontWeight}\n topInsetEnabled={insets.top !== 0}\n translucent={\n // This defaults to `true`, so we can't pass `undefined`\n headerTransparent === true\n }\n >\n {Platform.OS === 'ios' ? (\n <>\n {headerLeftElement != null ? (\n <ScreenStackHeaderLeftView>\n {headerLeftElement}\n </ScreenStackHeaderLeftView>\n ) : null}\n {headerTitleElement != null ? (\n <ScreenStackHeaderCenterView>\n {headerTitleElement}\n </ScreenStackHeaderCenterView>\n ) : null}\n </>\n ) : (\n <>\n {headerLeftElement != null || typeof headerTitle === 'function' ? (\n <ScreenStackHeaderLeftView>\n <View style={styles.row}>\n {headerLeftElement}\n {headerTitleAlign !== 'center' ? (\n typeof headerTitle === 'function' ? (\n headerTitleElement\n ) : (\n <HeaderTitle\n tintColor={tintColor}\n style={headerTitleStyleSupported}\n >\n {titleText}\n </HeaderTitle>\n )\n ) : null}\n </View>\n </ScreenStackHeaderLeftView>\n ) : null}\n {headerTitleAlign === 'center' ? (\n <ScreenStackHeaderCenterView>\n {typeof headerTitle === 'function' ? (\n headerTitleElement\n ) : (\n <HeaderTitle\n tintColor={tintColor}\n style={headerTitleStyleSupported}\n >\n {titleText}\n </HeaderTitle>\n )}\n </ScreenStackHeaderCenterView>\n ) : null}\n </>\n )}\n {headerBackImageSource !== undefined ? (\n <ScreenStackHeaderBackButtonImage source={headerBackImageSource} />\n ) : null}\n {headerRightElement != null ? (\n <ScreenStackHeaderRightView>\n {headerRightElement}\n </ScreenStackHeaderRightView>\n ) : null}\n {Platform.OS === 'ios' && headerSearchBarOptions != null ? (\n <ScreenStackHeaderSearchBarView>\n <SearchBar {...headerSearchBarOptions} />\n </ScreenStackHeaderSearchBarView>\n ) : null}\n </ScreenStackHeaderConfig>\n );\n}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n },\n});\n"]}
|