Use hitTest and pointInside for user interaction capability #258
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.
Details
This PR lays the groundwork for HorizonCalendar to support tappable day range indicators. Currently, day ranges are always drawn behind days (but above day backgrounds). Day ranges, day views, and all other views displayed in the calendar are wrapped in an internal
ItemView
type. Since day views are on top of day ranges, it was impossible to tap on a day range view "through" a day view.This PR allows people with this advanced use case to customize the pointInside function on their day view and day range view, allowing the day view (and its
superview
, the internalItemView
, to pass through touches to the day range view.Here's what it looks like in practice:
Screen.Recording.2023-08-22.at.3.23.13.PM.mov
Note that the days are only tappable in the top portion containing the label (due to an overridden
pointInside
implementation), and the day ranges are tappable even through they're behind the day views (thanks to the day view not capturing all touches, and the day range view implementing its own overriddenpointInside
function that).It's a bit low level, but it provides some extra flexibility for some advanced use cases. In the future, we might add an accessory view slot so that these tappable day ranges that appear below a row of days are possible without using hit-testing logic.
Related Issue
Motivation and Context
Airbnb (and one other app that I'm aware of) needs this
How Has This Been Tested
Example app
Types of changes
Checklist