Merge branch 'krille/status-header-fixes' into 'master'

Fix: Status header design

See merge request ChristianPauly/fluffychat-flutter!135
This commit is contained in:
Christian Pauly 2020-08-22 13:26:38 +00:00
commit e9d6a10949
2 changed files with 140 additions and 122 deletions

View File

@ -480,6 +480,7 @@ class _ChatState extends State<_Chat> {
), ),
Column( Column(
children: <Widget>[ children: <Widget>[
ConnectionStatusHeader(),
Expanded( Expanded(
child: FutureBuilder<bool>( child: FutureBuilder<bool>(
future: getTimeline(), future: getTimeline(),
@ -601,7 +602,6 @@ class _ChatState extends State<_Chat> {
}, },
), ),
), ),
ConnectionStatusHeader(),
AnimatedContainer( AnimatedContainer(
duration: Duration(milliseconds: 300), duration: Duration(milliseconds: 300),
height: editEvent != null || replyEvent != null ? 56 : 0, height: editEvent != null || replyEvent != null ? 56 : 0,

View File

@ -336,130 +336,148 @@ class _ChatListState extends State<ChatList> {
context, NewPrivateChatView()), context, NewPrivateChatView()),
(r) => r.isFirst), (r) => r.isFirst),
), ),
body: StreamBuilder( body: Column(
stream: Matrix.of(context) children: [
.client ConnectionStatusHeader(),
.onSync Expanded(
.stream child: StreamBuilder(
.where((s) => s.hasRoomUpdate), stream: Matrix.of(context)
builder: (context, snapshot) { .client
return FutureBuilder<void>( .onSync
future: waitForFirstSync(context), .stream
builder: (BuildContext context, snapshot) { .where((s) => s.hasRoomUpdate),
if (snapshot.hasData) { builder: (context, snapshot) {
var rooms = List<Room>.from( return FutureBuilder<void>(
Matrix.of(context).client.rooms); future: waitForFirstSync(context),
rooms.removeWhere((Room room) => builder: (BuildContext context, snapshot) {
room.lastEvent == null || if (snapshot.hasData) {
(searchMode && var rooms = List<Room>.from(
!room.displayname.toLowerCase().contains( Matrix.of(context).client.rooms);
searchController.text.toLowerCase() ?? rooms.removeWhere((Room room) =>
''))); room.lastEvent == null ||
if (rooms.isEmpty && (searchMode &&
(!searchMode || !room.displayname
publicRoomsResponse == null)) { .toLowerCase()
return Center( .contains(searchController.text
child: Column( .toLowerCase() ??
mainAxisSize: MainAxisSize.min, '')));
children: <Widget>[ if (rooms.isEmpty &&
Icon( (!searchMode ||
searchMode publicRoomsResponse == null)) {
? Icons.search return Center(
: Icons.chat_bubble_outline, child: Column(
size: 80, mainAxisSize: MainAxisSize.min,
color: Colors.grey, children: <Widget>[
), Icon(
Text(searchMode searchMode
? L10n.of(context).noRoomsFound ? Icons.search
: L10n.of(context) : Icons.chat_bubble_outline,
.startYourFirstChat), size: 80,
], color: Colors.grey,
), ),
); Text(searchMode
} ? L10n.of(context).noRoomsFound
final publicRoomsCount = : L10n.of(context)
(publicRoomsResponse?.chunk?.length ?? 0); .startYourFirstChat),
final totalCount = ],
rooms.length + publicRoomsCount; ),
final directChats =
rooms.where((r) => r.isDirectChat).toList();
final presences =
Matrix.of(context).client.presences;
directChats.sort((a, b) =>
presences[b.directChatMatrixID]
?.presence
?.statusMsg !=
null
? 1
: b.lastEvent.originServerTs.compareTo(
a.lastEvent.originServerTs));
return ListView.separated(
controller: _scrollController,
separatorBuilder: (BuildContext context,
int i) =>
i == totalCount - publicRoomsCount
? ListTile(
title: Text(
L10n.of(context).publicRooms +
':',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context)
.primaryColor,
),
),
)
: Container(),
itemCount: totalCount + 1,
itemBuilder: (BuildContext context, int i) {
if (i == 0) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
ConnectionStatusHeader(),
(directChats.isEmpty ||
selectMode ==
SelectMode.share)
? Container()
: PreferredSize(
preferredSize:
Size.fromHeight(90),
child: Container(
height: 82,
child: ListView.builder(
scrollDirection:
Axis.horizontal,
itemCount:
directChats.length,
itemBuilder: (BuildContext
context,
int i) =>
PresenceListItem(
directChats[i]),
),
),
),
],
); );
} }
i--; final publicRoomsCount =
return i < rooms.length (publicRoomsResponse?.chunk?.length ??
? ChatListItem( 0);
rooms[i], final totalCount =
activeChat: widget.activeChat == rooms.length + publicRoomsCount;
rooms[i].id, final directChats = rooms
) .where((r) => r.isDirectChat)
: PublicRoomListItem(publicRoomsResponse .toList();
.chunk[i - rooms.length]); final presences =
}); Matrix.of(context).client.presences;
} else { directChats.sort((a, b) => presences[
return Center( b.directChatMatrixID]
child: CircularProgressIndicator(), ?.presence
?.statusMsg !=
null
? 1
: b.lastEvent.originServerTs.compareTo(
a.lastEvent.originServerTs));
return ListView.separated(
controller: _scrollController,
separatorBuilder: (BuildContext context,
int i) =>
i == totalCount - publicRoomsCount
? ListTile(
title: Text(
L10n.of(context)
.publicRooms +
':',
style: TextStyle(
fontWeight:
FontWeight.bold,
color: Theme.of(context)
.primaryColor,
),
),
)
: Container(),
itemCount: totalCount + 1,
itemBuilder:
(BuildContext context, int i) {
if (i == 0) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
(directChats.isEmpty ||
selectMode ==
SelectMode.share)
? Container()
: PreferredSize(
preferredSize:
Size.fromHeight(90),
child: Container(
height: 82,
child:
ListView.builder(
scrollDirection:
Axis.horizontal,
itemCount:
directChats
.length,
itemBuilder: (BuildContext
context,
int i) =>
PresenceListItem(
directChats[
i]),
),
),
),
],
);
}
i--;
return i < rooms.length
? ChatListItem(
rooms[i],
activeChat:
widget.activeChat ==
rooms[i].id,
)
: PublicRoomListItem(
publicRoomsResponse
.chunk[i - rooms.length]);
});
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
); );
} }),
}, ),
); ],
}), ),
); );
}); });
}); });