mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-23 15:40:37 +00:00
Add a translate entry on the status context menu Fix #258
This commit is contained in:
parent
921d28a57a
commit
987f259130
2 changed files with 18 additions and 5 deletions
|
@ -3,6 +3,7 @@ import Foundation
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct StatusRowContextMenu: View {
|
struct StatusRowContextMenu: View {
|
||||||
|
@EnvironmentObject private var preferences: UserPreferences
|
||||||
@EnvironmentObject private var account: CurrentAccount
|
@EnvironmentObject private var account: CurrentAccount
|
||||||
@EnvironmentObject private var routerPath: RouterPath
|
@EnvironmentObject private var routerPath: RouterPath
|
||||||
|
|
||||||
|
@ -74,6 +75,17 @@ struct StatusRowContextMenu: View {
|
||||||
} label: {
|
} label: {
|
||||||
Label("status.action.copy-text", systemImage: "doc.on.doc")
|
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 {
|
if account.account?.id == viewModel.status.account.id {
|
||||||
Section("status.action.section.your-post") {
|
Section("status.action.section.your-post") {
|
||||||
|
|
|
@ -235,10 +235,8 @@ public struct StatusRowView: View {
|
||||||
})
|
})
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
|
|
||||||
if preferences.showTranslateButton {
|
makeTranslateView(status: status)
|
||||||
makeTranslateView(status: status)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let poll = status.poll {
|
if let poll = status.poll {
|
||||||
StatusPollView(poll: poll, status: status)
|
StatusPollView(poll: poll, status: status)
|
||||||
|
@ -288,6 +286,7 @@ public struct StatusRowView: View {
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func makeTranslateView(status: AnyStatus) -> some View {
|
private func makeTranslateView(status: AnyStatus) -> some View {
|
||||||
if let userLang = preferences.serverPreferences?.postLanguage,
|
if let userLang = preferences.serverPreferences?.postLanguage,
|
||||||
|
preferences.showTranslateButton,
|
||||||
status.language != nil,
|
status.language != nil,
|
||||||
userLang != status.language,
|
userLang != status.language,
|
||||||
!status.content.asRawText.isEmpty,
|
!status.content.asRawText.isEmpty,
|
||||||
|
@ -304,7 +303,9 @@ public struct StatusRowView: View {
|
||||||
Text("status.action.translate")
|
Text("status.action.translate")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let translation = viewModel.translation {
|
}
|
||||||
|
|
||||||
|
if let translation = viewModel.translation {
|
||||||
GroupBox {
|
GroupBox {
|
||||||
VStack(alignment: .leading, spacing: 4) {
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
Text(translation)
|
Text(translation)
|
||||||
|
|
Loading…
Reference in a new issue