@react-navigation/elements 1.1.2 → 1.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.
@@ -63,6 +63,7 @@ function Header(props) {
63
63
  headerTitleContainerStyle: titleContainerStyle,
64
64
  headerBackgroundContainerStyle: backgroundContainerStyle,
65
65
  headerStyle: customHeaderStyle,
66
+ headerShadowVisible,
66
67
  headerPressColor,
67
68
  headerPressOpacity,
68
69
  headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top
@@ -162,6 +163,11 @@ function Header(props) {
162
163
  }
163
164
  }
164
165
 
166
+ const backgroundStyle = [safeStyles, headerShadowVisible === false && {
167
+ elevation: 0,
168
+ shadowOpacity: 0,
169
+ borderBottomWidth: 0
170
+ }];
165
171
  const leftButton = headerLeft ? headerLeft({
166
172
  tintColor: headerTintColor,
167
173
  pressColor: headerPressColor,
@@ -180,9 +186,9 @@ function Header(props) {
180
186
  zIndex: 0
181
187
  }, backgroundContainerStyle]
182
188
  }, headerBackground ? headerBackground({
183
- style: safeStyles
189
+ style: backgroundStyle
184
190
  }) : headerTransparent ? null : /*#__PURE__*/React.createElement(_HeaderBackground.default, {
185
- style: safeStyles
191
+ style: backgroundStyle
186
192
  })), /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
187
193
  pointerEvents: "box-none",
