@react-navigation/native-stack 6.3.0 → 6.4.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.
@@ -99,8 +99,11 @@ function HeaderConfig(_ref) {
99
99
  tintColor,
100
100
  children: titleText
101
101
  }) : null;
102
+ const supportsHeaderSearchBar = typeof _reactNativeScreens.isSearchBarAvailableForCurrentPlatform === 'boolean' ? _reactNativeScreens.isSearchBarAvailableForCurrentPlatform : // Fallback for older versions of react-native-screens
103
+ _reactNative.Platform.OS === 'ios' && _reactNativeScreens.SearchBar != null;
104
+ const hasHeaderSearchBar = supportsHeaderSearchBar && headerSearchBarOptions != null;
102
105
 
103
- if (_reactNative.Platform.OS === 'ios' && headerSearchBarOptions != null && _reactNativeScreens.SearchBar == null) {
106
+ if (headerSearchBarOptions != null && !supportsHeaderSearchBar) {
104
107
  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.`);
105
108
  }
106
109
  /**
@@ -142,7 +145,8 @@ function HeaderConfig(_ref) {
142
145
  titleFontWeight: titleFontWeight,
143
146
  topInsetEnabled: insets.top !== 0,
144
147
  translucent: headerBackground != null || // This defaults to `true`, so we can't pass `undefined`
145
- headerTransparent === true
148
+ headerTransparent === true || // When using a SearchBar or large title, the header needs to be translucent for it to work on iOS
149
+ (hasHeaderSearchBar || headerLargeTitle) && _reactNative.Platform.OS === 'ios' && headerTransparent !== false
146
150
  }, _reactNative.Platform.OS === 'ios' ? /*#__PURE__*/React.createElement(React.Fragment, null, headerLeftElement != null ? /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStackHeaderLeftView, null, headerLeftElement) : null, headerTitleElement != null ? /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStackHeaderCenterView, null, headerTitleElement) : null) : /*#__PURE__*/React.createElement(React.Fragment, null, headerLeftElement != null || typeof headerTitle === 'function' ? /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStackHeaderLeftView, null, /*#__PURE__*/React.createElement(_reactNative.View, {
147
151
  style: styles.row
148
152
  }, headerLeftElement, headerTitleAlign !== 'center' ? typeof headerTitle === 'function' ? headerTitleElement : /*#__PURE__*/React.createElement(_elements.HeaderTitle, {
@@ -153,7 +157,7 @@ function HeaderConfig(_ref) {
153
157
  style: headerTitleStyleSupported
154
158
  }, titleText)) : null), headerBackImageSource !== undefined ? /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStackHeaderBackButtonImage, {
155
159
  source: headerBackImageSource
156
- }) : null, headerRightElement != null ? /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStackHeaderRightView, null, headerRightElement) : null, _reactNative.Platform.OS === 'ios' && headerSearchBarOptions != null ? /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStackHeaderSearchBarView, null, /*#__PURE__*/React.createElement(_reactNativeScreens.SearchBar, headerSearchBarOptions)) : null));
160
+ }) : null, headerRightElement != null ? /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStackHeaderRightView, null, headerRightElement) : null, hasHeaderSearchBar ? /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStackHeaderSearchBarView, null, /*#__PURE__*/React.createElement(_reactNativeScreens.SearchBar, headerSearchBarOptions)) : null));
157
161
  }
158
162
 
159
163
  const styles = _reactNative.StyleSheet.create({
@@ -1 +1 @@
1
- {"version":3,"sources":["HeaderConfig.tsx"],"names":["HeaderConfig","headerHeight","headerBackImageSource","headerBackButtonMenuEnabled","headerBackTitle","headerBackTitleStyle","headerBackTitleVisible","headerBackVisible","headerShadowVisible","headerLargeStyle","headerLargeTitle","headerLargeTitleShadowVisible","headerLargeTitleStyle","headerBackground","headerLeft","headerRight","headerShown","headerStyle","headerBlurEffect","headerTintColor","headerTitle","headerTitleAlign","headerTitleStyle","headerTransparent","headerSearchBarOptions","route","title","canGoBack","insets","colors","tintColor","Platform","OS","primary","text","headerBackTitleStyleFlattened","StyleSheet","flatten","headerLargeTitleStyleFlattened","headerTitleStyleFlattened","headerStyleFlattened","headerLargeStyleFlattened","backTitleFontFamily","largeTitleFontFamily","titleFontFamily","fontFamily","titleText","undefined","name","titleColor","color","titleFontSize","fontSize","titleFontWeight","fontWeight","headerTitleStyleSupported","headerLeftElement","label","headerRightElement","headerTitleElement","children","SearchBar","Error","backButtonInCustomView","styles","background","translucent","height","backgroundColor","card","I18nManager","isRTL","top","row","create","flexDirection","alignItems","position","left","right","zIndex","overflow"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAWA;;;;;;AAQe,SAASA,YAAT,OA4BQ;AAAA;;AAAA,MA5Bc;AACnCC,IAAAA,YADmC;AAEnCC,IAAAA,qBAFmC;AAGnCC,IAAAA,2BAHmC;AAInCC,IAAAA,eAJmC;AAKnCC,IAAAA,oBALmC;AAMnCC,IAAAA,sBAAsB,GAAG,IANU;AAOnCC,IAAAA,iBAPmC;AAQnCC,IAAAA,mBARmC;AASnCC,IAAAA,gBATmC;AAUnCC,IAAAA,gBAVmC;AAWnCC,IAAAA,6BAXmC;AAYnCC,IAAAA,qBAZmC;AAanCC,IAAAA,gBAbmC;AAcnCC,IAAAA,UAdmC;AAenCC,IAAAA,WAfmC;AAgBnCC,IAAAA,WAhBmC;AAiBnCC,IAAAA,WAjBmC;AAkBnCC,IAAAA,gBAlBmC;AAmBnCC,IAAAA,eAnBmC;AAoBnCC,IAAAA,WApBmC;AAqBnCC,IAAAA,gBArBmC;AAsBnCC,IAAAA,gBAtBmC;AAuBnCC,IAAAA,iBAvBmC;AAwBnCC,IAAAA,sBAxBmC;AAyBnCC,IAAAA,KAzBmC;AA0BnCC,IAAAA,KA1BmC;AA2BnCC,IAAAA;AA3BmC,GA4Bd;AACrB,QAAMC,MAAM,GAAG,oDAAf;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAa,uBAAnB;AACA,QAAMC,SAAS,GACbX,eADa,aACbA,eADa,cACbA,eADa,GACOY,sBAASC,EAAT,KAAgB,KAAhB,GAAwBH,MAAM,CAACI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,aAAa,EAAE,KADZ;AAEHC,IAAAA,UAAU,EAAE;AAFT,GAD0B;AAK/BV,EAAAA,WAAW,EAAE;AACXW,IAAAA,QAAQ,EAAE,UADC;AAEXL,IAAAA,GAAG,EAAE,CAFM;AAGXM,IAAAA,IAAI,EAAE,CAHK;AAIXC,IAAAA,KAAK,EAAE,CAJI;AAKXC,IAAAA,MAAM,EAAE;AALG,GALkB;AAY/Bf,EAAAA,UAAU,EAAE;AACVgB,IAAAA,QAAQ,EAAE;AADA;AAZmB,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 headerHeight: number;\n route: Route<string>;\n canGoBack: boolean;\n};\n\nexport default function HeaderConfig({\n headerHeight,\n headerBackImageSource,\n headerBackButtonMenuEnabled,\n headerBackTitle,\n headerBackTitleStyle,\n headerBackTitleVisible = true,\n headerBackVisible,\n headerShadowVisible,\n headerLargeStyle,\n headerLargeTitle,\n headerLargeTitleShadowVisible,\n headerLargeTitleStyle,\n headerBackground,\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\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 canGoBack,\n label: headerBackTitle,\n });\n const headerRightElement = headerRight?.({\n tintColor,\n canGoBack,\n });\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 <>\n {headerBackground != null ? (\n <View\n style={[\n styles.background,\n headerTransparent ? styles.translucent : null,\n { height: headerHeight },\n ]}\n >\n {headerBackground()}\n </View>\n ) : null}\n <ScreenStackHeaderConfig\n backButtonInCustomView={backButtonInCustomView}\n backgroundColor={\n headerStyleFlattened.backgroundColor ??\n (headerBackground != null || headerTransparent\n ? 'transparent'\n : 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={\n headerShadowVisible === false ||\n headerBackground != null ||\n headerTransparent\n }\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 headerBackground != null ||\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}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n },\n translucent: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n zIndex: 1,\n },\n background: {\n overflow: 'hidden',\n },\n});\n"]}
1
+ {"version":3,"sources":["HeaderConfig.tsx"],"names":["HeaderConfig","headerHeight","headerBackImageSource","headerBackButtonMenuEnabled","headerBackTitle","headerBackTitleStyle","headerBackTitleVisible","headerBackVisible","headerShadowVisible","headerLargeStyle","headerLargeTitle","headerLargeTitleShadowVisible","headerLargeTitleStyle","headerBackground","headerLeft","headerRight","headerShown","headerStyle","headerBlurEffect","headerTintColor","headerTitle","headerTitleAlign","headerTitleStyle","headerTransparent","headerSearchBarOptions","route","title","canGoBack","insets","colors","tintColor","Platform","OS","primary","text","headerBackTitleStyleFlattened","StyleSheet","flatten","headerLargeTitleStyleFlattened","headerTitleStyleFlattened","headerStyleFlattened","headerLargeStyleFlattened","backTitleFontFamily","largeTitleFontFamily","titleFontFamily","fontFamily","titleText","undefined","name","titleColor","color","titleFontSize","fontSize","titleFontWeight","fontWeight","headerTitleStyleSupported","headerLeftElement","label","headerRightElement","headerTitleElement","children","supportsHeaderSearchBar","isSearchBarAvailableForCurrentPlatform","SearchBar","hasHeaderSearchBar","Error","backButtonInCustomView","styles","background","translucent","height","backgroundColor","card","I18nManager","isRTL","top","row","create","flexDirection","alignItems","position","left","right","zIndex","overflow"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAYA;;;;;;AAQe,SAASA,YAAT,OA4BQ;AAAA;;AAAA,MA5Bc;AACnCC,IAAAA,YADmC;AAEnCC,IAAAA,qBAFmC;AAGnCC,IAAAA,2BAHmC;AAInCC,IAAAA,eAJmC;AAKnCC,IAAAA,oBALmC;AAMnCC,IAAAA,sBAAsB,GAAG,IANU;AAOnCC,IAAAA,iBAPmC;AAQnCC,IAAAA,mBARmC;AASnCC,IAAAA,gBATmC;AAUnCC,IAAAA,gBAVmC;AAWnCC,IAAAA,6BAXmC;AAYnCC,IAAAA,qBAZmC;AAanCC,IAAAA,gBAbmC;AAcnCC,IAAAA,UAdmC;AAenCC,IAAAA,WAfmC;AAgBnCC,IAAAA,WAhBmC;AAiBnCC,IAAAA,WAjBmC;AAkBnCC,IAAAA,gBAlBmC;AAmBnCC,IAAAA,eAnBmC;AAoBnCC,IAAAA,WApBmC;AAqBnCC,IAAAA,gBArBmC;AAsBnCC,IAAAA,gBAtBmC;AAuBnCC,IAAAA,iBAvBmC;AAwBnCC,IAAAA,sBAxBmC;AAyBnCC,IAAAA,KAzBmC;AA0BnCC,IAAAA,KA1BmC;AA2BnCC,IAAAA;AA3BmC,GA4Bd;AACrB,QAAMC,MAAM,GAAG,oDAAf;AAEA,QAAM;AAA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1B,gBACC,oBAAC,oDAAD;AAAkC,IAAA,MAAM,EAAE7C;AAA1C,IADD,GAEG,IAjGN,EAkGGwD,kBAAkB,IAAI,IAAtB,gBACC,oBAAC,8CAAD,QACGA,kBADH,CADD,GAIG,IAtGN,EAuGGM,kBAAkB,gBACjB,oBAAC,kDAAD,qBACE,oBAAC,6BAAD,EAAexC,sBAAf,CADF,CADiB,GAIf,IA3GN,CAZF,CADF;AA4HD;;AAED,MAAM2C,MAAM,GAAG/B,wBAAWyC,MAAX,CAAkB;AAC/BD,EAAAA,GAAG,EAAE;AACHE,IAAAA,aAAa,EAAE,KADZ;AAEHC,IAAAA,UAAU,EAAE;AAFT,GAD0B;AAK/BV,EAAAA,WAAW,EAAE;AACXW,IAAAA,QAAQ,EAAE,UADC;AAEXL,IAAAA,GAAG,EAAE,CAFM;AAGXM,IAAAA,IAAI,EAAE,CAHK;AAIXC,IAAAA,KAAK,EAAE,CAJI;AAKXC,IAAAA,MAAM,EAAE;AALG,GALkB;AAY/Bf,EAAAA,UAAU,EAAE;AACVgB,IAAAA,QAAQ,EAAE;AADA;AAZmB,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 isSearchBarAvailableForCurrentPlatform,\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 headerHeight: number;\n route: Route<string>;\n canGoBack: boolean;\n};\n\nexport default function HeaderConfig({\n headerHeight,\n headerBackImageSource,\n headerBackButtonMenuEnabled,\n headerBackTitle,\n headerBackTitleStyle,\n headerBackTitleVisible = true,\n headerBackVisible,\n headerShadowVisible,\n headerLargeStyle,\n headerLargeTitle,\n headerLargeTitleShadowVisible,\n headerLargeTitleStyle,\n headerBackground,\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\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 canGoBack,\n label: headerBackTitle,\n });\n const headerRightElement = headerRight?.({\n tintColor,\n canGoBack,\n });\n const headerTitleElement =\n typeof headerTitle === 'function'\n ? headerTitle({ tintColor, children: titleText })\n : null;\n\n const supportsHeaderSearchBar =\n typeof isSearchBarAvailableForCurrentPlatform === 'boolean'\n ? isSearchBarAvailableForCurrentPlatform\n : // Fallback for older versions of react-native-screens\n Platform.OS === 'ios' && SearchBar != null;\n\n const hasHeaderSearchBar =\n supportsHeaderSearchBar && headerSearchBarOptions != null;\n\n if (headerSearchBarOptions != null && !supportsHeaderSearchBar) {\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 <>\n {headerBackground != null ? (\n <View\n style={[\n styles.background,\n headerTransparent ? styles.translucent : null,\n { height: headerHeight },\n ]}\n >\n {headerBackground()}\n </View>\n ) : null}\n <ScreenStackHeaderConfig\n backButtonInCustomView={backButtonInCustomView}\n backgroundColor={\n headerStyleFlattened.backgroundColor ??\n (headerBackground != null || headerTransparent\n ? 'transparent'\n : 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={\n headerShadowVisible === false ||\n headerBackground != null ||\n headerTransparent\n }\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 headerBackground != null ||\n // This defaults to `true`, so we can't pass `undefined`\n headerTransparent === true ||\n // When using a SearchBar or large title, the header needs to be translucent for it to work on iOS\n ((hasHeaderSearchBar || headerLargeTitle) &&\n Platform.OS === 'ios' &&\n headerTransparent !== false)\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 {hasHeaderSearchBar ? (\n <ScreenStackHeaderSearchBarView>\n <SearchBar {...headerSearchBarOptions} />\n </ScreenStackHeaderSearchBarView>\n ) : null}\n </ScreenStackHeaderConfig>\n </>\n );\n}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n },\n translucent: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n zIndex: 1,\n },\n background: {\n overflow: 'hidden',\n },\n});\n"]}
@@ -3,7 +3,7 @@ import { useTheme } from '@react-navigation/native';
3
3
  import * as React from 'react';
4
4
  import { I18nManager, Platform, StyleSheet, View } from 'react-native';
5
5
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
6
- import { ScreenStackHeaderBackButtonImage, ScreenStackHeaderCenterView, ScreenStackHeaderConfig, ScreenStackHeaderLeftView, ScreenStackHeaderRightView, ScreenStackHeaderSearchBarView, SearchBar } from 'react-native-screens';
6
+ import { isSearchBarAvailableForCurrentPlatform, ScreenStackHeaderBackButtonImage, ScreenStackHeaderCenterView, ScreenStackHeaderConfig, ScreenStackHeaderLeftView, ScreenStackHeaderRightView, ScreenStackHeaderSearchBarView, SearchBar } from 'react-native-screens';
7
7
  import { processFonts } from './FontProcessor';
8
8
  export default function HeaderConfig(_ref) {
9
9
  var _ref2, _headerTitleStyleFlat, _headerStyleFlattened;
@@ -81,8 +81,11 @@ export default function HeaderConfig(_ref) {
81
81
  tintColor,
82
82
  children: titleText
83
83
  }) : null;
84
+ const supportsHeaderSearchBar = typeof isSearchBarAvailableForCurrentPlatform === 'boolean' ? isSearchBarAvailableForCurrentPlatform : // Fallback for older versions of react-native-screens
85
+ Platform.OS === 'ios' && SearchBar != null;
86
+ const hasHeaderSearchBar = supportsHeaderSearchBar && headerSearchBarOptions != null;
84
87
 
85
- if (Platform.OS === 'ios' && headerSearchBarOptions != null && SearchBar == null) {
88
+ if (headerSearchBarOptions != null && !supportsHeaderSearchBar) {
86
89
  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.`);
87
90
  }
