forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit 2b700dd
authored
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.1 parent 84cff31 commit 2b700ddCopy full SHA for 2b700dd
File tree
Expand file treeCollapse file tree
2 files changed
+429
-200
lines changedFilter options
- packages/flutter
- lib/src/cupertino
- test/cupertino
Expand file treeCollapse file tree
2 files changed
+429
-200
lines changed
0 commit comments