This PR implements the `CupertinoActionSheet` part of https://github.com/flutter/flutter/issues/19786.
This PR creates a new kind of gesture "sliding tap", which can be a simple tap but also allows the user to slide to other buttons during the tap, and select the button that the slide ends in.
The following video shows the behavior on a button list (left to right: Native iOS, after PR, before PR):
https://github.com/flutter/flutter/assets/1596656/1718630d-6890-4833-908b-762332a39568
Notice:
1. When the tap starts on a button or on the content section, the gesture can slide into a button to highlight it or activate it.
2. When the user performs a quick tap on a button, the button is immediately highlighted. (Before the PR, the highlight waits until the time out of a tap gesture, causing a quick tap to not highlight anything at all.)
The following video shows the behavior when the actions section scrolls (left to right: Native iOS, after PR)
https://github.com/flutter/flutter/assets/1596656/5eb70bc1-ec25-4376-9500-2aaa12f0034b
Notice:
1. Moving left or right doesn't cancel sliding tap, but moving vertically prioritizes the scrolling.
2. Moving before the drag starts is also recognized as a sliding tap.
Also, multiple pointers interact with the button list following an algorithm of "using earliest pointer". I can't record videos about it but I've added unit tests.
This PR changes `CupertinoActionSheet`'s layout algorithm, so that the actions section always has the lower priority to take up vertical space with a fixed minimum height of 84.3 px.
Currently `CupertinoActionSheet` uses a very complicated rule the determine the sizes of various sections:
1. If there are <= 3 buttons and a cancel button, or 1 button without a cancel button, then the actions section should never scroll.
2. Otherwise, then the content section takes priority to take over spaces but must leave at least `actionsMinHeight` for the actions section.
This has been the case since `CupertinoActionSheet` was first introduced ([first PR](https://github.com/flutter/flutter/pull/19232)). Maybe it was the case before, but it's no longer reproducible on the latest SwiftUI.
The following images for comparison (left to right: Current Flutter, Flutter after this PR, SwiftUI). Pay attention to whether the actions section scrolls. (There are also some height/padding issues, which will be fixed in a future PR.)
Two buttons:
<img width="1006" alt="image" src="https://github.com/flutter/flutter/assets/1596656/27ca5df7-1140-4bfd-9a5f-3b5972632c92">
Three buttons:
<img width="1025" alt="image" src="https://github.com/flutter/flutter/assets/1596656/f2be6a5c-1713-4ffe-9705-27a668e5133d">
Four buttons:
<img width="1024" alt="image" src="https://github.com/flutter/flutter/assets/1596656/5b90d9f4-11ed-4c04-bdea-0b81b1d2bd3d">
In SwiftUI, the action section seems to always have a minimum height of ~84 pixels regardless of the number of buttons. Therefore this PR also fixed this behavior, and adjusted the related tests.
When I implemented https://github.com/flutter/flutter/pull/149334, there was a bug that if the actions section is overscrolled for too far (typically due to a fling), the overscroll background might be so long that it overflows the actions section. This PR fixes this bug.
This PR rewrite `CupertinoActionSheet` to be based on layout widgets instead of the custom layout code in `_CupertinoDialogRenderWidget`, making it much easier to understand. It also fixes a layout deviation from SwiftUI, and add a few tests.
`_CupertinoDialogRenderWidget` is a custom layout widget that contains too much boilerplate code and is hard to understand where is customized. The plan is to replace it with widgets as much as possible. (Since this widget is used by both `CupertinoActionSheet` and `CupertinoAlertDialog`, this PR only removes the branches related to `isActionSheet`).
The need to use custom layout widget probably came from the following difficulties:
1. The parent needs to know whether an action button is being pressed to correctly render or hide each divider, but the action button is provided by the user as a built widget that also needs to respond to the tap gesture.
2. The main sheet's column needs to _prioritize_ allocating the space to the content section before allocating the remaining to the actions section, while also leaving the actions section a minimum height. This is not supported by simply `Column`.
3. The minimum height of the action section is a non-trivial algorithm.
Luckily, I've found out that all these problems are solvable with widgets.
All existing tests pass.
When a `TextField` is rendered before a `Navigator`, it breaks in semantics mode. This is because the framework generates the incorrect semantics tree (excludes the TextField) and when that tree gets sent to the engine, we don't get the signal to create the corresponding `<input>` element.
This happens for a few reasons:
* `ModalBarrier` uses `BlockSemantics` to drop the semantics of routes beneath the current route in `Navigator`
* `ModalBarrier` mistakenly recognizes the widget outside of the `Navigator` to be its sibling
* So we end up dropping the semantics node of the `TextField` rendered before it.
The fix is to let `Navigator` generate a semantics node so that `ModalBarrier` doesn't mistakenly think widgets outside of `Navigator` are its siblings.
`Navigator` doesn't currently do this, which causes all the nodes generated from its widget subtree to be directly attached to the parent semantics node above `Navigator` - since this is also the parent of `TextField`, it considers them siblings.
Fixes https://github.com/flutter/flutter/issues/129324
Remove more `textScaleFactor` references from flutter/flutter.
- Some changes are related to label scaling: the padding EdgeInsets values of some chip subclasses scale linearly between predetermined "max" padding values and "min" padding values. Before they scale with the `textScaleFactor` scalar, now they scale with the font size and are still capped at the original "max" and "min" values.
- The rest of them are tests or size heuristics that depend on `textScaleFactor`, these are replaced by an effective text scale factor computed using a default font size (which is determined in a pretty random fashion, but it will only make a difference on Android 14+).
No API changes in this batch. There are still some references left that I intend to remove in a different batch that would introduce API changes.
This turns on order shuffling for all tests that don't fail with it on, marking those tests that do fail with a tag so that they will be run without shuffling on.
To determine which tests fail with it on, I ran all the tests 100 times with different random shuffle seeds, and then also ran it with the date seeds from today until the end of July, and tagged all of the test suites (files) that fail, with a seed that caused them to fail.
Adds MediaQuery.maybeOf to replace calling MediaQuery.of(context, nullOk: true), and removes the nullOk parameter. Also changes MediaQuery.of to return a non-nullable value, and removes many instances of the ! operator, reducing the possible places where a null dereference could occur.
Flutter's `moreOrLessEquals` has a few advantages over `closeTo` from
the `matcher` package:
* It emits the epsilon value in the test result on failure.
* It uses a named parameter for epsilon, which improves readability
at the call site.
* It has a reasonable default for epsilon in cases where something
more specific isn't required.
Using it also has the nice property that it aids in its own discovery
when when people go looking for such functionality in new tests.
This change also includes a couple unrelated whitespace formatting cleanups.
* Update project.pbxproj files to say Flutter rather than Chromium
Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright.
* Update the copyright notice checker to require a standard notice on all files
* Update copyrights on Dart files. (This was a mechanical commit.)
* Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine.
Some were already marked "The Flutter Authors", not clear why. Their
dates have been normalized. Some were missing the blank line after the
license. Some were randomly different in trivial ways for no apparent
reason (e.g. missing the trailing period).
* Clean up the copyrights in non-Dart files. (Manual edits.)
Also, make sure templates don't have copyrights.
* Fix some more ORGANIZATIONNAMEs
* add trailing commas on list/map/parameters
* add trailing commas on Invocation with nb of arg>1
* add commas for widget containing widgets
* add trailing commas if instantiation contains trailing comma
* revert bad change