Commit Graph

90 Commits

Author SHA1 Message Date
Greg Spencer
333c076e53
Factor out RawView, make View listen to engine generated view focus events (#143259)
## Description

This factors out a separate `RawView` that doesn't add a `MediaQuery` or a `FocusScope`. This PR also adds a new method `WidgetsBindingObserver.didChangeViewFocus` which allows the observer to know when the `FlutterView` that has focus has changed.

It also makes the `View` widget a stateful widget that contains a `FocusScope` and ` FocusTraversalGroup` so that it can respond to changes in the focus of the view.

I've also added a new function to `FocusScopeNode` that will allow the scope node itself to be focused, without looking for descendants that could take the focus. This lets the focus be "parked" at the `FocusManager.instance.rootScope` so that nothing else appears to have focus.

## Tests
 - Added tests for the new functionality.
2024-05-20 17:17:55 +00:00
Justin McCandless
8e35cf5125
Reland Native ios context menu (#143002) (#148238) (#148265)
Reverting https://github.com/flutter/flutter/pull/148238 which was relanded in https://github.com/flutter/flutter/pull/148237 which was originally from https://github.com/flutter/flutter/pull/143002.

This time post-submit I saw a failure of a wasm version of a test added by this PR.
2024-05-15 18:37:05 +00:00
auto-submit[bot]
45e80fd63b
Reverts "Reland Native ios context menu (#143002) (#148238)" (#148254)
Reverts: flutter/flutter#148238
Initiated by: zanderso
Reason for reverting: Failures in post submit https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8748025189669617649/+/u/run_test.dart_for_web_canvaskit_tests_shard_and_subshard_3/stdout
Original PR Author: justinmc

Reviewed By: {hellohuanlin}

This change reverts the following previous change:
Reland of https://github.com/flutter/flutter/pull/143002, which was reverted in https://github.com/flutter/flutter/pull/148237 due to unresolved docs references. Not sure why those weren't caught in presubmit.

```
dartdoc:stdout: Generating docs for package flutter...
dartdoc:stderr:   error: unresolved doc reference [TextInput.showSystemContextMenu]
dartdoc:stderr:     from widgets.MediaQueryData.supportsShowingSystemContextMenu: (file:///b/s/w/ir/x/w/flutter/packages/flutter/lib/src/widgets/media_query.dart:579:14)
dartdoc:stderr:     in documentation inherited from widgets.MediaQueryData.supportsShowingSystemContextMenu: (file:///b/s/w/ir/x/w/flutter/packages/flutter/lib/src/widgets/media_query.dart:579:14)
dartdoc:stderr:   error: unresolved doc reference [showSystemContextMenu]
dartdoc:stderr:     from services.SystemContextMenuController.hide: (file:///b/s/w/ir/x/w/flutter/packages/flutter/lib/src/services/text_input.dart:2554:16)
dartdoc:stderr:   error: unresolved doc reference [hideSystemContextMenu]
dartdoc:stderr:     from services.SystemContextMenuController.show: (file:///b/s/w/ir/x/w/flutter/packages/flutter/lib/src/services/text_input.dart:2509:16)
```
2024-05-13 20:50:26 +00:00
Justin McCandless
42b3d9eb7f
Reland Native ios context menu (#143002) (#148238)
It's now possible to use the native-rendered text selection context menu on iOS. This sacrifices customizability in exchange for avoiding showing a notification when the user presses "Paste". It's off by default, but to enable, see the example system_context_menu.0.dart.
2024-05-13 12:53:36 -07:00
auto-submit[bot]
14d88ee0c8
Reverts "Native ios context menu (#143002)" (#148237)
Reverts: flutter/flutter#143002
Initiated by: cbracken
Reason for reverting: unresolved docs links. See failure here: https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20docs_test/16540/overview

```
dartdoc:stdout: Generating docs for package flutter...
dartdoc:stderr:   error: unresolved doc reference [TextInput.showSystemContextMenu]
dartdoc:stderr:     from widgets.MediaQueryData.supportsShowingSystemContextMenu: (file:///b/s/w/ir/x/w/flutter/packages/flutt
Original PR Author: justinmc

Reviewed By: {Renzo-Olivares, hellohuanlin}

This change reverts the following previous change:
In order to work around the fact that iOS 15 shows a notification on pressing Flutter's paste button (https://github.com/flutter/flutter/issues/103163), this PR allows showing the iOS system context menu in text fields.

<img width="385" alt="Screenshot 2024-02-06 at 11 52 25 AM" src="https://github.com/flutter/flutter/assets/389558/d82e18ee-b8a3-4082-9225-cf47fa7f3674">

It is currently opt-in, which a user would typically do like this (also in example system_context_menu.0.dart):

```dart
      contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) {
        // If supported, show the system context menu.
        if (SystemContextMenu.isSupported(context)) {
          return SystemContextMenu.editableText(
            editableTextState: editableTextState,
          );
        }
        // Otherwise, show the flutter-rendered context menu for the current
        // platform.
        return AdaptiveTextSelectionToolbar.editableText(
          editableTextState: editableTextState,
        );
      },
```

Requires engine PR https://github.com/flutter/engine/pull/50095.

## API changes

### SystemContextMenu
A widget that shows the system context menu when built, and removes it when disposed. The main high-level way that most users would use this PR. Only works on later versions of iOS.

### SystemContextMenuController
Used under the hood to hide and show a system context menu. There can only be one visible at a time.

### MediaQuery.supportsShowingSystemContextMenu
Sent by the iOS embedder to tell the framework whether or not the platform supports showing the system context menu. That way the framework, or Flutter developers, can decide to show a different menu.

### `flutter/platform ContextMenu.showSystemContextMenu`
Sent by the framework to show the menu at a given `targetRect`, which is the current selection rect.

### `flutter/platform ContextMenu.hideSystemContextMenu`
Sent by the framework to hide the menu. Typically not needed, because the platform will hide the menu when the user taps outside of it and after the user presses a button, but it handles edge cases where the user programmatically rebuilds the context menu, for example.

### `flutter/platform System.onDismissSystemContextMenu`
Sent by the iOS embedder to indicate that the system context menu has been hidden by the system, such as when the user taps outside of the menu.  This is useful when there are multiple instances of SystemContextMenu, such as with multiple text fields.
2024-05-13 17:43:36 +00:00
Justin McCandless
125543505d
Native ios context menu (#143002)
It's now possible to use the native-rendered text selection context menu on iOS. This sacrifices customizability in exchange for avoiding showing a notification when the user presses "Paste". It's off by default, but to enable, see the example system_context_menu.0.dart.
2024-05-13 08:48:56 -07:00
Michael Goderbauer
3f09b23338
cleanup now-irrelevant ignores for deprecated_member_use (#143403)
Follow-up to https://github.com/flutter/flutter/pull/143347.
2024-02-14 21:08:25 +00:00
Michael Goderbauer
4534a24c09
Reapply "Dynamic view sizing" (#140165) (#140918)
This reverts commit
d24c01bd0c.

The original change was reverted because it caused some apps to get
stuck on the splash screen on some phones.

An investigation determined that this was due to a rounding error.
Example: The device reports a physical size of 1008.0 x 2198.0 with a
dpr of 1.912500023841858. Flutter would translate that to a logical size
of 527.0588169589221 x 1149.2810314243163 and use that as the input for
its layout algorithm. Since the constraints here are tight, the layout
algorithm would determine that the resulting logical size of the root
render object must be 527.0588169589221 x 1149.2810314243163.
Translating this back to physical pixels by applying the dpr resulted in
a physical size of 1007.9999999999999 x 2198.0 for the frame. Android
now rejected that frame because it didn't match the expected size of
1008.0 x 2198.0 and since no frame had been rendered would never take
down the splash screen.

Prior to dynamically sized views, this wasn't an issue because we would
hard-code the frame size to whatever the requested size was.

Changes in this PR over the original PR:

* The issue has been fixed now by constraining the calculated physical
size to the input physical constraints which makes sure that we always
end up with a size that is acceptable to the operating system.
* The `ViewConfiguration` was refactored to use the slightly more
convenient `BoxConstraints` over the `ViewConstraints` to represent
constraints. Both essentially represent the same thing, but
`BoxConstraints` are more powerful and we avoid a couple of translations
between the two by translating the` ViewConstraints` from the
`FlutterView` to `BoxConstraints` directly when the `ViewConfiguration`
is created.

All changes over the original PR are contained in the second commit of
this PR.

Fixes b/316813075
Part of https://github.com/flutter/flutter/issues/134501.
2024-01-09 14:10:43 -08:00
Michael Goderbauer
68e346e41c
Remove outdated ignores from tool (#140467)
These were not ignoring anything (anymore).
2023-12-20 22:14:32 +00:00
Lau Ching Jun
d24c01bd0c
Revert "Dynamic view sizing" (#140165)
Reverts flutter/flutter#138648

This caused the app to be stuck in the splash screen on certain phone models.

Context: b/316244317
2023-12-14 19:42:06 +00:00
Michael Goderbauer
4f8a99147a
Dynamic view sizing (#138648)
Towards https://github.com/flutter/flutter/issues/134501.

This change is based on https://github.com/flutter/engine/pull/48090. It changes the `RenderView` to be dynamically sized based on its content if the `FlutterView` it is configured with allows it (i.e. the `FlutterView` has loose `FlutterView.physicalConstraints`). For that, it uses those `physicalConstraints` as input to the layout algorithm by passing them on to its child (after translating them to logical constraints via the device pixel ratio). The resulting `Size` that the `RenderView` would like to be is then communicated back to the engine by passing it to the `FlutterView.render` call.

Tests will fail until https://github.com/flutter/engine/pull/48090 has rolled into the framework.
2023-11-29 20:45:18 +00:00
Michael Goderbauer
bf5d2b875f
Prepare for dynamically sized views (#138565)
Towards https://github.com/flutter/flutter/issues/134501.

Required to roll https://github.com/flutter/engine/pull/48090 into the framework.

**DO NOT SUBMIT until https://github.com/flutter/flutter/pull/138648 and https://github.com/flutter/engine/pull/48090 are ready.**
2023-11-27 17:41:22 +00:00
Michael Goderbauer
1ef6e99867
Remove physicalGeometry (#138103)
Looks like this was proactively added in https://github.com/flutter/engine/pull/20496, but never wired up to anything on any platform. It is also unused in framework and customer code; we never exposed this on e.g. MediaQuery.

Related engine PR: https://github.com/flutter/engine/pull/47825
2023-11-08 21:43:59 +00:00
Hrishikesh Kadam
64d3937090
Fix minor typo in doc of window.dart (#137483) 2023-10-31 23:27:06 +00:00
Renzo Olivares
b1f691c9fc
Remove deprecated TestWindow.platformBrightnessTestValue/TestWindow.clearPlatformBrightnessTestValue (#133178)
Part of: https://github.com/flutter/flutter/issues/133171
2023-09-01 20:35:58 +00:00
Renzo Olivares
959cdb79fb
Remove deprecated TestWindow.textScaleFactorTestValue/TestWindow.clearTextScaleFactorTestValue (#133176)
Part of: https://github.com/flutter/flutter/issues/133171
2023-09-01 20:31:16 +00:00
Kate Lovett
72bd36026f
Remove deprecated onPlatformMessage from TestWindow and TestPlatformDispatcher (#133183) 2023-08-25 15:46:11 -05:00
Michael Goderbauer
ad78cf3506
Remove deprecated *TestValues from TestWindow (#131098)
Part of https://github.com/flutter/flutter/issues/133171.

Removes from `TestWindow`:
* `localeTestValue`
* `clearLocaleTestValue`
* `localesTestValue`
* `clearLocalesTestValue`
* `initialLifecycleStateTestValue`
* `alwaysUse24HourFormatTestValue`
* `clearAlwaysUse24HourTestValue`
* `brieflyShowPasswordTestValue`
* `defaultRouteNameTestValue`
* `clearDefaultRouteNameTestValue`
* `semanticsEnabledTestValue`
* `clearSemanticsEnabledTestValue`
* `accessibilityFeaturesTestValue`
* `clearAccessibilityFeaturesTestValue`

These properties have reached the end of their deprecation period.
2023-08-23 18:31:04 +00:00
Michael Goderbauer
64a0683b41
Analyze code snippets in flutter_test docs (#132246)
Fixes https://github.com/flutter/flutter/issues/132274.
2023-08-10 17:18:12 +00:00
Michael Goderbauer
cff67336d0
Add viewId to PointerEvents (#128287)
Follow-up to https://github.com/flutter/engine/pull/42493.
2023-06-06 19:16:02 -07:00
Michael Goderbauer
4c5db40ff5
Clean-up viewId casts in flutter_test (#128256)
Follow-up to https://github.com/flutter/engine/pull/42493.
2023-06-06 17:23:17 +00:00
Michael Goderbauer
17f86df8bd
Migrate SemanticsBinding to onSemanticsActionEvent (#128254)
Follow-up to https://github.com/flutter/engine/pull/42493.
2023-06-05 18:16:06 +00:00
Michael Goderbauer
e50b2507bf
Pre-migration for dart:ui multi view changes (#128092)
For https://github.com/flutter/engine/pull/42493.
2023-06-02 20:51:09 +00:00
pdblasi-google
07f7ffde50
Adds TestDisplay API for testing Display features (#127525)
* Adds `TestDisplay`
* Updates `TestPlatformDispatcher` to wrap all `Display`s and relate them to their appropriate `TestFlutterView`
* Updates `TestFlutterView` to tie `devicePixelRatio` to its display as per the documentation on `Display`

Closes #127225
2023-05-26 00:04:05 +00:00
Michael Goderbauer
a9073f787c
Deprecate BindingBase.window (#120998)
Deprecate BindingBase.window
2023-03-21 21:08:23 +00:00
pdblasi-google
4695fcc782
Deprecates TestWindow (#122824)
Deprecates `TestWindow`
2023-03-21 18:43:50 +00:00
pdblasi-google
0ba64488da
Reland: Updates flutter/test/material to no longer use TestWindow (#122643)
Reland: Updates `flutter/test/material` to no longer use `TestWindow`
2023-03-15 00:08:18 +00:00
yaakovschectman
46a8106781
Revert "Updates flutter/test/material to no longer use TestWindow (#122337)" (#122636)
This reverts commit b2fc5f9770.
2023-03-14 17:34:33 -04:00
pdblasi-google
b2fc5f9770
Updates flutter/test/material to no longer use TestWindow (#122337)
Updates `flutter/test/material` to no longer use `TestWindow`
2023-03-14 21:13:05 +00:00
pdblasi-google
7dd53fefe9
Reland (3): Removes single window assumptions from flutter_test (#122422)
Reland (3): Removes single window assumptions from `flutter_test`
2023-03-13 21:50:24 +00:00
Casey Hillers
1f42612323
Revert PRs relating to single window assumption (#122369)
* Revert "Remove references to BindingBase.window (#122119)"

This reverts commit c7681f00cf.

* Revert "Remove another reference to BindingBase.window (#122341)"

This reverts commit 6ec4445063.

* Revert "Reland (2): Removes single window assumptions from `flutter_test` (#122233)"

This reverts commit eb3d317ea0.

* Revert "Remove single view assumption from TestViewConfiguration (#122352)"

This reverts commit 927289fb4e.

* Revert "Updates `flutter/test/cupertino` to no longer use `TestWindow` (#122325)"

This reverts commit 67e17e45f0.

* Revert "Updates `flutter/test/gestures` to no longer reference `TestWindow` (#122327)"

This reverts commit c2a5111cc0.

* Revert "Updates `flutter/test/rendering` to no longer use `TestWindow` (#122347)"

This reverts commit 28b65e089b.

* Revert "Updates `flutter_localizations/test` to stop using `TestWindow` (#122321)"

This reverts commit 01367d52d7.
2023-03-09 22:53:38 -08:00
pdblasi-google
eb3d317ea0
Reland (2): Removes single window assumptions from flutter_test (#122233)
Reland (2): Removes single window assumptions from `flutter_test`
2023-03-09 00:52:05 +00:00
Casey Hillers
0091601057
Revert "Reland: Removes single window assumptions from flutter_test (#122060)" (#122193)
Revert "Reland: Removes single window assumptions from `flutter_test`"
2023-03-08 19:42:03 +00:00
pdblasi-google
a626f4db6f
Reland: Removes single window assumptions from flutter_test (#122060)
Reland: Removes single window assumptions from `flutter_test`
2023-03-07 21:12:59 +00:00
pdblasi-google
a53105d941
Revert "Removes single window assumptions from flutter_test (#121549)" (#122037)
This reverts commit f2dd19d5b6.
2023-03-06 11:49:40 -08:00
pdblasi-google
f2dd19d5b6
Removes single window assumptions from flutter_test (#121549)
Removes single window assumptions from `flutter_test`
2023-03-06 18:38:14 +00:00
Jason Simmons
95387c6621
Fix field cleared by TestWindow.clearGestureSettingsTestValue (#121956) 2023-03-04 16:59:14 -08:00
Michael Goderbauer
50c80d9b50
Remove all traces of ViewConfiguration/PlatformConfiguration (#121751)
Remove all traces of ViewConfiguration/PlatformConfiguration
2023-03-02 20:46:15 +00:00
Michael Goderbauer
92a1a8ba09
Migrate to FlutterView.gestureSettings (#121749) 2023-03-02 10:17:29 -08:00
Michael Goderbauer
5ccb4d4b95
Rename WindowPadding to ViewPadding (#121152)
* Rename WindowPadding to ViewPadding

* dart fix

* typos
2023-02-22 21:32:40 +00:00
Jason Simmons
496cf627e6
Delegate TestWindow.updateSemantics to the wrapped SingletonFlutterWindow (#114733)
This restores the updateSemantics capability in TestWindow that had been
removed in https://github.com/flutter/flutter/pull/113382
2022-11-07 17:27:50 +00:00
Alex Wallen
23d258df57
Remove deprecated updateSemantics API usage. (#113382) 2022-10-26 20:20:41 +00:00
Jonah Williams
4be0cfcb3f
[framework] add ignores for platformDispatcher deprecation (#113238) 2022-10-10 22:38:06 +00:00
Camille Simon
7db25c36ad
Re-land Add Spell Check to EditableText (#109643) 2022-08-17 16:16:02 +00:00
Jonah Williams
0ba88d8b43
Revert "Add Spellcheck to EditableText (Android) (#109334)" (#109631)
This reverts commit ff9fe35682.
2022-08-16 14:30:03 -07:00
Camille Simon
ff9fe35682
Add Spellcheck to EditableText (Android) (#109334) 2022-08-16 18:22:45 +00:00
Xilai Zhang
d6f090d952
[g3 roll] revert #105537 Implement frameData for TestWindow (#107168)
* Revert "Reland "Clipping if only one character text overflows (#99146)" (#102130)"

This reverts commit 3f43d9f3d4.

* Revert "Implement frameData for TestWindow (#105537)"

This reverts commit 21841d7e35.
2022-07-06 10:29:19 -07:00
Dan Field
21841d7e35
Implement frameData for TestWindow (#105537) 2022-06-27 20:26:08 +00:00
Alexandre Ardhuin
56c4e3cdd8
add some exports of public API in foundation/serialization.dart (#104231) 2022-06-08 13:33:12 -07:00
Pierre-Louis
74cfc3db67
Use curly_braces_in_flow_control_structures for non-flutter packages (#104629)
* Use `curly_braces_in_flow_control_structures` for `packages/flutter_driver`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_goldens`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_goldens_client`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_localizations`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_test`

* Use `curly_braces_in_flow_control_structures` for `packages/flutter_web_plugins`

* fix comments

* Use `curly_braces_in_flow_control_structures` for `packages/integration_test`

* fix indentation
2022-05-25 20:01:11 +02:00