showDesktopTopicActions static method
Implementation
static Future<void> showDesktopTopicActions({
required BuildContext context,
required Offset globalPosition,
required String currentTitle,
required Future<NIMResult<dynamic>> Function(String title) onRename,
required Future<NIMResult<void>> Function() onDelete,
bool Function()? checkNetwork,
}) async {
final overlay =
Overlay.of(context).context.findRenderObject() as RenderBox?;
if (overlay == null) {
return;
}
final action = await material.showMenu<_BotSubsessionAction>(
context: context,
position: RelativeRect.fromRect(
Rect.fromLTWH(globalPosition.dx, globalPosition.dy, 1, 1),
Offset.zero & overlay.size,
),
shape: material.RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
items: [
material.PopupMenuItem(
value: _BotSubsessionAction.rename,
height: 36,
child: Text(S.of(context).botSubsessionRename),
),
material.PopupMenuItem(
value: _BotSubsessionAction.delete,
height: 36,
child: Text(
S.of(context).chatMessageActionDelete,
style: const TextStyle(color: material.Color(0xFFF5222D)),
),
),
],
);
if (!context.mounted) {
return;
}
switch (action) {
case _BotSubsessionAction.rename:
await _renameTopic(
context: context,
currentTitle: currentTitle,
onRename: onRename,
checkNetwork: checkNetwork,
);
break;
case _BotSubsessionAction.delete:
await _deleteTopic(
context: context,
onDelete: onDelete,
);
break;
case null:
break;
}
}