mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 02:43:50 +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),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
chat.canBeDeleted
|
chat.canBeDeleted
|
||||||
|
@ -170,50 +172,80 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||||
.deleteChatModalTitle
|
.deleteChatModalTitle
|
||||||
: translations
|
: translations
|
||||||
.chatCantBeDeleted,
|
.chatCantBeDeleted,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 24,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 24),
|
||||||
if (chat.canBeDeleted)
|
if (chat.canBeDeleted)
|
||||||
Text(
|
Padding(
|
||||||
translations
|
padding: const EdgeInsets
|
||||||
.deleteChatModalDescription,
|
.symmetric(
|
||||||
style: const TextStyle(
|
horizontal: 16,
|
||||||
fontSize: 16,
|
),
|
||||||
|
child: Text(
|
||||||
|
translations
|
||||||
|
.deleteChatModalDescription,
|
||||||
|
textAlign:
|
||||||
|
TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(
|
||||||
|
height: 24,
|
||||||
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.center,
|
MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
TextButton(
|
ElevatedButton(
|
||||||
child: Text(
|
|
||||||
translations
|
|
||||||
.deleteChatModalCancel,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
Navigator.of(
|
Navigator.of(
|
||||||
context,
|
context,
|
||||||
).pop(false),
|
).pop(false),
|
||||||
|
child: Text(
|
||||||
|
translations
|
||||||
|
.deleteChatModalCancel,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
if (chat.canBeDeleted)
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
if (chat.canBeDeleted)
|
if (chat.canBeDeleted)
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
|
style: ElevatedButton
|
||||||
|
.styleFrom(
|
||||||
|
backgroundColor:
|
||||||
|
const Color
|
||||||
|
.fromRGBO(
|
||||||
|
113,
|
||||||
|
198,
|
||||||
|
209,
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
Navigator.of(
|
Navigator.of(
|
||||||
context,
|
context,
|
||||||
).pop(true),
|
).pop(
|
||||||
|
true,
|
||||||
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
translations
|
translations
|
||||||
.deleteChatModalConfirm,
|
.deleteChatModalConfirm,
|
||||||
style:
|
style:
|
||||||
const TextStyle(
|
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 widget.options.noChatsPlaceholderBuilder(widget.translations);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
itemCount: filteredUsers.length,
|
itemCount: filteredUsers.length,
|
||||||
separatorBuilder: (context, index) => const Padding(
|
separatorBuilder: (context, index) => const Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 28.0),
|
padding: EdgeInsets.symmetric(horizontal: 28.0),
|
||||||
child: Divider(),
|
child: Divider(),
|
||||||
), // Add Divider here
|
), // Add Divider here
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var user = filteredUsers[index];
|
var user = filteredUsers[index];
|
||||||
var isSelected = selectedUserList.any((selectedUser) => selectedUser == user);
|
var isSelected =
|
||||||
|
selectedUserList.any((selectedUser) => selectedUser == user);
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (selectedUserList.contains(user)) {
|
if (selectedUserList.contains(user)) {
|
||||||
selectedUserList.remove(user);
|
selectedUserList.remove(user);
|
||||||
} else {
|
} else {
|
||||||
selectedUserList.add(user);
|
selectedUserList.add(user);
|
||||||
}
|
}
|
||||||
debugPrint('The list of selected users is $selectedUserList');
|
debugPrint('The list of selected users is $selectedUserList');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
color: isSelected ? Colors.amber.shade200 : Colors.white,
|
color: isSelected ? Colors.amber.shade200 : Colors.white,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30),
|
padding:
|
||||||
child: Row(
|
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 30),
|
||||||
children: [
|
child: Row(
|
||||||
Padding(
|
children: [
|
||||||
padding: const EdgeInsets.only(left: 12.0, right: 12),
|
Padding(
|
||||||
child: widget.options.userAvatarBuilder(user, 40.0),
|
padding: const EdgeInsets.only(left: 12.0, right: 12),
|
||||||
),
|
child: widget.options.userAvatarBuilder(user, 40.0),
|
||||||
Expanded(
|
),
|
||||||
child: Container(
|
Expanded(
|
||||||
height: 40.0, // Adjust the height as needed
|
child: Container(
|
||||||
alignment: Alignment.centerLeft,
|
height: 40.0, // Adjust the height as needed
|
||||||
child: Text(
|
alignment: Alignment.centerLeft,
|
||||||
user.fullName ?? widget.translations.anonymousUser,
|
child: Text(
|
||||||
style: const TextStyle(
|
user.fullName ?? widget.translations.anonymousUser,
|
||||||
fontWeight: FontWeight.w800,
|
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