@@ -89,7 +89,28 @@ class _HomePageState extends State<HomePage> {
89
89
}
90
90
}
91
91
92
- void showMenu (BuildContext context) {
92
+ const Duration _bottomSheetEnterDuration = Duration (milliseconds: 250 );
93
+ const Duration _bottomSheetExitDuration = Duration (milliseconds: 200 );
94
+
95
+ class _PausableAnimationController extends AnimationController {
96
+ _PausableAnimationController ({
97
+ required super .vsync,
98
+ super .duration,
99
+ super .reverseDuration,
100
+ });
101
+
102
+ bool paused = false ;
103
+
104
+ @override
105
+ set value (double newValue) {
106
+ if (paused) {
107
+ return ;
108
+ }
109
+ super .value = (newValue);
110
+ }
111
+ }
112
+
113
+ void showMenu (BuildContext context) async {
93
114
final store = PerAccountStoreWidget .of (context);
94
115
final designVariables = DesignVariables .of (context);
95
116
final menuItems = < Widget > [
@@ -127,8 +148,16 @@ void showMenu(BuildContext context) {
127
148
const SizedBox (height: 8 ),
128
149
const _VersionInfo (),
129
150
];
130
-
131
- showModalBottomSheet <void >(
151
+ final animationController = _PausableAnimationController (
152
+ vsync: Navigator .of (context),
153
+ duration: _bottomSheetEnterDuration,
154
+ reverseDuration: _bottomSheetExitDuration,
155
+ );
156
+ bool handleScroll (ScrollNotification notification) {
157
+ animationController.paused = notification.metrics.extentBefore != 0 ;
158
+ return false ;
159
+ }
160
+ await showModalBottomSheet <void >(
132
161
context: context,
133
162
// Clip.hardEdge looks bad; Clip.antiAliasWithSaveLayer looks pixel-perfect
134
163
// on my iPhone 13 Pro but is marked as "much slower":
@@ -137,6 +166,7 @@ void showMenu(BuildContext context) {
137
166
useSafeArea: true ,
138
167
isScrollControlled: true ,
139
168
backgroundColor: designVariables.bgBotBar,
169
+ transitionAnimationController: animationController,
140
170
builder: (BuildContext _) {
141
171
return SafeArea (
142
172
minimum: const EdgeInsets .only (bottom: 8 ),
@@ -148,18 +178,24 @@ void showMenu(BuildContext context) {
148
178
Expanded (child: InsetShadowBox (
149
179
top: 8 , bottom: 8 ,
150
180
color: designVariables.bgBotBar,
151
- child: SingleChildScrollView (
152
- padding: const EdgeInsets .symmetric (vertical: 8 , horizontal: 8 ),
153
- child: Column (
154
- mainAxisAlignment: MainAxisAlignment .start,
155
- children: menuItems)))),
181
+ child: NotificationListener <ScrollNotification >(
182
+ onNotification: handleScroll,
183
+ child: SingleChildScrollView (
184
+ padding: const EdgeInsets .symmetric (vertical: 8 , horizontal: 8 ),
185
+ child: Column (
186
+ mainAxisAlignment: MainAxisAlignment .start,
187
+ children: menuItems))))),
156
188
const Padding (
157
189
padding: EdgeInsets .symmetric (horizontal: 16 ),
158
190
child: Scaled (
159
191
scaleEnd: 0.95 ,
160
192
duration: Duration (milliseconds: 100 ),
161
193
child: SizedBox (height: 44 , child: ActionSheetCancelButton ()))),
162
194
]));
195
+ }).whenComplete (() {
196
+ // See [TransitionRoute.didPop].
197
+ animationController.paused = false ;
198
+ animationController.reverse ().whenComplete (() => animationController.dispose ());
163
199
});
164
200
}
165
201
0 commit comments