diff --git a/packages/neon/lib/l10n/en.arb b/packages/neon/lib/l10n/en.arb index 0cd3eb6d..a696c27c 100644 --- a/packages/neon/lib/l10n/en.arb +++ b/packages/neon/lib/l10n/en.arb @@ -52,29 +52,19 @@ "exit": "Exit", "disabled": "Disabled", "settings": "Settings", - "settingsForApp": "Settings - {name}", - "@settingsForApp": { + "settingsApps": "Apps", + "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": { "name": { "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", "optionsCategoryTheme": "Theme", "optionsCategoryPushNotifications": "Push notifications", diff --git a/packages/neon/lib/l10n/localizations.dart b/packages/neon/lib/l10n/localizations.dart index 6d0e6e6d..ee0d8279 100644 --- a/packages/neon/lib/l10n/localizations.dart +++ b/packages/neon/lib/l10n/localizations.dart @@ -275,18 +275,6 @@ abstract class AppLocalizations { /// **'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. /// /// In en, this message translates to: @@ -311,6 +299,18 @@ abstract class AppLocalizations { /// **'Settings import has wrong file extension (has to be .json.base64)'** 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. /// /// In en, this message translates to: diff --git a/packages/neon/lib/l10n/localizations_en.dart b/packages/neon/lib/l10n/localizations_en.dart index be09b25f..5ae52801 100644 --- a/packages/neon/lib/l10n/localizations_en.dart +++ b/packages/neon/lib/l10n/localizations_en.dart @@ -106,16 +106,6 @@ class AppLocalizationsEn extends AppLocalizations { @override String get settings => 'Settings'; - @override - String settingsForApp(String name) { - return 'Settings - $name'; - } - - @override - String settingsForAccount(String username, String host) { - return 'Settings - $username@$host'; - } - @override String get settingsApps => 'Apps'; @@ -128,6 +118,14 @@ class AppLocalizationsEn extends AppLocalizations { @override 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 String get optionsCategoryGeneral => 'General'; diff --git a/packages/neon/lib/src/models/account.dart b/packages/neon/lib/src/models/account.dart index a5981028..54ca1090 100644 --- a/packages/neon/lib/src/models/account.dart +++ b/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() { _appIDsSubject.close(); for (final option in options) { diff --git a/packages/neon/lib/src/pages/settings/account_specific_settings.dart b/packages/neon/lib/src/pages/settings/account_specific_settings.dart index d87036a3..a91ff1a6 100644 --- a/packages/neon/lib/src/pages/settings/account_specific_settings.dart +++ b/packages/neon/lib/src/pages/settings/account_specific_settings.dart @@ -11,17 +11,26 @@ class AccountSpecificSettingsPage extends StatelessWidget { final Account account; late final _options = bloc.getOptions(account)!; + late final _name = '${account.username}@${Uri.parse(account.serverURL).host}'; @override Widget build(final BuildContext context) => Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar( - title: Text( - AppLocalizations.of(context).settingsForAccount( - account.username, - Uri.parse(account.serverURL).host, + title: Text(_name), + actions: [ + IconButton( + onPressed: () async { + if (await showConfirmationDialog( + context, + AppLocalizations.of(context).settingsResetForConfirmation(_name), + )) { + await _options.reset(); + } + }, + icon: const Icon(MdiIcons.cogRefresh), ), - ), + ], ), body: SettingsList( categories: [ diff --git a/packages/neon/lib/src/pages/settings/nextcloud_app_specific_settings.dart b/packages/neon/lib/src/pages/settings/nextcloud_app_specific_settings.dart index 04c085e3..1e5c9b70 100644 --- a/packages/neon/lib/src/pages/settings/nextcloud_app_specific_settings.dart +++ b/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( resizeToAvoidBottomInset: false, 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( categories: [ diff --git a/packages/neon/lib/src/pages/settings/settings.dart b/packages/neon/lib/src/pages/settings/settings.dart index fcb40bd2..9b59c1b7 100644 --- a/packages/neon/lib/src/pages/settings/settings.dart +++ b/packages/neon/lib/src/pages/settings/settings.dart @@ -19,6 +19,24 @@ class _SettingsPageState extends State { resizeToAvoidBottomInset: false, appBar: AppBar( 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>( bloc: accountsBloc, diff --git a/packages/neon/lib/src/utils/global_options.dart b/packages/neon/lib/src/utils/global_options.dart index 75a9f221..9bf6724b 100644 --- a/packages/neon/lib/src/utils/global_options.dart +++ b/packages/neon/lib/src/utils/global_options.dart @@ -64,6 +64,12 @@ class GlobalOptions { lastAccount, ]; + Future reset() async { + for (final option in options) { + await option.reset(); + } + } + void dispose() { _accountsIDsSubject.close(); _themeOLEDAsDarkEnabledSubject.close(); diff --git a/packages/neon/lib/src/utils/nextcloud_app_specific_options.dart b/packages/neon/lib/src/utils/nextcloud_app_specific_options.dart index 5953f3d6..cb55a9f7 100644 --- a/packages/neon/lib/src/utils/nextcloud_app_specific_options.dart +++ b/packages/neon/lib/src/utils/nextcloud_app_specific_options.dart @@ -7,6 +7,12 @@ abstract class NextcloudAppSpecificOptions { late final List categories; late final List