feat: 私信
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -69,9 +68,13 @@ class ChatItem extends StatelessWidget {
|
||||
Color textColor(BuildContext context) {
|
||||
return isOwner
|
||||
? 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) {
|
||||
var text = content['content'];
|
||||
if (e_infos != null) {
|
||||
@ -386,73 +389,98 @@ class ChatItem extends StatelessWidget {
|
||||
? messageContent(context)
|
||||
: isRevoke
|
||||
? const SizedBox()
|
||||
: Row(
|
||||
children: [
|
||||
if (!isOwner) const SizedBox(width: 12),
|
||||
if (isOwner) const Spacer(),
|
||||
Container(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 300.0, // 设置最大宽度为200.0
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isOwner
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: const Radius.circular(16),
|
||||
topRight: const Radius.circular(16),
|
||||
bottomLeft: Radius.circular(isOwner ? 16 : 6),
|
||||
bottomRight: Radius.circular(isOwner ? 6 : 16),
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: !isOwner
|
||||
? MainAxisAlignment.start
|
||||
: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(width: safeDistanceval),
|
||||
if (isOwner)
|
||||
Text(
|
||||
Utils.dateFormat(item.timestamp),
|
||||
style: Theme.of(context).textTheme.labelSmall!.copyWith(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
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),
|
||||
padding: EdgeInsets.only(
|
||||
top: 8,
|
||||
bottom: 6,
|
||||
left: isPic ? 8 : 12,
|
||||
right: isPic ? 8 : 12,
|
||||
),
|
||||
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),
|
||||
],
|
||||
if (!isOwner)
|
||||
Text(
|
||||
Utils.dateFormat(item.timestamp),
|
||||
style: Theme.of(context).textTheme.labelSmall!.copyWith(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
const SizedBox(width: safeDistanceval),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user