-
Notifications
You must be signed in to change notification settings - Fork 37
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DON-1089: Fixing a scroll issue in BPKCalendar #2158
Conversation
ee4a5c6
to
55375df
Compare
) | ||
.frame(height: headerHeight) | ||
.modifier(ReadSizeModifier { | ||
headerHeight = max($0.height, headerHeight ?? 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about having the initial headerHeight as 0 instead of optional nil ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered to that below
@@ -32,7 +33,7 @@ struct CalendarContainer<MonthContent: View>: View { | |||
LazyVStack(spacing: BPKSpacing.none) { | |||
ForEach(0...monthsToShow, id: \.self) { monthIndex in | |||
let firstDayOfMonth = firstDayOf(monthIndex: monthIndex) | |||
monthContent(firstDayOfMonth) | |||
monthContent(firstDayOfMonth, $accessoryViewHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need accessoryViewHeight
for monthContent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, the idea is to share between each month view the accessory view height, so it wouldn't need to calculate it each time
this should help with the consistency
the problem could be because the magnifier icon and the text have different heights (15.6 vs 16.0), so in my understanding, if one month has only one magnifiers, then when it happened to display a text, then it would need to recalculate the heights
and to avoid that issue I thought about this sharable height value, so every component already would aware of the target height
however (!), I've checked the latest changes with removing that sharable height and keeping it as a state (as it was before), and I haven't noticed anything wrong with that after some tests
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep it as it was before. It seems other fixes helped us to reduce/escape the flakiness on this height. I couldn't reproduce the issue again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure caching a height is a good solution here, it should be left to SwiftUI to calculate on real time based on constraints, I think there is something else happening here, perhaps something we're doing wrong when reusing month cells or similar? setting a frame for things should almost never be the solution unless specifically due to a design reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frugoman
This change has been reverted ✅ It was just an open comment.
@@ -28,7 +40,8 @@ struct CalendarMonthGrid< | |||
let calendar: Calendar | |||
let validRange: ClosedRange<Date> | |||
|
|||
@State private var dayCellHeight: CGFloat = 0 | |||
@State private var dayCellHeight: CGFloat? | |||
@Binding var accessoryViewHeight: CGFloat? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about having the initial accessoryViewHeight
and dayCellHeight
as 0 instead of optional nil ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't set 0s here
it's important to set nil as an initial value, so swiftui could calculate it correctly and return the correct view when we call .frame()
modifier
I tried to set to 0, it didn't work
that's an example
ScreenRecording_02-06-2025.13-26-57_1.MP4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense as we want to get the size behaviour from the view for the first time.
https://developer.apple.com/documentation/swiftui/view/frame(width:height:alignment:)
Thank you for checking.
920dd0c
to
909b47b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work and investigation 🚀
Fixed in #2167 |
DON-1089
When scrolling back upwards sometimes from a future month to a previous month the header jumps down and causes the overlapping issue on the right
![image](https://private-user-images.githubusercontent.com/7831380/410864161-f672523d-cd6e-4c28-b7b3-c728e7f7c2ea.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MjUzMjcsIm5iZiI6MTczOTQyNTAyNywicGF0aCI6Ii83ODMxMzgwLzQxMDg2NDE2MS1mNjcyNTIzZC1jZDZlLTRjMjgtYjdiMy1jNzI4ZTdmN2MyZWEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMDUzNzA3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NTI2Y2FjMjU4Y2M2ZjhlMzgwY2VhYzI1NjdlNzNlOGQzODhhMTMyNGM2MjkzMTc2OTdmYTU1NzRiMGY5M2M5YSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.C8rbw4hVdLi3TV6GeMFP19lPGgSsoTl9VTgZERSucDU)
The solution was to calculate heights and keep them cached. Also make all cells in a LazyVGrid contained in one array, so just one ForEach would be used (apparently, there is an issue with using multiple ForEach)
More info:
https://skyscanner.atlassian.net/wiki/x/Ty9rTQ
Remember to include the following changes:
README.md
Backpack.h
header fileIf you are curious about how we review, please read through the code review guidelines