|
|
|
@ -20,6 +20,7 @@ import '../utils/app_route.dart';
|
|
|
|
|
import '../utils/url_launcher.dart';
|
|
|
|
|
import '../utils/client_presence_extension.dart';
|
|
|
|
|
import 'archive.dart';
|
|
|
|
|
import 'homeserver_picker.dart';
|
|
|
|
|
import 'new_group.dart';
|
|
|
|
|
import 'new_private_chat.dart';
|
|
|
|
|
import 'settings.dart';
|
|
|
|
@ -222,6 +223,17 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return StreamBuilder<LoginState>(
|
|
|
|
|
stream: Matrix.of(context).client.onLoginStateChanged.stream,
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
if (snapshot.data == LoginState.loggedOut) {
|
|
|
|
|
Timer(Duration(seconds: 1), () {
|
|
|
|
|
Matrix.of(context).clean();
|
|
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
|
AppRoute.defaultRoute(context, HomeserverPicker()),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return StreamBuilder(
|
|
|
|
|
stream: Matrix.of(context).onShareContentChanged.stream,
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
@ -250,7 +262,8 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
ListTile(
|
|
|
|
|
leading: Icon(Icons.person_add),
|
|
|
|
|
title: Text(L10n.of(context).newPrivateChat),
|
|
|
|
|
onTap: () => _drawerTapAction(NewPrivateChatView()),
|
|
|
|
|
onTap: () =>
|
|
|
|
|
_drawerTapAction(NewPrivateChatView()),
|
|
|
|
|
),
|
|
|
|
|
Divider(height: 1),
|
|
|
|
|
ListTile(
|
|
|
|
@ -288,7 +301,8 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
? null
|
|
|
|
|
: IconButton(
|
|
|
|
|
icon: Icon(Icons.close),
|
|
|
|
|
onPressed: () => Matrix.of(context).shareContent = null,
|
|
|
|
|
onPressed: () =>
|
|
|
|
|
Matrix.of(context).shareContent = null,
|
|
|
|
|
),
|
|
|
|
|
titleSpacing: 0,
|
|
|
|
|
title: selectMode == SelectMode.share
|
|
|
|
@ -322,7 +336,8 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
floatingActionButton: (AdaptivePageLayout.columnMode(context) ||
|
|
|
|
|
floatingActionButton:
|
|
|
|
|
(AdaptivePageLayout.columnMode(context) ||
|
|
|
|
|
selectMode == SelectMode.share)
|
|
|
|
|
? null
|
|
|
|
|
: SpeedDial(
|
|
|
|
@ -336,10 +351,12 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
backgroundColor: Colors.blue,
|
|
|
|
|
label: L10n.of(context).createNewGroup,
|
|
|
|
|
labelStyle:
|
|
|
|
|
TextStyle(fontSize: 18.0, color: Colors.black),
|
|
|
|
|
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
|
AppRoute.defaultRoute(context, NewGroupView()),
|
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
fontSize: 18.0, color: Colors.black),
|
|
|
|
|
onTap: () => Navigator.of(context)
|
|
|
|
|
.pushAndRemoveUntil(
|
|
|
|
|
AppRoute.defaultRoute(
|
|
|
|
|
context, NewGroupView()),
|
|
|
|
|
(r) => r.isFirst),
|
|
|
|
|
),
|
|
|
|
|
SpeedDialChild(
|
|
|
|
@ -347,9 +364,10 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
backgroundColor: Colors.green,
|
|
|
|
|
label: L10n.of(context).newPrivateChat,
|
|
|
|
|
labelStyle:
|
|
|
|
|
TextStyle(fontSize: 18.0, color: Colors.black),
|
|
|
|
|
onTap: () => Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
fontSize: 18.0, color: Colors.black),
|
|
|
|
|
onTap: () => Navigator.of(context)
|
|
|
|
|
.pushAndRemoveUntil(
|
|
|
|
|
AppRoute.defaultRoute(
|
|
|
|
|
context, NewPrivateChatView()),
|
|
|
|
|
(r) => r.isFirst),
|
|
|
|
@ -363,14 +381,16 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
future: waitForFirstSync(context),
|
|
|
|
|
builder: (BuildContext context, snapshot) {
|
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
|
List<Room> rooms =
|
|
|
|
|
List<Room>.from(Matrix.of(context).client.rooms);
|
|
|
|
|
List<Room> rooms = List<Room>.from(
|
|
|
|
|
Matrix.of(context).client.rooms);
|
|
|
|
|
rooms.removeWhere((Room room) =>
|
|
|
|
|
searchMode &&
|
|
|
|
|
!room.displayname.toLowerCase().contains(
|
|
|
|
|
searchController.text.toLowerCase() ?? ""));
|
|
|
|
|
searchController.text.toLowerCase() ??
|
|
|
|
|
""));
|
|
|
|
|
if (rooms.isEmpty &&
|
|
|
|
|
(!searchMode || publicRoomsResponse == null)) {
|
|
|
|
|
(!searchMode ||
|
|
|
|
|
publicRoomsResponse == null)) {
|
|
|
|
|
return Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
@ -384,23 +404,27 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
),
|
|
|
|
|
Text(searchMode
|
|
|
|
|
? L10n.of(context).noRoomsFound
|
|
|
|
|
: L10n.of(context).startYourFirstChat),
|
|
|
|
|
: L10n.of(context)
|
|
|
|
|
.startYourFirstChat),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
final int publicRoomsCount =
|
|
|
|
|
(publicRoomsResponse?.publicRooms?.length ?? 0);
|
|
|
|
|
final int totalCount = rooms.length + publicRoomsCount;
|
|
|
|
|
(publicRoomsResponse?.publicRooms?.length ??
|
|
|
|
|
0);
|
|
|
|
|
final int totalCount =
|
|
|
|
|
rooms.length + publicRoomsCount;
|
|
|
|
|
return ListView.separated(
|
|
|
|
|
controller: _scrollController,
|
|
|
|
|
separatorBuilder: (BuildContext context, int i) =>
|
|
|
|
|
separatorBuilder:
|
|
|
|
|
(BuildContext context, int i) =>
|
|
|
|
|
i == totalCount - publicRoomsCount
|
|
|
|
|
? Material(
|
|
|
|
|
elevation: 2,
|
|
|
|
|
child: ListTile(
|
|
|
|
|
title: Text(
|
|
|
|
|
L10n.of(context).publicRooms),
|
|
|
|
|
title: Text(L10n.of(context)
|
|
|
|
|
.publicRooms),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
@ -414,17 +438,20 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
selectMode == SelectMode.share)
|
|
|
|
|
? Container()
|
|
|
|
|
: PreferredSize(
|
|
|
|
|
preferredSize: Size.fromHeight(89),
|
|
|
|
|
preferredSize:
|
|
|
|
|
Size.fromHeight(89),
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 81,
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
scrollDirection:
|
|
|
|
|
Axis.horizontal,
|
|
|
|
|
itemCount: Matrix.of(context)
|
|
|
|
|
.client
|
|
|
|
|
.statusList
|
|
|
|
|
.length,
|
|
|
|
|
itemBuilder:
|
|
|
|
|
(BuildContext context, int i) =>
|
|
|
|
|
itemBuilder: (BuildContext
|
|
|
|
|
context,
|
|
|
|
|
int i) =>
|
|
|
|
|
PresenceListItem(
|
|
|
|
|
Matrix.of(context)
|
|
|
|
|
.client
|
|
|
|
@ -437,8 +464,8 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
return i < rooms.length
|
|
|
|
|
? ChatListItem(
|
|
|
|
|
rooms[i],
|
|
|
|
|
activeChat:
|
|
|
|
|
widget.activeChat == rooms[i].id,
|
|
|
|
|
activeChat: widget.activeChat ==
|
|
|
|
|
rooms[i].id,
|
|
|
|
|
)
|
|
|
|
|
: PublicRoomListItem(publicRoomsResponse
|
|
|
|
|
.publicRooms[i - rooms.length]);
|
|
|
|
@ -453,5 +480,6 @@ class _ChatListState extends State<ChatList> {
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|