From 9a4b61aff32583e1a01b7343af22b7078e31cb30 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 26 Apr 2020 14:20:44 +0200 Subject: [PATCH] Update the "allowEveryoneToAddMembers" settings --- lib/helpers/conversations_helper.dart | 1 + .../screens/update_conversation_screen.dart | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/helpers/conversations_helper.dart b/lib/helpers/conversations_helper.dart index 3053f41..9b4ce2b 100644 --- a/lib/helpers/conversations_helper.dart +++ b/lib/helpers/conversations_helper.dart @@ -58,6 +58,7 @@ class ConversationsHelper { if (settings.isOwner) { request.addString("name", settings.hasName ? settings.name : "false"); request.addString("members", settings.members.join(",")); + request.addBool("canEveryoneAddMembers", settings.canEveryoneAddMembers); } final response = await request.exec(); diff --git a/lib/ui/screens/update_conversation_screen.dart b/lib/ui/screens/update_conversation_screen.dart index 101f492..39f5757 100644 --- a/lib/ui/screens/update_conversation_screen.dart +++ b/lib/ui/screens/update_conversation_screen.dart @@ -46,6 +46,7 @@ class _UpdateConversationScreen extends State { _nameController.text = widget.initialSettings.name; _members = widget.initialUsers; _followConversation = widget.initialSettings.following; + _canEveryoneAddMembers = widget.initialSettings.canEveryoneAddMembers; } } @@ -108,7 +109,7 @@ class _UpdateConversationScreen extends State { // Follow conversation ? Row( children: [ - Switch( + Switch.adaptive( value: _followConversation, onChanged: (b) => setState(() { _followConversation = b; @@ -118,6 +119,21 @@ class _UpdateConversationScreen extends State { ], ), + // Allow every members of the conversation to add users ? + Row( + children: [ + Switch.adaptive( + value: _canEveryoneAddMembers, + onChanged: isOwner + ? (b) => setState(() { + _canEveryoneAddMembers = b; + }) + : null, + ), + Text(tr("Allow all members of the conversation to add users")) + ], + ), + // Submit button RaisedButton( onPressed: _members.length < 1 ? null : _submitForm, @@ -160,8 +176,7 @@ class _UpdateConversationScreen extends State { if (isUpdating) error = !(await ConversationsHelper().updateConversation(settings)); else { - conversationID = - await ConversationsHelper().createConversation(settings); + conversationID = await ConversationsHelper().createConversation(settings); if (conversationID < 1) error = true; }