composed-swift / ComposedUI

A Swift framework for building User Interfaces with the Composed framework.
Other
12 stars 3 forks source link

Enable/disable context menus per element #10

Closed shaps80 closed 4 years ago

shaps80 commented 4 years ago

Without this change, currently if you've conformed to the protocol, long pressing will still make an attempt to show a context menu, even if you return an empty configuration. This results in a poorer UX.

The included API addition allows you to selectively disable the long press gesture (essentially) on a per element basis.

JosephDuffy commented 4 years ago

Had to lookup the API for this since I've not used it. It states:

Returning an empty configuration object causes the interaction to begin, and then end with a cancellation effect

You can use the cancellation effect from returning an empty configuration to indicate to users that it’s possible for a menu to be presented from this item, but that there are no actions to present at this particular time.

Sounds like that could be useful in some cases. Would an enum that allows for disallowed and cancelled to be handled be useful?

shaps80 commented 4 years ago

Had to lookup the API for this since I've not used it. It states:

Returning an empty configuration object causes the interaction to begin, and then end with a cancellation effect You can use the cancellation effect from returning an empty configuration to indicate to users that it’s possible for a menu to be presented from this item, but that there are no actions to present at this particular time.

Sounds like that could be useful in some cases. Would an enum that allows for disallowed and cancelled to be handled be useful?

You can still reproduce that by returning true here and then just returning a nil configuration, which is essentially what was happening before.

Do you think the API needs a more explicit action for this?

JosephDuffy commented 4 years ago

Had to lookup the API for this since I've not used it. It states:

Returning an empty configuration object causes the interaction to begin, and then end with a cancellation effect You can use the cancellation effect from returning an empty configuration to indicate to users that it’s possible for a menu to be presented from this item, but that there are no actions to present at this particular time.

Sounds like that could be useful in some cases. Would an enum that allows for disallowed and cancelled to be handled be useful?

You can still reproduce that by returning true here and then just returning a nil configuration, which is essentially what was happening before.

Do you think the API needs a more explicit action for this?

Ah right I see how that would work.

The API is probably ok then if the docs explain how that works.

shaps80 commented 4 years ago

Ok, I've added UITableView support and updated docs. Thanks!

If you're happy with this @JosephDuffy can you merge and make a release?

shaps80 commented 4 years ago

Ping @JosephDuffy ?