188
194
  style: [{
@@ -1 +1 @@
1
- {"version":3,"sources":["Header.tsx"],"names":["warnIfHeaderStylesDefined","styles","Object","keys","forEach","styleProp","value","console","warn","undefined","Header","props","insets","frame","isParentHeaderShown","React","useContext","HeaderShownContext","layout","modal","title","headerTitle","customTitle","headerTitleAlign","Platform","select","ios","default","headerLeft","headerLeftLabelVisible","headerTransparent","headerTintColor","headerBackground","headerRight","headerTitleAllowFontScaling","titleAllowFontScaling","headerTitleStyle","titleStyle","headerLeftContainerStyle","leftContainerStyle","headerRightContainerStyle","rightContainerStyle","headerTitleContainerStyle","titleContainerStyle","headerBackgroundContainerStyle","backgroundContainerStyle","headerStyle","customHeaderStyle","headerPressColor","headerPressOpacity","headerStatusBarHeight","top","defaultHeight","height","minHeight","maxHeight","backgroundColor","borderBottomColor","borderBottomEndRadius","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStartRadius","borderBottomWidth","borderColor","borderEndColor","borderEndWidth","borderLeftColor","borderLeftWidth","borderRadius","borderRightColor","borderRightWidth","borderStartColor","borderStartWidth","borderStyle","borderTopColor","borderTopEndRadius","borderTopLeftRadius","borderTopRightRadius","borderTopStartRadius","borderTopWidth","borderWidth","boxShadow","elevation","shadowColor","shadowOffset","shadowOpacity","shadowRadius","opacity","transform","unsafeStyles","StyleSheet","flatten","process","env","NODE_ENV","safeStyles","leftButton","tintColor","pressColor","pressOpacity","labelVisible","rightButton","absoluteFill","zIndex","style","content","left","expand","marginStart","maxWidth","width","Math","max","right","children","allowFontScaling","marginEnd","create","flex","flexDirection","alignItems","marginHorizontal","justifyContent","flexGrow","flexBasis"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;;;;;;;AAiBA,MAAMA,yBAAyB,GAAIC,MAAD,IAAiC;AACjEC,EAAAA,MAAM,CAACC,IAAP,CAAYF,MAAZ,EAAoBG,OAApB,CAA6BC,SAAD,IAAe;AACzC,UAAMC,KAAK,GAAGL,MAAM,CAACI,SAAD,CAApB;;AAEA,QAAIA,SAAS,KAAK,UAAd,IAA4BC,KAAK,KAAK,UAA1C,EAAsD;AACpDC,MAAAA,OAAO,CAACC,IAAR,CACE,iJADF;AAGD,KAJD,MAIO,IAAIF,KAAK,KAAKG,SAAd,EAAyB;AAC9BF,MAAAA,OAAO,CAACC,IAAR,CACG,GAAEH,SAAU,yBAAwBC,KAAM,sCAD7C;AAGD;AACF,GAZD;AAaD,CAdD;;AAgBe,SAASI,MAAT,CAAgBC,KAAhB,EAA8B;AAC3C,QAAMC,MAAM,GAAG,oDAAf;AACA,QAAMC,KAAK,GAAG,mDAAd;AAEA,QAAMC,mBAAmB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/Bb,EAAAA,MAAM,EAAE;AACNgB,IAAAA,QAAQ,EAAE,CADJ;AAENC,IAAAA,SAAS,EAAE;AAFL;AAlBuB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { Animated, Platform, StyleSheet, View, ViewStyle } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\n\nimport type { HeaderOptions, Layout } from '../types';\nimport getDefaultHeaderHeight from './getDefaultHeaderHeight';\nimport HeaderBackground from './HeaderBackground';\nimport HeaderShownContext from './HeaderShownContext';\nimport HeaderTitle from './HeaderTitle';\n\ntype Props = HeaderOptions & {\n /**\n * Whether the header is in a modal\n */\n modal?: boolean;\n /**\n * Layout of the screen.\n */\n layout?: Layout;\n /**\n * Title text for the header.\n */\n title: string;\n};\n\nconst warnIfHeaderStylesDefined = (styles: Record<string, any>) => {\n Object.keys(styles).forEach((styleProp) => {\n const value = styles[styleProp];\n\n if (styleProp === 'position' && value === 'absolute') {\n console.warn(\n \"position: 'absolute' is not supported on headerStyle. If you would like to render content under the header, use the 'headerTransparent' option.\"\n );\n } else if (value !== undefined) {\n console.warn(\n `${styleProp} was given a value of ${value}, this has no effect on headerStyle.`\n );\n }\n });\n};\n\nexport default function Header(props: Props) {\n const insets = useSafeAreaInsets();\n const frame = useSafeAreaFrame();\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n\n const {\n layout = frame,\n modal = false,\n title,\n headerTitle: customTitle,\n headerTitleAlign = Platform.select({\n ios: 'center',\n default: 'left',\n }),\n headerLeft,\n headerLeftLabelVisible,\n headerTransparent,\n headerTintColor,\n headerBackground,\n headerRight,\n headerTitleAllowFontScaling: titleAllowFontScaling,\n headerTitleStyle: titleStyle,\n headerLeftContainerStyle: leftContainerStyle,\n headerRightContainerStyle: rightContainerStyle,\n headerTitleContainerStyle: titleContainerStyle,\n headerBackgroundContainerStyle: backgroundContainerStyle,\n headerStyle: customHeaderStyle,\n headerPressColor,\n headerPressOpacity,\n headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,\n } = props;\n\n const defaultHeight = getDefaultHeaderHeight(\n layout,\n modal,\n headerStatusBarHeight\n );\n\n const {\n height = defaultHeight,\n minHeight,\n maxHeight,\n backgroundColor,\n borderBottomColor,\n borderBottomEndRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n borderBottomStartRadius,\n borderBottomWidth,\n borderColor,\n borderEndColor,\n borderEndWidth,\n borderLeftColor,\n borderLeftWidth,\n borderRadius,\n borderRightColor,\n borderRightWidth,\n borderStartColor,\n borderStartWidth,\n borderStyle,\n borderTopColor,\n borderTopEndRadius,\n borderTopLeftRadius,\n borderTopRightRadius,\n borderTopStartRadius,\n borderTopWidth,\n borderWidth,\n // @ts-expect-error: web support for shadow\n boxShadow,\n elevation,\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n opacity,\n transform,\n ...unsafeStyles\n } = StyleSheet.flatten(customHeaderStyle || {}) as ViewStyle;\n\n if (process.env.NODE_ENV !== 'production') {\n warnIfHeaderStylesDefined(unsafeStyles);\n }\n\n const safeStyles: ViewStyle = {\n backgroundColor,\n borderBottomColor,\n borderBottomEndRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n borderBottomStartRadius,\n borderBottomWidth,\n borderColor,\n borderEndColor,\n borderEndWidth,\n borderLeftColor,\n borderLeftWidth,\n borderRadius,\n borderRightColor,\n borderRightWidth,\n borderStartColor,\n borderStartWidth,\n borderStyle,\n borderTopColor,\n borderTopEndRadius,\n borderTopLeftRadius,\n borderTopRightRadius,\n borderTopStartRadius,\n borderTopWidth,\n borderWidth,\n // @ts-expect-error: boxShadow is only for Web\n boxShadow,\n elevation,\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n opacity,\n transform,\n };\n\n // Setting a property to undefined triggers default style\n // So we need to filter them out\n // Users can use `null` instead\n for (const styleProp in safeStyles) {\n // @ts-expect-error: typescript wrongly complains that styleProp cannot be used to index safeStyles\n if (safeStyles[styleProp] === undefined) {\n // @ts-expect-error\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete safeStyles[styleProp];\n }\n }\n\n const leftButton = headerLeft\n ? headerLeft({\n tintColor: headerTintColor,\n pressColor: headerPressColor,\n pressOpacity: headerPressOpacity,\n labelVisible: headerLeftLabelVisible,\n })\n : null;\n\n const rightButton = headerRight\n ? headerRight({\n tintColor: headerTintColor,\n pressColor: headerPressColor,\n pressOpacity: headerPressOpacity,\n })\n : null;\n\n const headerTitle =\n typeof customTitle !== 'function'\n ? (props: React.ComponentProps<typeof HeaderTitle>) => (\n <HeaderTitle {...props} />\n )\n : customTitle;\n\n return (\n <React.Fragment>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n StyleSheet.absoluteFill,\n { zIndex: 0 },\n backgroundContainerStyle,\n ]}\n >\n {headerBackground ? (\n headerBackground({ style: safeStyles })\n ) : headerTransparent ? null : (\n <HeaderBackground style={safeStyles} />\n )}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[{ height, minHeight, maxHeight, opacity, transform }]}\n >\n <View pointerEvents=\"none\" style={{ height: headerStatusBarHeight }} />\n <View pointerEvents=\"box-none\" style={styles.content}>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.left,\n headerTitleAlign === 'center' && styles.expand,\n { marginStart: insets.left },\n leftContainerStyle,\n ]}\n >\n {leftButton}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.title,\n {\n // Avoid the title from going offscreen or overlapping buttons\n maxWidth:\n headerTitleAlign === 'center'\n ? layout.width -\n ((leftButton\n ? headerLeftLabelVisible !== false\n ? 80\n : 32\n : 16) +\n Math.max(insets.left, insets.right)) *\n 2\n : layout.width -\n ((leftButton ? 72 : 16) +\n (rightButton ? 72 : 16) +\n insets.left -\n insets.right),\n },\n titleContainerStyle,\n ]}\n >\n {headerTitle({\n children: title,\n allowFontScaling: titleAllowFontScaling,\n tintColor: headerTintColor,\n style: titleStyle,\n })}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.right,\n styles.expand,\n { marginEnd: insets.right },\n rightContainerStyle,\n ]}\n >\n {rightButton}\n </Animated.View>\n </View>\n </Animated.View>\n </React.Fragment>\n );\n}\n\nconst styles = StyleSheet.create({\n content: {\n flex: 1,\n flexDirection: 'row',\n alignItems: 'stretch',\n },\n title: {\n marginHorizontal: 16,\n justifyContent: 'center',\n },\n left: {\n justifyContent: 'center',\n alignItems: 'flex-start',\n },\n right: {\n justifyContent: 'center',\n alignItems: 'flex-end',\n },\n expand: {\n flexGrow: 1,\n flexBasis: 0,\n },\n});\n"]}
1
+ {"version":3,"sources":["Header.tsx"],"names":["warnIfHeaderStylesDefined","styles","Object","keys","forEach","styleProp","value","console","warn","undefined","Header","props","insets","frame","isParentHeaderShown","React","useContext","HeaderShownContext","layout","modal","title","headerTitle","customTitle","headerTitleAlign","Platform","select","ios","default","headerLeft","headerLeftLabelVisible","headerTransparent","headerTintColor","headerBackground","headerRight","headerTitleAllowFontScaling","titleAllowFontScaling","headerTitleStyle","titleStyle","headerLeftContainerStyle","leftContainerStyle","headerRightContainerStyle","rightContainerStyle","headerTitleContainerStyle","titleContainerStyle","headerBackgroundContainerStyle","backgroundContainerStyle","headerStyle","customHeaderStyle","headerShadowVisible","headerPressColor","headerPressOpacity","headerStatusBarHeight","top","defaultHeight","height","minHeight","maxHeight","backgroundColor","borderBottomColor","borderBottomEndRadius","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStartRadius","borderBottomWidth","borderColor","borderEndColor","borderEndWidth","borderLeftColor","borderLeftWidth","borderRadius","borderRightColor","borderRightWidth","borderStartColor","borderStartWidth","borderStyle","borderTopColor","borderTopEndRadius","borderTopLeftRadius","borderTopRightRadius","borderTopStartRadius","borderTopWidth","borderWidth","boxShadow","elevation","shadowColor","shadowOffset","shadowOpacity","shadowRadius","opacity","transform","unsafeStyles","StyleSheet","flatten","process","env","NODE_ENV","safeStyles","backgroundStyle","leftButton","tintColor","pressColor","pressOpacity","labelVisible","rightButton","absoluteFill","zIndex","style","content","left","expand","marginStart","maxWidth","width","Math","max","right","children","allowFontScaling","marginEnd","create","flex","flexDirection","alignItems","marginHorizontal","justifyContent","flexGrow","flexBasis"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;;;;;;;AAiBA,MAAMA,yBAAyB,GAAIC,MAAD,IAAiC;AACjEC,EAAAA,MAAM,CAACC,IAAP,CAAYF,MAAZ,EAAoBG,OAApB,CAA6BC,SAAD,IAAe;AACzC,UAAMC,KAAK,GAAGL,MAAM,CAACI,SAAD,CAApB;;AAEA,QAAIA,SAAS,KAAK,UAAd,IAA4BC,KAAK,KAAK,UAA1C,EAAsD;AACpDC,MAAAA,OAAO,CAACC,IAAR,CACE,iJADF;AAGD,KAJD,MAIO,IAAIF,KAAK,KAAKG,SAAd,EAAyB;AAC9BF,MAAAA,OAAO,CAACC,IAAR,CACG,GAAEH,SAAU,yBAAwBC,KAAM,sCAD7C;AAGD;AACF,GAZD;AAaD,CAdD;;AAgBe,SAASI,MAAT,CAAgBC,KAAhB,EAA8B;AAC3C,QAAMC,MAAM,GAAG,oDAAf;AACA,QAAMC,KAAK,GAAG,mDAAd;AAEA,QAAMC,mBAAmB,GAAGC,KAAK,CAACC,UAAN,CAAiBC,2BAAjB,CAA5B;AAEA,QAAM;AACJC,IAAAA,MAAM,GAAGL,KADL;AAEJM,IAAAA,KAAK,GAAG,KAFJ;AAGJC,IAAAA,KAHI;AAIJC,IAAAA,WAAW,EAAEC,WAJT;AAKJC,IAAAA,gBAAgB,GAAGC,sBAASC,MAAT,CAAgB;AACjCC,MAAAA,GAAG,EAAE,QAD4B;AAEjCC,MAAAA,OAAO,EAAE;AAFwB,KAAhB,CALf;AASJC,IAAAA,UATI;AAUJC,IAAAA,sBAVI;AAWJC,IAAAA,iBAXI;AAYJC,IAAAA,eAZI;AAaJC,IAAAA,gBAbI;AAcJC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H,GAAQ,EADrB,IAEC3F,MAAM,CAACgG,IAFR,GAGChG,MAAM,CAACuG,KAJT;AAZR,KAFK,EAoBLxE,mBApBK;AAFT,KAyBGtB,WAAW,CAAC;AACX+F,IAAAA,QAAQ,EAAEhG,KADC;AAEXiG,IAAAA,gBAAgB,EAAElF,qBAFP;AAGXgE,IAAAA,SAAS,EAAEpE,eAHA;AAIX2E,IAAAA,KAAK,EAAErE;AAJI,GAAD,CAzBd,CAZF,eA4CE,oBAAC,qBAAD,CAAU,IAAV;AACE,IAAA,aAAa,EAAC,UADhB;AAEE,IAAA,KAAK,EAAE,CACLpC,MAAM,CAACkH,KADF,EAELlH,MAAM,CAAC4G,MAFF,EAGL;AAAES,MAAAA,SAAS,EAAE1G,MAAM,CAACuG;AAApB,KAHK,EAIL1E,mBAJK;AAFT,KASG8D,WATH,CA5CF,CALF,CAfF,CADF;AAgFD;;AAED,MAAMtG,MAAM,GAAG0F,wBAAW4B,MAAX,CAAkB;AAC/BZ,EAAAA,OAAO,EAAE;AACPa,IAAAA,IAAI,EAAE,CADC;AAEPC,IAAAA,aAAa,EAAE,KAFR;AAGPC,IAAAA,UAAU,EAAE;AAHL,GADsB;AAM/BtG,EAAAA,KAAK,EAAE;AACLuG,IAAAA,gBAAgB,EAAE,EADb;AAELC,IAAAA,cAAc,EAAE;AAFX,GANwB;AAU/BhB,EAAAA,IAAI,EAAE;AACJgB,IAAAA,cAAc,EAAE,QADZ;AAEJF,IAAAA,UAAU,EAAE;AAFR,GAVyB;AAc/BP,EAAAA,KAAK,EAAE;AACLS,IAAAA,cAAc,EAAE,QADX;AAELF,IAAAA,UAAU,EAAE;AAFP,GAdwB;AAkB/Bb,EAAAA,MAAM,EAAE;AACNgB,IAAAA,QAAQ,EAAE,CADJ;AAENC,IAAAA,SAAS,EAAE;AAFL;AAlBuB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { Animated, Platform, StyleSheet, View, ViewStyle } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\n\nimport type { HeaderOptions, Layout } from '../types';\nimport getDefaultHeaderHeight from './getDefaultHeaderHeight';\nimport HeaderBackground from './HeaderBackground';\nimport HeaderShownContext from './HeaderShownContext';\nimport HeaderTitle from './HeaderTitle';\n\ntype Props = HeaderOptions & {\n /**\n * Whether the header is in a modal\n */\n modal?: boolean;\n /**\n * Layout of the screen.\n */\n layout?: Layout;\n /**\n * Title text for the header.\n */\n title: string;\n};\n\nconst warnIfHeaderStylesDefined = (styles: Record<string, any>) => {\n Object.keys(styles).forEach((styleProp) => {\n const value = styles[styleProp];\n\n if (styleProp === 'position' && value === 'absolute') {\n console.warn(\n \"position: 'absolute' is not supported on headerStyle. If you would like to render content under the header, use the 'headerTransparent' option.\"\n );\n } else if (value !== undefined) {\n console.warn(\n `${styleProp} was given a value of ${value}, this has no effect on headerStyle.`\n );\n }\n });\n};\n\nexport default function Header(props: Props) {\n const insets = useSafeAreaInsets();\n const frame = useSafeAreaFrame();\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n\n const {\n layout = frame,\n modal = false,\n title,\n headerTitle: customTitle,\n headerTitleAlign = Platform.select({\n ios: 'center',\n default: 'left',\n }),\n headerLeft,\n headerLeftLabelVisible,\n headerTransparent,\n headerTintColor,\n headerBackground,\n headerRight,\n headerTitleAllowFontScaling: titleAllowFontScaling,\n headerTitleStyle: titleStyle,\n headerLeftContainerStyle: leftContainerStyle,\n headerRightContainerStyle: rightContainerStyle,\n headerTitleContainerStyle: titleContainerStyle,\n headerBackgroundContainerStyle: backgroundContainerStyle,\n headerStyle: customHeaderStyle,\n headerShadowVisible,\n headerPressColor,\n headerPressOpacity,\n headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,\n } = props;\n\n const defaultHeight = getDefaultHeaderHeight(\n layout,\n modal,\n headerStatusBarHeight\n );\n\n const {\n height = defaultHeight,\n minHeight,\n maxHeight,\n backgroundColor,\n borderBottomColor,\n borderBottomEndRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n borderBottomStartRadius,\n borderBottomWidth,\n borderColor,\n borderEndColor,\n borderEndWidth,\n borderLeftColor,\n borderLeftWidth,\n borderRadius,\n borderRightColor,\n borderRightWidth,\n borderStartColor,\n borderStartWidth,\n borderStyle,\n borderTopColor,\n borderTopEndRadius,\n borderTopLeftRadius,\n borderTopRightRadius,\n borderTopStartRadius,\n borderTopWidth,\n borderWidth,\n // @ts-expect-error: web support for shadow\n boxShadow,\n elevation,\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n opacity,\n transform,\n ...unsafeStyles\n } = StyleSheet.flatten(customHeaderStyle || {}) as ViewStyle;\n\n if (process.env.NODE_ENV !== 'production') {\n warnIfHeaderStylesDefined(unsafeStyles);\n }\n\n const safeStyles: ViewStyle = {\n backgroundColor,\n borderBottomColor,\n borderBottomEndRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n borderBottomStartRadius,\n borderBottomWidth,\n borderColor,\n borderEndColor,\n borderEndWidth,\n borderLeftColor,\n borderLeftWidth,\n borderRadius,\n borderRightColor,\n borderRightWidth,\n borderStartColor,\n borderStartWidth,\n borderStyle,\n borderTopColor,\n borderTopEndRadius,\n borderTopLeftRadius,\n borderTopRightRadius,\n borderTopStartRadius,\n borderTopWidth,\n borderWidth,\n // @ts-expect-error: boxShadow is only for Web\n boxShadow,\n elevation,\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n opacity,\n transform,\n };\n\n // Setting a property to undefined triggers default style\n // So we need to filter them out\n // Users can use `null` instead\n for (const styleProp in safeStyles) {\n // @ts-expect-error: typescript wrongly complains that styleProp cannot be used to index safeStyles\n if (safeStyles[styleProp] === undefined) {\n // @ts-expect-error\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete safeStyles[styleProp];\n }\n }\n\n const backgroundStyle = [\n safeStyles,\n headerShadowVisible === false && {\n elevation: 0,\n shadowOpacity: 0,\n borderBottomWidth: 0,\n },\n ];\n\n const leftButton = headerLeft\n ? headerLeft({\n tintColor: headerTintColor,\n pressColor: headerPressColor,\n pressOpacity: headerPressOpacity,\n labelVisible: headerLeftLabelVisible,\n })\n : null;\n\n const rightButton = headerRight\n ? headerRight({\n tintColor: headerTintColor,\n pressColor: headerPressColor,\n pressOpacity: headerPressOpacity,\n })\n : null;\n\n const headerTitle =\n typeof customTitle !== 'function'\n ? (props: React.ComponentProps<typeof HeaderTitle>) => (\n <HeaderTitle {...props} />\n )\n : customTitle;\n\n return (\n <React.Fragment>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n StyleSheet.absoluteFill,\n { zIndex: 0 },\n backgroundContainerStyle,\n ]}\n >\n {headerBackground ? (\n headerBackground({ style: backgroundStyle })\n ) : headerTransparent ? null : (\n <HeaderBackground style={backgroundStyle} />\n )}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[{ height, minHeight, maxHeight, opacity, transform }]}\n >\n <View pointerEvents=\"none\" style={{ height: headerStatusBarHeight }} />\n <View pointerEvents=\"box-none\" style={styles.content}>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.left,\n headerTitleAlign === 'center' && styles.expand,\n { marginStart: insets.left },\n leftContainerStyle,\n ]}\n >\n {leftButton}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.title,\n {\n // Avoid the title from going offscreen or overlapping buttons\n maxWidth:\n headerTitleAlign === 'center'\n ? layout.width -\n ((leftButton\n ? headerLeftLabelVisible !== false\n ? 80\n : 32\n : 16) +\n Math.max(insets.left, insets.right)) *\n 2\n : layout.width -\n ((leftButton ? 72 : 16) +\n (rightButton ? 72 : 16) +\n insets.left -\n insets.right),\n },\n titleContainerStyle,\n ]}\n >\n {headerTitle({\n children: title,\n allowFontScaling: titleAllowFontScaling,\n tintColor: headerTintColor,\n style: titleStyle,\n })}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.right,\n styles.expand,\n { marginEnd: insets.right },\n rightContainerStyle,\n ]}\n >\n {rightButton}\n </Animated.View>\n </View>\n </Animated.View>\n </React.Fragment>\n );\n}\n\nconst styles = StyleSheet.create({\n content: {\n flex: 1,\n flexDirection: 'row',\n alignItems: 'stretch',\n },\n title: {\n marginHorizontal: 16,\n justifyContent: 'center',\n },\n left: {\n justifyContent: 'center',\n alignItems: 'flex-start',\n },\n right: {\n justifyContent: 'center',\n alignItems: 'flex-end',\n },\n expand: {\n flexGrow: 1,\n flexBasis: 0,\n },\n});\n"]}
@@ -44,6 +44,7 @@ export default function Header(props) {
44
44
  headerTitleContainerStyle: titleContainerStyle,
45
45
  headerBackgroundContainerStyle: backgroundContainerStyle,
46
46
  headerStyle: customHeaderStyle,
47
+ headerShadowVisible,
47
48
  headerPressColor,
48
49
  headerPressOpacity,
49
50
  headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top
@@ -142,6 +143,11 @@ export default function Header(props) {
142
143
  }
143
144
  }
144
145
 
146
+ const backgroundStyle = [safeStyles, headerShadowVisible === false && {
147
+ elevation: 0,
148
+ shadowOpacity: 0,
149
+ borderBottomWidth: 0
150
+ }];
145
151
  const leftButton = headerLeft ? headerLeft({
146
152
  tintColor: headerTintColor,
147
153
  pressColor: headerPressColor,
@@ -160,9 +166,9 @@ export default function Header(props) {
160
166
  zIndex: 0
161
167
  }, backgroundContainerStyle]
162
168
  }, headerBackground ? headerBackground({
163
- style: safeStyles
169
+ style: backgroundStyle
164
170
  }) : headerTransparent ? null : /*#__PURE__*/React.createElement(HeaderBackground, {
165
- style: safeStyles
171
+ style: backgroundStyle
166
172
  })), /*#__PURE__*/React.createElement(Animated.View, {
167
173
  pointerEvents: "box-none",
168
174
  style: [{
@@ -1 +1 @@
1
- {"version":3,"sources":["Header.tsx"],"names":["React","Animated","Platform","StyleSheet","View","useSafeAreaFrame","useSafeAreaInsets","getDefaultHeaderHeight","HeaderBackground","HeaderShownContext","HeaderTitle","warnIfHeaderStylesDefined","styles","Object","keys","forEach","styleProp","value","console","warn","undefined","Header","props","insets","frame","isParentHeaderShown","useContext","layout","modal","title","headerTitle","customTitle","headerTitleAlign","select","ios","default","headerLeft","headerLeftLabelVisible","headerTransparent","headerTintColor","headerBackground","headerRight","headerTitleAllowFontScaling","titleAllowFontScaling","headerTitleStyle","titleStyle","headerLeftContainerStyle","leftContainerStyle","headerRightContainerStyle","rightContainerStyle","headerTitleContainerStyle","titleContainerStyle","headerBackgroundContainerStyle","backgroundContainerStyle","headerStyle","customHeaderStyle","headerPressColor","headerPressOpacity","headerStatusBarHeight","top","defaultHeight","height","minHeight","maxHeight","backgroundColor","borderBottomColor","borderBottomEndRadius","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStartRadius","borderBottomWidth","borderColor","borderEndColor","borderEndWidth","borderLeftColor","borderLeftWidth","borderRadius","borderRightColor","borderRightWidth","borderStartColor","borderStartWidth","borderStyle","borderTopColor","borderTopEndRadius","borderTopLeftRadius","borderTopRightRadius","borderTopStartRadius","borderTopWidth","borderWidth","boxShadow","elevation","shadowColor","shadowOffset","shadowOpacity","shadowRadius","opacity","transform","unsafeStyles","flatten","process","env","NODE_ENV","safeStyles","leftButton","tintColor","pressColor","pressOpacity","labelVisible","rightButton","absoluteFill","zIndex","style","content","left","expand","marginStart","maxWidth","width","Math","max","right","children","allowFontScaling","marginEnd","create","flex","flexDirection","alignItems","marginHorizontal","justifyContent","flexGrow","flexBasis"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,UAA7B,EAAyCC,IAAzC,QAAgE,cAAhE;AACA,SACEC,gBADF,EAEEC,iBAFF,QAGO,gCAHP;AAMA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,kBAAP,MAA+B,sBAA/B;AACA,OAAOC,WAAP,MAAwB,eAAxB;;AAiBA,MAAMC,yBAAyB,GAAIC,MAAD,IAAiC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,MAAAA,SAAS,EAAEpG,MAAM,CAACiG;AAApB,KAHK,EAILvE,mBAJK;AAFT,KASG2D,WATH,CA5CF,CALF,CAfF,CADF;AAgFD;AAED,MAAMhG,MAAM,GAAGT,UAAU,CAACyH,MAAX,CAAkB;AAC/BZ,EAAAA,OAAO,EAAE;AACPa,IAAAA,IAAI,EAAE,CADC;AAEPC,IAAAA,aAAa,EAAE,KAFR;AAGPC,IAAAA,UAAU,EAAE;AAHL,GADsB;AAM/BlG,EAAAA,KAAK,EAAE;AACLmG,IAAAA,gBAAgB,EAAE,EADb;AAELC,IAAAA,cAAc,EAAE;AAFX,GANwB;AAU/BhB,EAAAA,IAAI,EAAE;AACJgB,IAAAA,cAAc,EAAE,QADZ;AAEJF,IAAAA,UAAU,EAAE;AAFR,GAVyB;AAc/BP,EAAAA,KAAK,EAAE;AACLS,IAAAA,cAAc,EAAE,QADX;AAELF,IAAAA,UAAU,EAAE;AAFP,GAdwB;AAkB/Bb,EAAAA,MAAM,EAAE;AACNgB,IAAAA,QAAQ,EAAE,CADJ;AAENC,IAAAA,SAAS,EAAE;AAFL;AAlBuB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { Animated, Platform, StyleSheet, View, ViewStyle } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\n\nimport type { HeaderOptions, Layout } from '../types';\nimport getDefaultHeaderHeight from './getDefaultHeaderHeight';\nimport HeaderBackground from './HeaderBackground';\nimport HeaderShownContext from './HeaderShownContext';\nimport HeaderTitle from './HeaderTitle';\n\ntype Props = HeaderOptions & {\n /**\n * Whether the header is in a modal\n */\n modal?: boolean;\n /**\n * Layout of the screen.\n */\n layout?: Layout;\n /**\n * Title text for the header.\n */\n title: string;\n};\n\nconst warnIfHeaderStylesDefined = (styles: Record<string, any>) => {\n Object.keys(styles).forEach((styleProp) => {\n const value = styles[styleProp];\n\n if (styleProp === 'position' && value === 'absolute') {\n console.warn(\n \"position: 'absolute' is not supported on headerStyle. If you would like to render content under the header, use the 'headerTransparent' option.\"\n );\n } else if (value !== undefined) {\n console.warn(\n `${styleProp} was given a value of ${value}, this has no effect on headerStyle.`\n );\n }\n });\n};\n\nexport default function Header(props: Props) {\n const insets = useSafeAreaInsets();\n const frame = useSafeAreaFrame();\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n\n const {\n layout = frame,\n modal = false,\n title,\n headerTitle: customTitle,\n headerTitleAlign = Platform.select({\n ios: 'center',\n default: 'left',\n }),\n headerLeft,\n headerLeftLabelVisible,\n headerTransparent,\n headerTintColor,\n headerBackground,\n headerRight,\n headerTitleAllowFontScaling: titleAllowFontScaling,\n headerTitleStyle: titleStyle,\n headerLeftContainerStyle: leftContainerStyle,\n headerRightContainerStyle: rightContainerStyle,\n headerTitleContainerStyle: titleContainerStyle,\n headerBackgroundContainerStyle: backgroundContainerStyle,\n headerStyle: customHeaderStyle,\n headerPressColor,\n headerPressOpacity,\n headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,\n } = props;\n\n const defaultHeight = getDefaultHeaderHeight(\n layout,\n modal,\n headerStatusBarHeight\n );\n\n const {\n height = defaultHeight,\n minHeight,\n maxHeight,\n backgroundColor,\n borderBottomColor,\n borderBottomEndRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n borderBottomStartRadius,\n borderBottomWidth,\n borderColor,\n borderEndColor,\n borderEndWidth,\n borderLeftColor,\n borderLeftWidth,\n borderRadius,\n borderRightColor,\n borderRightWidth,\n borderStartColor,\n borderStartWidth,\n borderStyle,\n borderTopColor,\n borderTopEndRadius,\n borderTopLeftRadius,\n borderTopRightRadius,\n borderTopStartRadius,\n borderTopWidth,\n borderWidth,\n // @ts-expect-error: web support for shadow\n boxShadow,\n elevation,\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n opacity,\n transform,\n ...unsafeStyles\n } = StyleSheet.flatten(customHeaderStyle || {}) as ViewStyle;\n\n if (process.env.NODE_ENV !== 'production') {\n warnIfHeaderStylesDefined(unsafeStyles);\n }\n\n const safeStyles: ViewStyle = {\n backgroundColor,\n borderBottomColor,\n borderBottomEndRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n borderBottomStartRadius,\n borderBottomWidth,\n borderColor,\n borderEndColor,\n borderEndWidth,\n borderLeftColor,\n borderLeftWidth,\n borderRadius,\n borderRightColor,\n borderRightWidth,\n borderStartColor,\n borderStartWidth,\n borderStyle,\n borderTopColor,\n borderTopEndRadius,\n borderTopLeftRadius,\n borderTopRightRadius,\n borderTopStartRadius,\n borderTopWidth,\n borderWidth,\n // @ts-expect-error: boxShadow is only for Web\n boxShadow,\n elevation,\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n opacity,\n transform,\n };\n\n // Setting a property to undefined triggers default style\n // So we need to filter them out\n // Users can use `null` instead\n for (const styleProp in safeStyles) {\n // @ts-expect-error: typescript wrongly complains that styleProp cannot be used to index safeStyles\n if (safeStyles[styleProp] === undefined) {\n // @ts-expect-error\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete safeStyles[styleProp];\n }\n }\n\n const leftButton = headerLeft\n ? headerLeft({\n tintColor: headerTintColor,\n pressColor: headerPressColor,\n pressOpacity: headerPressOpacity,\n labelVisible: headerLeftLabelVisible,\n })\n : null;\n\n const rightButton = headerRight\n ? headerRight({\n tintColor: headerTintColor,\n pressColor: headerPressColor,\n pressOpacity: headerPressOpacity,\n })\n : null;\n\n const headerTitle =\n typeof customTitle !== 'function'\n ? (props: React.ComponentProps<typeof HeaderTitle>) => (\n <HeaderTitle {...props} />\n )\n : customTitle;\n\n return (\n <React.Fragment>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n StyleSheet.absoluteFill,\n { zIndex: 0 },\n backgroundContainerStyle,\n ]}\n >\n {headerBackground ? (\n headerBackground({ style: safeStyles })\n ) : headerTransparent ? null : (\n <HeaderBackground style={safeStyles} />\n )}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[{ height, minHeight, maxHeight, opacity, transform }]}\n >\n <View pointerEvents=\"none\" style={{ height: headerStatusBarHeight }} />\n <View pointerEvents=\"box-none\" style={styles.content}>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.left,\n headerTitleAlign === 'center' && styles.expand,\n { marginStart: insets.left },\n leftContainerStyle,\n ]}\n >\n {leftButton}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.title,\n {\n // Avoid the title from going offscreen or overlapping buttons\n maxWidth:\n headerTitleAlign === 'center'\n ? layout.width -\n ((leftButton\n ? headerLeftLabelVisible !== false\n ? 80\n : 32\n : 16) +\n Math.max(insets.left, insets.right)) *\n 2\n : layout.width -\n ((leftButton ? 72 : 16) +\n (rightButton ? 72 : 16) +\n insets.left -\n insets.right),\n },\n titleContainerStyle,\n ]}\n >\n {headerTitle({\n children: title,\n allowFontScaling: titleAllowFontScaling,\n tintColor: headerTintColor,\n style: titleStyle,\n })}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.right,\n styles.expand,\n { marginEnd: insets.right },\n rightContainerStyle,\n ]}\n >\n {rightButton}\n </Animated.View>\n </View>\n </Animated.View>\n </React.Fragment>\n );\n}\n\nconst styles = StyleSheet.create({\n content: {\n flex: 1,\n flexDirection: 'row',\n alignItems: 'stretch',\n },\n title: {\n marginHorizontal: 16,\n justifyContent: 'center',\n },\n left: {\n justifyContent: 'center',\n alignItems: 'flex-start',\n },\n right: {\n justifyContent: 'center',\n alignItems: 'flex-end',\n },\n expand: {\n flexGrow: 1,\n flexBasis: 0,\n },\n});\n"]}
1
+ {"version":3,"sources":["Header.tsx"],"names":["React","Animated","Platform","StyleSheet","View","useSafeAreaFrame","useSafeAreaInsets","getDefaultHeaderHeight","HeaderBackground","HeaderShownContext","HeaderTitle","warnIfHeaderStylesDefined","styles","Object","keys","forEach","styleProp","value","console","warn","undefined","Header","props","insets","frame","isParentHeaderShown","useContext","layout","modal","title","headerTitle","customTitle","headerTitleAlign","select","ios","default","headerLeft","headerLeftLabelVisible","headerTransparent","headerTintColor","headerBackground","headerRight","headerTitleAllowFontScaling","titleAllowFontScaling","headerTitleStyle","titleStyle","headerLeftContainerStyle","leftContainerStyle","headerRightContainerStyle","rightContainerStyle","headerTitleContainerStyle","titleContainerStyle","headerBackgroundContainerStyle","backgroundContainerStyle","headerStyle","customHeaderStyle","headerShadowVisible","headerPressColor","headerPressOpacity","headerStatusBarHeight","top","defaultHeight","height","minHeight","maxHeight","backgroundColor","borderBottomColor","borderBottomEndRadius","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStartRadius","borderBottomWidth","borderColor","borderEndColor","borderEndWidth","borderLeftColor","borderLeftWidth","borderRadius","borderRightColor","borderRightWidth","borderStartColor","borderStartWidth","borderStyle","borderTopColor","borderTopEndRadius","borderTopLeftRadius","borderTopRightRadius","borderTopStartRadius","borderTopWidth","borderWidth","boxShadow","elevation","shadowColor","shadowOffset","shadowOpacity","shadowRadius","opacity","transform","unsafeStyles","flatten","process","env","NODE_ENV","safeStyles","backgroundStyle","leftButton","tintColor","pressColor","pressOpacity","labelVisible","rightButton","absoluteFill","zIndex","style","content","left","expand","marginStart","maxWidth","width","Math","max","right","children","allowFontScaling","marginEnd","create","flex","flexDirection","alignItems","marginHorizontal","justifyContent","flexGrow","flexBasis"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,UAA7B,EAAyCC,IAAzC,QAAgE,cAAhE;AACA,SACEC,gBADF,EAEEC,iBAFF,QAGO,gCAHP;AAMA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,kBAAP,MAA+B,sBAA/B;AACA,OAAOC,WAAP,MAAwB,eAAxB;;AAiBA,MAAMC,yBAAyB,GAAIC,MAAD,IAAiC;AACjEC,EAAAA,MAAM,CAACC,IAAP,CAAYF,MA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,GAAD,CAzBd,CAZF,eA4CE,oBAAC,QAAD,CAAU,IAAV;AACE,IAAA,aAAa,EAAC,UADhB;AAEE,IAAA,KAAK,EAAE,CACLjC,MAAM,CAAC8G,KADF,EAEL9G,MAAM,CAACwG,MAFF,EAGL;AAAES,MAAAA,SAAS,EAAEtG,MAAM,CAACmG;AAApB,KAHK,EAILzE,mBAJK;AAFT,KASG6D,WATH,CA5CF,CALF,CAfF,CADF;AAgFD;AAED,MAAMlG,MAAM,GAAGT,UAAU,CAAC2H,MAAX,CAAkB;AAC/BZ,EAAAA,OAAO,EAAE;AACPa,IAAAA,IAAI,EAAE,CADC;AAEPC,IAAAA,aAAa,EAAE,KAFR;AAGPC,IAAAA,UAAU,EAAE;AAHL,GADsB;AAM/BpG,EAAAA,KAAK,EAAE;AACLqG,IAAAA,gBAAgB,EAAE,EADb;AAELC,IAAAA,cAAc,EAAE;AAFX,GANwB;AAU/BhB,EAAAA,IAAI,EAAE;AACJgB,IAAAA,cAAc,EAAE,QADZ;AAEJF,IAAAA,UAAU,EAAE;AAFR,GAVyB;AAc/BP,EAAAA,KAAK,EAAE;AACLS,IAAAA,cAAc,EAAE,QADX;AAELF,IAAAA,UAAU,EAAE;AAFP,GAdwB;AAkB/Bb,EAAAA,MAAM,EAAE;AACNgB,IAAAA,QAAQ,EAAE,CADJ;AAENC,IAAAA,SAAS,EAAE;AAFL;AAlBuB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport { Animated, Platform, StyleSheet, View, ViewStyle } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\n\nimport type { HeaderOptions, Layout } from '../types';\nimport getDefaultHeaderHeight from './getDefaultHeaderHeight';\nimport HeaderBackground from './HeaderBackground';\nimport HeaderShownContext from './HeaderShownContext';\nimport HeaderTitle from './HeaderTitle';\n\ntype Props = HeaderOptions & {\n /**\n * Whether the header is in a modal\n */\n modal?: boolean;\n /**\n * Layout of the screen.\n */\n layout?: Layout;\n /**\n * Title text for the header.\n */\n title: string;\n};\n\nconst warnIfHeaderStylesDefined = (styles: Record<string, any>) => {\n Object.keys(styles).forEach((styleProp) => {\n const value = styles[styleProp];\n\n if (styleProp === 'position' && value === 'absolute') {\n console.warn(\n \"position: 'absolute' is not supported on headerStyle. If you would like to render content under the header, use the 'headerTransparent' option.\"\n );\n } else if (value !== undefined) {\n console.warn(\n `${styleProp} was given a value of ${value}, this has no effect on headerStyle.`\n );\n }\n });\n};\n\nexport default function Header(props: Props) {\n const insets = useSafeAreaInsets();\n const frame = useSafeAreaFrame();\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n\n const {\n layout = frame,\n modal = false,\n title,\n headerTitle: customTitle,\n headerTitleAlign = Platform.select({\n ios: 'center',\n default: 'left',\n }),\n headerLeft,\n headerLeftLabelVisible,\n headerTransparent,\n headerTintColor,\n headerBackground,\n headerRight,\n headerTitleAllowFontScaling: titleAllowFontScaling,\n headerTitleStyle: titleStyle,\n headerLeftContainerStyle: leftContainerStyle,\n headerRightContainerStyle: rightContainerStyle,\n headerTitleContainerStyle: titleContainerStyle,\n headerBackgroundContainerStyle: backgroundContainerStyle,\n headerStyle: customHeaderStyle,\n headerShadowVisible,\n headerPressColor,\n headerPressOpacity,\n headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,\n } = props;\n\n const defaultHeight = getDefaultHeaderHeight(\n layout,\n modal,\n headerStatusBarHeight\n );\n\n const {\n height = defaultHeight,\n minHeight,\n maxHeight,\n backgroundColor,\n borderBottomColor,\n borderBottomEndRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n borderBottomStartRadius,\n borderBottomWidth,\n borderColor,\n borderEndColor,\n borderEndWidth,\n borderLeftColor,\n borderLeftWidth,\n borderRadius,\n borderRightColor,\n borderRightWidth,\n borderStartColor,\n borderStartWidth,\n borderStyle,\n borderTopColor,\n borderTopEndRadius,\n borderTopLeftRadius,\n borderTopRightRadius,\n borderTopStartRadius,\n borderTopWidth,\n borderWidth,\n // @ts-expect-error: web support for shadow\n boxShadow,\n elevation,\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n opacity,\n transform,\n ...unsafeStyles\n } = StyleSheet.flatten(customHeaderStyle || {}) as ViewStyle;\n\n if (process.env.NODE_ENV !== 'production') {\n warnIfHeaderStylesDefined(unsafeStyles);\n }\n\n const safeStyles: ViewStyle = {\n backgroundColor,\n borderBottomColor,\n borderBottomEndRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n borderBottomStartRadius,\n borderBottomWidth,\n borderColor,\n borderEndColor,\n borderEndWidth,\n borderLeftColor,\n borderLeftWidth,\n borderRadius,\n borderRightColor,\n borderRightWidth,\n borderStartColor,\n borderStartWidth,\n borderStyle,\n borderTopColor,\n borderTopEndRadius,\n borderTopLeftRadius,\n borderTopRightRadius,\n borderTopStartRadius,\n borderTopWidth,\n borderWidth,\n // @ts-expect-error: boxShadow is only for Web\n boxShadow,\n elevation,\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n opacity,\n transform,\n };\n\n // Setting a property to undefined triggers default style\n // So we need to filter them out\n // Users can use `null` instead\n for (const styleProp in safeStyles) {\n // @ts-expect-error: typescript wrongly complains that styleProp cannot be used to index safeStyles\n if (safeStyles[styleProp] === undefined) {\n // @ts-expect-error\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete safeStyles[styleProp];\n }\n }\n\n const backgroundStyle = [\n safeStyles,\n headerShadowVisible === false && {\n elevation: 0,\n shadowOpacity: 0,\n borderBottomWidth: 0,\n },\n ];\n\n const leftButton = headerLeft\n ? headerLeft({\n tintColor: headerTintColor,\n pressColor: headerPressColor,\n pressOpacity: headerPressOpacity,\n labelVisible: headerLeftLabelVisible,\n })\n : null;\n\n const rightButton = headerRight\n ? headerRight({\n tintColor: headerTintColor,\n pressColor: headerPressColor,\n pressOpacity: headerPressOpacity,\n })\n : null;\n\n const headerTitle =\n typeof customTitle !== 'function'\n ? (props: React.ComponentProps<typeof HeaderTitle>) => (\n <HeaderTitle {...props} />\n )\n : customTitle;\n\n return (\n <React.Fragment>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n StyleSheet.absoluteFill,\n { zIndex: 0 },\n backgroundContainerStyle,\n ]}\n >\n {headerBackground ? (\n headerBackground({ style: backgroundStyle })\n ) : headerTransparent ? null : (\n <HeaderBackground style={backgroundStyle} />\n )}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[{ height, minHeight, maxHeight, opacity, transform }]}\n >\n <View pointerEvents=\"none\" style={{ height: headerStatusBarHeight }} />\n <View pointerEvents=\"box-none\" style={styles.content}>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.left,\n headerTitleAlign === 'center' && styles.expand,\n { marginStart: insets.left },\n leftContainerStyle,\n ]}\n >\n {leftButton}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.title,\n {\n // Avoid the title from going offscreen or overlapping buttons\n maxWidth:\n headerTitleAlign === 'center'\n ? layout.width -\n ((leftButton\n ? headerLeftLabelVisible !== false\n ? 80\n : 32\n : 16) +\n Math.max(insets.left, insets.right)) *\n 2\n : layout.width -\n ((leftButton ? 72 : 16) +\n (rightButton ? 72 : 16) +\n insets.left -\n insets.right),\n },\n titleContainerStyle,\n ]}\n >\n {headerTitle({\n children: title,\n allowFontScaling: titleAllowFontScaling,\n tintColor: headerTintColor,\n style: titleStyle,\n })}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n style={[\n styles.right,\n styles.expand,\n { marginEnd: insets.right },\n rightContainerStyle,\n ]}\n >\n {rightButton}\n </Animated.View>\n </View>\n </Animated.View>\n </React.Fragment>\n );\n}\n\nconst styles = StyleSheet.create({\n content: {\n flex: 1,\n flexDirection: 'row',\n alignItems: 'stretch',\n },\n title: {\n marginHorizontal: 16,\n justifyContent: 'center',\n },\n left: {\n justifyContent: 'center',\n alignItems: 'flex-start',\n },\n right: {\n justifyContent: 'center',\n alignItems: 'flex-end',\n },\n expand: {\n flexGrow: 1,\n flexBasis: 0,\n },\n});\n"]}
@@ -93,6 +93,23 @@ export declare type HeaderOptions = {
93
93
  * Style object for the header. You can specify a custom background color here, for example.
94
94
  */
95
95
  headerStyle?: StyleProp<ViewStyle>;
96
+ /**
97
+ * Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.
98
+ *
99
+ * This is a short-hand for the following styles:
100
+ *
101
+ * ```js
102
+ * {
103
+ * elevation: 0,
104
+ * shadowOpacity: 0,
105
+ * borderBottomWidth: 0,
106
+ * }
107
+ * ```
108
+ *
109
+ * If the above styles are specified in `headerStyle` along with `headerShadowVisible: false`,
110
+ * then `headerShadowVisible: false` will take precedence.
111
+ */
112
+ headerShadowVisible?: boolean;
96
113
  /**
97
114
  * Extra padding to add at the top of header to account for translucent status bar.
98
115
  * By default, it uses the top value from the safe area insets of the device.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/elements",
3
3
  "description": "UI Components for React Navigation",
4
- "version": "1.1.2",
4
+ "version": "1.2.0",
5
5
  "keywords": [
6
6
  "react-native",
7
7
  "react-navigation",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@react-native-masked-view/masked-view": "^0.2.4",
41
- "@react-navigation/native": "^6.0.4",
41
+ "@react-navigation/native": "^6.0.5",
42
42
  "@testing-library/react-native": "^7.2.0",
43
43
  "@types/react": "^17.0.9",
44
44
  "@types/react-native": "~0.64.9",
@@ -68,5 +68,5 @@
68
68
  ]
69
69
  ]
70
70
  },
71
- "gitHead": "6a19be7dae997fc23ac9475040a17fb2db4ebd52"
71
+ "gitHead": "66a007b0649e443b528e6875df292563d0ed426c"
72
72
  }
@@ -70,6 +70,7 @@ export default function Header(props: Props) {
70
70
  headerTitleContainerStyle: titleContainerStyle,
71
71
  headerBackgroundContainerStyle: backgroundContainerStyle,
72
72
  headerStyle: customHeaderStyle,
73
+ headerShadowVisible,
73
74
  headerPressColor,
74
75
  headerPressOpacity,
75
76
  headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,
@@ -175,6 +176,15 @@ export default function Header(props: Props) {
175
176
  }
176
177
  }
177
178
 
179
+ const backgroundStyle = [
180
+ safeStyles,
181
+ headerShadowVisible === false && {
182
+ elevation: 0,
183
+ shadowOpacity: 0,
184
+ borderBottomWidth: 0,
185
+ },
186
+ ];
187
+
178
188
  const leftButton = headerLeft
179
189
  ? headerLeft({
180
190
  tintColor: headerTintColor,
@@ -210,9 +220,9 @@ export default function Header(props: Props) {
210
220
  ]}
211
221
  >
212
222
  {headerBackground ? (
213
- headerBackground({ style: safeStyles })
223
+ headerBackground({ style: backgroundStyle })
214
224
  ) : headerTransparent ? null : (
215
- <HeaderBackground style={safeStyles} />
225
+ <HeaderBackground style={backgroundStyle} />
216
226
  )}
217
227
  </Animated.View>
218
228
  <Animated.View
package/src/types.tsx CHANGED
@@ -99,6 +99,23 @@ export type HeaderOptions = {
99
99
  * Style object for the header. You can specify a custom background color here, for example.
100
100
  */
101
101
  headerStyle?: StyleProp<ViewStyle>;
102
+ /**
103
+ * Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.
104
+ *
105
+ * This is a short-hand for the following styles:
106
+ *
107
+ * ```js
108
+ * {
109
+ * elevation: 0,
110
+ * shadowOpacity: 0,
111
+ * borderBottomWidth: 0,
112
+ * }
113
+ * ```
114
+ *
115
+ * If the above styles are specified in `headerStyle` along with `headerShadowVisible: false`,
116
+ * then `headerShadowVisible: false` will take precedence.
117
+ */
118
+ headerShadowVisible?: boolean;
102
119
  /**
103
120
  * Extra padding to add at the top of header to account for translucent status bar.
104
121
  * By default, it uses the top value from the safe area insets of the device.