Skip to content

Commit

Permalink
fix(collapsible-style): use minHeaderHeight when calculating the iOS …
Browse files Browse the repository at this point in the history
…min height
  • Loading branch information
tiagocorreiaalmeida committed Oct 25, 2022
1 parent 9671587 commit bd373ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ export const Container = React.memo(
accDiffClamp,
indexDecimal,
containerHeight,
minHeaderHeight,
scrollYCurrent,
scrollY,
setRef,
Expand Down
15 changes: 12 additions & 3 deletions src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,29 @@ export function useCollapsibleStyle(): CollapsibleStyle {
containerHeight,
width,
allowHeaderOverscroll,
minHeaderHeight,
} = useTabsContext()
const [containerHeightVal, tabBarHeightVal, headerHeightVal] = [
useConvertAnimatedToValue(containerHeight),
useConvertAnimatedToValue(tabBarHeight),
useConvertAnimatedToValue(headerHeight),
]

const containerHeightWithMinHeader = Math.max(
0,
(containerHeightVal ?? 0) - minHeaderHeight
)

console.log('containerHeightWithMinHeader', containerHeightWithMinHeader)

return useMemo(
() => ({
style: { width },
contentContainerStyle: {
minHeight:
IS_IOS && !allowHeaderOverscroll
? (containerHeightVal || 0) - (tabBarHeightVal || 0)
: (containerHeightVal || 0) + (headerHeightVal || 0),
? containerHeightWithMinHeader - (tabBarHeightVal || 0)
: containerHeightWithMinHeader + (headerHeightVal || 0),
paddingTop:
IS_IOS && !allowHeaderOverscroll
? 0
Expand All @@ -163,10 +172,10 @@ export function useCollapsibleStyle(): CollapsibleStyle {
}),
[
allowHeaderOverscroll,
containerHeightVal,
headerHeightVal,
tabBarHeightVal,
width,
containerHeightWithMinHeader,
]
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ export type ContextType<T extends TabName = TabName> = {
* @default false
*/
allowHeaderOverscroll?: boolean

minHeaderHeight: number
}

export type ScrollViewProps = ComponentProps<typeof Animated.ScrollView>
Expand Down

0 comments on commit bd373ac

Please sign in to comment.