Browse Source

neon: Add reset settings buttons

pull/48/head
jld3103 2 years ago
parent
commit
755d6aedd0
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 24
      packages/neon/lib/l10n/en.arb
  2. 24
      packages/neon/lib/l10n/localizations.dart
  3. 18
      packages/neon/lib/l10n/localizations_en.dart
  4. 6
      packages/neon/lib/src/models/account.dart
  5. 19
      packages/neon/lib/src/pages/settings/account_specific_settings.dart
  6. 15
      packages/neon/lib/src/pages/settings/nextcloud_app_specific_settings.dart
  7. 18
      packages/neon/lib/src/pages/settings/settings.dart
  8. 6
      packages/neon/lib/src/utils/global_options.dart
  9. 6
      packages/neon/lib/src/utils/nextcloud_app_specific_options.dart

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

@ -52,29 +52,19 @@
"exit": "Exit", "exit": "Exit",
"disabled": "Disabled", "disabled": "Disabled",
"settings": "Settings", "settings": "Settings",
"settingsForApp": "Settings - {name}", "settingsApps": "Apps",
"@settingsForApp": { "settingsExport": "Export settings",
"settingsImport": "Import settings",
"settingsImportWrongFileExtension": "Settings import has wrong file extension (has to be .json.base64)",
"settingsResetAllConfirmation": "Do you want to reset all settings?",
"settingsResetForConfirmation": "Do you want to reset all settings for {name}?",
"@settingsResetForConfirmation": {
"placeholders": { "placeholders": {
"name": { "name": {
"type": "String" "type": "String"
} }
} }
}, },
"settingsForAccount": "Settings - {username}@{host}",
"@settingsForAccount": {
"placeholders": {
"username": {
"type": "String"
},
"host": {
"type": "String"
}
}
},
"settingsApps": "Apps",
"settingsExport": "Export settings",
"settingsImport": "Import settings",
"settingsImportWrongFileExtension": "Settings import has wrong file extension (has to be .json.base64)",
"optionsCategoryGeneral": "General", "optionsCategoryGeneral": "General",
"optionsCategoryTheme": "Theme", "optionsCategoryTheme": "Theme",
"optionsCategoryPushNotifications": "Push notifications", "optionsCategoryPushNotifications": "Push notifications",

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

