mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-24 14:02:53 +01:00
Add a translate entry on the status context menu Fix #258
This commit is contained in:
parent
921d28a57a
commit
987f259130
@ -3,6 +3,7 @@ import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct StatusRowContextMenu: View {
|
||||
@EnvironmentObject private var preferences: UserPreferences
|
||||
@EnvironmentObject private var account: CurrentAccount
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
|
||||
@ -74,6 +75,17 @@ struct StatusRowContextMenu: View {
|
||||
} label: {
|
||||
Label("status.action.copy-text", systemImage: "doc.on.doc")
|
||||
}
|
||||
|
||||
if let lang = preferences.serverPreferences?.postLanguage ?? Locale.current.language.languageCode?.identifier,
|
||||
viewModel.status.language != lang {
|
||||
Button {
|
||||
Task {
|
||||
await viewModel.translate(userLang: lang)
|
||||
}
|
||||
} label: {
|
||||
Label("status.action.translate", systemImage: "captions.bubble")
|
||||
}
|
||||
}
|
||||
|
||||
if account.account?.id == viewModel.status.account.id {
|
||||
Section("status.action.section.your-post") {
|
||||
|
@ -235,10 +235,8 @@ public struct StatusRowView: View {
|
||||
})
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if preferences.showTranslateButton {
|
||||
makeTranslateView(status: status)
|
||||
}
|
||||
|
||||
makeTranslateView(status: status)
|
||||
|
||||
if let poll = status.poll {
|
||||
StatusPollView(poll: poll, status: status)
|
||||
@ -288,6 +286,7 @@ public struct StatusRowView: View {
|
||||
@ViewBuilder
|
||||
private func makeTranslateView(status: AnyStatus) -> some View {
|
||||
if let userLang = preferences.serverPreferences?.postLanguage,
|
||||
preferences.showTranslateButton,
|
||||
status.language != nil,
|
||||
userLang != status.language,
|
||||
!status.content.asRawText.isEmpty,
|
||||
@ -304,7 +303,9 @@ public struct StatusRowView: View {
|
||||
Text("status.action.translate")
|
||||
}
|
||||
}
|
||||
} else if let translation = viewModel.translation {
|
||||
}
|
||||
|
||||
if let translation = viewModel.translation {
|
||||
GroupBox {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(translation)
|
||||
|
Loading…
Reference in New Issue
Block a user