Enable Formatting on Quoted Messages / Add "Replying To" Indicator #574
|
@ -1,5 +1,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:cwtch/config.dart';
|
||||
import 'package:cwtch/models/message.dart';
|
||||
import 'package:cwtch/models/messages/malformedmessage.dart';
|
||||
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||
|
@ -8,6 +9,9 @@ import 'package:cwtch/widgets/quotedmessage.dart';
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../settings.dart';
|
||||
import '../../third_party/linkify/flutter_linkify.dart';
|
||||
|
||||
class QuotedMessageStructure {
|
||||
final String quotedHash;
|
||||
final String body;
|
||||
|
@ -34,9 +38,16 @@ class QuotedMessage extends Message {
|
|||
this.content,
|
||||
);
|
||||
var content = message["body"];
|
||||
return Text(
|
||||
content,
|
||||
);
|
||||
var formatMessages = Provider.of<Settings>(context).isExperimentEnabled(FormattingExperiment);
|
||||
return SelectableLinkify(
|
||||
text: content + '\u202F',
|
||||
options: LinkifyOptions(messageFormatting: formatMessages, parseLinks: false, looseUrl: true, defaultToHttps: true),
|
||||
linkifiers: [UrlLinkifier()],
|
||||
onOpen: null,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(overflow: TextOverflow.ellipsis),
|
||||
codeStyle: TextStyle(overflow: TextOverflow.ellipsis),
|
||||
textWidthBasis: TextWidthBasis.longestLine);
|
||||
} catch (e) {
|
||||
return MalformedBubble();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../settings.dart';
|
||||
import '../../third_party/linkify/flutter_linkify.dart';
|
||||
|
||||
class TextMessage extends Message {
|
||||
final MessageMetadata metadata;
|
||||
final String content;
|
||||
|
@ -21,9 +24,16 @@ class TextMessage extends Message {
|
|||
return ChangeNotifierProvider.value(
|
||||
value: this.metadata,
|
||||
builder: (bcontext, child) {
|
||||
return Text(
|
||||
this.content,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
var formatMessages = Provider.of<Settings>(bcontext).isExperimentEnabled(FormattingExperiment);
|
||||
return SelectableLinkify(
|
||||
text: content + '\u202F',
|
||||
options: LinkifyOptions(messageFormatting: formatMessages, parseLinks: false, looseUrl: true, defaultToHttps: true),
|
||||
linkifiers: [UrlLinkifier()],
|
||||
onOpen: null,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(overflow: TextOverflow.ellipsis),
|
||||
codeStyle: TextStyle(overflow: TextOverflow.ellipsis),
|
||||
textWidthBasis: TextWidthBasis.longestLine,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ class Juniper extends CwtchDark {
|
|||
static final Color accent = Color(0xFF9E6A56);
|
||||
static final Color accentAlt = Color(0xFF845A48);
|
||||
|
||||
|
||||
get theme => juniper_theme;
|
||||
get mode => mode_dark;
|
||||
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
import 'package:cwtch/controllers/open_link_modal.dart';
|
||||
import 'package:cwtch/models/appstate.dart';
|
||||
import 'package:cwtch/models/contact.dart';
|
||||
import 'package:cwtch/models/message.dart';
|
||||
import 'package:cwtch/models/profile.dart';
|
||||
import 'package:cwtch/third_party/linkify/flutter_linkify.dart';
|
||||
import 'package:cwtch/views/contactsview.dart';
|
||||
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||
import 'package:cwtch/widgets/messageloadingbubble.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import '../settings.dart';
|
||||
import 'messagebubbledecorations.dart';
|
||||
|
||||
|
@ -45,6 +42,7 @@ class QuotedMessageBubbleState extends State<QuotedMessageBubble> {
|
|||
senderDisplayStr = Provider.of<MessageMetadata>(context).senderHandle;
|
||||
}
|
||||
}
|
||||
|
||||
var wdgSender = SelectableText(senderDisplayStr,
|
||||
style: TextStyle(fontSize: 9.0, color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor : Provider.of<Settings>(context).theme.messageFromOtherTextColor));
|
||||
|
||||
|
@ -81,8 +79,30 @@ class QuotedMessageBubbleState extends State<QuotedMessageBubble> {
|
|||
if (snapshot.hasData) {
|
||||
try {
|
||||
var qMessage = (snapshot.data! as Message);
|
||||
// Swap the background color for quoted tweets..
|
||||
|
||||
// If the sender is not us, then we want to give them a nickname...
|
||||
String qMessageSender;
|
||||
|
||||
// if we sent the quoted message then display our nickname
|
||||
if (qMessage.getMetadata().senderHandle == Provider.of<ProfileInfoState>(context).onion) {
|
||||
qMessageSender = Provider.of<ProfileInfoState>(context).nickname;
|
||||
} else {
|
||||
// default to handle
|
||||
qMessageSender = qMessage.getMetadata().senderHandle;
|
||||
// if we have the handle as a contact then replace with the nickname...
|
||||
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(qMessageSender);
|
||||
if (contact != null) {
|
||||
qMessageSender = contact.nickname;
|
||||
}
|
||||
}
|
||||
|
||||
var qTextColor = fromMe ? Provider.of<Settings>(context).theme.messageFromOtherTextColor : Provider.of<Settings>(context).theme.messageFromMeTextColor;
|
||||
|
||||
var wdgReplyingTo = SelectableText(
|
||||
AppLocalizations.of(context)!.replyingTo.replaceAll("%1", qMessageSender),
|
||||
style: TextStyle(fontSize: 10, color: qTextColor.withOpacity(0.8)),
|
||||
);
|
||||
// Swap the background color for quoted tweets..
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
|
@ -103,7 +123,9 @@ class QuotedMessageBubbleState extends State<QuotedMessageBubble> {
|
|||
color: fromMe ? Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor : Provider.of<Settings>(context).theme.messageFromMeBackgroundColor,
|
||||
),
|
||||
height: 75,
|
||||
child: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: [
|
||||
child: Column(children: [
|
||||
Align(alignment: Alignment.centerLeft, child: wdgReplyingTo),
|
||||
Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: [
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0), child: Icon(Icons.reply, size: 32, color: qTextColor)),
|
||||
Flexible(
|
||||
child: DefaultTextStyle(
|
||||
|
@ -112,6 +134,7 @@ class QuotedMessageBubbleState extends State<QuotedMessageBubble> {
|
|||
style: TextStyle(color: qTextColor),
|
||||
overflow: TextOverflow.fade,
|
||||
))
|
||||
])
|
||||
]))));
|
||||
} catch (e) {
|
||||
return MalformedBubble();
|
||||
|
|
Loading…
Reference in New Issue