Skip to content

Commit 4a99141

Browse files
committed
v6.0.3
1 parent 28fdada commit 4a99141

144 files changed

Lines changed: 22835 additions & 2134 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/ai_sample_app/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name: ai_sample_app
22
description: "CometChat Flutter AI Sample App - AI Agents Chat Experience"
33
publish_to: 'none'
4-
version: 6.0.2
4+
version: 6.0.3
55

66
environment:
77
sdk: ^3.6.0
88

99
dependencies:
1010
flutter:
1111
sdk: flutter
12-
cometchat_chat_uikit: ^6.0.2
12+
cometchat_chat_uikit: ^6.0.3
1313
http: ^1.2.0
1414
intl: ^0.20.2
1515
shared_preferences: ^2.2.0

examples/sample_app/lib/screens/banned_members_screen.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ class _BannedMembersScreenState extends State<BannedMembersScreen>
175175
confirmButtonBackground: _colorPalette.error,
176176
confirmButtonTextColor: _colorPalette.white,
177177
),
178-
onCancel: () => Navigator.pop(context),
179-
onConfirm: () => _performUnban(member),
178+
onCancel: (dialogContext) => Navigator.of(dialogContext).pop(),
179+
onConfirm: (dialogContext) => _performUnban(member, dialogContext),
180180
).show();
181181
}
182182

183-
void _performUnban(GroupMember member) {
183+
void _performUnban(GroupMember member, BuildContext dialogContext) {
184184
setState(() => _isUnbanning = true);
185185
CometChat.unbanGroupMember(
186186
guid: widget.group.guid,
@@ -209,12 +209,12 @@ class _BannedMembersScreenState extends State<BannedMembersScreen>
209209
_bannedMembers.removeWhere((m) => m.uid == member.uid);
210210
_isUnbanning = false;
211211
});
212-
Navigator.pop(context); // close dialog
212+
Navigator.of(dialogContext).pop(); // close dialog
213213
},
214214
onError: (e) {
215215
if (!mounted) return;
216216
setState(() => _isUnbanning = false);
217-
Navigator.pop(context);
217+
Navigator.of(dialogContext).pop();
218218
debugPrint('Unban failed: ${e.message}');
219219
},
220220
);

examples/sample_app/lib/screens/group_info_screen.dart

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter/material.dart';
23
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
34
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart' as cc;
5+
import 'package:sample_app/screens/responsive_home_screen.dart';
46
import 'add_members_screen.dart';
57
import 'banned_members_screen.dart';
68
import 'messages_screen.dart';
@@ -250,7 +252,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen>
250252
).show();
251253
}
252254

