Open shial4 opened 1 year ago
This is incredible! I am unfortunately about to hop on a bus to start a job at Apple so I canβt give this a thorough review π₯²
But hopefully @carson-katri can take a look at some point.
updated PR & its description
π
coordinate space broken for custom spaces while using fiber reconciler. ticket here: https://github.com/TokamakUI/Tokamak/issues/547
Add content shape modifier. Verify gesture start against the shape fill area. https://github.com/TokamakUI/Tokamak/issues/548
updated view change modifier, not to relay on _onChange or _onUnmount events due to this comment https://github.com/TokamakUI/Tokamak/pull/542#issuecomment-1709373845
@carson-katri ready for the review too :)
Tests for onChange & onReceive will pass after Fiber fixes attempt 2 will be merge
is this in a good state to use? (sorry to bother)
@aehlke
is this in a good state to use? (sorry to bother)
I'm building my apps of top of this branch. However would love to have fibre working with gesture, but for that we will need the fibre PR merged in + some other additions and improvements
Pull Request Description: Add Gestures Functionality
Description
This pull request aims to enhance the Tokamak framework by adding support for handling gestures in SwiftUI-like components. The goal is to enable developers to implement various interactive features in their applications using gestures, such as taps, long presses and drags.
Changes Made
The following changes have been made to the Tokamak framework to support gesture functionality:
Added support for gestures such as
TapGesture
,LongPressGesture
andDragGesture
. These gestures are now functional and update the respective state when triggered.Added helper
View
modifiers forTapGesture
andLongPressGesture
aiming to match SwiftUI counterpart.Implemented TokamakDOM renderer gestures par
Add basic implementation for
standard
,simultaneous
andhighPriority
gesture handling, without the use of GestureMask.Add coordinate space
Remaining Work
The following features are yet to be implemented:
Add AnyGesture for type erasure: A generic
AnyGesture
type is intended to be added to perform type erasure for gestures, allowing for a more flexible and unified approach when handling gestures. WIP, to be fixed.Add handling of GestureMask.
Example Use Case
To demonstrate the implemented gesture functionality, a sample use case has been provided. It includes examples of tap gestures, double tap gestures, long press gestures, and drag gestures. Certain parts of the code related to simultaneous gesture handling have been commented out, awaiting the implementation of gesture priority and simultaneous gesture support.
Please review and test the changes to ensure they work as expected and are aligned with the Tokamak framework's design and guidelines. Once reviewed and approved, this pull request can be merged into the main repository to enable gesture support in Tokamak.
https://github.com/TokamakUI/Tokamak/assets/8544773/e9e46205-68b9-4a81-b55a-f40fab774fa6
https://github.com/TokamakUI/Tokamak/assets/8544773/b28950ce-da0a-47d4-8c02-67cf8f8c964e
TestCode
The below code has been tested in SwiftUI and Tokamak to ensure the behavior is the same.
Basic implementation of
standard
,simultaneous
andhighPriority
gesture handling has been tested and compared against SwiftUI playgrounds with the below codeoutput
The main difference in
simultaneousGesture
is that Tokamak has different order wheresimultaneousGesture 2
is aftersimultaneousGesture
https://github.com/TokamakUI/Tokamak/assets/8544773/b1d17188-24c3-4732-84ed-4162afc520f3
With follow-up test
https://github.com/TokamakUI/Tokamak/assets/8544773/6ce32da4-36a5-47e6-bb2c-34731941e752
Added Fibre support for gestures
https://github.com/TokamakUI/Tokamak/assets/8544773/330f023d-553b-494c-9332-8e1e0162b77a
Tested with the below code