New status row context menu

This commit is contained in:
Thomas Ricouard 2024-01-22 09:14:45 +01:00
parent 9a8568d3fa
commit 46b8fbde29

View File

@ -37,38 +37,41 @@ struct StatusRowContextMenu: View {
var body: some View { var body: some View {
if !viewModel.isRemote { if !viewModel.isRemote {
Button { Task { ControlGroup {
HapticManager.shared.fireHaptic(.notification(.success)) Button {
SoundEffectManager.shared.playSound(.favorite) #if targetEnvironment(macCatalyst) || os(visionOS)
await statusDataController.toggleFavorite(remoteStatus: nil) openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.status))
} } label: { #else
Label(statusDataController.isFavorited ? "status.action.unfavorite" : "status.action.favorite", systemImage: statusDataController.isFavorited ? "star.fill" : "star") viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
} #endif
Button { Task { } label: {
HapticManager.shared.fireHaptic(.notification(.success)) Label("status.action.reply", systemImage: "arrowshape.turn.up.left")
SoundEffectManager.shared.playSound(.boost) }
await statusDataController.toggleReblog(remoteStatus: nil) Button { Task {
} } label: { HapticManager.shared.fireHaptic(.notification(.success))
boostLabel SoundEffectManager.shared.playSound(.favorite)
} await statusDataController.toggleFavorite(remoteStatus: nil)
.disabled(viewModel.status.visibility == .direct || viewModel.status.visibility == .priv && viewModel.status.account.id != account.account?.id) } } label: {
Button { Task { Label(statusDataController.isFavorited ? "status.action.unfavorite" : "status.action.favorite", systemImage: statusDataController.isFavorited ? "star.fill" : "star")
SoundEffectManager.shared.playSound(.bookmark) }
HapticManager.shared.fireHaptic(.notification(.success)) Button { Task {
await statusDataController.toggleBookmark(remoteStatus: nil) HapticManager.shared.fireHaptic(.notification(.success))
} } label: { SoundEffectManager.shared.playSound(.boost)
Label(statusDataController.isBookmarked ? "status.action.unbookmark" : "status.action.bookmark", await statusDataController.toggleReblog(remoteStatus: nil)
systemImage: statusDataController.isBookmarked ? "bookmark.fill" : "bookmark") } } label: {
} boostLabel
Button { }
#if targetEnvironment(macCatalyst) || os(visionOS) .disabled(viewModel.status.visibility == .direct || viewModel.status.visibility == .priv && viewModel.status.account.id != account.account?.id)
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.status)) Button { Task {
#else SoundEffectManager.shared.playSound(.bookmark)
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status) HapticManager.shared.fireHaptic(.notification(.success))
#endif await statusDataController.toggleBookmark(remoteStatus: nil)
} label: { } } label: {
Label("status.action.reply", systemImage: "arrowshape.turn.up.left") Label(statusDataController.isBookmarked ? "status.action.unbookmark" : "status.action.bookmark",
systemImage: statusDataController.isBookmarked ? "bookmark.fill" : "bookmark")
}
} }
.controlGroupStyle(.compactMenu)
Button { Button {
#if targetEnvironment(macCatalyst) || os(visionOS) #if targetEnvironment(macCatalyst) || os(visionOS)
openWindow(value: WindowDestinationEditor.quoteStatusEditor(status: viewModel.status)) openWindow(value: WindowDestinationEditor.quoteStatusEditor(status: viewModel.status))
@ -194,45 +197,6 @@ struct StatusRowContextMenu: View {
} else { } else {
if !viewModel.isRemote { if !viewModel.isRemote {
Section(viewModel.status.reblog?.account.acct ?? viewModel.status.account.acct) { Section(viewModel.status.reblog?.account.acct ?? viewModel.status.account.acct) {
Button {
viewModel.routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.reblog?.account ?? viewModel.status.account, visibility: .pub)
} label: {
Label("status.action.mention", systemImage: "at")
}
Button {
viewModel.routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.reblog?.account ?? viewModel.status.account, visibility: .direct)
} label: {
Label("status.action.message", systemImage: "tray.full")
}
if viewModel.authorRelationship?.blocking == true {
Button {
Task {
do {
let operationAccount = viewModel.status.reblog?.account ?? viewModel.status.account
viewModel.authorRelationship = try await client.post(endpoint: Accounts.unblock(id: operationAccount.id))
} catch {
print("Error while unblocking: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.unblock", systemImage: "person.crop.circle.badge.exclamationmark")
}
} else {
Button {
Task {
do {
let operationAccount = viewModel.status.reblog?.account ?? viewModel.status.account
viewModel.authorRelationship = try await client.post(endpoint: Accounts.block(id: operationAccount.id))
} catch {
print("Error while blocking: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.block", systemImage: "person.crop.circle.badge.xmark")
}
}
if viewModel.authorRelationship?.muting == true { if viewModel.authorRelationship?.muting == true {
Button { Button {
Task { Task {
@ -264,6 +228,45 @@ struct StatusRowContextMenu: View {
Label("account.action.mute", systemImage: "speaker.slash") Label("account.action.mute", systemImage: "speaker.slash")
} }
} }
ControlGroup {
Button {
viewModel.routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.reblog?.account ?? viewModel.status.account, visibility: .pub)
} label: {
Label("status.action.mention", systemImage: "at")
}
Button {
viewModel.routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.reblog?.account ?? viewModel.status.account, visibility: .direct)
} label: {
Label("status.action.message", systemImage: "tray.full")
}
if viewModel.authorRelationship?.blocking == true {
Button {
Task {
do {
let operationAccount = viewModel.status.reblog?.account ?? viewModel.status.account
viewModel.authorRelationship = try await client.post(endpoint: Accounts.unblock(id: operationAccount.id))
} catch {
print("Error while unblocking: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.unblock", systemImage: "person.crop.circle.badge.exclamationmark")
}
} else {
Button {
Task {
do {
let operationAccount = viewModel.status.reblog?.account ?? viewModel.status.account
viewModel.authorRelationship = try await client.post(endpoint: Accounts.block(id: operationAccount.id))
} catch {
print("Error while blocking: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.block", systemImage: "person.crop.circle.badge.xmark")
}
}
}
} }
} }
Section { Section {