253-
void _leaveGroup() {
255+
void _leaveGroup(BuildContext dialogContext) {
254256
setState(() => _isLeaveLoading = true);
255257
CometChat.leaveGroup(
256258
_group.guid,
@@ -261,7 +263,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen>
261263
cc.Action(
262264
conversationId: _conversationId ?? '',
263265
message:
264-
'${_loggedInUser?.name} ${cc.Translations.of(context).left}',
266+
'${_loggedInUser?.name} ${cc.Translations.of(context).left}',
265267
oldScope: _group.scope ?? GroupMemberScope.participant,
266268
newScope: '',
267269
muid: DateTime.now().microsecondsSinceEpoch.toString(),
@@ -274,14 +276,25 @@ class _GroupInfoScreenState extends State<GroupInfoScreen>
274276
_loggedInUser!,
275277
_group,
276278
);
277-
// Pop group info + messages screen
278-
Navigator.of(context)
279-
..pop()
280-
..pop();
279+
// Dismiss dialog, then pop group info screen
280+
Navigator.of(dialogContext).pop();
281+
if (kIsWeb) {
282+
Navigator.of(context, rootNavigator: true).pushAndRemoveUntil(
283+
MaterialPageRoute(
284+
builder: (_) => const ResponsiveHomeScreen(),
285+
),
286+
(route) => false,
287+
);
288+
} else {
289+
// Pop GroupInfo → Messages → back to Home
290+
Navigator.of(context).pop();
291+
Navigator.of(context).pop();
292+
}
281293
},
282294
onError: (e) {
283295
if (!mounted) return;
284296
setState(() => _isLeaveLoading = false);
297+
Navigator.of(dialogContext).pop();
285298
ScaffoldMessenger.of(context).showSnackBar(
286299
SnackBar(
287300
backgroundColor: _colorPalette.error,
@@ -322,21 +335,45 @@ class _GroupInfoScreenState extends State<GroupInfoScreen>
322335
confirmButtonBackground: _colorPalette.primary,
323336
confirmButtonTextColor: _colorPalette.white,
324337
),
325-
onCancel: () => Navigator.pop(context),
326-
onConfirm: () {
327-
Navigator.pop(context); // close dialog
338+
onCancel: (dialogContext) => Navigator.of(dialogContext).pop(),
339+
onConfirm: (dialogContext) {
340+
Navigator.of(dialogContext).pop(); // close dialog
328341
Navigator.push(
329342
context,
330343
MaterialPageRoute(
331344
builder: (_) => TransferOwnershipScreen(group: _group),
332345
),
333346
).then((value) {
334-
if (value == 'LeaveGroup') _leaveGroup();
347+
if (value == 'LeaveGroup') _leaveGroupAfterTransfer();
335348
});
336349
},
337350
).show();
338351
}
339352

353+
/// Leave group without a dialog to dismiss (called after transfer ownership)
354+
void _leaveGroupAfterTransfer() {
355+
if (!mounted) return;
356+
_group.membersCount--;
357+
CometChatGroupEvents.ccGroupLeft(
358+
cc.Action(
359+
conversationId: _conversationId ?? '',
360+
message: '${_loggedInUser?.name} ${cc.Translations.of(context).left}',
361+
oldScope: _group.scope ?? GroupMemberScope.participant,
362+
newScope: '',
363+
muid: DateTime.now().microsecondsSinceEpoch.toString(),
364+
sender: _loggedInUser!,
365+
receiverUid: _group.guid,
366+
type: MessageTypeConstants.groupActions,
367+
receiverType: ReceiverTypeConstants.group,
368+
parentMessageId: 0,
369+
),
370+
_loggedInUser!,
371+
_group,
372+
);
373+
// Pop group info screen (transfer screen already popped itself)
374+
Navigator.of(context).pop();
375+
}
376+
340377
void _onDeleteAndExit() {
341378
CometChatConfirmDialog(
342379
context: context,
@@ -379,23 +416,32 @@ class _GroupInfoScreenState extends State<GroupInfoScreen>
379416
).show();
380417
}
381418

382-
void _deleteGroup() {
419+
void _deleteGroup(BuildContext dialogContext) {
383420
setState(() => _isDeleteLoading = true);
384421
CometChat.deleteGroup(
385422
_group.guid,
386423
onSuccess: (_) {
387424
if (!mounted) return;
388425
CometChatGroupEvents.ccGroupDeleted(_group);
389-
// Pop dialog + group info + messages
390-
Navigator.of(context)
391-
..pop()
392-
..pop()
393-
..pop();
426+
427+
if (kIsWeb) {
428+
// Dismiss dialog, then pop group info + messages.
429+
// This preserves the current tab (Groups/Chats/Users).
430+
Navigator.of(dialogContext).pop();
431+
Navigator.of(context)
432+
..pop() // pop GroupInfo
433+
..pop(); // pop Messages
434+
} else {
435+
// Dismiss dialog, then pop group info screen
436+
Navigator.of(dialogContext).pop();
437+
Navigator.of(context).pop();
438+
Navigator.of(context).pop();
439+
}
394440
},
395441
onError: (e) {
396442
if (!mounted) return;
397443
setState(() => _isDeleteLoading = false);
398-
Navigator.pop(context); // close dialog
444+
Navigator.of(dialogContext).pop(); // close dialog
399445
ScaffoldMessenger.of(context).showSnackBar(
400446
SnackBar(
401447
backgroundColor: _colorPalette.error,

examples/sample_app/lib/screens/messages_screen.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class MessagesScreen extends StatefulWidget {
1212
final int? goToMessageId;
1313
final BaseMessage? parentMessage;
1414
final bool isHistory;
15+
final bool isNewChat;
16+
17+
/// When true, the back button in the message header is hidden.
18+
/// Used in desktop split-pane layout where the screen is embedded.
19+
final bool hideBackButton;
1520

1621
const MessagesScreen({
1722
super.key,
@@ -20,6 +25,8 @@ class MessagesScreen extends StatefulWidget {
2025
this.goToMessageId,
2126
this.parentMessage,
2227
this.isHistory = false,
28+
this.isNewChat = false,
29+
this.hideBackButton = false,
2330
}) : assert(user != null || group != null);
2431

2532
@override
@@ -334,7 +341,8 @@ class _MessagesScreenState extends State<MessagesScreen>
334341
appBar: CometChatMessageHeader(
335342
user: _user,
336343
group: _group,
337-
onBack: () => Navigator.pop(context),
344+
showBackButton: !widget.hideBackButton,
345+
onBack: widget.hideBackButton ? null : () => Navigator.pop(context),
338346
hideVideoCallButton: _isAI || _toggles.hideVideoCallButton.value,
339347
hideVoiceCallButton: _isAI || _toggles.hideVoiceCallButton.value,
340348
usersStatusVisibility: _toggles.headerUsersStatusVisibility.value,

0 commit comments

Comments
 (0)