This commit is contained in:
xsahil03x
2020-11-20 19:31:13 +05:30
parent 8bc9e62917
commit 879f5d31bc
+45 -5
View File
@@ -736,6 +736,10 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
setState(() { setState(() {
_selectedUsers.add(user); _selectedUsers.add(user);
}); });
} else {
setState(() {
_selectedUsers.remove(user);
});
} }
}, },
pagination: PaginationParams( pagination: PaginationParams(
@@ -939,7 +943,7 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
), ),
Expanded( Expanded(
child: ListView.separated( child: ListView.separated(
itemCount: _selectedUsers.length, itemCount: _selectedUsers.length + 1,
separatorBuilder: (_, __) => Container( separatorBuilder: (_, __) => Container(
height: 1, height: 1,
color: Theme.of(context).brightness == Brightness.dark color: Theme.of(context).brightness == Brightness.dark
@@ -947,12 +951,48 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
: Colors.black.withOpacity(0.1), : Colors.black.withOpacity(0.1),
), ),
itemBuilder: (_, index) { itemBuilder: (_, index) {
if (index == _selectedUsers.length) {
return Container(
height: 1,
color: Theme.of(context).brightness == Brightness.dark
? Colors.white.withOpacity(0.1)
: Colors.black.withOpacity(0.1),
);
}
final user = _selectedUsers[index]; final user = _selectedUsers[index];
return UserItem( return ListTile(
key: ObjectKey(user), key: ObjectKey(user),
user: user, leading: UserAvatar(
selected: true, user: user,
showLastOnline: false, constraints: BoxConstraints.tightFor(
width: 40,
height: 40,
),
),
title: Text(
user.name,
style: TextStyle(fontWeight: FontWeight.bold),
),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
trailing: IconButton(
icon: Icon(
Icons.clear_rounded,
color: Colors.black,
),
padding: const EdgeInsets.all(0),
splashRadius: 24,
onPressed: () {
setState(() {
_selectedUsers.remove(user);
});
if (_selectedUsers.isEmpty) {
Navigator.pop(context);
}
},
),
); );
}, },
), ),