Make status rows draggable (#2141)

This commit is contained in:
fwcd 2024-07-29 07:56:42 +02:00 committed by GitHub
parent 9af98c3921
commit 33c2646ea1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 6 deletions

View file

@ -124,6 +124,7 @@ public struct StatusRowView: View {
}
}
}
.if(viewModel.url != nil) { $0.draggable(viewModel.url!) }
.contextMenu {
contextMenu
.onAppear {

View file

@ -106,6 +106,10 @@ import SwiftUI
status.inReplyToId != nil || status.inReplyToAccountId != nil
}
var url: URL? {
(status.reblog?.url ?? status.url).flatMap(URL.init(string:))
}
@ViewBuilder
func makeBackgroundColor(isHomeTimeline: Bool) -> some View {
if isHomeTimeline, theme.showContentGradient {

View file

@ -81,6 +81,7 @@ public struct StatusRowCardView: View {
.stroke(.gray.opacity(0.35), lineWidth: 1)
}
}
.draggable(url)
.contextMenu {
ShareLink(item: url) {
Label("status.card.share", systemImage: "square.and.arrow.up")

View file

@ -88,9 +88,7 @@ struct StatusRowContextMenu: View {
Divider()
Menu("status.action.share-title") {
if let urlString = viewModel.status.reblog?.url ?? viewModel.status.url,
let url = URL(string: urlString)
{
if let url = viewModel.url {
ShareLink(item: url,
subject: Text(viewModel.status.reblog?.account.safeDisplayName ?? viewModel.status.account.safeDisplayName),
message: Text(viewModel.status.reblog?.content.asRawText ?? viewModel.status.content.asRawText))
@ -133,7 +131,7 @@ struct StatusRowContextMenu: View {
}
}
if let url = URL(string: viewModel.status.reblog?.url ?? viewModel.status.url ?? "") {
if let url = viewModel.url {
Button { UIApplication.shared.open(url) } label: {
Label("status.action.view-in-browser", systemImage: "safari")
}
@ -152,7 +150,7 @@ struct StatusRowContextMenu: View {
}
Button {
UIPasteboard.general.string = viewModel.status.reblog?.url ?? viewModel.status.url
UIPasteboard.general.url = viewModel.url
} label: {
Label("status.action.copy-link", systemImage: "link")
}