88
91
  /**
@@ -124,7 +127,8 @@ export default function HeaderConfig(_ref) {
124
127
  titleFontWeight: titleFontWeight,
125
128
  topInsetEnabled: insets.top !== 0,
126
129
  translucent: headerBackground != null || // This defaults to `true`, so we can't pass `undefined`
127
- headerTransparent === true
130
+ headerTransparent === true || // When using a SearchBar or large title, the header needs to be translucent for it to work on iOS
131
+ (hasHeaderSearchBar || headerLargeTitle) && Platform.OS === 'ios' && headerTransparent !== false
128
132
  }, 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, {
129
133
  style: styles.row
130
134
  }, headerLeftElement, headerTitleAlign !== 'center' ? typeof headerTitle === 'function' ? headerTitleElement : /*#__PURE__*/React.createElement(HeaderTitle, {
@@ -135,7 +139,7 @@ export default function HeaderConfig(_ref) {
135
139
  style: headerTitleStyleSupported
136
140
  }, titleText)) : null), headerBackImageSource !== undefined ? /*#__PURE__*/React.createElement(ScreenStackHeaderBackButtonImage, {
137
141
  source: headerBackImageSource
138
- }) : 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));
142
+ }) : null, headerRightElement != null ? /*#__PURE__*/React.createElement(ScreenStackHeaderRightView, null, headerRightElement) : null, hasHeaderSearchBar ? /*#__PURE__*/React.createElement(ScreenStackHeaderSearchBarView, null, /*#__PURE__*/React.createElement(SearchBar, headerSearchBarOptions)) : null));
139
143
  }
