@@ -40,16 +40,20 @@ type State = {
4040 leftLabelLayout ?: Layout ;
4141} ;
4242
43- const warnIfHeaderStyleDefined = ( value : any , styleProp : string ) => {
44- if ( styleProp === 'position' && value === 'absolute' ) {
45- console . warn (
46- "position: 'absolute' is not supported on headerStyle. If you would like to render content under the header, use the headerTransparent navigationOption."
47- ) ;
48- } else if ( value !== undefined ) {
49- console . warn (
50- `${ styleProp } was given a value of ${ value } , this has no effect on headerStyle.`
51- ) ;
52- }
43+ const warnIfHeaderStylesDefined = ( styles : { [ key : string ] : any } ) => {
44+ Object . keys ( styles ) . forEach ( styleProp => {
45+ const value = styles [ styleProp ] ;
46+
47+ if ( styleProp === 'position' && value === 'absolute' ) {
48+ console . warn (
49+ "position: 'absolute' is not supported on headerStyle. If you would like to render content under the header, use the 'headerTransparent' navigationOption."
50+ ) ;
51+ } else if ( value !== undefined ) {
52+ console . warn (
53+ `${ styleProp } was given a value of ${ value } , this has no effect on headerStyle.`
54+ ) ;
55+ }
56+ } ) ;
5357} ;
5458
5559export const getDefaultHeaderHeight = ( layout : Layout ) => {
@@ -179,50 +183,91 @@ export default class HeaderSegment extends React.Component<Props, State> {
179183
180184 const {
181185 height = getDefaultHeaderHeight ( layout ) ,
182- alignItems,
183- justifyContent,
184- flex,
185- flexDirection,
186- flexGrow,
187- flexShrink,
188- flexBasis,
189- flexWrap,
190- position,
191- padding,
192- paddingHorizontal,
193- paddingRight,
194- paddingLeft,
195- paddingVertical,
196- paddingTop,
197- paddingBottom,
198- top,
199- right : _right ,
200- bottom : _bottom ,
201- left : _left ,
202- ...safeHeaderStyle
186+ minHeight,
187+ maxHeight,
188+ backgroundColor,
189+ borderBottomColor,
190+ borderBottomEndRadius,
191+ borderBottomLeftRadius,
192+ borderBottomRightRadius,
193+ borderBottomStartRadius,
194+ borderBottomWidth,
195+ borderColor,
196+ borderEndColor,
197+ borderEndWidth,
198+ borderLeftColor,
199+ borderLeftWidth,
200+ borderRadius,
201+ borderRightColor,
202+ borderRightWidth,
203+ borderStartColor,
204+ borderStartWidth,
205+ borderStyle,
206+ borderTopColor,
207+ borderTopEndRadius,
208+ borderTopLeftRadius,
209+ borderTopRightRadius,
210+ borderTopStartRadius,
211+ borderTopWidth,
212+ borderWidth,
213+ // @ts -ignore: web support for shadow
214+ boxShadow,
215+ elevation,
216+ shadowColor,
217+ shadowOffset,
218+ shadowOpacity,
219+ shadowRadius,
220+ ...unsafeStyles
203221 } = StyleSheet . flatten ( customHeaderStyle || { } ) as ViewStyle ;
204222
205223 if ( process . env . NODE_ENV !== 'production' ) {
206- warnIfHeaderStyleDefined ( alignItems , 'alignItems' ) ;
207- warnIfHeaderStyleDefined ( justifyContent , 'justifyContent' ) ;
208- warnIfHeaderStyleDefined ( flex , 'flex' ) ;
209- warnIfHeaderStyleDefined ( flexDirection , 'flexDirection' ) ;
210- warnIfHeaderStyleDefined ( flexGrow , 'flexGrow' ) ;
211- warnIfHeaderStyleDefined ( flexShrink , 'flexShrink' ) ;
212- warnIfHeaderStyleDefined ( flexBasis , 'flexBasis' ) ;
213- warnIfHeaderStyleDefined ( flexWrap , 'flexWrap' ) ;
214- warnIfHeaderStyleDefined ( padding , 'padding' ) ;
215- warnIfHeaderStyleDefined ( position , 'position' ) ;
216- warnIfHeaderStyleDefined ( paddingHorizontal , 'paddingHorizontal' ) ;
217- warnIfHeaderStyleDefined ( paddingRight , 'paddingRight' ) ;
218- warnIfHeaderStyleDefined ( paddingLeft , 'paddingLeft' ) ;
219- warnIfHeaderStyleDefined ( paddingVertical , 'paddingVertical' ) ;
220- warnIfHeaderStyleDefined ( paddingTop , 'paddingTop' ) ;
221- warnIfHeaderStyleDefined ( paddingBottom , 'paddingBottom' ) ;
222- warnIfHeaderStyleDefined ( top , 'top' ) ;
223- warnIfHeaderStyleDefined ( _right , 'right' ) ;
224- warnIfHeaderStyleDefined ( _bottom , 'bottom' ) ;
225- warnIfHeaderStyleDefined ( _left , 'left' ) ;
224+ warnIfHeaderStylesDefined ( unsafeStyles ) ;
225+ }
226+
227+ const safeStyles = {
228+ backgroundColor,
229+ borderBottomColor,
230+ borderBottomEndRadius,
231+ borderBottomLeftRadius,
232+ borderBottomRightRadius,
233+ borderBottomStartRadius,
234+ borderBottomWidth,
235+ borderColor,
236+ borderEndColor,
237+ borderEndWidth,
238+ borderLeftColor,
239+ borderLeftWidth,
240+ borderRadius,
241+ borderRightColor,
242+ borderRightWidth,
243+ borderStartColor,
244+ borderStartWidth,
245+ borderStyle,
246+ borderTopColor,
247+ borderTopEndRadius,
248+ borderTopLeftRadius,
249+ borderTopRightRadius,
250+ borderTopStartRadius,
251+ borderTopWidth,
252+ borderWidth,
253+ // @ts -ignore
254+ boxShadow,
255+ elevation,
256+ shadowColor,
257+ shadowOffset,
258+ shadowOpacity,
259+ shadowRadius,
260+ } ;
261+
262+ // Setting a property to undefined triggers default style
263+ // So we need to filter them out
264+ // Users can use `null` instead
265+ for ( const styleProp in safeStyles ) {
266+ // @ts -ignore
267+ if ( safeStyles [ styleProp ] === undefined ) {
268+ // @ts -ignore
269+ delete safeStyles [ styleProp ] ;
270+ }
226271 }
227272
228273 return (
@@ -234,10 +279,13 @@ export default class HeaderSegment extends React.Component<Props, State> {
234279 { headerBackground ? (
235280 headerBackground ( )
236281 ) : headerTransparent ? null : (
237- < HeaderBackground style = { safeHeaderStyle } />
282+ < HeaderBackground style = { safeStyles } />
238283 ) }
239284 </ Animated . View >
240- < Animated . View pointerEvents = "box-none" style = { [ { height } ] } >
285+ < Animated . View
286+ pointerEvents = "box-none"
287+ style = { [ { height, minHeight, maxHeight } ] }
288+ >
241289 < View
242290 pointerEvents = "none"
243291 style = { { height : headerStatusBarHeight } }
0 commit comments