@ -275,18 +275,6 @@ abstract class AppLocalizations {
/// **'Settings'** /// **'Settings'**
String get settings; String get settings;
/// No description provided for @settingsForApp.
///
/// In en, this message translates to:
/// **'Settings - {name}'**
String settingsForApp(String name);
/// No description provided for @settingsForAccount.
///
/// In en, this message translates to:
/// **'Settings - {username}@{host}'**
String settingsForAccount(String username, String host);
/// No description provided for @settingsApps. /// No description provided for @settingsApps.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
@ -311,6 +299,18 @@ abstract class AppLocalizations {
/// **'Settings import has wrong file extension (has to be .json.base64)'** /// **'Settings import has wrong file extension (has to be .json.base64)'**
String get settingsImportWrongFileExtension; String get settingsImportWrongFileExtension;
/// No description provided for @settingsResetAllConfirmation.
///
/// In en, this message translates to:
/// **'Do you want to reset all settings?'**
String get settingsResetAllConfirmation;
/// No description provided for @settingsResetForConfirmation.
///
/// In en, this message translates to:
/// **'Do you want to reset all settings for {name}?'**
String settingsResetForConfirmation(String name);
/// No description provided for @optionsCategoryGeneral. /// No description provided for @optionsCategoryGeneral.
/// ///
/// In en, this message translates to: /// In en, this message translates to:

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

@ -106,16 +106,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get settings => 'Settings'; String get settings => 'Settings';
@override
String settingsForApp(String name) {
return 'Settings - $name';
}
@override
String settingsForAccount(String username, String host) {
return 'Settings - $username@$host';
}
@override @override
String get settingsApps => 'Apps'; String get settingsApps => 'Apps';
@ -128,6 +118,14 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get settingsImportWrongFileExtension => 'Settings import has wrong file extension (has to be .json.base64)'; String get settingsImportWrongFileExtension => 'Settings import has wrong file extension (has to be .json.base64)';
@override
String get settingsResetAllConfirmation => 'Do you want to reset all settings?';
@override
String settingsResetForConfirmation(String name) {
return 'Do you want to reset all settings for $name?';
}
@override @override
String get optionsCategoryGeneral => 'General'; String get optionsCategoryGeneral => 'General';

6
packages/neon/lib/src/models/account.dart

@ -102,6 +102,12 @@ class AccountSpecificOptions {
}); });
} }
Future reset() async {
for (final option in options) {
await option.reset();
}
}
void dispose() { void dispose() {
_appIDsSubject.close(); _appIDsSubject.close();
for (final option in options) { for (final option in options) {

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

@ -11,17 +11,26 @@ class AccountSpecificSettingsPage extends StatelessWidget {
final Account account; final Account account;
late final _options = bloc.getOptions(account)!; late final _options = bloc.getOptions(account)!;
late final _name = '${account.username}@${Uri.parse(account.serverURL).host}';
@override @override
Widget build(final BuildContext context) => Scaffold( Widget build(final BuildContext context) => Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: Text( title: Text(_name),
AppLocalizations.of(context).settingsForAccount( actions: [
account.username, IconButton(
Uri.parse(account.serverURL).host, onPressed: () async {
), if (await showConfirmationDialog(
context,
AppLocalizations.of(context).settingsResetForConfirmation(_name),
)) {
await _options.reset();
}
},
icon: const Icon(MdiIcons.cogRefresh),
), ),
],
), ),
body: SettingsList( body: SettingsList(
categories: [ categories: [

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

@ -12,7 +12,20 @@ class NextcloudAppSpecificSettingsPage extends StatelessWidget {
Widget build(final BuildContext context) => Scaffold( Widget build(final BuildContext context) => Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: Text(AppLocalizations.of(context).settingsForApp(appImplementation.name(context))), title: Text(appImplementation.name(context)),
actions: [
IconButton(
onPressed: () async {
if (await showConfirmationDialog(
context,
AppLocalizations.of(context).settingsResetForConfirmation(appImplementation.name(context)),
)) {
await appImplementation.options.reset();
}
},
icon: const Icon(MdiIcons.cogRefresh),
),
],
), ),
body: SettingsList( body: SettingsList(
categories: [ categories: [

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

@ -19,6 +19,24 @@ class _SettingsPageState extends State<SettingsPage> {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: Text(AppLocalizations.of(context).settings), title: Text(AppLocalizations.of(context).settings),
actions: [
IconButton(
onPressed: () async {
if (await showConfirmationDialog(context, AppLocalizations.of(context).settingsResetAllConfirmation)) {
await globalOptions.reset();
for (final appImplementation in appImplementations) {
await appImplementation.options.reset();
}
for (final account in accountsBloc.accounts.value) {
await accountsBloc.getOptions(account)!.reset();
}
}
},
icon: const Icon(MdiIcons.cogRefresh),
),
],
), ),
body: RxBlocBuilder<AccountsBloc, List<Account>>( body: RxBlocBuilder<AccountsBloc, List<Account>>(
bloc: accountsBloc, bloc: accountsBloc,

6
packages/neon/lib/src/utils/global_options.dart

@ -64,6 +64,12 @@ class GlobalOptions {
lastAccount, lastAccount,
]; ];
Future reset() async {
for (final option in options) {
await option.reset();
}
}
void dispose() { void dispose() {
_accountsIDsSubject.close(); _accountsIDsSubject.close();
_themeOLEDAsDarkEnabledSubject.close(); _themeOLEDAsDarkEnabledSubject.close();

6
packages/neon/lib/src/utils/nextcloud_app_specific_options.dart

@ -7,6 +7,12 @@ abstract class NextcloudAppSpecificOptions {
late final List<OptionsCategory> categories; late final List<OptionsCategory> categories;
late final List<Option> options; late final List<Option> options;
Future reset() async {
for (final option in options) {
await option.reset();
}
}
void dispose() { void dispose() {
for (final option in options) { for (final option in options) {
option.dispose(); option.dispose();

Loading…
Cancel
Save