-
Notifications
You must be signed in to change notification settings - Fork 249
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
[SuperTextField][mobile] Migrate popover toolbars to OverlayPortal (Resolves #1602) #1604
[SuperTextField][mobile] Migrate popover toolbars to OverlayPortal (Resolves #1602) #1604
Conversation
@matthew-carroll Tests are failing due to a compilation error: lib/src/default_editor/document_hardware_keyboard/document_physical_keyboard.dart:125:23: Error: The argument type 'RawKeyEvent' can't be assigned to the parameter type 'KeyEvent'.
- 'RawKeyEvent' is from 'package:flutter/src/services/raw_keyboard.dart' ('/opt/hostedtoolcache/flutter/master-any-x64/packages/flutter/lib/src/services/raw_keyboard.dart').
- 'KeyEvent' is from 'package:flutter/src/services/hardware_keyboard.dart' ('/opt/hostedtoolcache/flutter/master-any-x64/packages/flutter/lib/src/services/hardware_keyboard.dart').
if (key.accepts(keyEvent, RawKeyboard.instance)) { It seems to be related to this PR: #1593 |
final _popoverController = OverlayPortalController(); | ||
|
||
/// Notifies the popover toolbar to rebuild itself. | ||
final _popoverRebuildSignal = SignalNotifier(); |
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.
Is this rebuild signal here because we're scheduling extra frames to position the toolbar? If so, can we use a Leader
and Follower
instead?
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.
Yes, this is used to position the toolbar. Currently, we are doing _controlsOverlayEntry?.markNeedsBuild();
to do this.
We can use Leader
and Follower
, but it will require big change. I'm not sure we should do that on this PR.
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.
Ok. We can do it in a follow up. Can you file a ticket for that?
child: TextScrollView( | ||
key: _scrollKey, | ||
textScrollController: _textScrollController, | ||
return OverlayPortal( |
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.
Now that we're bringing an overlay portal into this, let's breakdown this build method so it's clear which pieces are what.
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.
Updated.
|
||
void main() { | ||
group('SuperTextField', () { | ||
testWidgetsOnIos('applies app theme to the popover toolbar (on iOS)', (tester) async { |
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.
You don't need to specify "(on iOS)" when using testWidgetsOnIos()
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.
testWidgetsOnIos
itself doesn't add the "(on iOS)" suffix.
Maybe it's time to change that?
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.
Really? I thought I saw "(on iOS)" appended to all sorts of tests that we run? If for some reason that test runner is the only one that isn't adding its name, then yes, we should add that, but I was almost certain that we already have iOS tests that add the suffix.
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.
@matthew-carroll It's the testWidgetsOnMobile
and testWidgetsOnAllPlatforms
that appends the suffixes. Can we make that change in a separate PR?
This PR mentions that In Should we repeat the approach from |
@matthew-carroll If we want to be consistent, we probably want to use the same approach from |
@angelosilvestre can you file an issue about compositional overlay controls to match |
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.
LGTM - Pending the "(on iOS)" suffix for the test runner
@angelosilvestre can you take the last step for this PR? |
@matthew-carroll Opened Flutter-Bounty-Hunters/testing#1 to add the suffixes directly on the |
@angelosilvestre I merged your PR in the testing repo |
897a717
to
e185c0d
Compare
@matthew-carroll Already removed the suffixes from here. I think #1593 needs to get merged to fix the tests. |
@angelosilvestre did you check all the tests to make sure there aren't any new failures aside from those existing problems? |
@matthew-carroll All failing tests are failing due to the compilation error related to the RawKeyEvent -> KeyEvent migration. |
[SuperTextField][mobile] Migrate popover toolbar to OverlayPortal (Resolves #1602)
Currently, the mobile toolbars are displayed in the app
Overlay
. Because of that, it doesn't have access toInheritedWidgets
placed belowMaterialApp
.As a result, if an app adds a
Theme
widget aboveSuperTextField
, theSuperTextField
uses thisTheme
, but the popover toolbar uses theMaterialApp
's theme.This PR changes the popover toolbars to be displayed in an
OverlayPortal
instead of anOverlay
. By doing so, the popovers "see" the sameInheritedWidgets
that theSuperTextField
sees.In the tests, I had to use the platform textfields directly, as
SuperTextField
doesn't expose thepopoverToolbarBuilder
in its public API.I also noticed that the iOS textfield is always using the
_defaultPopoverToolbarBuilder
instead of the givenpopoverToolbarBuilder
. This PR fixes that.