Skip to content

Commit eda3f16

Browse files
author
darkhan.nausharipov
committed
showProgressOverlay (apache#25255)
1 parent 2ab46ec commit eda3f16

5 files changed

Lines changed: 64 additions & 14 deletions

File tree

learning/tour-of-beam/frontend/lib/components/profile/user_menu.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ class _Buttons extends StatelessWidget {
133133
text: 'dialogs.deleteAccountWarning'.tr(),
134134
continueLabel: 'ui.deleteMyAccount'.tr(),
135135
title: 'ui.deleteTobAccount'.tr(),
136-
onContinue: () {
137-
authNotifier.deleteAccount().then(
138-
(_) {
139-
Navigator.pop(context);
140-
},
136+
onContinue: () async {
137+
Navigator.pop(context);
138+
await BeamOverlays.showProgressOverlay(
139+
context,
140+
authNotifier.deleteAccount,
141141
);
142142
},
143143
),

playground/frontend/playground_components/lib/playground_components.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ export 'src/widgets/output/output_area.dart';
7171
export 'src/widgets/output/output_tab.dart';
7272
export 'src/widgets/output/output_tabs.dart';
7373
export 'src/widgets/overlay/body.dart';
74-
export 'src/widgets/overlay/dismissible.dart';
7574
export 'src/widgets/overlay/opener.dart';
75+
export 'src/widgets/overlay/overlays.dart';
76+
export 'src/widgets/overlay/widget.dart';
7677
export 'src/widgets/reset_button.dart';
7778
export 'src/widgets/run_or_cancel_button.dart';
7879
export 'src/widgets/shortcut_tooltip.dart';

playground/frontend/playground_components/lib/src/widgets/overlay/opener.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@
1919
import 'package:flutter/material.dart';
2020

2121
import '../../controllers/public_notifier.dart';
22-
import 'dismissible.dart';
22+
import 'widget.dart';
2323

2424
void openOverlay({
2525
required BuildContext context,
2626
required PublicNotifier closeNotifier,
2727
required Positioned positioned,
28+
bool isDismissible = true,
2829
}) {
2930
final overlay = OverlayEntry(
3031
builder: (context) {
31-
return DismissibleOverlay(
32+
return BeamOverlay(
3233
close: closeNotifier.notifyPublic,
34+
isDismissible: isDismissible,
3335
child: positioned,
3436
);
3537
},
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import 'package:flutter/material.dart';
20+
21+
import '../../../playground_components.dart';
22+
23+
class BeamOverlays {
24+
// TODO(nausharipov) review: add label?
25+
// TODO(nausharipov) review: add grey-ish background?
26+
static Future<void> showProgressOverlay(
27+
BuildContext context,
28+
Future Function() future,
29+
) async {
30+
final closeNotifier = PublicNotifier();
31+
openOverlay(
32+
context: context,
33+
closeNotifier: closeNotifier,
34+
isDismissible: false,
35+
positioned: const Positioned.fill(
36+
child: Align(
37+
child: CircularProgressIndicator(),
38+
),
39+
),
40+
);
41+
await future();
42+
closeNotifier.notifyPublic();
43+
}
44+
}

playground/frontend/playground_components/lib/src/widgets/overlay/dismissible.dart renamed to playground/frontend/playground_components/lib/src/widgets/overlay/widget.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,27 @@
1818

1919
import 'package:flutter/material.dart';
2020

21-
class DismissibleOverlay extends StatelessWidget {
21+
class BeamOverlay extends StatelessWidget {
2222
final VoidCallback close;
2323
final Positioned child;
24+
final bool isDismissible;
2425

25-
const DismissibleOverlay({
26+
const BeamOverlay({
2627
required this.close,
2728
required this.child,
29+
required this.isDismissible,
2830
});
2931

3032
@override
3133
Widget build(BuildContext context) {
3234
return Stack(
3335
children: [
34-
Positioned.fill(
35-
child: GestureDetector(
36-
onTap: close,
36+
if (isDismissible)
37+
Positioned.fill(
38+
child: GestureDetector(
39+
onTap: close,
40+
),
3741
),
38-
),
3942
child,
4043
],
4144
);

0 commit comments

Comments
 (0)