From f02f8a27cbcfdcad16981d2803be9fe1ce8d6cb7 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 31 Dec 2020 14:19:03 +0530 Subject: [PATCH] fix: fixed group member list --- example/lib/group_info_screen.dart | 176 +++++++++++++++++++---------- lib/src/image_footer.dart | 5 +- 2 files changed, 121 insertions(+), 60 deletions(-) diff --git a/example/lib/group_info_screen.dart b/example/lib/group_info_screen.dart index 1c926106..3c469b9f 100644 --- a/example/lib/group_info_screen.dart +++ b/example/lib/group_info_screen.dart @@ -32,6 +32,8 @@ class _GroupInfoScreenState extends State { bool namedChanged = false; String changedName = ''; + int groupMemberListLength; + void _userNameListener() { if (_searchController.text == _userNameQuery) { return; @@ -161,78 +163,134 @@ class _GroupInfoScreenState extends State { ); } - return ListView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: snapshot.data.members.length, - itemBuilder: (context, position) { - return Material( - child: InkWell( - onTap: () { - var userMember = snapshot.data.members.firstWhere( - (e) => e.user.id == StreamChat.of(context).user.id); - _showUserInfoModal(snapshot.data.members[position].user, - userMember.role == 'owner'); - }, - child: Container( - height: 65.0, - child: Column( - children: [ - Row( + groupMemberListLength ??= + snapshot.data.members.length > 6 ? 6 : snapshot.data.members.length; + + return Column( + children: [ + ListView.builder( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: groupMemberListLength, + itemBuilder: (context, position) { + return Material( + child: InkWell( + onTap: () { + var userMember = snapshot.data.members.firstWhere( + (e) => e.user.id == StreamChat.of(context).user.id); + _showUserInfoModal(snapshot.data.members[position].user, + userMember.role == 'owner'); + }, + child: Container( + height: 65.0, + child: Column( children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8.0, vertical: 12.0), - child: UserAvatar( - user: snapshot.data.members[position].user, - constraints: BoxConstraints( - maxHeight: 40.0, maxWidth: 40.0), - ), - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - snapshot.data.members[position].user.name, - style: TextStyle(fontWeight: FontWeight.bold), + Row( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8.0, vertical: 12.0), + child: UserAvatar( + user: snapshot.data.members[position].user, + constraints: BoxConstraints( + maxHeight: 40.0, maxWidth: 40.0), ), - SizedBox( - height: 1.0, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + snapshot.data.members[position].user.name, + style: TextStyle( + fontWeight: FontWeight.bold), + ), + SizedBox( + height: 1.0, + ), + Text( + _getLastSeen( + snapshot.data.members[position].user), + style: TextStyle( + color: Colors.black.withOpacity(0.5)), + ), + ], ), - Text( - _getLastSeen( - snapshot.data.members[position].user), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + snapshot.data.members[position].role == + 'owner' + ? 'Owner' + : '', style: TextStyle( color: Colors.black.withOpacity(0.5)), ), - ], - ), + ), + ], ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - snapshot.data.members[position].role == 'owner' - ? 'Owner' - : '', - style: TextStyle( - color: Colors.black.withOpacity(0.5)), - ), + Container( + height: 1.0, + color: Color(0xffdbdbdb), ), ], ), - Container( - height: 1.0, - color: Color(0xffdbdbdb), - ), - ], + ), + ), + color: Colors.white, + ); + }, + ), + if (groupMemberListLength != snapshot.data.members.length) + InkWell( + onTap: () { + setState(() { + groupMemberListLength = snapshot.data.members.length; + }); + }, + child: Material( + child: Container( + height: 65.0, + child: Column( + children: [ + Expanded( + child: Row( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 21.0, vertical: 12.0), + child: StreamSvgIcon.down( + color: Color(0xff7a7a7a), + ), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '${snapshot.data.members.length - groupMemberListLength} more', + style: + TextStyle(color: Color(0xff7a7a7a)), + ), + ], + ), + ), + ], + ), + ), + Container( + height: 1.0, + color: Color(0xffdbdbdb), + ), + ], + ), ), ), ), - color: Colors.white, - ); - }, + ], ); }, future: _memberQueryFuture, diff --git a/lib/src/image_footer.dart b/lib/src/image_footer.dart index 97e40cba..8a3738ac 100644 --- a/lib/src/image_footer.dart +++ b/lib/src/image_footer.dart @@ -104,7 +104,10 @@ class _ImageFooterState extends State { @override Widget build(BuildContext context) { return SizedBox.fromSize( - size: widget.preferredSize, + size: Size( + MediaQuery.of(context).size.width, + MediaQuery.of(context).padding.bottom + widget.preferredSize.height, + ), child: MediaQuery.removePadding( context: context, removeTop: true,