Make all gestural interactions conform to Togglable.
ClosedPublic

Authored by featherless on Fri, Apr 14, 3:10 PM.

Details

Summary

This makes it possible to disable gestural interactions. We simply connect the enabled property to the gesture recognizer's isEnabled property.

Closes https://github.com/material-motion/material-motion-swift/issues/100

May help reduce some need for https://github.com/material-motion/material-motion-swift/issues/98

Diff Detail

Repository
rREACTIVEMOTIONSWIFT reactive-motion-swift
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
featherless created this revision.Fri, Apr 14, 3:10 PM
Restricted Application added a reviewer: O2: Material Motion. · View Herald TranscriptFri, Apr 14, 3:10 PM
Restricted Application added a project: Material Motion. · View Herald Transcript
Restricted Application added a reviewer: O4: Material Apple platform reviewers. · View Herald Transcript
Restricted Application added a reviewer: Material Motion. · View Herald Transcript
featherless edited the summary of this revision. (Show Details)Fri, Apr 14, 3:11 PM
featherless edited the summary of this revision. (Show Details)
  • No need to store gesture recognizers.
markwei accepted this revision.Fri, Apr 14, 4:12 PM
markwei added a subscriber: markwei.
markwei added inline comments.
src/interactions/Draggable.swift
55

this block is interesting. The way I've written this is to explicitly subscribe to the property:

enabled.subscribe { value in
  gestureRecognizer.isEnabled = value
}

Is there any reason to use runtime.connect()? Do you intend for runtime.connect() to be sugar for *all* reactive property subscriptions, or just this one?

This revision is now accepted and ready to land.Fri, Apr 14, 4:12 PM
featherless added inline comments.Fri, Apr 14, 4:19 PM
src/interactions/Draggable.swift
55

I mainly do this so that the interaction doesn't have to hold on to an array of subscriptions. Generally-speaking, I also feel like keeping the runtime aware of all connections is beneficial from a consistency and eventual tooling point of view.

markwei added inline comments.Fri, Apr 14, 4:30 PM
src/interactions/Draggable.swift
55

Interesting that you say that. Can you explain why you use a subscription here? https://github.com/material-motion/material-motion-swift/blob/develop/src/systems/coreAnimationSpringToStream.swift#L80

featherless added inline comments.Fri, Apr 14, 4:37 PM
src/interactions/Draggable.swift
55

We don't have access to the runtime there unfortunately.

There are essentially two types of subscription: pure subscription and runtime connection.

Pure subscriptions are "hidden" from the runtime, whereas runtime connections are known and managed by the runtime. I've been attempting to err towards the latter as much as possible, but there are cases where this can't presently be avoided.

markwei added inline comments.Fri, Apr 14, 4:44 PM
src/interactions/Draggable.swift
55

Very cool. The ambiguousness makes me worried, but I like the concept of having the runtime be aware of all connections.

This revision was automatically updated to reflect the committed changes.