first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
"use strict";
export function processFonts(_) {
throw new Error('Not supported on Web');
}
//# sourceMappingURL=FontProcessor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["processFonts","_","Error"],"sourceRoot":"../../../src","sources":["views/FontProcessor.tsx"],"mappings":";;AAAA,OAAO,SAASA,YAAYA,CAC1BC,CAAyB,EACD;EACxB,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;AACzC","ignoreList":[]}

View File

@@ -0,0 +1,12 @@
"use strict";
// @ts-expect-error importing private module
import ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
export function processFonts(fontFamilies) {
const fontFamilyProcessor = ReactNativeStyleAttributes.fontFamily?.process;
if (typeof fontFamilyProcessor === 'function') {
return fontFamilies.map(fontFamilyProcessor);
}
return fontFamilies;
}
//# sourceMappingURL=FontProcessor.native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["ReactNativeStyleAttributes","processFonts","fontFamilies","fontFamilyProcessor","fontFamily","process","map"],"sourceRoot":"../../../src","sources":["views/FontProcessor.native.tsx"],"mappings":";;AAAA;AACA,OAAOA,0BAA0B,MAAM,mEAAmE;AAE1G,OAAO,SAASC,YAAYA,CAC1BC,YAAoC,EACZ;EACxB,MAAMC,mBAAmB,GAAGH,0BAA0B,CAACI,UAAU,EAAEC,OAAO;EAC1E,IAAI,OAAOF,mBAAmB,KAAK,UAAU,EAAE;IAC7C,OAAOD,YAAY,CAACI,GAAG,CAACH,mBAAmB,CAAC;EAC9C;EACA,OAAOD,YAAY;AACrB","ignoreList":[]}

View File

@@ -0,0 +1,14 @@
"use strict";
import React from 'react';
import { ScreenFooter } from 'react-native-screens';
import { jsx as _jsx } from "react/jsx-runtime";
export function FooterComponent({
children
}) {
return /*#__PURE__*/_jsx(ScreenFooter, {
collapsable: false,
children: children
});
}
//# sourceMappingURL=FooterComponent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["React","ScreenFooter","jsx","_jsx","FooterComponent","children","collapsable"],"sourceRoot":"../../../src","sources":["views/FooterComponent.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMpD,OAAO,SAASC,eAAeA,CAAC;EAAEC;AAAsB,CAAC,EAAE;EACzD,oBAAOF,IAAA,CAACF,YAAY;IAACK,WAAW,EAAE,KAAM;IAAAD,QAAA,EAAEA;EAAQ,CAAe,CAAC;AACpE","ignoreList":[]}

View File