140
144
  const styles = StyleSheet.create({
141
145
  row: {
@@ -1 +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","headerHeight","headerBackImageSource","headerBackButtonMenuEnabled","headerBackTitle","headerBackTitleStyle","headerBackTitleVisible","headerBackVisible","headerShadowVisible","headerLargeStyle","headerLargeTitle","headerLargeTitleShadowVisible","headerLargeTitleStyle","headerBackground","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","styles","background","translucent","height","backgroundColor","card","isRTL","top","row","create","flexDirection","alignItems","position","left","right","zIndex","overflow"],"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,EA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,IAAAA,GAAG,EAAE,CAFM;AAGXM,IAAAA,IAAI,EAAE,CAHK;AAIXC,IAAAA,KAAK,EAAE,CAJI;AAKXC,IAAAA,MAAM,EAAE;AALG,GALkB;AAY/Bd,EAAAA,UAAU,EAAE;AACVe,IAAAA,QAAQ,EAAE;AADA;AAZmB,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 headerHeight: number;\n route: Route<string>;\n canGoBack: boolean;\n};\n\nexport default function HeaderConfig({\n headerHeight,\n headerBackImageSource,\n headerBackButtonMenuEnabled,\n headerBackTitle,\n headerBackTitleStyle,\n headerBackTitleVisible = true,\n headerBackVisible,\n headerShadowVisible,\n headerLargeStyle,\n headerLargeTitle,\n headerLargeTitleShadowVisible,\n headerLargeTitleStyle,\n headerBackground,\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\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 canGoBack,\n label: headerBackTitle,\n });\n const headerRightElement = headerRight?.({\n tintColor,\n canGoBack,\n });\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 <>\n {headerBackground != null ? (\n <View\n style={[\n styles.background,\n headerTransparent ? styles.translucent : null,\n { height: headerHeight },\n ]}\n >\n {headerBackground()}\n </View>\n ) : null}\n <ScreenStackHeaderConfig\n backButtonInCustomView={backButtonInCustomView}\n backgroundColor={\n headerStyleFlattened.backgroundColor ??\n (headerBackground != null || headerTransparent\n ? 'transparent'\n : 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={\n headerShadowVisible === false ||\n headerBackground != null ||\n headerTransparent\n }\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 headerBackground != null ||\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}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n },\n translucent: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n zIndex: 1,\n },\n background: {\n overflow: 'hidden',\n },\n});\n"]}
1
+ {"version":3,"sources":["HeaderConfig.tsx"],"names":["HeaderTitle","useTheme","React","I18nManager","Platform","StyleSheet","View","useSafeAreaInsets","isSearchBarAvailableForCurrentPlatform","ScreenStackHeaderBackButtonImage","ScreenStackHeaderCenterView","ScreenStackHeaderConfig","ScreenStackHeaderLeftView","ScreenStackHeaderRightView","ScreenStackHeaderSearchBarView","SearchBar","processFonts","HeaderConfig","headerHeight","headerBackImageSource","headerBackButtonMenuEnabled","headerBackTitle","headerBackTitleStyle","headerBackTitleVisible","headerBackVisible","headerShadowVisible","headerLargeStyle","headerLargeTitle","headerLargeTitleShadowVisible","headerLargeTitleStyle","headerBackground","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","supportsHeaderSearchBar","hasHeaderSearchBar","Error","backButtonInCustomView","styles","background","translucent","height","backgroundColor","card","isRTL","top","row","create","flexDirection","alignItems","position","left","right","zIndex","overflow"],"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,sCADF,EAEEC,gCAFF,EAGEC,2BAHF,EAIEC,uBAJF,EAKEC,yBALF,EAMEC,0BANF,EAOEC,8BAPF,EAQEC,SARF,QASO,sBATP;AAYA,SAASC,YAAT,QAA6B,iBAA7B;AAQA,eAAe,SAASC,YAAT,OA4BQ;AAAA;;AAAA,MA5Bc;AACnCC,IAAAA,YADmC;AAEnCC,IAAAA,qBAFmC;AAGnCC,IAAAA,2BAHmC;AAInCC,IAAAA,eAJmC;AAKnCC,IAAAA,oBALmC;AAMnCC,IAAAA,sBAAsB,GAAG,IANU;AAOnCC,IAAAA,iBAPmC;AAQnCC,IAAAA,mBARmC;AASnCC,IAAAA,gBATmC;AAUnCC,IAAAA,gBAVmC;AAWnCC,IAAAA,6BAXmC;AAYnCC,IAAAA,qBAZmC;AAanCC,IAAAA,gBAbmC;AAcnCC,IAAAA,UAdmC;AAenCC,IAAAA,WAfmC;AAgBnCC,IAAAA,WAhB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GjC,gBAAgB,KAAK,QAArB,GACC,OAAOD,WAAP,KAAuB,UAAvB,GACEqC,kBADF,gBAGE,oBAAC,WAAD;AACE,IAAA,SAAS,EAAE3B,SADb;AAEE,IAAA,KAAK,EAAEuB;AAFT,KAIGT,SAJH,CAJH,GAWG,IAbN,CADF,CADD,GAkBG,IAnBN,EAoBGvB,gBAAgB,KAAK,QAArB,gBACC,oBAAC,2BAAD,QACG,OAAOD,WAAP,KAAuB,UAAvB,GACCqC,kBADD,gBAGC,oBAAC,WAAD;AACE,IAAA,SAAS,EAAE3B,SADb;AAEE,IAAA,KAAK,EAAEuB;AAFT,KAIGT,SAJH,CAJJ,CADD,GAaG,IAjCN,CA3DJ,EA+FG1C,qBAAqB,KAAK2C,SAA1B,gBACC,oBAAC,gCAAD;AAAkC,IAAA,MAAM,EAAE3C;AAA1C,IADD,GAEG,IAjGN,EAkGGsD,kBAAkB,IAAI,IAAtB,gBACC,oBAAC,0BAAD,QACGA,kBADH,CADD,GAIG,IAtGN,EAuGGI,kBAAkB,gBACjB,oBAAC,8BAAD,qBACE,oBAAC,SAAD,EAAepC,sBAAf,CADF,CADiB,GAIf,IA3GN,CAZF,CADF;AA4HD;AAED,MAAMuC,MAAM,GAAG3E,UAAU,CAACoF,MAAX,CAAkB;AAC/BD,EAAAA,GAAG,EAAE;AACHE,IAAAA,aAAa,EAAE,KADZ;AAEHC,IAAAA,UAAU,EAAE;AAFT,GAD0B;AAK/BT,EAAAA,WAAW,EAAE;AACXU,IAAAA,QAAQ,EAAE,UADC;AAEXL,IAAAA,GAAG,EAAE,CAFM;AAGXM,IAAAA,IAAI,EAAE,CAHK;AAIXC,IAAAA,KAAK,EAAE,CAJI;AAKXC,IAAAA,MAAM,EAAE;AALG,GALkB;AAY/Bd,EAAAA,UAAU,EAAE;AACVe,IAAAA,QAAQ,EAAE;AADA;AAZmB,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 isSearchBarAvailableForCurrentPlatform,\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 headerHeight: number;\n route: Route<string>;\n canGoBack: boolean;\n};\n\nexport default function HeaderConfig({\n headerHeight,\n headerBackImageSource,\n headerBackButtonMenuEnabled,\n headerBackTitle,\n headerBackTitleStyle,\n headerBackTitleVisible = true,\n headerBackVisible,\n headerShadowVisible,\n headerLargeStyle,\n headerLargeTitle,\n headerLargeTitleShadowVisible,\n headerLargeTitleStyle,\n headerBackground,\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\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 canGoBack,\n label: headerBackTitle,\n });\n const headerRightElement = headerRight?.({\n tintColor,\n canGoBack,\n });\n const headerTitleElement =\n typeof headerTitle === 'function'\n ? headerTitle({ tintColor, children: titleText })\n : null;\n\n const supportsHeaderSearchBar =\n typeof isSearchBarAvailableForCurrentPlatform === 'boolean'\n ? isSearchBarAvailableForCurrentPlatform\n : // Fallback for older versions of react-native-screens\n Platform.OS === 'ios' && SearchBar != null;\n\n const hasHeaderSearchBar =\n supportsHeaderSearchBar && headerSearchBarOptions != null;\n\n if (headerSearchBarOptions != null && !supportsHeaderSearchBar) {\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 <>\n {headerBackground != null ? (\n <View\n style={[\n styles.background,\n headerTransparent ? styles.translucent : null,\n { height: headerHeight },\n ]}\n >\n {headerBackground()}\n </View>\n ) : null}\n <ScreenStackHeaderConfig\n backButtonInCustomView={backButtonInCustomView}\n backgroundColor={\n headerStyleFlattened.backgroundColor ??\n (headerBackground != null || headerTransparent\n ? 'transparent'\n : 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={\n headerShadowVisible === false ||\n headerBackground != null ||\n headerTransparent\n }\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 headerBackground != null ||\n // This defaults to `true`, so we can't pass `undefined`\n headerTransparent === true ||\n // When using a SearchBar or large title, the header needs to be translucent for it to work on iOS\n ((hasHeaderSearchBar || headerLargeTitle) &&\n Platform.OS === 'ios' &&\n headerTransparent !== false)\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 {hasHeaderSearchBar ? (\n <ScreenStackHeaderSearchBarView>\n <SearchBar {...headerSearchBarOptions} />\n </ScreenStackHeaderSearchBarView>\n ) : null}\n </ScreenStackHeaderConfig>\n </>\n );\n}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n },\n translucent: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n zIndex: 1,\n },\n background: {\n overflow: 'hidden',\n },\n});\n"]}
@@ -145,6 +145,7 @@ export declare type NativeStackNavigationOptions = {
145
145
  *
146
146
  * For large title to collapse on scroll, the content of the screen should be wrapped in a scrollable view such as `ScrollView` or `FlatList`.
147
147
  * If the scrollable area doesn't fill the screen, the large title won't collapse on scroll.
148
+ * You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
148
149
  *
149
150
  * Only supported on iOS.
150
151
  *
@@ -263,9 +264,11 @@ export declare type NativeStackNavigationOptions = {
263
264
  color?: string;
264
265
  }>;
265
266
  /**
266
- * Options to render a native search bar on iOS.
267
+ * Options to render a native search bar.
268
+ * You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
269
+ * If you don't have a `ScrollView`, specify `headerTransparent: false`.
267
270
  *
268
- * @platform ios
271
+ * Only supported on iOS and Android.
269
272
  */
270
273
  headerSearchBarOptions?: SearchBarProps;
271
274
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/native-stack",
3
3
  "description": "Native stack navigator using react-native-screens",
4
- "version": "6.3.0",
4
+ "version": "6.4.0",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -41,11 +41,11 @@
41
41
  "clean": "del lib"
42
42
  },
