Copy text of status

This commit is contained in:
Lumaa 2024-01-26 14:09:52 +01:00
parent 95c63952e1
commit 3564ceb470
2 changed files with 65 additions and 15 deletions

View File

@ -1,30 +1,43 @@
//Made by Lumaa //Made by Lumaa
import SwiftUI import SwiftUI
import UniformTypeIdentifiers
struct PostMenu: View { struct PostMenu: View {
@Environment(\.colorScheme) private var colorScheme
@Environment(Navigator.self) private var navigator @Environment(Navigator.self) private var navigator
@Environment(AccountManager.self) private var accountManager
@Environment(\.colorScheme) private var colorScheme
@Environment(\.displayScale) private var displayScale @Environment(\.displayScale) private var displayScale
var status: Status var status: Status
private var isOwner: Bool {
if let acc = accountManager.getAccount() {
return status.account.id == acc.id
}
return false
}
var body: some View { var body: some View {
Menu { Menu {
Button(role: .destructive) { if isOwner {
print("Delete") Button(role: .destructive) {
} label: { Task {
Label("status.menu.delete", systemImage: "trash") await deleteStatus()
}
} label: {
Label("status.menu.delete", systemImage: "trash")
}
Button {
navigator.presentedSheet = .post(content: status.reblogAsAsStatus?.content.asRawText ?? status.content.asRawText, replyId: nil, editId: status.reblogAsAsStatus?.id ?? status.id)
} label: {
Label("status.menu.edit", systemImage: "pencil.and.scribble")
}
Divider()
} }
Button {
print("Edit")
} label: {
Label("status.menu.edit", systemImage: "pencil.and.scribble")
}
Divider()
Menu { Menu {
ShareLink(item: URL(string: status.url ?? "https://joinmastodon.org/")!) { ShareLink(item: URL(string: status.url ?? "https://joinmastodon.org/")!) {
Label("status.menu.share-link", systemImage: "square.and.arrow.up") Label("status.menu.share-link", systemImage: "square.and.arrow.up")
@ -32,11 +45,19 @@ struct PostMenu: View {
Button { Button {
Task { Task {
await createImage() createImage()
} }
} label: { } label: {
Label("status.menu.share-image", systemImage: "photo") Label("status.menu.share-image", systemImage: "photo")
} }
Divider()
Button {
UIPasteboard.general.setValue(status.reblogAsAsStatus?.content.asRawText ?? status.content.asRawText, forPasteboardType: UTType.plainText.identifier)
} label: {
Label("status.menu.copy-text", systemImage: "list.clipboard")
}
} label: { } label: {
Label("status.menu.share", systemImage: "paperplane") Label("status.menu.share", systemImage: "paperplane")
} }
@ -64,7 +85,13 @@ struct PostMenu: View {
render.isOpaque = false render.isOpaque = false
if let image = render.uiImage { if let image = render.uiImage {
navigator.presentedSheet = .shareImage(image: image) navigator.presentedSheet = .shareImage(image: image, status: status)
}
}
private func deleteStatus() async {
if let client = accountManager.getClient() {
_ = try? await client.delete(endpoint: Statuses.status(id: status.id))
} }
} }
} }

View File

@ -1,6 +1,9 @@
{ {
"sourceLanguage" : "en", "sourceLanguage" : "en",
"strings" : { "strings" : {
"@%@" : {
},
"#%@" : { "#%@" : {
}, },
@ -404,6 +407,16 @@
} }
} }
}, },
"status.editing" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Editing post"
}
}
}
},
"status.favourites-%lld" : { "status.favourites-%lld" : {
"localizations" : { "localizations" : {
"en" : { "en" : {
@ -426,6 +439,16 @@
} }
} }
}, },
"status.menu.copy-text" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Copy text"
}
}
}
},
"status.menu.delete" : { "status.menu.delete" : {
"localizations" : { "localizations" : {
"en" : { "en" : {