2020-02-11 11:49:39 +00:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
2020-05-07 05:52:40 +00:00
|
|
|
import 'package:fluffychat/l10n/l10n.dart';
|
2020-02-11 11:49:39 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2020-05-09 11:36:41 +00:00
|
|
|
import 'html_message.dart';
|
|
|
|
import 'matrix.dart';
|
|
|
|
|
2020-02-11 11:49:39 +00:00
|
|
|
class ReplyContent extends StatelessWidget {
|
|
|
|
final Event replyEvent;
|
|
|
|
final bool lightText;
|
|
|
|
|
|
|
|
const ReplyContent(this.replyEvent, {this.lightText = false, Key key})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-05-09 11:36:41 +00:00
|
|
|
Widget replyBody;
|
2020-05-13 13:58:59 +00:00
|
|
|
if (replyEvent != null &&
|
|
|
|
Matrix.of(context).renderHtml &&
|
|
|
|
[EventTypes.Message, EventTypes.Encrypted].contains(replyEvent.type) &&
|
|
|
|
[MessageTypes.Text, MessageTypes.Notice, MessageTypes.Emote]
|
|
|
|
.contains(replyEvent.messageType) &&
|
|
|
|
!replyEvent.redacted &&
|
|
|
|
replyEvent.content['format'] == 'org.matrix.custom.html' &&
|
|
|
|
replyEvent.content['formatted_body'] is String) {
|
2020-05-09 11:36:41 +00:00
|
|
|
String html = replyEvent.content['formatted_body'];
|
|
|
|
if (replyEvent.messageType == MessageTypes.Emote) {
|
2020-05-13 13:58:59 +00:00
|
|
|
html = '* $html';
|
2020-05-09 11:36:41 +00:00
|
|
|
}
|
|
|
|
replyBody = HtmlMessage(
|
|
|
|
html: html,
|
|
|
|
textColor: lightText
|
|
|
|
? Colors.white
|
|
|
|
: Theme.of(context).textTheme.bodyText2.color,
|
|
|
|
maxLines: 1,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
replyBody = Text(
|
|
|
|
replyEvent?.getLocalizedBody(
|
|
|
|
L10n.of(context),
|
|
|
|
withSenderNamePrefix: false,
|
|
|
|
hideReply: true,
|
|
|
|
) ??
|
2020-05-13 13:58:59 +00:00
|
|
|
'',
|
2020-05-09 11:36:41 +00:00
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 1,
|
|
|
|
style: TextStyle(
|
|
|
|
color: lightText
|
|
|
|
? Colors.white
|
|
|
|
: Theme.of(context).textTheme.bodyText2.color),
|
|
|
|
);
|
|
|
|
}
|
2020-02-11 11:49:39 +00:00
|
|
|
return Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
width: 3,
|
|
|
|
height: 36,
|
|
|
|
color: lightText ? Colors.white : Theme.of(context).primaryColor,
|
|
|
|
),
|
|
|
|
SizedBox(width: 6),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
2020-05-13 13:58:59 +00:00
|
|
|
(replyEvent?.sender?.calcDisplayname() ?? '') + ':',
|
2020-02-11 11:49:39 +00:00
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color:
|
|
|
|
lightText ? Colors.white : Theme.of(context).primaryColor,
|
|
|
|
),
|
|
|
|
),
|
2020-05-09 11:36:41 +00:00
|
|
|
replyBody,
|
2020-02-11 11:49:39 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|