43
43
  "dependencies": {
44
- "@react-navigation/elements": "^1.3.0",
44
+ "@react-navigation/elements": "^1.3.1",
45
45
  "warn-once": "^0.1.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@react-navigation/native": "^6.0.7",
48
+ "@react-navigation/native": "^6.0.8",
49
49
  "@testing-library/react-native": "^7.2.0",
50
50
  "@types/react": "^17.0.9",
51
51
  "@types/react-native": "~0.64.9",
@@ -76,5 +76,5 @@
76
76
  ]
77
77
  ]
78
78
  },
79
- "gitHead": "4c5805867ce946d99ba17f71b4d6086bb8751262"
79
+ "gitHead": "4cddbce150413c15db93897c76b813f436f5186d"
80
80
  }
package/src/types.tsx CHANGED
@@ -182,6 +182,7 @@ export type NativeStackNavigationOptions = {
182
182
  *
183
183
  * For large title to collapse on scroll, the content of the screen should be wrapped in a scrollable view such as `ScrollView` or `FlatList`.
184
184
  * If the scrollable area doesn't fill the screen, the large title won't collapse on scroll.
185
+ * You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
185
186
  *
186
187
  * Only supported on iOS.
187
188
  *
@@ -304,9 +305,11 @@ export type NativeStackNavigationOptions = {
304
305
  }
305
306
  >;
306
307
  /**
307
- * Options to render a native search bar on iOS.
308
+ * Options to render a native search bar.
309
+ * You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
310
+ * If you don't have a `ScrollView`, specify `headerTransparent: false`.
308
311
  *
309
- * @platform ios
312
+ * Only supported on iOS and Android.
310
313
  */
311
314
  headerSearchBarOptions?: SearchBarProps;
312
315
  /**
@@ -10,6 +10,7 @@ import {
10
10
  } from 'react-native';
11
11
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
12
12
  import {
13
+ isSearchBarAvailableForCurrentPlatform,
13
14
  ScreenStackHeaderBackButtonImage,
14
15
  ScreenStackHeaderCenterView,
15
16
  ScreenStackHeaderConfig,
@@ -112,11 +113,16 @@ export default function HeaderConfig({
112
113
  ? headerTitle({ tintColor, children: titleText })
113
114
  : null;
114
115
 
115
- if (
116
- Platform.OS === 'ios' &&
117
- headerSearchBarOptions != null &&
118
- SearchBar == null
119
- ) {
116
+ const supportsHeaderSearchBar =
117
+ typeof isSearchBarAvailableForCurrentPlatform === 'boolean'
118
+ ? isSearchBarAvailableForCurrentPlatform
119
+ : // Fallback for older versions of react-native-screens
120
+ Platform.OS === 'ios' && SearchBar != null;
121
+
122
+ const hasHeaderSearchBar =
123
+ supportsHeaderSearchBar && headerSearchBarOptions != null;
124
+
125
+ if (headerSearchBarOptions != null && !supportsHeaderSearchBar) {
120
126
  throw new Error(
121
127
  `The current version of 'react-native-screens' doesn't support SearchBar in the header. Please update to the latest version to use this option.`
122
128
  );
@@ -182,7 +188,11 @@ export default function HeaderConfig({
182
188
  translucent={
183
189
  headerBackground != null ||
184
190
  // This defaults to `true`, so we can't pass `undefined`
185
- headerTransparent === true
191
+ headerTransparent === true ||
192
+ // When using a SearchBar or large title, the header needs to be translucent for it to work on iOS
193
+ ((hasHeaderSearchBar || headerLargeTitle) &&
194
+ Platform.OS === 'ios' &&
195
+ headerTransparent !== false)
186
196
  }
187
197
  >
188
198
  {Platform.OS === 'ios' ? (
@@ -243,7 +253,7 @@ export default function HeaderConfig({
243
253
  {headerRightElement}
244
254
  </ScreenStackHeaderRightView>
245
255
  ) : null}
246
- {Platform.OS === 'ios' && headerSearchBarOptions != null ? (
256
+ {hasHeaderSearchBar ? (
247
257
  <ScreenStackHeaderSearchBarView>
248
258
  <SearchBar {...headerSearchBarOptions} />
249
259
  </ScreenStackHeaderSearchBarView>