diff --git a/learning/tour-of-beam/frontend/lib/components/profile/user_menu.dart b/learning/tour-of-beam/frontend/lib/components/profile/user_menu.dart index 4e5aa574b3488..e85232766d498 100644 --- a/learning/tour-of-beam/frontend/lib/components/profile/user_menu.dart +++ b/learning/tour-of-beam/frontend/lib/components/profile/user_menu.dart @@ -133,11 +133,11 @@ class _Buttons extends StatelessWidget { text: 'dialogs.deleteAccountWarning'.tr(), continueLabel: 'ui.deleteMyAccount'.tr(), title: 'ui.deleteTobAccount'.tr(), - onContinue: () { - authNotifier.deleteAccount().then( - (_) { - Navigator.pop(context); - }, + onContinue: () async { + Navigator.pop(context); + await BeamOverlays.showProgressOverlay( + context, + authNotifier.deleteAccount, ); }, ), diff --git a/playground/frontend/playground_components/lib/playground_components.dart b/playground/frontend/playground_components/lib/playground_components.dart index 524cb03b7c89d..3d14b1821e902 100644 --- a/playground/frontend/playground_components/lib/playground_components.dart +++ b/playground/frontend/playground_components/lib/playground_components.dart @@ -71,8 +71,9 @@ export 'src/widgets/output/output_area.dart'; export 'src/widgets/output/output_tab.dart'; export 'src/widgets/output/output_tabs.dart'; export 'src/widgets/overlay/body.dart'; -export 'src/widgets/overlay/dismissible.dart'; export 'src/widgets/overlay/opener.dart'; +export 'src/widgets/overlay/overlays.dart'; +export 'src/widgets/overlay/widget.dart'; export 'src/widgets/reset_button.dart'; export 'src/widgets/run_or_cancel_button.dart'; export 'src/widgets/shortcut_tooltip.dart'; diff --git a/playground/frontend/playground_components/lib/src/widgets/overlay/opener.dart b/playground/frontend/playground_components/lib/src/widgets/overlay/opener.dart index cb4e107f5f02a..48edf2ef664bd 100644 --- a/playground/frontend/playground_components/lib/src/widgets/overlay/opener.dart +++ b/playground/frontend/playground_components/lib/src/widgets/overlay/opener.dart @@ -19,17 +19,19 @@ import 'package:flutter/material.dart'; import '../../controllers/public_notifier.dart'; -import 'dismissible.dart'; +import 'widget.dart'; void openOverlay({ required BuildContext context, required PublicNotifier closeNotifier, required Positioned positioned, + bool isDismissible = true, }) { final overlay = OverlayEntry( builder: (context) { - return DismissibleOverlay( + return BeamOverlay( close: closeNotifier.notifyPublic, + isDismissible: isDismissible, child: positioned, ); }, diff --git a/playground/frontend/playground_components/lib/src/widgets/overlay/overlays.dart b/playground/frontend/playground_components/lib/src/widgets/overlay/overlays.dart new file mode 100644 index 0000000000000..f2780128176a3 --- /dev/null +++ b/playground/frontend/playground_components/lib/src/widgets/overlay/overlays.dart @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; + +import '../../../playground_components.dart'; + +class BeamOverlays { + // TODO(nausharipov) review: add label? + // TODO(nausharipov) review: add grey-ish background? + static Future showProgressOverlay( + BuildContext context, + Future Function() future, + ) async { + final closeNotifier = PublicNotifier(); + openOverlay( + context: context, + closeNotifier: closeNotifier, + isDismissible: false, + positioned: const Positioned.fill( + child: Align( + child: CircularProgressIndicator(), + ), + ), + ); + await future(); + closeNotifier.notifyPublic(); + } +} diff --git a/playground/frontend/playground_components/lib/src/widgets/overlay/dismissible.dart b/playground/frontend/playground_components/lib/src/widgets/overlay/widget.dart similarity index 80% rename from playground/frontend/playground_components/lib/src/widgets/overlay/dismissible.dart rename to playground/frontend/playground_components/lib/src/widgets/overlay/widget.dart index e32e55c56a716..12e5405ae0c5f 100644 --- a/playground/frontend/playground_components/lib/src/widgets/overlay/dismissible.dart +++ b/playground/frontend/playground_components/lib/src/widgets/overlay/widget.dart @@ -18,24 +18,27 @@ import 'package:flutter/material.dart'; -class DismissibleOverlay extends StatelessWidget { +class BeamOverlay extends StatelessWidget { final VoidCallback close; final Positioned child; + final bool isDismissible; - const DismissibleOverlay({ + const BeamOverlay({ required this.close, required this.child, + required this.isDismissible, }); @override Widget build(BuildContext context) { return Stack( children: [ - Positioned.fill( - child: GestureDetector( - onTap: close, + if (isDismissible) + Positioned.fill( + child: GestureDetector( + onTap: close, + ), ), - ), child, ], );