Skip to content

Commit 6005103

Browse files
author
darkhan.nausharipov
committed
addressing review comments (apache#25255)
1 parent fde6ace commit 6005103

8 files changed

Lines changed: 112 additions & 102 deletions

File tree

learning/tour-of-beam/frontend/assets/translations/en.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ ui:
2222
continueGitHub: Continue with GitHub
2323
continueGoogle: Continue with Google
2424
copyright: © The Apache Software Foundation
25-
hint: Hint
2625
deleteMyAccount: Delete my account
2726
deleteTobAccount: Delete my Tour of Beam account
2827
privacyPolicy: Privacy Policy
@@ -41,7 +40,8 @@ pages:
4140
tour:
4241
assignment: Assignment
4342
completeUnit: Complete Unit
44-
showSolution: Show
43+
hint: Hint
44+
showSolution: Show the solution
4545
solution: Solution
4646
solveYourself: Before revealing the solution, try solving the challenge on your own. Remember, the more you practice, the better you will become. Give it a shot and see how far you can get.
4747
summaryTitle: Table of Contents

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ class _Buttons extends StatelessWidget {
129129
closeOverlayCallback();
130130
showDialog(
131131
context: context,
132-
builder: (context) => BeamAlertDialog(
133-
text: 'dialogs.deleteAccountWarning'.tr(),
134-
continueLabel: 'ui.deleteMyAccount'.tr(),
132+
builder: (context) => ActionApprovalDialog(
133+
actionLabel: 'ui.deleteMyAccount'.tr(),
134+
bodyText: 'dialogs.deleteAccountWarning'.tr(),
135135
title: 'ui.deleteTobAccount'.tr(),
136-
onContinue: () async {
136+
onActionPressed: () async {
137137
Navigator.pop(context);
138138
await BeamOverlays.showProgressOverlay(
139139
context,

learning/tour-of-beam/frontend/lib/pages/tour/widgets/hints.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class HintsWidget extends StatelessWidget {
4646
}
4747
},
4848
icon: SvgPicture.asset(Assets.svg.hint),
49-
label: const Text('ui.hint').tr(),
49+
label: const Text('pages.tour.hint').tr(),
5050
);
5151
}
5252
}
@@ -69,7 +69,7 @@ class _Popup extends StatelessWidget {
6969
mainAxisSize: MainAxisSize.min,
7070
children: [
7171
Text(
72-
'ui.hint',
72+
'pages.tour.hint',
7373
style: Theme.of(context).textTheme.headlineLarge,
7474
).tr(),
7575
const SizedBox(height: BeamSizes.size8),

learning/tour-of-beam/frontend/lib/pages/tour/widgets/solution_button.dart

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,25 @@ class SolutionButton extends StatelessWidget {
4545
),
4646
onPressed: () {
4747
// TODO(nausharipov): resolve the conflict with save user code
48-
showDialog(
49-
context: context,
50-
builder: (context) => BeamAlertDialog(
51-
continueLabel: 'pages.tour.showSolution'.tr(),
52-
title: 'pages.tour.solveYourself'.tr(),
53-
onContinue: () {
54-
tourNotifier.toggleShowingSolution();
55-
Navigator.pop(context);
56-
},
57-
),
58-
);
48+
if (tourNotifier.isShowingSolution) {
49+
tourNotifier.toggleShowingSolution();
50+
} else {
51+
showDialog(
52+
context: context,
53+
builder: (context) => ActionApprovalDialog(
54+
bodyText: 'pages.tour.solveYourself'.tr(),
55+
actionLabel: 'pages.tour.showSolution'.tr(),
56+
title: 'pages.tour.solution'.tr(),
57+
onActionPressed: () {
58+
Navigator.pop(context);
59+
tourNotifier.toggleShowingSolution();
60+
},
61+
),
62+
);
63+
}
5964
},
6065
icon: SvgPicture.asset(Assets.svg.solution),
61-
label: const Text('ui.solution').tr(),
66+
label: const Text('pages.tour.solution').tr(),
6267
),
6368
);
6469
}

playground/frontend/playground_components/lib/playground_components.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export 'src/util/string.dart';
6060
export 'src/widgets/bubble.dart';
6161
export 'src/widgets/clickable.dart';
6262
export 'src/widgets/complexity.dart';
63-
export 'src/widgets/dialogs/alert_dialog.dart';
63+
export 'src/widgets/dialogs/action_approval.dart';
6464
export 'src/widgets/divider.dart';
6565
export 'src/widgets/header_icon_button.dart';
6666
export 'src/widgets/loading_error.dart';
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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:easy_localization/easy_localization.dart';
20+
import 'package:flutter/material.dart';
21+
22+
import '../../../playground_components.dart';
23+
24+
/// Dialog to approve or cancel user actions.
25+
class ActionApprovalDialog extends StatelessWidget {
26+
final String actionLabel;
27+
final VoidCallback onActionPressed;
28+
final String title;
29+
final String? bodyText;
30+
31+
const ActionApprovalDialog({
32+
required this.actionLabel,
33+
required this.onActionPressed,
34+
required this.title,
35+
this.bodyText,
36+
});
37+
38+
@override
39+
Widget build(BuildContext context) {
40+
return Dialog(
41+
backgroundColor: Colors.transparent,
42+
child: OverlayBody(
43+
child: Container(
44+
width: BeamSizes.popupWidth,
45+
padding: const EdgeInsets.all(BeamSizes.size16),
46+
child: SingleChildScrollView(
47+
child: Column(
48+
crossAxisAlignment: CrossAxisAlignment.start,
49+
mainAxisSize: MainAxisSize.min,
50+
children: [
51+
Text(
52+
title,
53+
style: Theme.of(context).textTheme.headlineMedium,
54+
),
55+
if (bodyText != null)
56+
Padding(
57+
padding: const EdgeInsets.only(top: BeamSizes.size8),
58+
child: Text(bodyText!),
59+
),
60+
const SizedBox(height: BeamSizes.size8),
61+
Row(
62+
mainAxisAlignment: MainAxisAlignment.end,
63+
children: [
64+
TextButton(
65+
onPressed: () {
66+
Navigator.pop(context);
67+
},
68+
child: const Text('dialogs.cancel').tr(),
69+
),
70+
const SizedBox(width: BeamSizes.size8),
71+
TextButton(
72+
onPressed: onActionPressed,
73+
child: Text(actionLabel),
74+
),
75+
],
76+
),
77+
],
78+
),
79+
),
80+
),
81+
),
82+
);
83+
}
84+
}

playground/frontend/playground_components/lib/src/widgets/dialogs/alert_dialog.dart

Lines changed: 0 additions & 81 deletions
This file was deleted.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import 'package:flutter/material.dart';
2020

2121
import '../../../playground_components.dart';
2222

23+
/// Shows different types of overlays.
2324
class BeamOverlays {
25+
/// Undismissable overlay of a progress indicator.
2426
static Future<void> showProgressOverlay(
2527
BuildContext context,
2628
Future Function() future,

0 commit comments

Comments
 (0)