Commit Graph

48 Commits

Author SHA1 Message Date
Tong Mu
87f68a8876
[CupertinoActionSheet] Add sliding tap gesture (#149471)
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.
2024-06-06 22:41:05 +00:00
Tong Mu
c246ecdf8e
Fix the scrolling layout deviation of CupertinoActionSheet (#149439)
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.
2024-06-04 01:06:22 +00:00
Tong Mu
691a18df5f
[CupertinoActionSheet] Fix overflow of the overscroll section when the user scrolls far (#149542)
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.
2024-06-03 19:12:11 +00:00
Tong Mu
2b700dda38
Rewrite CupertinoActionSheet, and fix layout deviation (#149334)
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.
2024-05-31 20:56:04 +00:00
Jesús S Guerrero
b5262f0d80
Revert "[web] - Fix broken TextField in semantics mode when it's a sibling of Navigator" (#142129)
Reverts flutter/flutter#138446

b/322136071
2024-01-24 16:13:26 +00:00
Hassan Toor
59e892d391
[web] - Fix broken TextField in semantics mode when it's a sibling of Navigator (#138446)
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
2024-01-22 17:03:14 +00:00
LongCatIsLooong
5892a0039b
Remove more textScaleFactor references (#141816)
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.
2024-01-20 00:27:18 +00:00
Polina Cherkasova
baf739c8e6
Remove usage of testWidgetsWithLeakTracking. (#140239) 2023-12-15 14:13:31 -08:00
Akito Nishiyama
f8ddd4b653
🎨: fix cupertionActionSheet design (#134345)
## Overview
Fixed the implementation of CupertionActionSheet based on [Apple Design Resource](https://www.figma.com/community/file/1248375255495415511).
I also deleted devicePixelRatio because Flutter uses logical pixels based on https://api.flutter.dev/flutter/dart-ui/FlutterView/devicePixelRatio.html.

ISSUE: #134539 

UPDATED GOLDEN: https://flutter-gold.skia.org/search?issue=134345&crs=github&patchsets=3&corpus=flutter

### Before
<img src="https://github.com/flutter/flutter/assets/40790076/8492fe5f-582f-4623-86eb-c60cb88d81a1" width=300>

### After
<img src="https://github.com/flutter/flutter/assets/40790076/fcdd7f7e-6ab5-4b68-a7b0-27a6fc2975b8" width=300>
2023-12-14 18:40:59 +00:00
Kostia Sokolovskyi
ffecedbca4
Cover more test/widgets tests with leak tracking #11 (#135231) 2023-09-21 16:30:32 -07:00
Kostia Sokolovskyi
854bbb901c
Fix memory leak in CupertinoActionSheet (#134885) 2023-09-16 14:59:13 -07:00
Greg Price
a28aae918e
Remove no-shuffle from framework tests, part 1: easy cases (#123751)
Remove no-shuffle from framework tests, part 1: easy cases
2023-03-30 18:28:51 +00:00
chunhtai
3fdd6ee46f
Reland "Overlay always applies clip (#113770)" (#116674)
* Reland "Overlay always applies clip (#113770)"

This reverts commit d0afbd72a7.

* Root navigator will not clip
2023-02-09 18:38:47 +00:00
Michael Goderbauer
b308555ed1
Enable dangling_library_doc_comments and library_annotations lints (#117365) 2022-12-20 16:03:21 -08:00
Callum Moffat
73cb7c2fc5
Squashed MediaQuery InheritedModel (#114459) 2022-12-09 20:59:11 +00:00
chunhtai
d0afbd72a7
Revert "Overlay always applies clip (#113770)" (#114442)
This reverts commit 103a5c98b8.
2022-11-01 12:05:01 -07:00
chunhtai
103a5c98b8
Overlay always applies clip (#113770) 2022-10-20 18:54:52 +00:00
Xilai Zhang
de230d393c
Revert "Add ability for ModalRoutes to ignore pointers during transitions and do so on Cupertino routes (#95757)" (#104520)
This reverts commit 4c0b0be2da.
2022-05-24 11:10:13 -07:00
Tong Mu
23bc3d64eb
[Mouse] Remove all pointers at the end of tests (#102694) 2022-05-19 17:48:10 -07:00
Will Lockwood
4c0b0be2da
Add ability for ModalRoutes to ignore pointers during transitions and do so on Cupertino routes (#95757) 2022-05-19 15:33:12 -07:00
Taha Tesser
d2cb63c8fa
CupertinoActionSheet/CupertinoAlertDialog: Add clickable cursor for web (#99548) 2022-03-28 01:15:08 -07:00
Greg Spencer
738ce43d97
Randomize tests, exclude tests that fail with randomization. (#86793)
* Randomize tests, exclude tests that fail with randomization.

* Disable some more tool tests
2021-07-26 23:40:49 -07:00
Greg Spencer
6adea05276
Revert "Randomize Framework tests, opt out some tests that currently fail. (#85159)" (#85673)
This reverts commit b5f9612 because it is taking about 40% longer to run the tests, which is causing timeouts.
2021-06-30 19:38:09 -07:00
Greg Spencer
b5f9612cac
Randomize Framework tests, opt out some tests that currently fail. (#85159)
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.
2021-06-29 13:46:13 -07:00
David Martos
e9542ec646
Assert for valid ScrollController in Scrollbar gestures (#81278) 2021-06-10 12:54:03 -07:00
Kate Lovett
92992550e6
Fix widgets with built-in scrollbars (#83828) 2021-06-03 17:44:05 -07:00
Alexandre Ardhuin
80dd6a406a
add missing trailing commas (#81080) 2021-04-27 09:59:03 -07:00
Ian Hickson
824042f9b2
Catch cases in tests where people try to tap on widgets that aren't reachable. (#74798) 2021-02-03 16:11:02 -08:00
Sam Rawlins
02c348b8bf
Remove "unnecessary" imports in cupertino tests (#75006) 2021-01-29 14:41:04 -08:00
Greg Spencer
55289324c6
Remove nullOk in MediaQuery.of (#68736)
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.
2020-10-28 07:56:41 -07:00
Alexandre Ardhuin
555cb66ece
fix tree (#67410) 2020-10-06 14:38:19 +02:00
Kate Lovett
b42cf8a75b
[NNBD] Migrate some Cupertino tests (#67086) 2020-10-05 12:17:03 -07:00
Chris Bracken
c0ea00ed3f
Prefer moreOrLessEquals over closeTo (#64915)
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.
2020-08-30 22:20:16 -07:00
chunhtai
5623fea53c
Reverse the semantics order of modal barrier and modal scope (#59290)
* Add semantics sort key for modal scope and modal barrier

* fix test

* fix test

* fix test

* fix space

* fix more tests

* addressing comments
2020-06-24 10:37:53 -07:00
Alexandre Ardhuin
4d7525f05c
Opt out nnbd in packages/flutter (#59186)
* add language version 2.8 in packages/flutter

* enable non-nullable analyzer flag
2020-06-11 14:11:30 +02:00
Alexandre Ardhuin
dfbd585668 implicit-casts:false in flutter/test (#46245) 2019-12-16 15:03:02 -08:00
Ian Hickson
449f4a6673
License update (#45373)
* 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
2019-11-27 15:04:02 -08:00
Alexandre Ardhuin
f0553ba58e
Missing trailing commas (#41473)
* add missing trailing commas

* add more missing trailing commas

* add more and more missing trailing commas
2019-09-30 18:48:23 +02:00
LongCatIsLooong
da151c95ba
CupertinoAlertDialog dark mode & CupertinoActionSheet fidelity (#40007) 2019-09-10 20:40:06 -07:00
LongCatIsLooong
e7f608072b
CupertinoActionSheet dark mode & fidelity (#39215) 2019-09-03 13:48:09 -07:00
Marco Scannadinari
4418ec467b Adjust remaining Cupertino route animations to match native (#28597) 2019-03-20 14:53:22 -07:00
Alexandre Ardhuin
a0d1f93b07
fix block formatting (#29051) 2019-03-09 09:03:11 +01:00
Alexandre Ardhuin
440ce8fde6
Fix indentations of statements in BlockFunctionBody (#28933)
* fix indentof statements in BlockFunctionBody

* fix indentof statements in BlockFunctionBody in tests
2019-03-07 21:09:28 +01:00
Alexandre Ardhuin
387f885481
Add missing trailing commas (#28673)
* 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
2019-03-01 08:17:55 +01:00
Alexandre Ardhuin
32d65fef1c
fix some formatting issues (#25474) 2018-12-18 10:05:12 +01:00
Jonah Williams
9d81c67a3f
Pass correct physics instance to Scrollable semantics (#24416) 2018-11-19 10:31:02 -08:00
Alexandre Ardhuin
d927c93310
Unnecessary new (#20138)
* enable lint unnecessary_new

* fix tests

* fix tests

* fix tests
2018-09-12 08:29:29 +02:00
Natalie Sampsell
96326d4743
CupertinoActionSheet (#19232)
Adding CupertinoActionSheet, showCupertinoModalPopup
2018-08-09 21:55:41 -07:00