From f6710484a291da781ba732eb37af6f260a325890 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Thu, 24 Nov 2022 13:28:25 -0800 Subject: [PATCH] Add replying to --- lib/themes/juniper.dart | 1 - lib/widgets/quotedmessage.dart | 49 ++++++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/lib/themes/juniper.dart b/lib/themes/juniper.dart index a8965657..33308e32 100644 --- a/lib/themes/juniper.dart +++ b/lib/themes/juniper.dart @@ -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; diff --git a/lib/widgets/quotedmessage.dart b/lib/widgets/quotedmessage.dart index 038d9052..ab03e46d 100644 --- a/lib/widgets/quotedmessage.dart +++ b/lib/widgets/quotedmessage.dart @@ -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 { senderDisplayStr = Provider.of(context).senderHandle; } } + var wdgSender = SelectableText(senderDisplayStr, style: TextStyle(fontSize: 9.0, color: fromMe ? Provider.of(context).theme.messageFromMeTextColor : Provider.of(context).theme.messageFromOtherTextColor)); @@ -81,8 +79,28 @@ class QuotedMessageBubbleState extends State { 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 are quoted then display our nickname + if (qMessage.getMetadata().senderHandle == Provider.of(context).onion) { + qMessageSender = Provider.of(context).nickname; + } else { + qMessageSender = Provider.of(context).senderHandle; + ContactInfoState? contact = Provider.of(context).contactList.findContact(qMessage.getMetadata().senderHandle); + if (contact != null) { + qMessageSender = contact.nickname; + } + } + var qTextColor = fromMe ? Provider.of(context).theme.messageFromOtherTextColor : Provider.of(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,15 +121,18 @@ class QuotedMessageBubbleState extends State { color: fromMe ? Provider.of(context).theme.messageFromOtherBackgroundColor : Provider.of(context).theme.messageFromMeBackgroundColor, ), height: 75, - child: 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( - textWidthBasis: TextWidthBasis.parent, - child: qMessage.getPreviewWidget(context), - style: TextStyle(color: qTextColor), - overflow: TextOverflow.fade, - )) + 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( + textWidthBasis: TextWidthBasis.parent, + child: qMessage.getPreviewWidget(context), + style: TextStyle(color: qTextColor), + overflow: TextOverflow.fade, + )) + ]) ])))); } catch (e) { return MalformedBubble();