feat: 私信

This commit is contained in:
guozhigq
2024-06-15 16:03:45 +08:00
parent c4441dccb2
commit 5e63f0da7b
7 changed files with 373 additions and 278 deletions

View File

@ -1,4 +1,6 @@
import 'dart:convert';
import 'dart:math'; import 'dart:math';
import 'package:dio/dio.dart';
import '../models/msg/account.dart'; import '../models/msg/account.dart';
import '../models/msg/session.dart'; import '../models/msg/session.dart';
import '../utils/wbi_sign.dart'; import '../utils/wbi_sign.dart';
@ -134,56 +136,42 @@ class MsgHttp {
// 发送私信 // 发送私信
static Future sendMsg({ static Future sendMsg({
int? senderUid, required int senderUid,
int? receiverId, required int receiverId,
int? receiverType, int? receiverType,
int? msgType, int? msgType,
dynamic content, dynamic content,
}) async { }) async {
String csrf = await Request.getCsrf(); String csrf = await Request.getCsrf();
Map<String, dynamic> params = await WbiSign().makSign({ var res = await Request().post(
'msg[sender_uid]': senderUid, Api.sendMsg,
'msg[receiver_id]': receiverId, data: {
'msg[receiver_type]': receiverType ?? 1, 'msg[sender_uid]': senderUid,
'msg[msg_type]': msgType ?? 1, 'msg[receiver_id]': receiverId,
'msg[msg_status]': 0, 'msg[receiver_type]': 1,
'msg[dev_id]': getDevId(), 'msg[msg_type]': 1,
'msg[timestamp]': DateTime.now().millisecondsSinceEpoch ~/ 1000, 'msg[msg_status]': 0,
'msg[new_face_version]': 0, 'msg[content]': jsonEncode(content),
'msg[content]': content, 'msg[timestamp]': DateTime.now().millisecondsSinceEpoch ~/ 1000,
'from_firework': 0, 'msg[new_face_version]': 0,
'build': 0, 'msg[dev_id]': getDevId(),
'mobi_app': 'web', 'from_firework': 0,
'csrf_token': csrf, 'build': 0,
'csrf': csrf, 'mobi_app': 'web',
}); 'csrf_token': csrf,
var res = 'csrf': csrf,
await Request().post(Api.sendMsg, queryParameters: <String, dynamic>{ },
...params, options: Options(
'csrf_token': csrf, contentType: Headers.formUrlEncodedContentType,
'csrf': csrf, ),
}, data: { );
'w_sender_uid': params['msg[sender_uid]'],
'w_receiver_id': params['msg[receiver_id]'],
'w_dev_id': params['msg[dev_id]'],
'w_rid': params['w_rid'],
'wts': params['wts'],
'csrf_token': csrf,
'csrf': csrf,
});
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return { return {
'status': true, 'status': true,
'data': res.data['data'], 'data': res.data['data'],
}; };
} else { } else {
return { return {'status': false, 'date': [], 'msg': res.data['message']};
'status': false,
'date': [],
'msg': "message: ${res.data['message']},"
" msg: ${res.data['msg']},"
" code: ${res.data['code']}",
};
} }
} }

View File

