Better sharing for status and account close #837

This commit is contained in:
Thomas Ricouard 2023-02-14 07:26:57 +01:00
parent df98e0f987
commit 1f14311c2c
3 changed files with 11 additions and 5 deletions

View File

@ -498,7 +498,7 @@ public struct AccountDetailView: View {
}
if let url = account.url {
ShareLink(item: url) {
ShareLink(item: url, subject: Text(account.safeDisplayName)) {
Label("account.action.share", systemImage: "square.and.arrow.up")
}
Button { UIApplication.shared.open(url) } label: {

View File

@ -63,8 +63,11 @@ struct StatusActionsView: View {
HStack {
ForEach(Actions.allCases, id: \.self) { action in
if action == .share {
if let url = viewModel.status.reblog?.url ?? viewModel.status.url {
ShareLink(item: url) {
if let urlString = viewModel.status.reblog?.url ?? viewModel.status.url,
let url = URL(string: urlString) {
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)) {
Image(systemName: action.iconName(viewModel: viewModel))
}
.buttonStyle(.borderless)

View File

@ -57,8 +57,11 @@ struct StatusRowContextMenu: View {
Divider()
if let url = viewModel.status.reblog?.url ?? viewModel.status.url {
ShareLink(item: url) {
if let urlString = viewModel.status.reblog?.url ?? viewModel.status.url,
let url = URL(string: urlString) {
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)) {
Label("status.action.share", systemImage: "square.and.arrow.up")
}
}