Skip to content

Commit

Permalink
showProgressOverlay (apache#25255)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhan.nausharipov committed Feb 9, 2023
1 parent 2ab46ec commit eda3f16
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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<void> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
);
Expand Down

0 comments on commit eda3f16

Please sign in to comment.