mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59: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/models/conversation.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/widgets/comunic_back_button_widget.dart';
|
||||
import 'package:comunic/ui/widgets/conversation_image_widget.dart';
|
||||
@ -65,13 +64,8 @@ class _ConversationRouteState extends SafeState<ConversationRoute> {
|
||||
}
|
||||
}
|
||||
|
||||
void _openSettings() {
|
||||
MainController.of(context).push(
|
||||
UpdateConversationRoute(
|
||||
conversationID: widget.conversationID,
|
||||
),
|
||||
hideNavBar: true);
|
||||
}
|
||||
void _openSettings() =>
|
||||
MainController.of(context).openConversationSettingsRoute(_conversation);
|
||||
|
||||
Widget _buildRouteBody() {
|
||||
//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/main_route/page_info.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/conversations_list_screen.dart';
|
||||
import 'package:comunic/ui/screens/friends_list_screen.dart';
|
||||
@ -169,6 +170,15 @@ abstract class MainController extends State<MainRoute> {
|
||||
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
|
||||
void openConversationMessageStats(
|
||||
Conversation conv, ConversationMessage message) =>
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:comunic/models/advanced_group_info.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/group_conversation_section.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_settings_screen.dart';
|
||||
@ -75,9 +75,7 @@ class _AuthorizedGroupPageScreenState
|
||||
1,
|
||||
_group.conversations
|
||||
.map((e) => _GroupPageTab(
|
||||
widget: (c) => ConversationScreen(
|
||||
conversationID: e.id,
|
||||
),
|
||||
widget: (c) => GroupConversationSection(conv: e),
|
||||
label: e.name))
|
||||
.toList());
|
||||
|
||||
|
@ -8,7 +8,6 @@ import 'package:comunic/lists/groups_list.dart';
|
||||
import 'package:comunic/lists/users_list.dart';
|
||||
import 'package:comunic/models/conversation.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/tiles/conversation_tile.dart';
|
||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||
@ -122,11 +121,7 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
||||
|
||||
/// Handle conversations updated requests
|
||||
void _updateConversation(Conversation conversation) {
|
||||
MainController.of(context).push(
|
||||
UpdateConversationRoute(
|
||||
conversationID: conversation.id,
|
||||
),
|
||||
);
|
||||
MainController.of(context).openConversationSettingsRoute(conversation);
|
||||
}
|
||||
|
||||
/// 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;
|
||||
|
||||
bool get _isGroupConversation =>
|
||||
isUpdating && _conversation.isGroupConversation;
|
||||
|
||||
bool get _canAddMembers =>
|
||||
(isAdmin || _conversation.canEveryoneAddMembers) &&
|
||||
(!isUpdating || !_conversation.isManaged);
|
||||
@ -122,6 +125,10 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
_isGroupConversation
|
||||
? Text(tr("This conversation is managed by a group"))
|
||||
: Container(),
|
||||
|
||||
// Conversation name
|
||||
TextField(
|
||||
controller: _nameController,
|
||||
@ -161,7 +168,9 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
||||
),
|
||||
|
||||
// Allow every members of the conversation to add users ?
|
||||
Row(
|
||||
_isGroupConversation
|
||||
? Container()
|
||||
: Row(
|
||||
children: <Widget>[
|
||||
Switch.adaptive(
|
||||
value: _canEveryoneAddMembers,
|
||||
|
Loading…
Reference in New Issue
Block a user