thunder-app / thunder

Thunder - An open-source cross-platform Lemmy client for iOS and Android built with Flutter
https://thunderapp.dev
GNU Affero General Public License v3.0
712 stars 62 forks source link

Add selectable post/comment text #1327

Closed micahmo closed 2 weeks ago

micahmo commented 3 weeks ago

Pull Request Description

Alright, here's take 2 of allowing posts/comments to be selectable. This can replace #1272. Now, when choosing the option to select text, a bottom modal is displayed. There are also some quick actions for viewing raw, selecting all, and copying the selection.

P.S. I removed the checkmark related to the "View source" feature, and simply changed the text to "View original" when in source mode. This feels a little cleaner to me.

Issue Being Fixed

Issue Number: N/A

Screenshots / Recordings

https://github.com/thunder-app/thunder/assets/7417301/7f1e429e-7877-4e16-a8f0-5af6af46e518

Checklist

micahmo commented 2 weeks ago
  • Could we move the text actions so that the copy actions are together? We can have it in this order as an example:
    • Select text
    • Copy comment (renamed from copy text) to indicate that we just want to copy the whole comment. Alternatively, we could just remove this option if you feel like it might be redundant
    • View original

Of course! How does this look?

image

When we are in the bottom sheet, "Copy selected" should be disabled if the user has not selected any text to copy

Hmm, this is a good idea. I can handle most things through onSelectionChanged. However, it seems like tapping elsewhere on the text, which also dismisses the selection, does not trigger this event. I tried a bunch of other stuff, like wrapping everything in a GestureDetector, listening to changes from the FocusNode, and handling the onTapText from CommonMarkdownBody, but none of them seem to give me a way to know when the selection was dismissed due to tapping on the text.

At the very least, I could make the button disable initially and only enabled once the first selection is made. Thoughts?

hjiangsu commented 2 weeks ago

Of course! How does this look?

It looks great. Thanks!

I could make the button disable initially and only enabled once the first selection is made. Thoughts?

I think that works for now. Thanks for trying this out!

micahmo commented 2 weeks ago

I think that works for now. Thanks for trying this out!

No problem! Here's what it'll look like.

https://github.com/thunder-app/thunder/assets/7417301/2a8cb674-30ef-4e92-b3da-78cec2d2fc07

This should be ready to go now!