mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-06-02 21:39:36 +00:00
Swift Format
This commit is contained in:
parent
bb81bc43e4
commit
2f2e00d3b7
|
@ -68,17 +68,17 @@ struct TranslationSettingsView: View {
|
|||
return true
|
||||
}
|
||||
#if canImport(_Translation_SwiftUI)
|
||||
if #available(iOS 17.4, *) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
if #available(iOS 17.4, *) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
#else
|
||||
return false
|
||||
return false
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var deepLPicker: some View {
|
||||
@Bindable var preferences = preferences
|
||||
|
@ -102,11 +102,12 @@ struct TranslationSettingsView: View {
|
|||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var backgroundAPIKey: some View {
|
||||
if preferences.preferredTranslationType != .useDeepl,
|
||||
!apiKey.isEmpty {
|
||||
!apiKey.isEmpty
|
||||
{
|
||||
Section {
|
||||
Text("settings.translation.api-key-still-stored")
|
||||
Button(role: .destructive) {
|
||||
|
|
|
@ -32,7 +32,7 @@ public enum DeepLUserAPIHandler {
|
|||
public static func readKey() -> String {
|
||||
return readKeyInternal() ?? ""
|
||||
}
|
||||
|
||||
|
||||
private static func readKeyInternal() -> String? {
|
||||
keychain.synchronizable = true
|
||||
return keychain.get(key)
|
||||
|
|
|
@ -7,12 +7,12 @@ public enum TranslationType: String, CaseIterable {
|
|||
|
||||
public var description: LocalizedStringKey {
|
||||
switch self {
|
||||
case .useServerIfPossible:
|
||||
"enum.translation-type.use-server-if-possible"
|
||||
case .useDeepl:
|
||||
"enum.translation-type.deepl"
|
||||
case .useApple:
|
||||
"enum.translation-type.apple"
|
||||
case .useServerIfPossible:
|
||||
"enum.translation-type.use-server-if-possible"
|
||||
case .useDeepl:
|
||||
"enum.translation-type.deepl"
|
||||
case .useApple:
|
||||
"enum.translation-type.apple"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,13 +60,13 @@ import SwiftUI
|
|||
@AppStorage("show_reply_indentation") public var showReplyIndentation: Bool = true
|
||||
|
||||
@AppStorage("show_account_popover") public var showAccountPopover: Bool = true
|
||||
|
||||
|
||||
@AppStorage("sidebar_expanded") public var isSidebarExpanded: Bool = false
|
||||
|
||||
init() {
|
||||
prepareTranslationType()
|
||||
}
|
||||
|
||||
|
||||
private func prepareTranslationType() {
|
||||
let sharedDefault = UserDefaults.standard
|
||||
if let alwaysUseDeepl = (sharedDefault.object(forKey: "always_use_deepl") as? Bool) {
|
||||
|
@ -75,16 +75,17 @@ import SwiftUI
|
|||
}
|
||||
sharedDefault.removeObject(forKey: "always_use_deepl")
|
||||
}
|
||||
#if canImport(_Translation_SwiftUI)
|
||||
if #unavailable(iOS 17.4),
|
||||
preferredTranslationType == .useApple {
|
||||
preferredTranslationType = .useServerIfPossible
|
||||
}
|
||||
#else
|
||||
if preferredTranslationType == .useApple {
|
||||
preferredTranslationType = .useServerIfPossible
|
||||
}
|
||||
#endif
|
||||
#if canImport(_Translation_SwiftUI)
|
||||
if #unavailable(iOS 17.4),
|
||||
preferredTranslationType == .useApple
|
||||
{
|
||||
preferredTranslationType = .useServerIfPossible
|
||||
}
|
||||
#else
|
||||
if preferredTranslationType == .useApple {
|
||||
preferredTranslationType = .useServerIfPossible
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,7 +351,7 @@ import SwiftUI
|
|||
storage.showAccountPopover = showAccountPopover
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public var isSidebarExpanded: Bool {
|
||||
didSet {
|
||||
storage.isSidebarExpanded = isSidebarExpanded
|
||||
|
|
|
@ -6,17 +6,17 @@ import Models
|
|||
import Network
|
||||
import SwiftUI
|
||||
#if canImport(_Translation_SwiftUI)
|
||||
import Translation
|
||||
import Translation
|
||||
|
||||
extension View {
|
||||
func addTranslateView(isPresented: Binding<Bool>, text: String) -> some View {
|
||||
if #available(iOS 17.4, *) {
|
||||
return self.translationPresentation(isPresented: isPresented, text: text)
|
||||
} else {
|
||||
return self
|
||||
extension View {
|
||||
func addTranslateView(isPresented: Binding<Bool>, text: String) -> some View {
|
||||
if #available(iOS 17.4, *) {
|
||||
return self.translationPresentation(isPresented: isPresented, text: text)
|
||||
} else {
|
||||
return self
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@MainActor
|
||||
|
@ -232,9 +232,9 @@ public struct StatusRowView: View {
|
|||
StatusDataControllerProvider.shared.dataController(for: viewModel.finalStatus,
|
||||
client: viewModel.client)
|
||||
)
|
||||
#if canImport(_Translation_SwiftUI)
|
||||
#if canImport(_Translation_SwiftUI)
|
||||
.addTranslateView(isPresented: $viewModel.showAppleTranslation, text: viewModel.finalStatus.content.asRawText)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
|
Loading…
Reference in a new issue