@ -208,7 +208,17 @@ class ProfilePanel extends StatelessWidget {
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: TextButton( child: TextButton(
onPressed: () {}, onPressed: () {
Get.toNamed(
'/whisperDetail',
parameters: {
'name': memberInfo.name!,
'face': memberInfo.face!,
'mid': memberInfo.mid.toString(),
'heroTag': ctr.heroTag!,
},
);
},
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: Theme.of(context) backgroundColor: Theme.of(context)
.colorScheme .colorScheme

View File

@ -62,4 +62,13 @@ class WhisperController extends GetxController {
Future onRefresh() async { Future onRefresh() async {
querySessionList('onRefresh'); querySessionList('onRefresh');
} }
void refreshLastMsg(int talkerId, String content) {
final SessionList currentItem =
sessionList.where((p0) => p0.talkerId == talkerId).first;
currentItem.lastMsg!.content['content'] = content;
sessionList.removeWhere((p0) => p0.talkerId == talkerId);
sessionList.insert(0, currentItem);
sessionList.refresh();
}
} }

View File

@ -202,6 +202,7 @@ class SessionItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String heroTag = Utils.makeHeroTag(sessionItem.accountInfo.mid);
final content = sessionItem.lastMsg.content; final content = sessionItem.lastMsg.content;
return ListTile( return ListTile(
onTap: () { onTap: () {
@ -214,6 +215,7 @@ class SessionItem extends StatelessWidget {
'name': sessionItem.accountInfo.name, 'name': sessionItem.accountInfo.name,
'face': sessionItem.accountInfo.face, 'face': sessionItem.accountInfo.face,
'mid': sessionItem.accountInfo.mid.toString(), 'mid': sessionItem.accountInfo.mid.toString(),
'heroTag': heroTag,
}, },
); );
}, },
@ -221,11 +223,14 @@ class SessionItem extends StatelessWidget {
isLabelVisible: sessionItem.unreadCount > 0, isLabelVisible: sessionItem.unreadCount > 0,
label: Text(sessionItem.unreadCount.toString()), label: Text(sessionItem.unreadCount.toString()),
alignment: Alignment.topRight, alignment: Alignment.topRight,
child: NetworkImgLayer( child: Hero(
width: 45, tag: heroTag,
height: 45, child: NetworkImgLayer(
type: 'avatar', width: 45,
src: sessionItem.accountInfo.face, height: 45,
type: 'avatar',
src: sessionItem.accountInfo.face,
),
), ),
), ),
title: Text(sessionItem.accountInfo.name), title: Text(sessionItem.accountInfo.name),
@ -245,10 +250,10 @@ class SessionItem extends StatelessWidget {
.copyWith(color: Theme.of(context).colorScheme.outline)), .copyWith(color: Theme.of(context).colorScheme.outline)),
trailing: Text( trailing: Text(
Utils.dateFormat(sessionItem.lastMsg.timestamp), Utils.dateFormat(sessionItem.lastMsg.timestamp),
style: Theme.of(context) style: TextStyle(
.textTheme fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
.labelSmall! color: Theme.of(context).colorScheme.outline,
.copyWith(color: Theme.of(context).colorScheme.outline), ),
), ),
); );
} }

View File

