Clickable hyperlinks for MessageBubbles #235
|
@ -68,7 +68,7 @@ class MessageBubbleState extends State<MessageBubble> {
|
|||
text: widget.content + '\u202F',
|
||||
// TODO: onOpen breaks the "selectable" functionality. Maybe something to do with gesture handler?
|
||||
|
||||
options: LinkifyOptions(humanize: false),
|
||||
linkifiers: [UrlLinkifier()], // TODO: double-check on this (only web links to avoid Android messiness)
|
||||
linkifiers: [UrlLinkifier()],
|
||||
NimaBoscarino
commented
This restricts Linkify to only format URLs. Does this sound okay for now? This restricts Linkify to only format URLs. Does this sound okay for now?
sarah
commented
Yeah this sounds good. Yeah this sounds good.
|
||||
onOpen: (link) {
|
||||
_modalOpenLink(context, link);
|
||||
},
|
||||
|
@ -122,7 +122,6 @@ class MessageBubbleState extends State<MessageBubble> {
|
|||
context: ctx,
|
||||
builder: (BuildContext bcontext) {
|
||||
return Container(
|
||||
// TODO: Ask re: hard-coded height
|
||||
height: 200, // bespoke value courtesy of the [TextField] docs
|
||||
child: Center(
|
||||
NimaBoscarino
commented
I stole this modal from elsewhere in the code. Since the height has been hard-coded to 200 in several places, should I extract the modal out to be its own widget? I stole this modal from elsewhere in the code. Since the height has been hard-coded to 200 in several places, should I extract the modal out to be its own widget?
sarah
commented
I think having this widget defined here right now is fine. We have a separate task planned to go through and check widgets like (with hard coded heights etc.) I think having this widget defined here right now is fine. We have a separate task planned to go through and check widgets like (with hard coded heights etc.)
|
||||
child: Padding(
|
||||
|
@ -134,7 +133,6 @@ class MessageBubbleState extends State<MessageBubble> {
|
|||
Text(
|
||||
"Opening this link will launch an application outside of Cwtch and may reveal metadata or otherwise compromise the security of Cwtch. Only open links from people you trust. Are you sure you want to continue?"
|
||||
),
|
||||
// TODO: Ask about styling preferences (should this be a reusable "inline-button"?)
|
||||
Flex(direction: Axis.horizontal, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
|
||||
NimaBoscarino
commented
I'm quite new to styling and layout in Flutter. Does this look okay, or are there cleaner/other ways preferred? I'm quite new to styling and layout in Flutter. Does this look okay, or are there cleaner/other ways preferred?
sarah
commented
This looks fine :) This looks fine :)
|
||||
|
@ -143,10 +141,11 @@ class MessageBubbleState extends State<MessageBubble> {
|
|||
onPressed: () {
|
||||
Clipboard.setData(new ClipboardData(text: link.url));
|
||||
|
||||
// TODO: Ask about desired SnackBar + modal behaviour
|
||||
final snackBar = SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!.copiedClipboardNotification),
|
||||
);
|
||||
|
||||
NimaBoscarino
commented
I saw that in other places in Cwtch there's a snackbar displayed for the "Copy to clipboard" action, so I did the same here. It currently renders under the modal though, and I'm not sure how to make it display above. Any thoughts/suggestions for that? I saw that in other places in Cwtch there's a snackbar displayed for the "Copy to clipboard" action, so I did the same here. It currently renders under the modal though, and I'm not sure how to make it display above. Any thoughts/suggestions for that?
sarah
commented
You will probably need to cancel/destroy the modal prior to launching the snackBar. You will probably need to cancel/destroy the modal prior to launching the snackBar.
|
||||
Navigator.pop(bcontext);
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
},
|
||||
),
|
||||
|
|
For some reason, once I add the
onOpen
handler the text selection breaks (e.g. https://i.imgur.com/SrtOLIG.mp4). I don't know enough about Flutter/Dart to figure it out easily, do you know what the case might be? I tried to recreate it in a fresh sandbox but had no luck, so I'm wondering if maybe theTapGestureRecognizer
in Linkify conflicts with theMouseRegion
inmessagerow.dart
?We've definitely had a few issues with widgets interacting in these kinds of ways. I will take a look into this early next week.
I could not replicate the lack of text selection on Linux under the following Flutter Build
As such I wonder if this is platform specific (or perhaps fixed in a newer version of flutter).
I tried it with
and still ran into the issue, so it looks like it might be as macOS-specific issue!