Conversation
DickoEvaldo
reviewed
Apr 14, 2026
Comment on lines
+119
to
+121
| @State private var scrollID: Int? = middleIndex | ||
| @State private var baseDate = Date() | ||
| @State private var dateSelect = Date() |
Contributor
There was a problem hiding this comment.
Lets move all the states and logic to the view model instead, makes the view logic more testable and adhere to the architecture too
DickoEvaldo
reviewed
Apr 14, 2026
Comment on lines
+136
to
+138
| extension Double { | ||
| static let day: Double = 86_400 | ||
| } |
Contributor
There was a problem hiding this comment.
this might be a reusable Double extension put it in a common file instead of this view file
Comment on lines
+140
to
+144
| extension Date { | ||
| static func +(lhs: Date, rhs: Double) -> Date { | ||
| lhs.addingTimeInterval(rhs) | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
if the extension is only being used in this file use fileprivate extension Date but if might be used in othe component define the extension in the model file
Comment on lines
+65
to
+76
| .onChange(of: scrollID) { oldValue, newValue in | ||
| if let newValue, let oldValue, abs(newValue - oldValue) == 1 { | ||
| dateSelect = baseDate + (Double(newValue - Self.middleIndex) * .day) | ||
| } | ||
| } | ||
| .onChange(of: dateSelect) { _, newValue in | ||
| let currentScroll = scrollID ?? Self.middleIndex | ||
| let expectedDate = baseDate + (Double(currentScroll - Self.middleIndex) * .day) | ||
|
|
||
| if abs(newValue.timeIntervalSince(expectedDate)) > 1 { | ||
| baseDate = newValue | ||
| scrollID = Self.middleIndex |
Contributor
There was a problem hiding this comment.
logic in the view model so its testable
Comment on lines
+72
to
+78
| if Calendar.current.isDateInToday(dateSelect) { | ||
| let currentHour = max(dateComponent.hour ?? 0, 9) | ||
| withAnimation(.easeInOut(duration: 0.5)) { | ||
| proxy.scrollTo(currentHour, anchor: .top) | ||
| } | ||
| } else { | ||
| proxy.scrollTo(9, anchor: .top) |
Contributor
There was a problem hiding this comment.
move this to a onAppear function in the viewModel
DickoEvaldo
reviewed
Apr 14, 2026
Comment on lines
+73
to
+78
| let currentHour = max(dateComponent.hour ?? 0, 9) | ||
| withAnimation(.easeInOut(duration: 0.5)) { | ||
| proxy.scrollTo(currentHour, anchor: .top) | ||
| } | ||
| } else { | ||
| proxy.scrollTo(9, anchor: .top) |
Contributor
|
very nice feature king |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adding paging when looking at bookings in the calendar.
Why
Suggestion from lucas and also better ux!
How
Hard coded 1000 pages and just calculated changes depending on the index to the date.
Key checks:
Automated tests:
Manual tests:
Screenshot / Recording
output.mp4