From dbf2ed868a7b7f0af2414b1a6cc8679b140afbc3 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 1 May 2020 20:55:24 +0200 Subject: [PATCH] Simplify code --- .../general_account_settings.dart | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/lib/ui/routes/account_settings/general_account_settings.dart b/lib/ui/routes/account_settings/general_account_settings.dart index 60d2116..b5180af 100644 --- a/lib/ui/routes/account_settings/general_account_settings.dart +++ b/lib/ui/routes/account_settings/general_account_settings.dart @@ -5,6 +5,7 @@ import 'package:comunic/models/general_settings.dart'; import 'package:comunic/ui/dialogs/multi_choices_dialog.dart'; import 'package:comunic/ui/dialogs/virtual_directory_dialog.dart'; import 'package:comunic/ui/widgets/async_screen_widget.dart'; +import 'package:comunic/ui/widgets/settings/multi_choices_settings_tile.dart'; import 'package:comunic/ui/widgets/settings/text_settings_edit_tile.dart'; import 'package:comunic/utils/account_utils.dart'; import 'package:comunic/utils/input_utils.dart'; @@ -141,25 +142,14 @@ class __GeneralAccountSettingsBodyState List _pageSettingsTiles() { return [ // Page visibility - SettingsTile( - title: tr("Page visibility"), - subtitle: _visibilityChoices - .firstWhere((f) => f.id == _settings.pageVisibility) - .subtitle, - onTap: () async { - final choice = await showMultiChoicesDialog( - context: context, - choices: _visibilityChoices, - defaultChoice: _settings.pageVisibility, - title: tr("Change your page visibility"), - ); - - if (choice == null) return; - - _settings.pageVisibility = choice; - _updateSettings(); - }, - ), + MultiChoicesSettingsTile( + title: tr("Page visibility"), + choices: _visibilityChoices, + currentValue: _settings.pageVisibility, + onChanged: (v) { + _settings.pageVisibility = v; + _updateSettings(); + }), // Allow comments on user page ? SettingsTile.switchTile(