Repository navigation
Revise Action API - #42940
Merged
Merged
Revise Action API#42940
Conversation
This comment has been minimized.
This comment has been minimized.
gspencergoog
force-pushed
the
nodeless_actions
branch
5 times, most recently
from
October 31, 2019 07:12
076e57a to
838afea
Compare
gspencergoog
marked this pull request as ready for review
November 1, 2019 01:05
gspencergoog
force-pushed
the
nodeless_actions
branch
2 times, most recently
from
November 1, 2019 02:45
704c477 to
af339df
Compare
gspencergoog
force-pushed
the
nodeless_actions
branch
6 times, most recently
from
November 22, 2019 22:39
2b4cdfd to
3c8d8b2
Compare
gspencergoog
force-pushed
the
nodeless_actions
branch
4 times, most recently
from
December 19, 2019 23:27
5c4a210 to
ba67cf0
Compare
gspencergoog
force-pushed
the
nodeless_actions
branch
3 times, most recently
from
January 31, 2020 00:20
04a86dd to
2200d39
Compare
gspencergoog
force-pushed
the
nodeless_actions
branch
5 times, most recently
from
March 3, 2020 14:27
199b309 to
8e8bb87
Compare
gspencergoog
force-pushed
the
nodeless_actions
branch
from
March 4, 2020 08:05
8e8bb87 to
c9d6b7e
Compare
gspencergoog
force-pushed
the
nodeless_actions
branch
3 times, most recently
from
March 12, 2020 21:41
1b79aba to
6c11dd2
Compare
gspencergoog
force-pushed
the
nodeless_actions
branch
2 times, most recently
from
March 25, 2020 20:05
737609e to
517c658
Compare
goderbauer
reviewed
Mar 26, 2020
goderbauer
left a comment
Member
There was a problem hiding this comment.
The new API is pretty nice!
gspencergoog
force-pushed
the
nodeless_actions
branch
2 times, most recently
from
March 31, 2020 23:09
ec432aa to
b9dd6a5
Compare
Contributor
Author
|
@goderbauer, Thanks for your review! I think this is ready for another look. |
goderbauer
approved these changes
Apr 2, 2020
gspencergoog
force-pushed
the
nodeless_actions
branch
from
April 3, 2020 03:16
b9dd6a5 to
80c5bee
Compare
goderbauer
approved these changes
Apr 3, 2020
gspencergoog
force-pushed
the
nodeless_actions
branch
from
April 3, 2020 20:19
0d7c948 to
2100461
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
We've had some feedback that people would like to be able to invoke actions when they are not in the context of keyboard input (from a mouse click, etc.).
The original design was oriented towards invoking actions from widgets, and
having those actions act in the context of the widget. Teams have been using
actions, and found several limitations in that design that needed to be
addressed:
Examples of this include processing a script of commands, and some undo/redo
systems.
Intentand then toActionwasn'talways clear, since the data structures were mapping
LogicalKeySet=>Intentand thenLocalKey=>ActionFactory. The new mapping is stillLogicalKeySet=>Intentbut then it mapsType(Intenttype) =>Action, which more direct and readable, since the type of the intent iswritten in the mapping.
it was not always possible for the Intent to have access to the state
necessary to decide if the intent/action should be enabled or not.
Here are the changes made to address these problems:
FocusNodeargument toAction.invokeandActions.invokewas removed.Map<LocalKey, ActionFactory>that was given to theActionswidget isnow a
Map<Type, Action<Intent>>(the type is the type of theIntent).isEnabledmethod was moved from theIntentto theActionclass.Action.Actionclass is now a generic (Action<T extends Intent>) for bettertype safety.
LocalKeyis no longer an argument to theIntentconstructor.Actionclass may now be listened to for changes in state.OnInvokeCallbackused byCallbackActionno longer takes aFocusNodeargument.
LocalKeyargument toCallbackActionhas been removed.ActionDispatcher.invokeActionsignature has changed to not accept anoptional
FocusNode, but instead take an optionalBuildContext.LocalKeystatic constants (namedkey) inActionsubclasses have beenremoved.
Action.invokeandActionDispatcher.invokeActionmethods now returnthe result of invoking the action.
There is a design doc for the changes in the PR: https://flutter.dev/go/actions-and-shortcuts-design-revision
Tests
Related Issues
Breaking Change
Actions, and probablyShortcutstoo.Action.invokehas changed significantly, as has theActionconstructor.RequestFocusActionnow requires the use of aRequestFocusIntent.onInvokeproperty of theCallbackActionhas also changed.invokeActionsignature on theActionDispatcherhas changed.Actionswidget is now aMap<Type, Action<Intent>>.