✨ Render replied message!
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:solian/models/message.dart';
|
||||
import 'package:solian/widgets/chat/content.dart';
|
||||
import 'package:solian/widgets/posts/content/attachment.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
import 'dart:math' as math;
|
||||
|
||||
class ChatMessage extends StatelessWidget {
|
||||
final Message item;
|
||||
@@ -21,6 +24,49 @@ class ChatMessage extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Widget renderReply() {
|
||||
final padding =
|
||||
underMerged ? const EdgeInsets.only(left: 14, right: 8, top: 4) : const EdgeInsets.only(left: 8, right: 8);
|
||||
|
||||
if (item.replyTo != null) {
|
||||
return Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: padding,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Transform(
|
||||
alignment: Alignment.center,
|
||||
transform: Matrix4.rotationY(math.pi),
|
||||
child: const Icon(Icons.reply, size: 16),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
CircleAvatar(
|
||||
radius: 10,
|
||||
backgroundImage: NetworkImage(item.replyTo!.sender.account.avatar),
|
||||
),
|
||||
]),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 12, top: 2),
|
||||
child: ChatMessageContent(item: item.replyTo!),
|
||||
),
|
||||
renderAttachment()
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final contentPart = Padding(
|
||||
@@ -48,27 +94,32 @@ class ChatMessage extends StatelessWidget {
|
||||
const SizedBox(width: 40),
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [contentPart, renderAttachment()],
|
||||
children: [renderReply(), contentPart, renderAttachment()],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
return Column(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundImage: NetworkImage(item.sender.account.avatar),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
userinfoPart,
|
||||
contentPart,
|
||||
renderAttachment(),
|
||||
],
|
||||
),
|
||||
renderReply(),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundImage: NetworkImage(item.sender.account.avatar),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
userinfoPart,
|
||||
contentPart,
|
||||
renderAttachment(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
Reference in New Issue
Block a user