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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hitTest and pointInside for user interaction capability #258

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

bryankeller
Copy link
Contributor

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 internal ItemView, 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
  • Each red square is a day view (that would previously capture touches
  • The blue outlined box is the border of the entire day range view (which spans 2 rows of days, and is behind the translucent red day views)

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 overridden pointInside 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

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@bryankeller bryankeller merged commit d45ab96 into master Aug 23, 2023
2 checks passed
@bryankeller bryankeller added the enhancement New feature or request label Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants