feat: 会话移除
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@ -105,4 +106,41 @@ class WhisperDetailController extends GetxController {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
void removeSession(context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
title: const Text('提示'),
|
||||
content: const Text('确认清空会话内容并移除会话?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
var res = await MsgHttp.removeSession(talkerId: talkerId);
|
||||
if (res['status']) {
|
||||
SmartDialog.showToast('操作成功');
|
||||
try {
|
||||
late final WhisperController whisperController =
|
||||
Get.find<WhisperController>();
|
||||
whisperController.removeSessionMsg(talkerId!);
|
||||
Get.back();
|
||||
} catch (_) {}
|
||||
}
|
||||
},
|
||||
child: const Text('确认'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
|
||||
src: _whisperDetailController.face,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
_whisperDetailController.name,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
@ -158,12 +158,14 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.more_vert_outlined,
|
||||
size: 20,
|
||||
),
|
||||
PopupMenuButton(
|
||||
icon: const Icon(Icons.more_vert_outlined, size: 20),
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
|
||||
PopupMenuItem(
|
||||
onTap: () => _whisperDetailController.removeSession(context),
|
||||
child: const Text('关闭会话'),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 14)
|
||||
],
|
||||
|
||||
@ -389,8 +389,19 @@ class ChatItem extends StatelessWidget {
|
||||
? messageContent(context)
|
||||
: isRevoke
|
||||
? const SizedBox()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
: Container(
|
||||
padding: const EdgeInsets.only(top: 6, bottom: 6),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
left: item.msgStatus == 1 && !isOwner
|
||||
? BorderSide(
|
||||
width: 4, color: Theme.of(context).dividerColor)
|
||||
: BorderSide.none,
|
||||
right: item.msgStatus == 1 && isOwner
|
||||
? BorderSide(
|
||||
width: 4, color: Theme.of(context).primaryColor)
|
||||
: BorderSide.none,
|
||||
)),
|
||||
child: Row(
|
||||
mainAxisAlignment: !isOwner
|
||||
? MainAxisAlignment.start
|
||||
|
||||
Reference in New Issue
Block a user