mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Update conversation settings
This commit is contained in:
parent
1d0609f66e
commit
661475dec7
@ -3,7 +3,6 @@ import 'package:comunic/helpers/users_helper.dart';
|
|||||||
import 'package:comunic/lists/users_list.dart';
|
import 'package:comunic/lists/users_list.dart';
|
||||||
import 'package:comunic/models/conversation.dart';
|
import 'package:comunic/models/conversation.dart';
|
||||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||||
import 'package:comunic/ui/routes/update_conversation_route.dart';
|
|
||||||
import 'package:comunic/ui/screens/conversation_screen.dart';
|
import 'package:comunic/ui/screens/conversation_screen.dart';
|
||||||
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/conversation_image_widget.dart';
|
import 'package:comunic/ui/widgets/conversation_image_widget.dart';
|
||||||
@ -65,13 +64,8 @@ class _ConversationRouteState extends SafeState<ConversationRoute> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _openSettings() {
|
void _openSettings() =>
|
||||||
MainController.of(context).push(
|
MainController.of(context).openConversationSettingsRoute(_conversation);
|
||||||
UpdateConversationRoute(
|
|
||||||
conversationID: widget.conversationID,
|
|
||||||
),
|
|
||||||
hideNavBar: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildRouteBody() {
|
Widget _buildRouteBody() {
|
||||||
//Handle errors
|
//Handle errors
|
||||||
|
@ -5,6 +5,7 @@ import 'package:comunic/ui/routes/conversation_message_stats_route.dart';
|
|||||||
import 'package:comunic/ui/routes/conversation_route.dart';
|
import 'package:comunic/ui/routes/conversation_route.dart';
|
||||||
import 'package:comunic/ui/routes/main_route/page_info.dart';
|
import 'package:comunic/ui/routes/main_route/page_info.dart';
|
||||||
import 'package:comunic/ui/routes/settings/account_settings_route.dart';
|
import 'package:comunic/ui/routes/settings/account_settings_route.dart';
|
||||||
|
import 'package:comunic/ui/routes/update_conversation_route.dart';
|
||||||
import 'package:comunic/ui/screens/call_screen.dart';
|
import 'package:comunic/ui/screens/call_screen.dart';
|
||||||
import 'package:comunic/ui/screens/conversations_list_screen.dart';
|
import 'package:comunic/ui/screens/conversations_list_screen.dart';
|
||||||
import 'package:comunic/ui/screens/friends_list_screen.dart';
|
import 'package:comunic/ui/screens/friends_list_screen.dart';
|
||||||
@ -169,6 +170,15 @@ abstract class MainController extends State<MainRoute> {
|
|||||||
hideNavBar: true,
|
hideNavBar: true,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
/// Open conversation settings route
|
||||||
|
void openConversationSettingsRoute(Conversation conv) => pushPage(PageInfo(
|
||||||
|
child: UpdateConversationRoute(
|
||||||
|
conversationID: conv.id,
|
||||||
|
),
|
||||||
|
canShowAsDialog: true,
|
||||||
|
hideNavBar: true,
|
||||||
|
));
|
||||||
|
|
||||||
/// Open a conversation message statistics page
|
/// Open a conversation message statistics page
|
||||||
void openConversationMessageStats(
|
void openConversationMessageStats(
|
||||||
Conversation conv, ConversationMessage message) =>
|
Conversation conv, ConversationMessage message) =>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:comunic/models/advanced_group_info.dart';
|
import 'package:comunic/models/advanced_group_info.dart';
|
||||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||||
import 'package:comunic/ui/screens/conversation_screen.dart';
|
|
||||||
import 'package:comunic/ui/screens/group_sections/about_group_section.dart';
|
import 'package:comunic/ui/screens/group_sections/about_group_section.dart';
|
||||||
|
import 'package:comunic/ui/screens/group_sections/group_conversation_section.dart';
|
||||||
import 'package:comunic/ui/screens/group_sections/group_members_screen.dart';
|
import 'package:comunic/ui/screens/group_sections/group_members_screen.dart';
|
||||||
import 'package:comunic/ui/screens/group_sections/group_posts_section.dart';
|
import 'package:comunic/ui/screens/group_sections/group_posts_section.dart';
|
||||||
import 'package:comunic/ui/screens/group_settings_screen.dart';
|
import 'package:comunic/ui/screens/group_settings_screen.dart';
|
||||||
@ -75,9 +75,7 @@ class _AuthorizedGroupPageScreenState
|
|||||||
1,
|
1,
|
||||||
_group.conversations
|
_group.conversations
|
||||||
.map((e) => _GroupPageTab(
|
.map((e) => _GroupPageTab(
|
||||||
widget: (c) => ConversationScreen(
|
widget: (c) => GroupConversationSection(conv: e),
|
||||||
conversationID: e.id,
|
|
||||||
),
|
|
||||||
label: e.name))
|
label: e.name))
|
||||||
.toList());
|
.toList());
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import 'package:comunic/lists/groups_list.dart';
|
|||||||
import 'package:comunic/lists/users_list.dart';
|
import 'package:comunic/lists/users_list.dart';
|
||||||
import 'package:comunic/models/conversation.dart';
|
import 'package:comunic/models/conversation.dart';
|
||||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||||
import 'package:comunic/ui/routes/update_conversation_route.dart';
|
|
||||||
import 'package:comunic/ui/screens/create_conversation_screen.dart';
|
import 'package:comunic/ui/screens/create_conversation_screen.dart';
|
||||||
import 'package:comunic/ui/tiles/conversation_tile.dart';
|
import 'package:comunic/ui/tiles/conversation_tile.dart';
|
||||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||||
@ -122,11 +121,7 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
|||||||
|
|
||||||
/// Handle conversations updated requests
|
/// Handle conversations updated requests
|
||||||
void _updateConversation(Conversation conversation) {
|
void _updateConversation(Conversation conversation) {
|
||||||
MainController.of(context).push(
|
MainController.of(context).openConversationSettingsRoute(conversation);
|
||||||
UpdateConversationRoute(
|
|
||||||
conversationID: conversation.id,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle conversation deletion request
|
/// Handle conversation deletion request
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:comunic/models/conversation.dart';
|
||||||
|
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../conversation_screen.dart';
|
||||||
|
|
||||||
|
/// Group conversation section
|
||||||
|
///
|
||||||
|
/// @author Pierre Hubert
|
||||||
|
|
||||||
|
class GroupConversationSection extends StatelessWidget {
|
||||||
|
final Conversation conv;
|
||||||
|
|
||||||
|
const GroupConversationSection({
|
||||||
|
Key key,
|
||||||
|
@required this.conv,
|
||||||
|
}) : assert(conv != null),
|
||||||
|
super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => Stack(
|
||||||
|
children: [
|
||||||
|
ConversationScreen(
|
||||||
|
conversationID: conv.id,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 1.0,
|
||||||
|
child: IconButton(
|
||||||
|
icon: Icon(Icons.settings),
|
||||||
|
onPressed: () => MainController.of(context)
|
||||||
|
.openConversationSettingsRoute(conv),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
@ -68,6 +68,9 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
|||||||
|
|
||||||
get isAdmin => !isUpdating || _conversation.isAdmin;
|
get isAdmin => !isUpdating || _conversation.isAdmin;
|
||||||
|
|
||||||
|
bool get _isGroupConversation =>
|
||||||
|
isUpdating && _conversation.isGroupConversation;
|
||||||
|
|
||||||
bool get _canAddMembers =>
|
bool get _canAddMembers =>
|
||||||
(isAdmin || _conversation.canEveryoneAddMembers) &&
|
(isAdmin || _conversation.canEveryoneAddMembers) &&
|
||||||
(!isUpdating || !_conversation.isManaged);
|
(!isUpdating || !_conversation.isManaged);
|
||||||
@ -122,6 +125,10 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
|||||||
padding: EdgeInsets.all(8.0),
|
padding: EdgeInsets.all(8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
_isGroupConversation
|
||||||
|
? Text(tr("This conversation is managed by a group"))
|
||||||
|
: Container(),
|
||||||
|
|
||||||
// Conversation name
|
// Conversation name
|
||||||
TextField(
|
TextField(
|
||||||
controller: _nameController,
|
controller: _nameController,
|
||||||
@ -161,21 +168,23 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
// Allow every members of the conversation to add users ?
|
// Allow every members of the conversation to add users ?
|
||||||
Row(
|
_isGroupConversation
|
||||||
children: <Widget>[
|
? Container()
|
||||||
Switch.adaptive(
|
: Row(
|
||||||
value: _canEveryoneAddMembers,
|
children: <Widget>[
|
||||||
onChanged: isAdmin
|
Switch.adaptive(
|
||||||
? (b) => setState(() {
|
value: _canEveryoneAddMembers,
|
||||||
_canEveryoneAddMembers = b;
|
onChanged: isAdmin
|
||||||
})
|
? (b) => setState(() {
|
||||||
: null,
|
_canEveryoneAddMembers = b;
|
||||||
),
|
})
|
||||||
Flexible(
|
: null,
|
||||||
child: Text(tr(
|
),
|
||||||
"Allow all members of the conversation to add users")))
|
Flexible(
|
||||||
],
|
child: Text(tr(
|
||||||
),
|
"Allow all members of the conversation to add users")))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
// Add a member to the conversation
|
// Add a member to the conversation
|
||||||
PickUserWidget(
|
PickUserWidget(
|
||||||
|
Loading…
Reference in New Issue
Block a user