mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Open conversations in their context
This commit is contained in:
@ -26,11 +26,13 @@ Color get _headerColor => Colors.blueAccent.shade700;
|
||||
|
||||
class AuthorizedGroupPageScreen extends StatefulWidget {
|
||||
final AdvancedGroupInfo advancedGroupInfo;
|
||||
final int conversationID;
|
||||
final Function() needRefresh;
|
||||
|
||||
const AuthorizedGroupPageScreen({
|
||||
Key key,
|
||||
@required this.advancedGroupInfo,
|
||||
@required this.conversationID,
|
||||
@required this.needRefresh,
|
||||
}) : assert(advancedGroupInfo != null),
|
||||
assert(needRefresh != null),
|
||||
@ -83,7 +85,11 @@ class _AuthorizedGroupPageScreenState
|
||||
void initState() {
|
||||
_tabController = TabController(
|
||||
length: _tabs.length,
|
||||
initialIndex: 0,
|
||||
initialIndex: widget.conversationID == null
|
||||
? 0
|
||||
: 1 +
|
||||
_group.conversations
|
||||
.indexWhere((element) => element.id == widget.conversationID),
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
@ -105,7 +111,7 @@ class _AuthorizedGroupPageScreenState
|
||||
Material(
|
||||
color: _headerColor,
|
||||
child: TabBar(
|
||||
isScrollable: true,
|
||||
isScrollable: _tabController.length > 4,
|
||||
tabs: _tabs.map((e) => e.tab).toList(),
|
||||
controller: _tabController,
|
||||
),
|
||||
|
@ -108,8 +108,8 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
||||
}
|
||||
|
||||
/// Open a conversation
|
||||
void _openConversation(int conversationId) {
|
||||
MainController.of(context).openConversation(conversationId);
|
||||
void _openConversation(Conversation conv) {
|
||||
MainController.of(context).openConversation(conv);
|
||||
if (widget.onOpen != null) widget.onOpen();
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
||||
usersList: _users,
|
||||
groupsList: _groups,
|
||||
onOpen: (c) {
|
||||
_openConversation(c.id);
|
||||
_openConversation(c);
|
||||
},
|
||||
onRequestUpdate: _updateConversation,
|
||||
onRequestLeave: _requestLeaveConversation,
|
||||
|
@ -12,9 +12,13 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class GroupPageScreen extends StatefulWidget {
|
||||
final int groupID;
|
||||
final int conversationID;
|
||||
|
||||
const GroupPageScreen({Key key, @required this.groupID})
|
||||
: assert(groupID != null),
|
||||
const GroupPageScreen({
|
||||
Key key,
|
||||
@required this.groupID,
|
||||
this.conversationID,
|
||||
}) : assert(groupID != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@ -57,6 +61,7 @@ class _GroupPageScreenState extends SafeState<GroupPageScreen> {
|
||||
// Now we can show group page
|
||||
return AuthorizedGroupPageScreen(
|
||||
advancedGroupInfo: _getGroupResult.info,
|
||||
conversationID: widget.conversationID,
|
||||
needRefresh: () => _refreshPage(),
|
||||
);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class _UnreadConversationsScreenState
|
||||
]),
|
||||
),
|
||||
trailing: Text(diffTimeFromNowToStr(conv.message.timeSent)),
|
||||
onTap: () => MainController.of(context).openConversation(conv.conv.id),
|
||||
onTap: () => MainController.of(context).openConversationById(conv.conv.id),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
||||
color: _color));
|
||||
|
||||
MainController.of(context).popPage();
|
||||
MainController.of(context).openConversation(conversationID);
|
||||
MainController.of(context).openConversationById(conversationID);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user