@@ -0,0 +1,134 @@
"use strict";
import { getHeaderTitle, Header, HeaderBackButton, HeaderBackContext, SafeAreaProviderCompat, Screen, useHeaderHeight } from '@react-navigation/elements';
import { useLinkBuilder } from '@react-navigation/native';
import * as React from 'react';
import { Animated, Image, StyleSheet, View } from 'react-native';
import { AnimatedHeaderHeightContext } from "../utils/useAnimatedHeaderHeight.js";
import { jsx as _jsx } from "react/jsx-runtime";
const TRANSPARENT_PRESENTATIONS = ['transparentModal', 'containedTransparentModal'];
export function NativeStackView({
state,
descriptors,
describe
}) {
const parentHeaderBack = React.useContext(HeaderBackContext);
const {
buildHref
} = useLinkBuilder();
const preloadedDescriptors = state.preloadedRoutes.reduce((acc, route) => {
acc[route.key] = acc[route.key] || describe(route, true);
return acc;
}, {});
return /*#__PURE__*/_jsx(SafeAreaProviderCompat, {
children: state.routes.concat(state.preloadedRoutes).map((route, i) => {
const isFocused = state.index === i;
const previousKey = state.routes[i - 1]?.key;
const nextKey = state.routes[i + 1]?.key;
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
const {
options,
navigation,
render
} = descriptors[route.key] ?? preloadedDescriptors[route.key];
const headerBack = previousDescriptor ? {
title: getHeaderTitle(previousDescriptor.options, previousDescriptor.route.name),
href: buildHref(previousDescriptor.route.name, previousDescriptor.route.params)
} : parentHeaderBack;
const canGoBack = headerBack != null;
const {
header,
headerShown,
headerBackIcon,
headerBackImageSource,
headerLeft,
headerTransparent,
headerBackTitle,
presentation,
contentStyle,
...rest
} = options;
const nextPresentation = nextDescriptor?.options.presentation;
const isPreloaded = preloadedDescriptors[route.key] !== undefined && descriptors[route.key] === undefined;
return /*#__PURE__*/_jsx(Screen, {
focused: isFocused,
route: route,
navigation: navigation,
headerShown: headerShown,
headerTransparent: headerTransparent,
header: header !== undefined ? header({
back: headerBack,
options,
route,
navigation
}) : /*#__PURE__*/_jsx(Header, {
...rest,
back: headerBack,
title: getHeaderTitle(options, route.name),
headerLeft: typeof headerLeft === 'function' ? ({
label,
...rest
}) => headerLeft({
...rest,
label: headerBackTitle ?? label
}) : headerLeft === undefined && canGoBack ? ({
tintColor,
label,
...rest
}) => /*#__PURE__*/_jsx(HeaderBackButton, {
...rest,
label: headerBackTitle ?? label,
tintColor: tintColor,
backImage: headerBackIcon !== undefined || headerBackImageSource !== undefined ? () => /*#__PURE__*/_jsx(Image, {
source: headerBackIcon?.source ?? headerBackImageSource,
resizeMode: "contain",
tintColor: tintColor,
style: styles.backImage
}) : undefined,
onPress: navigation.goBack
}) : headerLeft,
headerTransparent: headerTransparent
}),
style: [StyleSheet.absoluteFill, {
display: (isFocused || nextPresentation != null && TRANSPARENT_PRESENTATIONS.includes(nextPresentation)) && !isPreloaded ? 'flex' : 'none'
}, presentation != null && TRANSPARENT_PRESENTATIONS.includes(presentation) ? {
backgroundColor: 'transparent'
} : null],
children: /*#__PURE__*/_jsx(HeaderBackContext.Provider, {
value: headerBack,
children: /*#__PURE__*/_jsx(AnimatedHeaderHeightProvider, {
children: /*#__PURE__*/_jsx(View, {
style: [styles.contentContainer, contentStyle],
children: render()
})
})
})
}, route.key);
})
});
}
const AnimatedHeaderHeightProvider = ({
children
}) => {
const headerHeight = useHeaderHeight();
const [animatedHeaderHeight] = React.useState(() => new Animated.Value(headerHeight));
React.useEffect(() => {
animatedHeaderHeight.setValue(headerHeight);
}, [animatedHeaderHeight, headerHeight]);
return /*#__PURE__*/_jsx(AnimatedHeaderHeightContext.Provider, {
value: animatedHeaderHeight,
children: children
});
};
const styles = StyleSheet.create({
contentContainer: {
flex: 1
},
backImage: {
height: 24,
width: 24,
margin: 3
}
});
//# sourceMappingURL=NativeStackView.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,490 @@
"use strict";
import { getDefaultHeaderHeight, getHeaderTitle, HeaderBackContext, HeaderHeightContext, HeaderShownContext, SafeAreaProviderCompat, useFrameSize } from '@react-navigation/elements';
import { NavigationProvider, StackActions, usePreventRemoveContext, useTheme } from '@react-navigation/native';
import * as React from 'react';
import { Animated, Platform, StatusBar, StyleSheet, useAnimatedValue, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { compatibilityFlags, ScreenStack, ScreenStackItem } from 'react-native-screens';
import { debounce } from "../utils/debounce.js";
import { getModalRouteKeys } from "../utils/getModalRoutesKeys.js";
import { AnimatedHeaderHeightContext } from "../utils/useAnimatedHeaderHeight.js";
import { useDismissedRouteError } from "../utils/useDismissedRouteError.js";
import { useInvalidPreventRemoveError } from "../utils/useInvalidPreventRemoveError.js";
import { useHeaderConfigProps } from "./useHeaderConfigProps.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const ANDROID_DEFAULT_HEADER_HEIGHT = 56;
function isFabric() {
return 'nativeFabricUIManager' in global;
}
const useNativeDriver = Platform.OS !== 'web';
const SceneView = ({
index,
focused,
shouldFreeze,
descriptor,
previousDescriptor,
nextDescriptor,
isPresentationModal,
isPreloaded,
onWillDisappear,
onWillAppear,
onAppear,
onDisappear,
onDismissed,
onHeaderBackButtonClicked,
onNativeDismissCancelled,
onGestureCancel,
onSheetDetentChanged
}) => {
const {
route,
navigation,
options,
render
} = descriptor;
let {
animation,
animationMatchesGesture,
presentation = isPresentationModal ? 'modal' : 'card',
fullScreenGestureEnabled
} = options;
const {
animationDuration,
animationTypeForReplace = 'push',
fullScreenGestureShadowEnabled = true,
gestureEnabled,
gestureDirection = presentation === 'card' ? 'horizontal' : 'vertical',
gestureResponseDistance,
header,
headerBackButtonMenuEnabled,
headerShown,
headerBackground,
headerTransparent,
autoHideHomeIndicator,
keyboardHandlingEnabled,
navigationBarColor,
navigationBarTranslucent,
navigationBarHidden,
orientation,
sheetAllowedDetents = [1.0],
sheetLargestUndimmedDetentIndex = -1,
sheetGrabberVisible = false,
sheetCornerRadius = -1.0,
sheetElevation = 24,
sheetExpandsWhenScrolledToEdge = true,
sheetInitialDetentIndex = 0,
sheetShouldOverflowTopInset = false,
sheetResizeAnimationEnabled = true,
statusBarAnimation,
statusBarHidden,
statusBarStyle,
statusBarTranslucent,
statusBarBackgroundColor,
unstable_sheetFooter,
scrollEdgeEffects,
freezeOnBlur,
contentStyle
} = options;
if (gestureDirection === 'vertical' && Platform.OS === 'ios') {
// for `vertical` direction to work, we need to set `fullScreenGestureEnabled` to `true`
// so the screen can be dismissed from any point on screen.
// `animationMatchesGesture` needs to be set to `true` so the `animation` set by user can be used,
// otherwise `simple_push` will be used.
// Also, the default animation for this direction seems to be `slide_from_bottom`.
if (fullScreenGestureEnabled === undefined) {
fullScreenGestureEnabled = true;
}
if (animationMatchesGesture === undefined) {
animationMatchesGesture = true;
}
if (animation === undefined) {
animation = 'slide_from_bottom';
}
}
// workaround for rn-screens where gestureDirection has to be set on both
// current and previous screen - software-mansion/react-native-screens/pull/1509
const nextGestureDirection = nextDescriptor?.options.gestureDirection;
const gestureDirectionOverride = nextGestureDirection != null ? nextGestureDirection : gestureDirection;
if (index === 0) {
// first screen should always be treated as `card`, it resolves problems with no header animation
// for navigator with first screen as `modal` and the next as `card`
presentation = 'card';
}
const {
colors
} = useTheme();
const insets = useSafeAreaInsets();
// `modal`, `formSheet` and `pageSheet` presentations do not take whole screen, so should not take the inset.
const isModal = presentation === 'modal' || presentation === 'formSheet' || presentation === 'pageSheet';
// Modals are fullscreen in landscape only on iPhone
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad || Platform.isTV);
const isParentHeaderShown = React.useContext(HeaderShownContext);
const parentHeaderHeight = React.useContext(HeaderHeightContext);
const parentHeaderBack = React.useContext(HeaderBackContext);
const isLandscape = useFrameSize(frame => frame.width > frame.height);
const topInset = isParentHeaderShown || Platform.OS === 'ios' && isModal || isIPhone && isLandscape ? 0 : insets.top;
const defaultHeaderHeight = useFrameSize(frame => Platform.select({
// FIXME: Currently screens isn't using Material 3
// So our `getDefaultHeaderHeight` doesn't return the correct value
// So we hardcode the value here for now until screens is updated
android: ANDROID_DEFAULT_HEADER_HEIGHT + topInset,
default: getDefaultHeaderHeight(frame, isModal, topInset)
}));
const {
preventedRoutes
} = usePreventRemoveContext();
const [headerHeight, setHeaderHeight] = React.useState(defaultHeaderHeight);
// eslint-disable-next-line react-hooks/exhaustive-deps
const setHeaderHeightDebounced = React.useCallback(
// Debounce the header height updates to avoid excessive re-renders
debounce(setHeaderHeight, 100), []);
const hasCustomHeader = header != null;
const usesNewAndroidHeaderHeightImplementation = 'usesNewAndroidHeaderHeightImplementation' in compatibilityFlags && compatibilityFlags['usesNewAndroidHeaderHeightImplementation'] === true;
let headerHeightCorrectionOffset = 0;
if (Platform.OS === 'android' && !hasCustomHeader && !usesNewAndroidHeaderHeightImplementation) {
const statusBarHeight = StatusBar.currentHeight ?? 0;
// On Android, the native header height is not correctly calculated
// It includes status bar height even if statusbar is not translucent
// And the statusbar value itself doesn't match the actual status bar height
// So we subtract the bogus status bar height and add the actual top inset
headerHeightCorrectionOffset = -statusBarHeight + topInset;
}
const rawAnimatedHeaderHeight = useAnimatedValue(defaultHeaderHeight);
const animatedHeaderHeight = React.useMemo(() => Animated.add(rawAnimatedHeaderHeight, headerHeightCorrectionOffset), [headerHeightCorrectionOffset, rawAnimatedHeaderHeight]);
// During the very first render topInset is > 0 when running
// in non edge-to-edge mode on Android, while on every consecutive render
// topInset === 0, causing header content to jump, as we add padding on the first frame,
// just to remove it in next one. To prevent this, when statusBarTranslucent is set,
// we apply additional padding in header only if its true.
// For more details see: https://github.com/react-navigation/react-navigation/pull/12014
const headerTopInsetEnabled = typeof statusBarTranslucent === 'boolean' ? statusBarTranslucent : topInset !== 0;
const canGoBack = previousDescriptor != null || parentHeaderBack != null;
const backTitle = previousDescriptor ? getHeaderTitle(previousDescriptor.options, previousDescriptor.route.name) : parentHeaderBack?.title;
const headerBack = React.useMemo(() => {
if (canGoBack) {
return {
href: undefined,
// No href needed for native
title: backTitle
};
}
return undefined;
}, [canGoBack, backTitle]);
const isRemovePrevented = preventedRoutes[route.key]?.preventRemove;
const headerConfig = useHeaderConfigProps({
...options,
route,
headerBackButtonMenuEnabled: isRemovePrevented !== undefined ? !isRemovePrevented : headerBackButtonMenuEnabled,
headerBackTitle: options.headerBackTitle !== undefined ? options.headerBackTitle : undefined,
headerHeight,
headerShown: header !== undefined ? false : headerShown,
headerTopInsetEnabled,
headerTransparent,
headerBack
});
const onHeaderHeightChange = hasCustomHeader ?
// If we have a custom header, don't use native header height
undefined :
// On Fabric, there's a bug where native event drivers for Animated objects
// are created after the first notifications about the header height
// from the native side, `onHeaderHeightChange` event does not notify
// `animatedHeaderHeight` about initial values on appearing screens at the moment.
Animated.event([{
nativeEvent: {
headerHeight: rawAnimatedHeaderHeight
}
}], {
useNativeDriver,
listener: e => {
if (e.nativeEvent && typeof e.nativeEvent === 'object' && 'headerHeight' in e.nativeEvent && typeof e.nativeEvent.headerHeight === 'number') {
const headerHeight = e.nativeEvent.headerHeight;
// Only debounce if header has large title or search bar
// As it's the only case where the header height can change frequently
const doesHeaderAnimate = Platform.OS === 'ios' && (options.headerLargeTitleEnabled || options.headerSearchBarOptions);
if (doesHeaderAnimate) {
setHeaderHeightDebounced(headerHeight);
} else {
if (Platform.OS === 'android' && headerHeight !== 0 && headerHeight <= ANDROID_DEFAULT_HEADER_HEIGHT) {
// FIXME: On Android, events may get delivered out-of-order
// https://github.com/facebook/react-native/issues/54636
// We seem to get header height without status bar height first,
// and then the correct height with status bar height included
// But due to out-of-order delivery, we may get the correct height first
// and then the one without status bar height
// This is hack to include status bar height if it's not already included
// It only works because header height doesn't change dynamically on Android
setHeaderHeight(headerHeight + insets.top);
} else {
setHeaderHeight(headerHeight);
}
}
}
}
});
return /*#__PURE__*/_jsx(NavigationProvider, {
route: route,
navigation: navigation,
children: /*#__PURE__*/_jsx(ScreenStackItem, {
screenId: route.key,
activityState: isPreloaded ? 0 : 2,
style: StyleSheet.absoluteFill,
"aria-hidden": !focused,
customAnimationOnSwipe: animationMatchesGesture,
fullScreenSwipeEnabled: fullScreenGestureEnabled,
fullScreenSwipeShadowEnabled: fullScreenGestureShadowEnabled,
freezeOnBlur: freezeOnBlur,
gestureEnabled: Platform.OS === 'android' ?
// This prop enables handling of system back gestures on Android
// Since we handle them in JS side, we disable this
false : gestureEnabled,
homeIndicatorHidden: autoHideHomeIndicator,
hideKeyboardOnSwipe: keyboardHandlingEnabled,
navigationBarColor: navigationBarColor,
navigationBarTranslucent: navigationBarTranslucent,
navigationBarHidden: navigationBarHidden,
replaceAnimation: animationTypeForReplace,
stackPresentation: presentation === 'card' ? 'push' : presentation,
stackAnimation: animation,
screenOrientation: orientation,
sheetAllowedDetents: sheetAllowedDetents,
sheetLargestUndimmedDetentIndex: sheetLargestUndimmedDetentIndex,
sheetGrabberVisible: sheetGrabberVisible,
sheetInitialDetentIndex: sheetInitialDetentIndex,
sheetCornerRadius: sheetCornerRadius,
sheetElevation: sheetElevation,
sheetExpandsWhenScrolledToEdge: sheetExpandsWhenScrolledToEdge,
sheetShouldOverflowTopInset: sheetShouldOverflowTopInset,
sheetDefaultResizeAnimationEnabled: sheetResizeAnimationEnabled,
statusBarAnimation: statusBarAnimation,
statusBarHidden: statusBarHidden,
statusBarStyle: statusBarStyle,
statusBarColor: statusBarBackgroundColor,
statusBarTranslucent: statusBarTranslucent,
swipeDirection: gestureDirectionOverride,
transitionDuration: animationDuration,
onWillAppear: onWillAppear,
onWillDisappear: onWillDisappear,
onAppear: onAppear,
onDisappear: onDisappear,
onDismissed: onDismissed,
onGestureCancel: onGestureCancel,
onSheetDetentChanged: onSheetDetentChanged,
gestureResponseDistance: gestureResponseDistance,
nativeBackButtonDismissalEnabled: false // on Android
,
onHeaderBackButtonClicked: onHeaderBackButtonClicked,
preventNativeDismiss: isRemovePrevented // on iOS
,
scrollEdgeEffects: {
bottom: scrollEdgeEffects?.bottom ?? 'automatic',
top: scrollEdgeEffects?.top ?? 'automatic',
left: scrollEdgeEffects?.left ?? 'automatic',
right: scrollEdgeEffects?.right ?? 'automatic'
},
onNativeDismissCancelled: onNativeDismissCancelled,
onHeaderHeightChange: onHeaderHeightChange,
contentStyle: [presentation !== 'transparentModal' && presentation !== 'containedTransparentModal' && {
backgroundColor: colors.background
}, contentStyle],
headerConfig: headerConfig,
unstable_sheetFooter: unstable_sheetFooter
// When ts-expect-error is added, it affects all the props below it
// So we keep any props that need it at the end
// Otherwise invalid props may not be caught by TypeScript
,
shouldFreeze: shouldFreeze,
children: /*#__PURE__*/_jsx(AnimatedHeaderHeightContext.Provider, {
value: animatedHeaderHeight,
children: /*#__PURE__*/_jsxs(HeaderHeightContext.Provider, {
value: headerShown !== false ? headerHeight : parentHeaderHeight ?? 0,
children: [headerBackground != null ?
/*#__PURE__*/
/**
* To show a custom header background, we render it at the top of the screen below the header
* The header also needs to be positioned absolutely (with `translucent` style)
*/
_jsx(View, {
style: [styles.background, headerTransparent ? styles.translucent : null, {
height: headerHeight
}],
children: headerBackground()
}) : null, header != null && headerShown !== false ? /*#__PURE__*/_jsx(View, {
onLayout: e => {
const headerHeight = e.nativeEvent.layout.height;
setHeaderHeight(headerHeight);
rawAnimatedHeaderHeight.setValue(headerHeight);
},
style: [styles.header, headerTransparent ? styles.absolute : null],
children: header({
back: headerBack,
options,
route,
navigation
})
}) : null, /*#__PURE__*/_jsx(HeaderShownContext.Provider, {
value: isParentHeaderShown || headerShown !== false,
children: /*#__PURE__*/_jsx(HeaderBackContext.Provider, {
value: headerBack,
children: render()
})
})]
})
})
})
});
};
export function NativeStackView({
state,
navigation,
descriptors,
describe
}) {
const {
setNextDismissedKey
} = useDismissedRouteError(state);
useInvalidPreventRemoveError(descriptors);
const modalRouteKeys = getModalRouteKeys(state.routes, descriptors);
const preloadedDescriptors = state.preloadedRoutes.reduce((acc, route) => {
acc[route.key] = acc[route.key] || describe(route, true);
return acc;
}, {});
return /*#__PURE__*/_jsx(SafeAreaProviderCompat, {
children: /*#__PURE__*/_jsx(ScreenStack, {
style: styles.container,
children: state.routes.concat(state.preloadedRoutes).map((route, index) => {
const descriptor = descriptors[route.key] ?? preloadedDescriptors[route.key];
const isFocused = state.index === index;
const isBelowFocused = state.index - 1 === index;
const previousKey = state.routes[index - 1]?.key;
const nextKey = state.routes[index + 1]?.key;
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
const isModal = modalRouteKeys.includes(route.key);
const isModalOnIos = isModal && Platform.OS === 'ios';
const isPreloaded = preloadedDescriptors[route.key] !== undefined && descriptors[route.key] === undefined;
// On Fabric, when screen is frozen, animated and reanimated values are not updated
// due to component being unmounted. To avoid this, we don't freeze the previous screen there
const shouldFreeze = isFabric() ? !isPreloaded && !isFocused && !isBelowFocused && !isModalOnIos : !isPreloaded && !isFocused && !isModalOnIos;
return /*#__PURE__*/_jsx(SceneView, {
index: index,
focused: isFocused,
shouldFreeze: shouldFreeze,
descriptor: descriptor,
previousDescriptor: previousDescriptor,
nextDescriptor: nextDescriptor,
isPresentationModal: isModal,
isPreloaded: isPreloaded,
onWillDisappear: () => {
navigation.emit({
type: 'transitionStart',
data: {
closing: true
},
target: route.key
});
},
onWillAppear: () => {
navigation.emit({
type: 'transitionStart',
data: {
closing: false
},
target: route.key
});
},
onAppear: () => {
navigation.emit({
type: 'transitionEnd',
data: {
closing: false
},
target: route.key
});
},
onDisappear: () => {
navigation.emit({
type: 'transitionEnd',
data: {
closing: true
},
target: route.key
});
},
onDismissed: event => {
navigation.dispatch({
...StackActions.pop(event.nativeEvent.dismissCount),
source: route.key,
target: state.key
});
setNextDismissedKey(route.key);
},
onHeaderBackButtonClicked: () => {
navigation.dispatch({
...StackActions.pop(),
source: route.key,
target: state.key
});
},
onNativeDismissCancelled: event => {
navigation.dispatch({
...StackActions.pop(event.nativeEvent.dismissCount),
source: route.key,
target: state.key
});
},
onGestureCancel: () => {
navigation.emit({
type: 'gestureCancel',
target: route.key
});
},
onSheetDetentChanged: event => {
navigation.emit({
type: 'sheetDetentChange',
target: route.key,
data: {
index: event.nativeEvent.index,
stable: event.nativeEvent.isStable
}
});
}
}, route.key);
})
})
});
}
const styles = StyleSheet.create({
container: {
flex: 1
},
header: {
zIndex: 1
},
absolute: {
position: 'absolute',
top: 0,
start: 0,
end: 0
},
translucent: {
position: 'absolute',
top: 0,
start: 0,
end: 0,
zIndex: 1,
elevation: 1
},
background: {
overflow: 'hidden'
}
});
//# sourceMappingURL=NativeStackView.native.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,367 @@
"use strict";
import { getHeaderTitle, HeaderTitle } from '@react-navigation/elements';
import { useLocale, useTheme } from '@react-navigation/native';
import color from 'color';
import { Platform, StyleSheet, View } from 'react-native';
import { isSearchBarAvailableForCurrentPlatform, ScreenStackHeaderBackButtonImage, ScreenStackHeaderCenterView, ScreenStackHeaderLeftView, ScreenStackHeaderRightView, ScreenStackHeaderSearchBarView, SearchBar } from 'react-native-screens';
import { processFonts } from './FontProcessor';
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
const processBarButtonItems = (items, colors, fonts) => {
return items?.map((item, index) => {
if (item.type === 'custom') {
// Handled with `ScreenStackHeaderLeftView` or `ScreenStackHeaderRightView`
return null;
}
if (item.type === 'spacing') {
if (item.spacing == null) {
throw new Error(`Spacing item must have a 'spacing' property defined: ${JSON.stringify(item)}`);
}
return item;
}
if (item.type === 'button' || item.type === 'menu') {
if (item.type === 'menu' && item.menu == null) {
throw new Error(`Menu item must have a 'menu' property defined: ${JSON.stringify(item)}`);
}
const {
badge,
label,
labelStyle,
icon,
...rest
} = item;
const processedItemCommon = {
...rest,
index,
title: label,
titleStyle: {
...fonts.regular,
...labelStyle
},
icon: transformIcon(icon)
};
let processedItem;
if (processedItemCommon.type === 'menu' && item.type === 'menu') {
const {
multiselectable,
layout
} = item.menu;
processedItem = {
...processedItemCommon,
menu: {
...processedItemCommon.menu,
singleSelection: !multiselectable,
displayAsPalette: layout === 'palette',
items: item.menu.items.map(getMenuItem)
}
};
} else if (processedItemCommon.type === 'button' && item.type === 'button') {
processedItem = processedItemCommon;
} else {
throw new Error(`Invalid item type: ${JSON.stringify(item)}. Valid types are 'button' and 'menu'.`);
}
if (badge) {
const badgeBackgroundColor = badge.style?.backgroundColor ?? colors.notification;
const badgeTextColor = color(badgeBackgroundColor).isLight() ? 'black' : 'white';
processedItem = {
...processedItem,
badge: {
...badge,
value: String(badge.value),
style: {
backgroundColor: badgeBackgroundColor,
color: badgeTextColor,
...fonts.regular,
...badge.style
}
}
};
}
return processedItem;
}
throw new Error(`Invalid item type: ${JSON.stringify(item)}. Valid types are 'button', 'menu', 'custom' and 'spacing'.`);
}).filter(item => item != null);
};
const transformIcon = icon => {
if (icon?.type === 'image') {
return icon.tinted === false ? {
type: 'imageSource',
imageSource: icon.source
} : {
type: 'templateSource',
templateSource: icon.source
};
}
return icon;
};
const getMenuItem = item => {
if (item.type === 'submenu') {
const {
label,
icon,
inline,
layout,
items,
multiselectable,
...rest
} = item;
return {
...rest,
icon: transformIcon(icon),
title: label,
displayAsPalette: layout === 'palette',
displayInline: inline,
singleSelection: !multiselectable,
items: items.map(getMenuItem)
};
}
const {
label,
icon,
description,
...rest
} = item;
return {
...rest,
icon: transformIcon(icon),
title: label,
subtitle: description
};
};
export function useHeaderConfigProps({
headerBackIcon,
headerBackImageSource,
headerBackButtonDisplayMode,
headerBackButtonMenuEnabled,
headerBackTitle,
headerBackTitleStyle,
headerBackVisible,
headerShadowVisible,
headerLargeStyle,
headerLargeTitle: headerLargeTitleDeprecated,
headerLargeTitleEnabled = headerLargeTitleDeprecated,
headerLargeTitleShadowVisible,
headerLargeTitleStyle,
headerBackground,
headerLeft,
headerRight,
headerShown,
headerStyle,
headerBlurEffect,
headerTintColor,
headerTitle,
headerTitleAlign,
headerTitleStyle,
headerTransparent,
headerSearchBarOptions,
headerTopInsetEnabled,
headerBack,
route,
title,
unstable_headerLeftItems: headerLeftItems,
unstable_headerRightItems: headerRightItems
}) {
const {
direction
} = useLocale();
const {
colors,
fonts,
dark
} = useTheme();
const tintColor = headerTintColor ?? (Platform.OS === 'ios' ? colors.primary : colors.text);
const headerBackTitleStyleFlattened = StyleSheet.flatten([fonts.regular, headerBackTitleStyle]) || {};
const headerLargeTitleStyleFlattened = StyleSheet.flatten([Platform.select({
ios: fonts.heavy,
default: fonts.medium
}), headerLargeTitleStyle]) || {};
const headerTitleStyleFlattened = StyleSheet.flatten([Platform.select({
ios: fonts.bold,
default: fonts.medium
}), headerTitleStyle]) || {};
const headerStyleFlattened = StyleSheet.flatten(headerStyle) || {};
const headerLargeStyleFlattened = StyleSheet.flatten(headerLargeStyle) || {};
const [backTitleFontFamily, largeTitleFontFamily, titleFontFamily] = processFonts([headerBackTitleStyleFlattened.fontFamily, headerLargeTitleStyleFlattened.fontFamily, headerTitleStyleFlattened.fontFamily]);
const backTitleFontSize = 'fontSize' in headerBackTitleStyleFlattened ? headerBackTitleStyleFlattened.fontSize : undefined;
const titleText = getHeaderTitle({
title,
headerTitle
}, route.name);
const titleColor = 'color' in headerTitleStyleFlattened ? headerTitleStyleFlattened.color : headerTintColor ?? colors.text;
const titleFontSize = 'fontSize' in headerTitleStyleFlattened ? headerTitleStyleFlattened.fontSize : undefined;
const titleFontWeight = headerTitleStyleFlattened.fontWeight;
const largeTitleBackgroundColor = headerLargeStyleFlattened.backgroundColor;
const largeTitleColor = 'color' in headerLargeTitleStyleFlattened ? headerLargeTitleStyleFlattened.color : undefined;
const largeTitleFontSize = 'fontSize' in headerLargeTitleStyleFlattened ? headerLargeTitleStyleFlattened.fontSize : undefined;
const largeTitleFontWeight = headerLargeTitleStyleFlattened.fontWeight;
const headerTitleStyleSupported = {
color: titleColor
};
if (headerTitleStyleFlattened.fontFamily != null) {
headerTitleStyleSupported.fontFamily = headerTitleStyleFlattened.fontFamily;
}
if (titleFontSize != null) {
headerTitleStyleSupported.fontSize = titleFontSize;
}
if (titleFontWeight != null) {
headerTitleStyleSupported.fontWeight = titleFontWeight;
}
const headerBackgroundColor = headerStyleFlattened.backgroundColor ?? (headerBackground != null || headerTransparent ||
// The title becomes invisible if background color is set with large title on iOS 26
Platform.OS === 'ios' && headerLargeTitleEnabled ? 'transparent' : colors.card);
const canGoBack = headerBack != null;
const headerLeftElement = headerLeft?.({
tintColor,
canGoBack,
label: headerBackTitle ?? headerBack?.title,
// `href` is only applicable to web
href: undefined
});
const headerRightElement = headerRight?.({
tintColor,
canGoBack
});
const headerTitleElement = typeof headerTitle === 'function' ? headerTitle({
tintColor,
children: titleText
}) : null;
const supportsHeaderSearchBar = typeof isSearchBarAvailableForCurrentPlatform === 'boolean' ? isSearchBarAvailableForCurrentPlatform :
// Fallback for older versions of react-native-screens
Platform.OS === 'ios' && SearchBar != null;
const hasHeaderSearchBar = supportsHeaderSearchBar && headerSearchBarOptions != null;
/**
* We need to set this in if:
* - Back button should stay visible when `headerLeft` is specified
* - If `headerTitle` for Android is specified, so we only need to remove the title and keep the back button
*/
const backButtonInCustomView = headerBackVisible || Platform.OS === 'android' && headerTitleElement != null && headerLeftElement == null;
const translucent = headerBackground != null || headerTransparent ||
// When using a SearchBar or large title, the header needs to be translucent for it to work on iOS
(hasHeaderSearchBar || headerLargeTitleEnabled) && Platform.OS === 'ios' && headerTransparent !== false;
const isBackButtonDisplayModeAvailable =
// On iOS 14+
Platform.OS === 'ios' && parseInt(Platform.Version, 10) >= 14 && (
// Doesn't have custom styling, by default System, see: https://github.com/software-mansion/react-native-screens/pull/2105#discussion_r1565222738
backTitleFontFamily == null || backTitleFontFamily === 'System') && backTitleFontSize == null &&
// Back button menu is not disabled
headerBackButtonMenuEnabled !== false;
const isCenterViewRenderedAndroid = headerTitleAlign === 'center';
const leftItems = headerLeftItems?.({
tintColor,
canGoBack
});
let rightItems = headerRightItems?.({
tintColor,
canGoBack
});
if (rightItems) {
// iOS renders right items in reverse order
// So we need to reverse them here to match the order
rightItems = [...rightItems].reverse();
}
const children = /*#__PURE__*/_jsxs(_Fragment, {
children: [Platform.OS === 'ios' ? /*#__PURE__*/_jsxs(_Fragment, {
children: [leftItems ? leftItems.map((item, index) => {
if (item.type === 'custom') {
return /*#__PURE__*/_jsx(ScreenStackHeaderLeftView
// eslint-disable-next-line @eslint-react/no-array-index-key
, {
hidesSharedBackground: item.hidesSharedBackground,
children: item.element
}, index);
}
return null;
}) : headerLeftElement != null ? /*#__PURE__*/_jsx(ScreenStackHeaderLeftView, {
children: headerLeftElement
}) : null, headerTitleElement != null ? /*#__PURE__*/_jsx(ScreenStackHeaderCenterView, {
children: headerTitleElement
}) : null]
}) : /*#__PURE__*/_jsxs(_Fragment, {
children: [headerLeftElement != null || typeof headerTitle === 'function' ?
/*#__PURE__*/
// The style passed to header left, together with title element being wrapped
// in flex view is reqruied for proper header layout, in particular,
// for the text truncation to work.
_jsxs(ScreenStackHeaderLeftView, {
style: !isCenterViewRenderedAndroid ? {
flex: 1
} : null,
children: [headerLeftElement, headerTitleAlign !== 'center' ? typeof headerTitle === 'function' ? /*#__PURE__*/_jsx(View, {
style: {
flex: 1
},
children: headerTitleElement
}) : /*#__PURE__*/_jsx(View, {
style: {
flex: 1
},
children: /*#__PURE__*/_jsx(HeaderTitle, {
tintColor: tintColor,
style: headerTitleStyleSupported,
children: titleText
})
}) : null]
}) : null, isCenterViewRenderedAndroid ? /*#__PURE__*/_jsx(ScreenStackHeaderCenterView, {
children: typeof headerTitle === 'function' ? headerTitleElement : /*#__PURE__*/_jsx(HeaderTitle, {
tintColor: tintColor,
style: headerTitleStyleSupported,
children: titleText
})
}) : null]
}), headerBackIcon !== undefined || headerBackImageSource !== undefined ? /*#__PURE__*/_jsx(ScreenStackHeaderBackButtonImage, {
source: headerBackIcon?.source ?? headerBackImageSource
}) : null, Platform.OS === 'ios' && rightItems ? rightItems.map((item, index) => {
if (item.type === 'custom') {
return /*#__PURE__*/_jsx(ScreenStackHeaderRightView
// eslint-disable-next-line @eslint-react/no-array-index-key
, {
hidesSharedBackground: item.hidesSharedBackground,
children: item.element
}, index);
}
return null;
}) : headerRightElement != null ? /*#__PURE__*/_jsx(ScreenStackHeaderRightView, {
children: headerRightElement
}) : null, hasHeaderSearchBar ? /*#__PURE__*/_jsx(ScreenStackHeaderSearchBarView, {
children: /*#__PURE__*/_jsx(SearchBar, {
...headerSearchBarOptions
})
}) : null]
});
return {
backButtonInCustomView,
backgroundColor: headerBackgroundColor,
backTitle: headerBackTitle,
backTitleVisible: isBackButtonDisplayModeAvailable ? undefined : headerBackButtonDisplayMode !== 'minimal',
backButtonDisplayMode: isBackButtonDisplayModeAvailable ? headerBackButtonDisplayMode : undefined,
backTitleFontFamily,
backTitleFontSize,
blurEffect: headerBlurEffect,
color: tintColor,
direction,
disableBackButtonMenu: headerBackButtonMenuEnabled === false,
hidden: headerShown === false,
hideBackButton: headerBackVisible === false,
hideShadow: headerShadowVisible === false || headerBackground != null || headerTransparent && headerShadowVisible !== true,
largeTitle: headerLargeTitleEnabled,
largeTitleBackgroundColor,
largeTitleColor,
largeTitleFontFamily,
largeTitleFontSize,
largeTitleFontWeight,
largeTitleHideShadow: headerLargeTitleShadowVisible === false,
title: titleText,
titleColor,
titleFontFamily,
titleFontSize,
titleFontWeight: String(titleFontWeight),
topInsetEnabled: headerTopInsetEnabled,
translucent: translucent === true,
children,
headerLeftBarButtonItems: processBarButtonItems(leftItems, colors, fonts),
headerRightBarButtonItems: processBarButtonItems(rightItems, colors, fonts),
experimental_userInterfaceStyle: dark ? 'dark' : 'light'
};
}
//# sourceMappingURL=useHeaderConfigProps.js.map

File diff suppressed because one or more lines are too long