Run SwiftFormat

This commit is contained in:
Thomas Ricouard 2023-01-22 06:38:30 +01:00
parent 5991641d32
commit a79c5691e0
49 changed files with 234 additions and 237 deletions

View file

@ -220,7 +220,6 @@ class AppDelegate: NSObject, UIApplicationDelegate {
}
func application(_: UIApplication, didFailToRegisterForRemoteNotificationsWithError _: Error) {}
}
class ThemeObserverViewController: UIViewController {

View file

@ -1,10 +1,10 @@
import AppAccount
import Env
import Models
import Network
import Notifications
import SwiftUI
import Timeline
import Models
struct NotificationsTab: View {
@EnvironmentObject private var client: Client

View file

@ -5,9 +5,9 @@ import Env
import Models
import Network
import NukeUI
import SafariServices
import Shimmer
import SwiftUI
import SafariServices
struct AddAccountView: View {
@Environment(\.dismiss) private var dismiss
@ -235,11 +235,9 @@ struct AddAccountView: View {
struct SafariView: UIViewControllerRepresentable {
let url: URL
func makeUIViewController(context: UIViewControllerRepresentableContext<SafariView>) -> SFSafariViewController {
func makeUIViewController(context _: UIViewControllerRepresentableContext<SafariView>) -> SFSafariViewController {
SFSafariViewController(url: url)
}
func updateUIViewController(_ uiViewController: SFSafariViewController, context: UIViewControllerRepresentableContext<SafariView>) {
}
func updateUIViewController(_: SFSafariViewController, context _: UIViewControllerRepresentableContext<SafariView>) {}
}

View file

@ -1,8 +1,8 @@
import DesignSystem
import Env
import Models
import Status
import SwiftUI
import Env
struct DisplaySettingsView: View {
@EnvironmentObject private var theme: Theme
@ -16,15 +16,15 @@ struct DisplaySettingsView: View {
Toggle("settings.display.theme.systemColor", isOn: $theme.followSystemColorScheme)
themeSelectorButton
ColorPicker("settings.display.theme.tint", selection: $theme.tintColor)
.onChange(of: theme.tintColor) { newValue in
.onChange(of: theme.tintColor) { _ in
theme.followSystemColorScheme = false
}
ColorPicker("settings.display.theme.background", selection: $theme.primaryBackgroundColor)
.onChange(of: theme.primaryBackgroundColor) { newValue in
.onChange(of: theme.primaryBackgroundColor) { _ in
theme.followSystemColorScheme = false
}
ColorPicker("settings.display.theme.secondary-background", selection: $theme.secondaryBackgroundColor)
.onChange(of: theme.primaryBackgroundColor) { newValue in
.onChange(of: theme.primaryBackgroundColor) { _ in
theme.followSystemColorScheme = false
}
}

View file

@ -9,14 +9,15 @@ public class FollowButtonViewModel: ObservableObject {
public let accountId: String
public let shouldDisplayNotify: Bool
public let relationshipUpdated: ((Relationship) -> Void)
public let relationshipUpdated: (Relationship) -> Void
@Published public private(set) var relationship: Relationship
@Published public private(set) var isUpdating: Bool = false
public init(accountId: String,
relationship: Relationship,
shouldDisplayNotify: Bool,
relationshipUpdated: @escaping ((Relationship) -> Void)) {
relationshipUpdated: @escaping ((Relationship) -> Void))
{
self.accountId = accountId
self.relationship = relationship
self.shouldDisplayNotify = shouldDisplayNotify

View file

@ -43,8 +43,7 @@ class ConversationsListViewModel: ObservableObject {
nextPage = nil
}
isLoadingNextPage = false
} catch {
}
} catch {}
}
}

View file

@ -1,14 +1,13 @@
import SwiftUI
import Env
import SwiftUI
@MainActor
extension Font {
public static func userScaledFontSize(baseSize: CGFloat) -> CGFloat {
public extension Font {
static func userScaledFontSize(baseSize: CGFloat) -> CGFloat {
UIFontMetrics.default.scaledValue(for: baseSize * UserPreferences.shared.fontSizeScale)
}
public static var scaledTitle: Font {
static var scaledTitle: Font {
if ProcessInfo.processInfo.isiOSAppOnMac {
return .system(size: userScaledFontSize(baseSize: 28))
} else {
@ -16,7 +15,7 @@ extension Font {
}
}
public static var scaledHeadline: Font {
static var scaledHeadline: Font {
if ProcessInfo.processInfo.isiOSAppOnMac {
return .system(size: userScaledFontSize(baseSize: 20), weight: .semibold)
} else {
@ -24,7 +23,7 @@ extension Font {
}
}
public static var scaledBody: Font {
static var scaledBody: Font {
if ProcessInfo.processInfo.isiOSAppOnMac {
return .system(size: userScaledFontSize(baseSize: 19))
} else {
@ -32,7 +31,7 @@ extension Font {
}
}
public static var scaledBodyUIFont: UIFont {
static var scaledBodyUIFont: UIFont {
if ProcessInfo.processInfo.isiOSAppOnMac {
return UIFont.systemFont(ofSize: userScaledFontSize(baseSize: 19))
} else {
@ -40,7 +39,7 @@ extension Font {
}
}
public static var scaledCallout: Font {
static var scaledCallout: Font {
if ProcessInfo.processInfo.isiOSAppOnMac {
return .system(size: userScaledFontSize(baseSize: 17))
} else {
@ -48,7 +47,7 @@ extension Font {
}
}
public static var scaledSubheadline: Font {
static var scaledSubheadline: Font {
if ProcessInfo.processInfo.isiOSAppOnMac {
return .system(size: userScaledFontSize(baseSize: 16))
} else {
@ -56,8 +55,7 @@ extension Font {
}
}
public static var scaledFootnote: Font {
static var scaledFootnote: Font {
if ProcessInfo.processInfo.isiOSAppOnMac {
return .system(size: userScaledFontSize(baseSize: 15))
} else {
@ -65,7 +63,7 @@ extension Font {
}
}
public static var scaledCaption: Font {
static var scaledCaption: Font {
if ProcessInfo.processInfo.isiOSAppOnMac {
return .system(size: userScaledFontSize(baseSize: 14))
} else {

View file

@ -31,9 +31,10 @@ struct ThemeApplier: ViewModifier {
if !theme.isThemePreviouslySet {
theme.selectedSet = colorScheme == .dark ? .iceCubeDark : .iceCubeLight
theme.isThemePreviouslySet = true
} else if theme.followSystemColorScheme && theme.isThemePreviouslySet,
} else if theme.followSystemColorScheme, theme.isThemePreviouslySet,
let sets = availableColorsSets
.first(where: { $0.light.name == theme.selectedSet || $0.dark.name == theme.selectedSet }) {
.first(where: { $0.light.name == theme.selectedSet || $0.dark.name == theme.selectedSet })
{
theme.selectedSet = colorScheme == .dark ? sets.dark.name : sets.light.name
}
setWindowTint(theme.tintColor)
@ -48,7 +49,8 @@ struct ThemeApplier: ViewModifier {
.onChange(of: colorScheme) { newColorScheme in
if theme.followSystemColorScheme,
let sets = availableColorsSets
.first(where: { $0.light.name == theme.selectedSet || $0.dark.name == theme.selectedSet }) {
.first(where: { $0.light.name == theme.selectedSet || $0.dark.name == theme.selectedSet })
{
theme.selectedSet = newColorScheme == .dark ? sets.dark.name : sets.light.name
}
}

View file

@ -27,6 +27,7 @@ class ExploreViewModel: ObservableObject {
isSearching = true
}
}
@Published var results: [String: SearchResults] = [:]
@Published var isLoaded = false
@Published var isSearching = false

View file

@ -20,6 +20,7 @@ public struct DeepLClient {
public let detectedSourceLanguage: String
public let text: String
}
public let translations: [Translation]
}
@ -31,7 +32,7 @@ public struct DeepLClient {
public init() {}
public func request(target: String, source: String?, text: String) async throws -> String {
public func request(target: String, source _: String?, text: String) async throws -> String {
do {
var components = URLComponents(string: endpoint)!
var queryItems: [URLQueryItem] = []

View file

@ -1,9 +1,9 @@
import DesignSystem
import Env
import Models
import NukeUI
import PhotosUI
import SwiftUI
import NukeUI
struct StatusEditorAccessoryView: View {
@EnvironmentObject private var preferences: UserPreferences

View file

@ -126,7 +126,6 @@ public class StatusEditorViewModel: ObservableObject {
}
}
// MARK: - Status Text manipulations
func insertStatusText(text: String) {
@ -245,7 +244,7 @@ public class StatusEditorViewModel: ObservableObject {
range: NSRange(location: range.location, length: range.length))
}
var mediaAdded: Bool = false
var mediaAdded = false
statusText.enumerateAttribute(.attachment, in: range) { attachment, range, _ in
if let attachment = attachment as? NSTextAttachment, let image = attachment.image {
mediasImages.append(.init(image: image, mediaAttachment: nil, error: nil))
@ -262,6 +261,7 @@ public class StatusEditorViewModel: ObservableObject {
}
// MARK: - Shar sheet / Item provider
private func processItemsProvider(items: [NSItemProvider]) {
Task {
var initialText: String = ""
@ -302,7 +302,6 @@ public class StatusEditorViewModel: ObservableObject {
return options.isEmpty ? nil : options
}
// MARK: - Embeds
private func checkEmbed() {
@ -464,6 +463,7 @@ public class StatusEditorViewModel: ObservableObject {
}
// MARK: - Custom emojis
func fetchCustomEmojis() async {
guard let client else { return }
do {

View file

@ -1,7 +1,7 @@
import SwiftUI
import DesignSystem
import Models
import Network
import DesignSystem
import SwiftUI
public struct StatusEditHistoryView: View {
@Environment(\.dismiss) private var dismiss

View file

@ -1,10 +1,10 @@
import DesignSystem
import Env
import Models
import Nuke
import NukeUI
import Shimmer
import SwiftUI
import Nuke
public struct StatusMediaPreviewView: View {
@Environment(\.openURL) private var openURL
@ -175,7 +175,6 @@ public struct StatusMediaPreviewView: View {
.fill(Color.gray)
.frame(maxHeight: isNotifications || theme.statusDisplayStyle == .compact ? imageMaxHeight : nil)
.shimmering()
}
)
}
@ -197,7 +196,6 @@ public struct StatusMediaPreviewView: View {
isAltAlertDisplayed = true
} label: {
Text("ALT")
}
.padding(8)
.background(.thinMaterial)
@ -298,7 +296,6 @@ public struct StatusMediaPreviewView: View {
Label("status.media.sensitive.show", systemImage: "eye")
} else {
Label("status.media.content.show", systemImage: "eye")
}
}
.buttonStyle(.borderedProminent)

View file

@ -289,7 +289,8 @@ public struct StatusRowView: View {
status.language != nil,
userLang != status.language,
!status.content.asRawText.isEmpty,
viewModel.translation == nil {
viewModel.translation == nil
{
Button {
Task {
await viewModel.translate(userLang: userLang)