-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add gestures initial functionality #538
base: main
Are you sure you want to change the base?
Conversation
Add tap, lonPress and Drag gestures.
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. |
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.
This is amazing, you for working on this! Left a few notes.
Sources/TokamakCore/Gestures/Recognizers/LongPressGesture.swift
Outdated
Show resolved
Hide resolved
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.
Hey, I've addressed PR feedback. Have some questions where I tagged you. Could use some input
Sources/TokamakCore/Gestures/Performing/GestureStateGesture.swift
Outdated
Show resolved
Hide resolved
updated PR & its description 🚀 |
1. **Gesture Coordinate Space**: A new gesture coordinate space has been added to provide better support for gesture-based interactions. 2. **Geometry Reader Update**: The geometry reader has been updated to offer improved functionality and performance. 3. **Geometry Proxy Preparation**: A geometry proxy has been prepared to streamline and optimize geometric operations. 4. **Coordinate Space Enhancement**: The coordinate space has been enhanced to support new use cases and scenarios.
…dinate-space # Conflicts: # Sources/TokamakCore/Gestures/GestureEnvironmentKey.swift # Sources/TokamakCore/Modifiers/OnChangeModifier.swift
fixed |
coordinate space broken for custom spaces while using fiber reconciler. |
commit 6ad4a06a6d11a461d993cda8697a6fa8d9ebbdc6 Author: Szymon Lorenz <[email protected]> Date: Sat Aug 26 13:32:06 2023 +1000 Add demos
Add content shape modifier. Verify gesture start against the shape fill area. |
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.
It looks like formatting was changed in many of the files. Could you run swift-lint or check if you have the pre-commit hook installed?
https://github.com/TokamakUI/Tokamak/blob/main/CONTRIBUTING.md#coding-style
import TokamakCore | ||
|
||
|
||
enum GestureEventsObserver { |
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.
Nice refactor 👍
updated view change modifier, not to relay on _onChange or _onUnmount events @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) |
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.
_WASM_SwiftUI_gestures.mov
Screen.Recording.2023-08-14.at.20.28.32.mov
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
Screen.Recording.2023-08-13.at.20.46.33.mov
With follow-up test
Screen.Recording.2023-08-13.at.20.45.57.mov
Added Fibre support for gestures
Screen_Recording_2023-08-25_at_19.26.10.mov
Tested with the below code