Skip to content

Commit

Permalink
Swift Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Havhingstor committed May 10, 2024
1 parent bb81bc4 commit 2f2e00d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
19 changes: 10 additions & 9 deletions IceCubesApp/App/Tabs/Settings/TranslationSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Packages/Env/Sources/Env/DeepLUserAPIHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions Packages/Env/Sources/Env/TranslationType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
27 changes: 14 additions & 13 deletions Packages/Env/Sources/Env/UserPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
}

Expand Down Expand Up @@ -350,7 +351,7 @@ import SwiftUI
storage.showAccountPopover = showAccountPopover
}
}

public var isSidebarExpanded: Bool {
didSet {
storage.isSidebarExpanded = isSidebarExpanded
Expand Down
20 changes: 10 additions & 10 deletions Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2f2e00d

Please sign in to comment.