mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-18 18:33:49 +02:00
refactor: change delete chat snackbar
This commit is contained in:
parent
6bafc86a2d
commit
e85b107038
2 changed files with 103 additions and 68 deletions
|
@ -163,6 +163,8 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
chat.canBeDeleted
|
||||
|
@ -170,50 +172,80 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||
.deleteChatModalTitle
|
||||
: translations
|
||||
.chatCantBeDeleted,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 24),
|
||||
if (chat.canBeDeleted)
|
||||
Text(
|
||||
translations
|
||||
.deleteChatModalDescription,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
Padding(
|
||||
padding: const EdgeInsets
|
||||
.symmetric(
|
||||
horizontal: 16,
|
||||
),
|
||||
child: Text(
|
||||
translations
|
||||
.deleteChatModalDescription,
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
translations
|
||||
.deleteChatModalCancel,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(
|
||||
context,
|
||||
).pop(false),
|
||||
child: Text(
|
||||
translations
|
||||
.deleteChatModalCancel,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (chat.canBeDeleted)
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
if (chat.canBeDeleted)
|
||||
ElevatedButton(
|
||||
style: ElevatedButton
|
||||
.styleFrom(
|
||||
backgroundColor:
|
||||
const Color
|
||||
.fromRGBO(
|
||||
113,
|
||||
198,
|
||||
209,
|
||||
1,
|
||||
),
|
||||
),
|
||||
onPressed: () =>
|
||||
Navigator.of(
|
||||
context,
|
||||
).pop(true),
|
||||
).pop(
|
||||
true,
|
||||
),
|
||||
child: Text(
|
||||
translations
|
||||
.deleteChatModalConfirm,
|
||||
style:
|
||||
const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -146,59 +146,62 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
|||
return widget.options.noChatsPlaceholderBuilder(widget.translations);
|
||||
}
|
||||
|
||||
return ListView.separated(
|
||||
itemCount: filteredUsers.length,
|
||||
separatorBuilder: (context, index) => const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 28.0),
|
||||
child: Divider(),
|
||||
), // Add Divider here
|
||||
itemBuilder: (context, index) {
|
||||
var user = filteredUsers[index];
|
||||
var isSelected = selectedUserList.any((selectedUser) => selectedUser == user);
|
||||
return ListView.separated(
|
||||
itemCount: filteredUsers.length,
|
||||
separatorBuilder: (context, index) => const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 28.0),
|
||||
child: Divider(),
|
||||
), // Add Divider here
|
||||
itemBuilder: (context, index) {
|
||||
var user = filteredUsers[index];
|
||||
var isSelected =
|
||||
selectedUserList.any((selectedUser) => selectedUser == user);
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
if (selectedUserList.contains(user)) {
|
||||
selectedUserList.remove(user);
|
||||
} else {
|
||||
selectedUserList.add(user);
|
||||
}
|
||||
debugPrint('The list of selected users is $selectedUserList');
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
color: isSelected ? Colors.amber.shade200 : Colors.white,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30),
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 12.0, right: 12),
|
||||
child: widget.options.userAvatarBuilder(user, 40.0),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 40.0, // Adjust the height as needed
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
user.fullName ?? widget.translations.anonymousUser,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w800,
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
if (selectedUserList.contains(user)) {
|
||||
selectedUserList.remove(user);
|
||||
} else {
|
||||
selectedUserList.add(user);
|
||||
}
|
||||
debugPrint('The list of selected users is $selectedUserList');
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
color: isSelected ? Colors.amber.shade200 : Colors.white,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30),
|
||||
child: Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 12.0, right: 12),
|
||||
child: widget.options.userAvatarBuilder(user, 40.0),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 40.0, // Adjust the height as needed
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
user.fullName ?? widget.translations.anonymousUser,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isSelected)
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(right: 16.0),
|
||||
child: Icon(Icons.check_circle, color: Colors.green),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (isSelected)
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(right: 16.0),
|
||||
child: Icon(Icons.check_circle, color: Colors.green),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue