Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Use EmptyView when geometry reader is still sized at 0 #22

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

joncottrell
Copy link
Contributor

@joncottrell joncottrell commented Jul 26, 2022

I can't think of any instance where the geometry reader has a size of 0 where we would want to display the bottom sheet.
I have tested this in my own app and it appears to work quite well.
This fixes "flickering" when using bottom sheet anywhere that is not a top-level view.

@joncottrell
Copy link
Contributor Author

@weitieda what do you think?

@weitieda
Copy link
Owner

Hey @joncottrell thanks for bringing it up and working on the fix.

I think I'm fine with this change, but I don't quite understand the issue here. Mind share more detail/demo of the issue? technically when zero and false, the sheet should be hidden?

@joncottrell
Copy link
Contributor Author

I have observed a flicker sometimes and it occurs because of the following line of code.

               .offset(y: self.isPresented ? (geometry.size.height/2 - sheetHeight(in: geometry)/2 + geometry.safeAreaInsets.bottom + self.draggedOffset) : (geometry.size.height/2 + sheetHeight(in: geometry)/2 + geometry.safeAreaInsets.bottom))

This can occur even if self.isPresented is false and size is zero. A successful render will cause the sheet to be offset only by (geometry.size.height/2 + sheetHeight(in: geometry)/2 + geometry.safeAreaInsets.bottom))
which in that scenario is 0 + 0 + safeAreaInsets.bottom
So it is offset very little if at all and will be visible until the geometry reader fixes itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants