Skip to content

Commit ca0bf3c

Browse files
committed
feat(neon,neon_news,neon_files,neon_notes,neon_notifications): make dialog adaptive
Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
1 parent 20c0146 commit ca0bf3c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1437
-770
lines changed

packages/neon/neon/lib/l10n/en.arb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@
7777
}
7878
}
7979
},
80+
"errorDialog": "An error has occurred",
8081
"actionYes": "Yes",
8182
"actionNo": "No",
8283
"actionClose": "Close",
8384
"actionRetry": "Retry",
8485
"actionShowSlashHide": "Show/Hide",
8586
"actionExit": "Exit",
8687
"actionContinue": "Continue",
88+
"actionCancel": "Cancel",
8789
"firstLaunchGoToSettingsToEnablePushNotifications": "Go to the settings to enable push notifications",
8890
"nextPushSupported": "NextPush is supported!",
8991
"nextPushSupportedText": "NextPush is a FOSS way of receiving push notifications using the UnifiedPush protocol via a Nextcloud instance.\nYou can install NextPush from the F-Droid app store.",
@@ -97,9 +99,11 @@
9799
"settingsAccountManage": "Manage accounts",
98100
"settingsExport": "Export settings",
99101
"settingsImport": "Import settings",
102+
"settingsReset": "Reset settings?",
100103
"settingsImportWrongFileExtension": "Settings import has wrong file extension (has to be .json.base64)",
101104
"settingsResetAll": "Reset all settings",
102105
"settingsResetAllConfirmation": "Do you want to reset all settings?",
106+
"settingsResetAllExplanation": "This will reset all preferences back to their default settings.",
103107
"settingsResetFor": "Reset all settings for {name}",
104108
"@settingsResetFor": {
105109
"placeholders": {
@@ -108,6 +112,8 @@
108112
}
109113
}
110114
},
115+
"settingsResetForExplanation": "This will reset your account preferences back to their default settings.",
116+
"settingsResetForClientExplanation": "This will reset all preferences for the app back to their default settings.",
111117
"settingsResetForConfirmation": "Do you want to reset all settings for {name}?",
112118
"@settingsResetForConfirmation": {
113119
"placeholders": {

packages/neon/neon/lib/l10n/localizations.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ abstract class NeonLocalizations {
269269
/// **'Route not found: {route}'**
270270
String errorRouteNotFound(String route);
271271

272+
/// No description provided for @errorDialog.
273+
///
274+
/// In en, this message translates to:
275+
/// **'An error has occurred'**
276+
String get errorDialog;
277+
272278
/// No description provided for @actionYes.
273279
///
274280
/// In en, this message translates to:
@@ -311,6 +317,12 @@ abstract class NeonLocalizations {
311317
/// **'Continue'**
312318
String get actionContinue;
313319

320+
/// No description provided for @actionCancel.
321+
///
322+
/// In en, this message translates to:
323+
/// **'Cancel'**
324+
String get actionCancel;
325+
314326
/// No description provided for @firstLaunchGoToSettingsToEnablePushNotifications.
315327
///
316328
/// In en, this message translates to:
@@ -389,6 +401,12 @@ abstract class NeonLocalizations {
389401
/// **'Import settings'**
390402
String get settingsImport;
391403

404+
/// No description provided for @settingsReset.
405+
///
406+
/// In en, this message translates to:
407+
/// **'Reset settings?'**
408+
String get settingsReset;
409+
392410
/// No description provided for @settingsImportWrongFileExtension.
393411
///
394412
/// In en, this message translates to:
@@ -407,12 +425,30 @@ abstract class NeonLocalizations {
407425
/// **'Do you want to reset all settings?'**
408426
String get settingsResetAllConfirmation;
409427

428+
/// No description provided for @settingsResetAllExplanation.
429+
///
430+
/// In en, this message translates to:
431+
/// **'This will reset all preferences back to their default settings.'**
432+
String get settingsResetAllExplanation;
433+
410434
/// No description provided for @settingsResetFor.
411435
///
412436
/// In en, this message translates to:
413437
/// **'Reset all settings for {name}'**
414438
String settingsResetFor(String name);
415439

440+
/// No description provided for @settingsResetForExplanation.
441+
///
442+
/// In en, this message translates to:
443+
/// **'This will reset your account preferences back to their default settings.'**
444+
String get settingsResetForExplanation;
445+
446+
/// No description provided for @settingsResetForClientExplanation.
447+
///
448+
/// In en, this message translates to:
449+
/// **'This will reset all preferences for the app back to their default settings.'**
450+
String get settingsResetForClientExplanation;
451+
416452
/// No description provided for @settingsResetForConfirmation.
417453
///
418454
/// In en, this message translates to:

packages/neon/neon/lib/l10n/localizations_en.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ class NeonLocalizationsEn extends NeonLocalizations {
126126
return 'Route not found: $route';
127127
}
128128

129+
@override
130+
String get errorDialog => 'An error has occurred';
131+
129132
@override
130133
String get actionYes => 'Yes';
131134

@@ -147,6 +150,9 @@ class NeonLocalizationsEn extends NeonLocalizations {
147150
@override
148151
String get actionContinue => 'Continue';
149152

153+
@override
154+
String get actionCancel => 'Cancel';
155+
150156
@override
151157
String get firstLaunchGoToSettingsToEnablePushNotifications => 'Go to the settings to enable push notifications';
152158

@@ -187,6 +193,9 @@ class NeonLocalizationsEn extends NeonLocalizations {
187193
@override
188194
String get settingsImport => 'Import settings';
189195

196+
@override
197+
String get settingsReset => 'Reset settings?';
198+
190199
@override
191200
String get settingsImportWrongFileExtension => 'Settings import has wrong file extension (has to be .json.base64)';
192201

@@ -196,11 +205,21 @@ class NeonLocalizationsEn extends NeonLocalizations {
196205
@override
197206
String get settingsResetAllConfirmation => 'Do you want to reset all settings?';
198207

208+
@override
209+
String get settingsResetAllExplanation => 'This will reset all preferences back to their default settings.';
210+
199211
@override
200212
String settingsResetFor(String name) {
201213
return 'Reset all settings for $name';
202214
}
203215

216+
@override
217+
String get settingsResetForExplanation => 'This will reset your account preferences back to their default settings.';
218+
219+
@override
220+
String get settingsResetForClientExplanation =>
221+
'This will reset all preferences for the app back to their default settings.';
222+
204223
@override
205224
String settingsResetForConfirmation(String name) {
206225
return 'Do you want to reset all settings for $name?';

packages/neon/neon/lib/src/pages/account_settings.dart

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'package:neon/src/settings/widgets/settings_category.dart';
1313
import 'package:neon/src/settings/widgets/settings_list.dart';
1414
import 'package:neon/src/theme/dialog.dart';
1515
import 'package:neon/src/utils/adaptive.dart';
16-
import 'package:neon/src/utils/dialog.dart';
16+
import 'package:neon/src/widgets/dialog.dart';
1717
import 'package:neon/src/widgets/error.dart';
1818
import 'package:nextcloud/provisioning_api.dart' as provisioning_api;
1919

@@ -46,15 +46,23 @@ class AccountSettingsPage extends StatelessWidget {
4646
actions: [
4747
IconButton(
4848
onPressed: () async {
49-
if (await showConfirmationDialog(
50-
context,
51-
NeonLocalizations.of(context).accountOptionsRemoveConfirm(account.humanReadableID),
52-
)) {
49+
final decision = await showAdaptiveDialog<bool>(
50+
context: context,
51+
builder: (final context) => NeonConfirmationDialog(
52+
icon: const Icon(Icons.logout),
53+
title: NeonLocalizations.of(context).accountOptionsRemove,
54+
content: Text(
55+
NeonLocalizations.of(context).accountOptionsRemoveConfirm(account.humanReadableID),
56+
),
57+
),
58+
);
59+
60+
if (decision ?? false) {
5361
final isActive = bloc.activeAccount.valueOrNull == account;
5462

63+
options.reset();
5564
bloc.removeAccount(account);
5665

57-
// ignore: use_build_context_synchronously
5866
if (!context.mounted) {
5967
return;
6068
}
@@ -71,10 +79,18 @@ class AccountSettingsPage extends StatelessWidget {
7179
),
7280
IconButton(
7381
onPressed: () async {
74-
if (await showConfirmationDialog(
75-
context,
76-
NeonLocalizations.of(context).settingsResetForConfirmation(name),
77-
)) {
82+
final content =
83+
'${NeonLocalizations.of(context).settingsResetForConfirmation(name)} ${NeonLocalizations.of(context).settingsResetForExplanation}';
84+
final decision = await showAdaptiveDialog<bool>(
85+
context: context,
86+
builder: (final context) => NeonConfirmationDialog(
87+
icon: const Icon(Icons.restart_alt),
88+
title: NeonLocalizations.of(context).settingsReset,
89+
content: Text(content),
90+
),
91+
);
92+
93+
if (decision ?? false) {
7894
options.reset();
7995
}
8096
},

packages/neon/neon/lib/src/pages/home.dart

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'dart:async';
22

33
import 'package:flutter/material.dart';
44
import 'package:meta/meta.dart';
5-
import 'package:neon/l10n/localizations.dart';
65
import 'package:neon/src/bloc/result.dart';
76
import 'package:neon/src/blocs/accounts.dart';
87
import 'package:neon/src/blocs/apps.dart';
@@ -11,11 +10,11 @@ import 'package:neon/src/models/app_implementation.dart';
1110
import 'package:neon/src/utils/global_options.dart';
1211
import 'package:neon/src/utils/global_options.dart' as global_options;
1312
import 'package:neon/src/utils/global_popups.dart';
14-
import 'package:neon/src/utils/provider.dart';
1513
import 'package:neon/src/widgets/app_bar.dart';
1614
import 'package:neon/src/widgets/drawer.dart';
1715
import 'package:neon/src/widgets/error.dart';
1816
import 'package:neon/src/widgets/unified_search_results.dart';
17+
import 'package:neon/utils.dart';
1918
import 'package:nextcloud/core.dart' as core;
2019
import 'package:provider/provider.dart';
2120

@@ -68,7 +67,7 @@ class _HomePageState extends State<HomePage> {
6867
}
6968

7069
final message = l10n.errorUnsupportedAppVersions(buffer.toString());
71-
unawaited(_showProblem(message));
70+
unawaited(showErrorDialog(context: context, message: message));
7271
});
7372

7473
GlobalPopups().register(context);
@@ -86,10 +85,10 @@ class _HomePageState extends State<HomePage> {
8685
Future<void> _checkMaintenanceMode() async {
8786
try {
8887
final status = await _account.client.core.getStatus();
88+
8989
if (status.body.maintenance && mounted) {
90-
await _showProblem(
91-
NeonLocalizations.of(context).errorServerInMaintenanceMode,
92-
);
90+
final message = NeonLocalizations.of(context).errorServerInMaintenanceMode;
91+
await showErrorDialog(context: context, message: message);
9392
}
9493
} catch (e, s) {
9594
debugPrint(e.toString());
@@ -100,29 +99,6 @@ class _HomePageState extends State<HomePage> {
10099
}
101100
}
102101

103-
Future<void> _showProblem(final String title) async {
104-
final colorScheme = Theme.of(context).colorScheme;
105-
106-
await showDialog<void>(
107-
context: context,
108-
builder: (final context) => AlertDialog(
109-
title: Text(title),
110-
actions: [
111-
ElevatedButton(
112-
style: ElevatedButton.styleFrom(
113-
backgroundColor: colorScheme.error,
114-
foregroundColor: colorScheme.onError,
115-
),
116-
onPressed: () {
117-
Navigator.of(context).pop();
118-
},
119-
child: Text(NeonLocalizations.of(context).actionClose),
120-
),
121-
],
122-
),
123-
);
124-
}
125-
126102
@override
127103
Widget build(final BuildContext context) {
128104
const drawer = NeonDrawer();

packages/neon/neon/lib/src/pages/nextcloud_app_settings.dart

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:neon/src/settings/widgets/option_settings_tile.dart';
77
import 'package:neon/src/settings/widgets/settings_category.dart';
88
import 'package:neon/src/settings/widgets/settings_list.dart';
99
import 'package:neon/src/theme/dialog.dart';
10-
import 'package:neon/src/utils/dialog.dart';
10+
import 'package:neon/src/widgets/dialog.dart';
1111

1212
@internal
1313
class NextcloudAppSettingsPage extends StatelessWidget {
@@ -25,10 +25,19 @@ class NextcloudAppSettingsPage extends StatelessWidget {
2525
actions: [
2626
IconButton(
2727
onPressed: () async {
28-
if (await showConfirmationDialog(
29-
context,
30-
NeonLocalizations.of(context).settingsResetForConfirmation(appImplementation.name(context)),
31-
)) {
28+
final content =
29+
'${NeonLocalizations.of(context).settingsResetForConfirmation(appImplementation.name(context))} ${NeonLocalizations.of(context).settingsResetForClientExplanation}';
30+
31+
final decision = await showAdaptiveDialog<bool>(
32+
context: context,
33+
builder: (final context) => NeonConfirmationDialog(
34+
icon: const Icon(Icons.restart_alt),
35+
title: NeonLocalizations.of(context).settingsReset,
36+
content: Text(content),
37+
),
38+
);
39+
40+
if (decision ?? false) {
3241
appImplementation.options.reset();
3342
}
3443
},

packages/neon/neon/lib/src/pages/settings.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import 'package:neon/src/settings/widgets/text_settings_tile.dart';
1919
import 'package:neon/src/theme/branding.dart';
2020
import 'package:neon/src/theme/dialog.dart';
2121
import 'package:neon/src/utils/adaptive.dart';
22-
import 'package:neon/src/utils/dialog.dart';
2322
import 'package:neon/src/utils/global_options.dart';
2423
import 'package:neon/src/utils/provider.dart';
2524
import 'package:neon/src/utils/save_file.dart';
25+
import 'package:neon/src/widgets/dialog.dart';
2626
import 'package:neon/src/widgets/error.dart';
2727
import 'package:package_info_plus/package_info_plus.dart';
2828
import 'package:url_launcher/url_launcher_string.dart';
@@ -96,7 +96,18 @@ class _SettingsPageState extends State<SettingsPage> {
9696
actions: [
9797
IconButton(
9898
onPressed: () async {
99-
if (await showConfirmationDialog(context, NeonLocalizations.of(context).settingsResetAllConfirmation)) {
99+
final content =
100+
'${NeonLocalizations.of(context).settingsResetAllConfirmation} ${NeonLocalizations.of(context).settingsResetAllExplanation}';
101+
final decision = await showAdaptiveDialog<bool>(
102+
context: context,
103+
builder: (final context) => NeonConfirmationDialog(
104+
icon: const Icon(Icons.restart_alt),
105+
title: NeonLocalizations.of(context).settingsReset,
106+
content: Text(content),
107+
),
108+
);
109+
110+
if (decision ?? false) {
100111
globalOptions.reset();
101112

102113
for (final appImplementation in appImplementations) {

0 commit comments

Comments
 (0)