From f450a46e993993ad1e17cbeeb9cfeeef8a365a0f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 1 May 2020 21:13:31 +0200 Subject: [PATCH] Can change group posts creation level --- lib/models/group.dart | 2 +- lib/ui/screens/group_settings_screen.dart | 28 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/models/group.dart b/lib/models/group.dart index cf28c01..aac3026 100644 --- a/lib/models/group.dart +++ b/lib/models/group.dart @@ -27,7 +27,7 @@ class Group { GroupMembershipLevel membershipLevel; GroupVisibilityLevel visibilityLevel; GroupRegistrationLevel registrationLevel; - final GroupPostCreationLevel postCreationLevel; + GroupPostCreationLevel postCreationLevel; String virtualDirectory; bool following; diff --git a/lib/ui/screens/group_settings_screen.dart b/lib/ui/screens/group_settings_screen.dart index 5f2a6d2..3af5a5f 100644 --- a/lib/ui/screens/group_settings_screen.dart +++ b/lib/ui/screens/group_settings_screen.dart @@ -184,9 +184,25 @@ class _GroupSettingsScreenState extends SafeState { ), ]; + List> get _postsCreationLevels => [ + MultiChoiceEntry( + id: GroupPostCreationLevel.MEMBERS, + title: tr("All members"), + subtitle: + tr("All the members of the group can create posts on the group"), + ), + MultiChoiceEntry( + id: GroupPostCreationLevel.MODERATORS, + title: tr("Moderators only"), + subtitle: tr( + "Only moderators and administrators of the group can create posts on it"), + ), + ]; + Widget _buildAccessRestrictions() => SettingsSection( title: tr("Access restrictions"), tiles: [ + // Group visibility MultiChoicesSettingsTile( title: tr("Group visibility"), choices: _visibilityLevels, @@ -195,6 +211,8 @@ class _GroupSettingsScreenState extends SafeState { _groupSettings.visibilityLevel = v; _updateSettings(); }), + + // Group registration level MultiChoicesSettingsTile( title: tr("Group registration level"), choices: _registrationLevels, @@ -203,6 +221,16 @@ class _GroupSettingsScreenState extends SafeState { _groupSettings.registrationLevel = v; _updateSettings(); }), + + // Group posts creation levels + MultiChoicesSettingsTile( + title: tr("Posts creation level"), + choices: _postsCreationLevels, + currentValue: _groupSettings.postCreationLevel, + onChanged: (s) { + _groupSettings.postCreationLevel = s; + _updateSettings(); + }), ], ); }