@ -1,30 +1,39 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:pilipala/http/msg.dart'; import 'package:pilipala/http/msg.dart';
import 'package:pilipala/models/msg/session.dart'; import 'package:pilipala/models/msg/session.dart';
import 'package:pilipala/pages/whisper/index.dart';
import '../../utils/feed_back.dart'; import '../../utils/feed_back.dart';
import '../../utils/storage.dart'; import '../../utils/storage.dart';
class WhisperDetailController extends GetxController { class WhisperDetailController extends GetxController {
late int talkerId; int? talkerId;
late String name; late String name;
late String face; late String face;
late String mid; late String mid;
late String heroTag;
RxList<MessageItem> messageList = <MessageItem>[].obs; RxList<MessageItem> messageList = <MessageItem>[].obs;
//表情转换图片规则 //表情转换图片规则
List<dynamic>? eInfos; RxList<dynamic> eInfos = [].obs;
final TextEditingController replyContentController = TextEditingController(); final TextEditingController replyContentController = TextEditingController();
Box userInfoCache = GStrorage.userInfo; Box userInfoCache = GStrorage.userInfo;
List emoteList = [];
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
talkerId = int.parse(Get.parameters['talkerId']!); if (Get.parameters.containsKey('talkerId')) {
talkerId = int.parse(Get.parameters['talkerId']!);
} else {
talkerId = int.parse(Get.parameters['mid']!);
}
name = Get.parameters['name']!; name = Get.parameters['name']!;
face = Get.parameters['face']!; face = Get.parameters['face']!;
mid = Get.parameters['mid']!; mid = Get.parameters['mid']!;
heroTag = Get.parameters['heroTag']!;
} }
Future querySessionMsg() async { Future querySessionMsg() async {
@ -34,7 +43,7 @@ class WhisperDetailController extends GetxController {
if (messageList.isNotEmpty) { if (messageList.isNotEmpty) {
ackSessionMsg(); ackSessionMsg();
if (res['data'].eInfos != null) { if (res['data'].eInfos != null) {
eInfos = res['data'].eInfos; eInfos.value = res['data'].eInfos;
} }
} }
} else { } else {
@ -73,7 +82,25 @@ class WhisperDetailController extends GetxController {
msgType: 1, msgType: 1,
); );
if (result['status']) { if (result['status']) {
SmartDialog.showToast('发送成功'); String content = jsonDecode(result['data']['msg_content'])['content'];
messageList.insert(
0,
MessageItem(
msgSeqno: result['data']['msg_key'],
senderUid: userInfo.mid,
receiverId: int.parse(mid),
content: {'content': content},
msgType: 1,
timestamp: DateTime.now().millisecondsSinceEpoch,
),
);
eInfos.addAll(emoteList);
replyContentController.clear();
try {
late final WhisperController whisperController =
Get.find<WhisperController>();
whisperController.refreshLastMsg(talkerId!, message);
} catch (_) {}
} else { } else {
SmartDialog.showToast(result['msg']); SmartDialog.showToast(result['msg']);
} }

View File

@ -1,9 +1,12 @@
import 'dart:async'; import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/video/reply/emote.dart';
import 'package:pilipala/pages/emote/index.dart'; import 'package:pilipala/pages/emote/index.dart';
import 'package:pilipala/pages/video/detail/reply_new/toolbar_icon_button.dart';
import 'package:pilipala/pages/whisper_detail/controller.dart'; import 'package:pilipala/pages/whisper_detail/controller.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import '../../utils/storage.dart'; import '../../utils/storage.dart';
@ -24,9 +27,9 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
late TextEditingController _replyContentController; late TextEditingController _replyContentController;
final FocusNode replyContentFocusNode = FocusNode(); final FocusNode replyContentFocusNode = FocusNode();
final _debouncer = Debouncer(milliseconds: 200); // 设置延迟时间 final _debouncer = Debouncer(milliseconds: 200); // 设置延迟时间
late double emoteHeight = 0.0; late double emoteHeight = 230.0;
double keyboardHeight = 0.0; // 键盘高度 double keyboardHeight = 0.0; // 键盘高度
String toolbarType = 'input'; RxString toolbarType = ''.obs;
Box userInfoCache = GStrorage.userInfo; Box userInfoCache = GStrorage.userInfo;
@override @override
@ -41,9 +44,7 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
_focuslistener() { _focuslistener() {
replyContentFocusNode.addListener(() { replyContentFocusNode.addListener(() {
if (replyContentFocusNode.hasFocus) { if (replyContentFocusNode.hasFocus) {
setState(() { toolbarType.value = 'input';
toolbarType = 'input';
});
} }
}); });
} }
@ -52,7 +53,7 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
void didChangeMetrics() { void didChangeMetrics() {
super.didChangeMetrics(); super.didChangeMetrics();
final String routePath = Get.currentRoute; final String routePath = Get.currentRoute;
if (mounted && routePath.startsWith('/whisper_detail')) { if (mounted && routePath.startsWith('/whisperDetail')) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
// 键盘高度 // 键盘高度
final viewInsets = EdgeInsets.fromViewPadding( final viewInsets = EdgeInsets.fromViewPadding(
@ -61,8 +62,11 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
if (mounted) { if (mounted) {
if (keyboardHeight == 0) { if (keyboardHeight == 0) {
setState(() { setState(() {
emoteHeight = keyboardHeight = keyboardHeight =
keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight; keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight;
if (keyboardHeight != 0) {
emoteHeight = keyboardHeight;
}
}); });
} }
} }
@ -79,6 +83,23 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
super.dispose(); super.dispose();
} }
void onChooseEmote(PackageItem package, Emote emote) {
_whisperDetailController.emoteList.add(
{'text': emote.text, 'url': emote.url},
);
final int cursorPosition =
max(_replyContentController.selection.baseOffset, 0);
final String currentText = _replyContentController.text;
final String newText = currentText.substring(0, cursorPosition) +
emote.text! +
currentText.substring(cursorPosition);
_replyContentController.value = TextEditingValue(
text: newText,
selection:
TextSelection.collapsed(offset: cursorPosition + emote.text!.length),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -88,30 +109,20 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
width: double.infinity, width: double.infinity,
height: 50, height: 50,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
SizedBox( SizedBox(
width: 34, width: 34,
height: 34, height: 34,
child: IconButton( child: IconButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
backgroundColor: MaterialStateProperty.resolveWith(
(Set<MaterialState> states) {
return Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.6);
}),
),
onPressed: () => Get.back(), onPressed: () => Get.back(),
icon: Icon( icon: Icon(
Icons.arrow_back_outlined, Icons.arrow_back_ios,
size: 18, size: 18,
color: Theme.of(context).colorScheme.onPrimaryContainer, color: Theme.of(context).colorScheme.onPrimaryContainer,
), ),
), ),
), ),
const SizedBox(width: 10),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
feedBack(); feedBack();
@ -125,11 +136,14 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
}, },
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
NetworkImgLayer( Hero(
width: 34, tag: _whisperDetailController.heroTag,
height: 34, child: NetworkImgLayer(
type: 'avatar', width: 34,
src: _whisperDetailController.face, height: 34,
type: 'avatar',
src: _whisperDetailController.face,
),
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
Text( Text(
@ -143,155 +157,169 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
], ],
), ),
), ),
), actions: [
body: GestureDetector( IconButton(
onTap: () { onPressed: () {},
FocusScope.of(context).unfocus(); icon: const Icon(
setState(() { Icons.more_vert_outlined,
keyboardHeight = 0; size: 20,
});
},
child: FutureBuilder(
future: _futureBuilderFuture,
builder: (BuildContext context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data == null) {
return const SizedBox();
}
final Map data = snapshot.data as Map;
if (data['status']) {
List messageList = _whisperDetailController.messageList;
return Obx(
() => messageList.isEmpty
? const SizedBox()
: ListView.builder(
itemCount: messageList.length,
shrinkWrap: true,
reverse: true,
itemBuilder: (_, int i) {
if (i == 0) {
return Column(
children: [
ChatItem(
item: messageList[i],
e_infos: _whisperDetailController.eInfos),
const SizedBox(height: 12),
],
);
} else {
return ChatItem(
item: messageList[i],
e_infos: _whisperDetailController.eInfos);
}
},
),
);
} else {
// 请求错误
return const SizedBox();
}
} else {
// 骨架屏
return const SizedBox();
}
},
),
),
// resizeToAvoidBottomInset: true,
bottomNavigationBar: Container(
width: double.infinity,
height: MediaQuery.of(context).padding.bottom + 70 + keyboardHeight,
padding: EdgeInsets.only(
left: 8,
right: 12,
top: 12,
bottom: MediaQuery.of(context).padding.bottom,
),
decoration: BoxDecoration(
border: Border(
top: BorderSide(
width: 4,
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
), ),
), ),
), const SizedBox(width: 14)
child: Column( ],
children: [ ),
Row( body: Column(
mainAxisAlignment: MainAxisAlignment.center, children: [
crossAxisAlignment: CrossAxisAlignment.start, Expanded(
children: [ child: GestureDetector(
// IconButton( onTap: () {
// onPressed: () {}, FocusScope.of(context).unfocus();
// icon: Icon( toolbarType.value = '';
// Icons.add_circle_outline, },
// color: Theme.of(context).colorScheme.outline, child: FutureBuilder(
// ), future: _futureBuilderFuture,
// ), builder: (BuildContext context, snapshot) {
IconButton( if (snapshot.connectionState == ConnectionState.done) {
onPressed: () { if (snapshot.data == null) {
// if (toolbarType == 'input') { return const SizedBox();
// setState(() { }
// toolbarType = 'emote'; final Map data = snapshot.data as Map;
// }); if (data['status']) {
// } List messageList = _whisperDetailController.messageList;
// FocusScope.of(context).unfocus(); return Obx(
}, () => messageList.isEmpty
icon: Icon( ? const SizedBox()
Icons.emoji_emotions_outlined, : Align(
color: Theme.of(context).colorScheme.outline, alignment: Alignment.topCenter,
child: ListView.builder(
itemCount: messageList.length,
shrinkWrap: true,
reverse: true,
itemBuilder: (_, int i) {
if (i == 0) {
return Column(
children: [
ChatItem(
item: messageList[i],
e_infos: _whisperDetailController
.eInfos),
const SizedBox(height: 20),
],
);
} else {
return ChatItem(
item: messageList[i],
e_infos:
_whisperDetailController.eInfos);
}
},
),
),
);
} else {
// 请求错误
return const SizedBox();
}
} else {
// 骨架屏
return const SizedBox();
}
},
),
),
),
Obx(
() => Container(
padding: EdgeInsets.fromLTRB(
8,
12,
12,
toolbarType.value == ''
? MediaQuery.of(context).padding.bottom + 6
: 6,
),
decoration: BoxDecoration(
border: Border(
top: BorderSide(
width: 1,
color: Colors.grey.withOpacity(0.15),
), ),
), ),
Expanded( ),
child: Container( child: Row(
height: 45, mainAxisAlignment: MainAxisAlignment.center,
decoration: BoxDecoration( children: [
color: Theme.of(context) ToolbarIconButton(
.colorScheme onPressed: () {
.primary if (toolbarType.value == '') {
.withOpacity(0.08), toolbarType.value = 'emote';
borderRadius: BorderRadius.circular(40.0), } else if (toolbarType.value == 'input') {
), FocusScope.of(context).unfocus();
child: TextField( toolbarType.value = 'emote';
readOnly: true, } else if (toolbarType.value == 'emote') {
style: Theme.of(context).textTheme.titleMedium, FocusScope.of(context).requestFocus();
controller: _replyContentController, }
autofocus: false, },
focusNode: replyContentFocusNode, icon: const Icon(Icons.emoji_emotions_outlined, size: 22),
decoration: const InputDecoration( toolbarType: toolbarType.value,
border: InputBorder.none, // 移除默认边框 selected: false,
hintText: '开发中 ...', // 提示文本 ),
contentPadding: EdgeInsets.symmetric( const SizedBox(width: 4),
horizontal: 16.0, vertical: 12.0), // 内边距 Expanded(
child: Container(
height: 45,
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.outline
.withOpacity(0.05),
borderRadius: BorderRadius.circular(40.0),
),
child: TextField(
style: Theme.of(context).textTheme.titleMedium,
controller: _replyContentController,
autofocus: false,
focusNode: replyContentFocusNode,
decoration: const InputDecoration(
border: InputBorder.none, // 移除默认边框
hintText: '文明发言 ', // 提示文本
contentPadding: EdgeInsets.symmetric(
horizontal: 16.0, vertical: 12.0), // 内边距
),
), ),
), ),
), ),
), IconButton(
IconButton( onPressed: _whisperDetailController.sendMsg,
// onPressed: _whisperDetailController.sendMsg, icon: Icon(
onPressed: null, Icons.send,
icon: Icon( color: Theme.of(context).colorScheme.outline,
Icons.send, ),
color: Theme.of(context).colorScheme.outline,
), ),
), ],
// const SizedBox(width: 16), ),
],
), ),
AnimatedSize( ),
curve: Curves.easeInOut, Obx(
duration: const Duration(milliseconds: 300), () => AnimatedSize(
curve: Curves.linear,
duration: const Duration(milliseconds: 200),
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
height: toolbarType == 'input' ? keyboardHeight : emoteHeight, height: toolbarType.value == 'input'
? keyboardHeight
: toolbarType.value == 'emote'
? emoteHeight
: 0,
child: EmotePanel( child: EmotePanel(
onChoose: (package, emote) => {}, onChoose: (package, emote) => onChooseEmote(package, emote),
), ),
), ),
), ),
], ),
), ],
), ),
resizeToAvoidBottomInset: false,
); );
} }
} }

