deleteConversationFromIndex method
void
deleteConversationFromIndex(
- int index
)
override
Implementation
@override
void deleteConversationFromIndex(int index) async {
late String conversationWith;
late String conversationType;
if (list[index].conversationType.toLowerCase() ==
ReceiverTypeConstants.group.toLowerCase()) {
conversationWith = (list[index].conversationWith as Group).guid;
conversationType = ReceiverTypeConstants.group;
} else {
conversationWith = (list[index].conversationWith as User).uid;
conversationType = ReceiverTypeConstants.user;
}
if (context != null) {
showCometChatConfirmDialog(
context: context!,
confirmButtonText: Translations.of(context!).deleteCapital,
cancelButtonText: Translations.of(context!).cancelCapital,
messageText: Text(
Translations.of(context!).deleteConfirm,
style: TextStyle(
fontSize: theme?.typography.title2.fontSize,
fontWeight: theme?.typography.title2.fontWeight,
color: theme?.palette.getAccent(),
fontFamily: theme?.typography.title2.fontFamily),
),
onCancel: () {
Navigator.pop(context!);
},
style: ConfirmDialogStyle(
backgroundColor: deleteConversationDialogStyle?.backgroundColor ??
(theme?.palette.mode == PaletteThemeModes.light
? theme?.palette.getBackground()
: Color.alphaBlend(theme!.palette.getAccent200(),
theme!.palette.getBackground())),
shadowColor: deleteConversationDialogStyle?.shadowColor ??
theme?.palette.getAccent300(),
confirmButtonTextStyle: TextStyle(
fontSize: theme?.typography.text2.fontSize,
fontWeight: theme?.typography.text2.fontWeight,
color: theme?.palette.getPrimary())
.merge(deleteConversationDialogStyle?.confirmButtonTextStyle),
cancelButtonTextStyle: TextStyle(
fontSize: theme?.typography.text2.fontSize,
fontWeight: theme?.typography.text2.fontWeight,
color: theme?.palette.getPrimary())
.merge(deleteConversationDialogStyle?.cancelButtonTextStyle)),
onConfirm: () async {
await CometChat.deleteConversation(
conversationWith, conversationType, onSuccess: (_) {
removeElementAt(index);
CometChatConversationEvents.ccConversationDeleted(list[index]);
}, onError: onError);
Navigator.pop(context!);
update();
});
}
}