View File

@ -1,7 +1,6 @@
// ignore_for_file: must_be_immutable // ignore_for_file: must_be_immutable
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@ -69,9 +68,13 @@ class ChatItem extends StatelessWidget {
Color textColor(BuildContext context) { Color textColor(BuildContext context) {
return isOwner return isOwner
? Theme.of(context).colorScheme.onPrimary ? Theme.of(context).colorScheme.onPrimary
: Theme.of(context).colorScheme.onSecondaryContainer; : Theme.of(context).colorScheme.onBackground;
} }
const double safeDistanceval = 6;
const double borderRadiusVal = 12;
const double paddingVal = 10;
Widget richTextMessage(BuildContext context) { Widget richTextMessage(BuildContext context) {
var text = content['content']; var text = content['content'];
if (e_infos != null) { if (e_infos != null) {
@ -386,73 +389,98 @@ class ChatItem extends StatelessWidget {
? messageContent(context) ? messageContent(context)
: isRevoke : isRevoke
? const SizedBox() ? const SizedBox()
: Row( : Padding(
children: [ padding: const EdgeInsets.only(top: 12),
if (!isOwner) const SizedBox(width: 12), child: Row(
if (isOwner) const Spacer(), mainAxisAlignment: !isOwner
Container( ? MainAxisAlignment.start
constraints: const BoxConstraints( : MainAxisAlignment.end,
maxWidth: 300.0, // 设置最大宽度为200.0 crossAxisAlignment: CrossAxisAlignment.center,
), children: [
decoration: BoxDecoration( const SizedBox(width: safeDistanceval),
color: isOwner if (isOwner)
? Theme.of(context).colorScheme.primary Text(
: Theme.of(context).colorScheme.secondaryContainer, Utils.dateFormat(item.timestamp),
borderRadius: BorderRadius.only( style: Theme.of(context).textTheme.labelSmall!.copyWith(
topLeft: const Radius.circular(16), color: Theme.of(context).colorScheme.outline),
topRight: const Radius.circular(16),
bottomLeft: Radius.circular(isOwner ? 16 : 6),
bottomRight: Radius.circular(isOwner ? 6 : 16),
), ),
Container(
constraints: const BoxConstraints(
maxWidth: 300.0, // 设置最大宽度为200.0
),
decoration: BoxDecoration(
color: isOwner
? Theme.of(context)
.colorScheme
.primary
.withAlpha(180)
: Theme.of(context)
.colorScheme
.outlineVariant
.withOpacity(0.6)
.withAlpha(125),
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(borderRadiusVal),
topRight: const Radius.circular(borderRadiusVal),
bottomLeft:
Radius.circular(isOwner ? borderRadiusVal : 2),
bottomRight:
Radius.circular(isOwner ? 2 : borderRadiusVal),
),
),
margin: const EdgeInsets.only(
left: 8,
right: 8,
),
padding: const EdgeInsets.all(paddingVal),
child: messageContent(context),
// child: Column(
// crossAxisAlignment: isOwner
// ? CrossAxisAlignment.end
// : CrossAxisAlignment.start,
// children: [
// messageContent(context),
// SizedBox(height: isPic ? 7 : 2),
// Row(
// mainAxisSize: MainAxisSize.min,
// children: [
// Text(
// Utils.dateFormat(item.timestamp),
// style: Theme.of(context)
// .textTheme
// .labelSmall!
// .copyWith(
// color: isOwner
// ? Theme.of(context)
// .colorScheme
// .onPrimary
// .withOpacity(0.8)
// : Theme.of(context)
// .colorScheme
// .onSecondaryContainer
// .withOpacity(0.8)),
// ),
// item.msgStatus == 1
// ? Text(
// ' 已撤回',
// style:
// Theme.of(context).textTheme.labelSmall!,
// )
// : const SizedBox()
// ],
// )
// ],
// ),
), ),
margin: const EdgeInsets.only(top: 12), if (!isOwner)
padding: EdgeInsets.only( Text(
top: 8, Utils.dateFormat(item.timestamp),
bottom: 6, style: Theme.of(context).textTheme.labelSmall!.copyWith(
left: isPic ? 8 : 12, color: Theme.of(context).colorScheme.outline),
right: isPic ? 8 : 12, ),
), const SizedBox(width: safeDistanceval),
child: Column( ],
crossAxisAlignment: isOwner ),
? CrossAxisAlignment.end
: CrossAxisAlignment.start,
children: [
messageContent(context),
SizedBox(height: isPic ? 7 : 2),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
Utils.dateFormat(item.timestamp),
style: Theme.of(context)
.textTheme
.labelSmall!
.copyWith(
color: isOwner
? Theme.of(context)
.colorScheme
.onPrimary
.withOpacity(0.8)
: Theme.of(context)
.colorScheme
.onSecondaryContainer
.withOpacity(0.8)),
),
item.msgStatus == 1
? Text(
' 已撤回',
style:
Theme.of(context).textTheme.labelSmall!,
)
: const SizedBox()
],
)
],
),
),
if (!isOwner) const Spacer(),
if (isOwner) const SizedBox(width: 12),
],
); );
} }
} }