Various fixes for Xcode 15.3

This commit is contained in:
Thomas Ricouard 2024-03-11 08:59:29 +01:00
parent bc2a09891a
commit 9a7e6b7cb0
15 changed files with 22 additions and 54 deletions

View file

@ -7,6 +7,7 @@ import Observation
import StatusKit import StatusKit
import SwiftUI import SwiftUI
@MainActor
@Observable class DisplaySettingsLocalValues { @Observable class DisplaySettingsLocalValues {
var tintColor = Theme.shared.tintColor var tintColor = Theme.shared.tintColor
var primaryBackgroundColor = Theme.shared.primaryBackgroundColor var primaryBackgroundColor = Theme.shared.primaryBackgroundColor

View file

@ -2,6 +2,7 @@ import DesignSystem
import Env import Env
import SwiftUI import SwiftUI
@MainActor
struct SidebarEntriesSettingsView: View { struct SidebarEntriesSettingsView: View {
@Environment(Theme.self) private var theme @Environment(Theme.self) private var theme
@Environment(UserPreferences.self) private var userPreferences @Environment(UserPreferences.self) private var userPreferences

View file

@ -157,6 +157,7 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable, Codable {
} }
} }
@MainActor
@Observable @Observable
class SidebarTabs { class SidebarTabs {
struct SidedebarTab: Hashable, Codable { struct SidedebarTab: Hashable, Codable {
@ -202,6 +203,7 @@ class SidebarTabs {
} }
} }
@MainActor
@Observable @Observable
class iOSTabs { class iOSTabs {
enum TabEntries: String { enum TabEntries: String {

View file

@ -371,6 +371,7 @@ public struct AccountDetailView: View {
} }
extension View { extension View {
@MainActor
func applyAccountDetailsRowStyle(theme: Theme) -> some View { func applyAccountDetailsRowStyle(theme: Theme) -> some View {
listRowInsets(.init()) listRowInsets(.init())
.listRowSeparator(.hidden) .listRowSeparator(.hidden)

View file

@ -33,11 +33,11 @@ public struct AppAccountsSelectorView: View {
public init(routerPath: RouterPath, public init(routerPath: RouterPath,
accountCreationEnabled: Bool = true, accountCreationEnabled: Bool = true,
avatarConfig: AvatarView.FrameConfig = .badge) avatarConfig: AvatarView.FrameConfig? = nil)
{ {
self.routerPath = routerPath self.routerPath = routerPath
self.accountCreationEnabled = accountCreationEnabled self.accountCreationEnabled = accountCreationEnabled
self.avatarConfig = avatarConfig self.avatarConfig = avatarConfig ?? .badge
} }
public var body: some View { public var body: some View {

View file

@ -2,7 +2,7 @@ import Combine
import UIKit import UIKit
@Observable @Observable
public class SceneDelegate: NSObject, UIWindowSceneDelegate, Sendable { @MainActor public class SceneDelegate: NSObject, UIWindowSceneDelegate, Sendable {
public var window: UIWindow? public var window: UIWindow?
#if os(visionOS) #if os(visionOS)
public private(set) var windowWidth: CGFloat = 0 public private(set) var windowWidth: CGFloat = 0
@ -47,12 +47,12 @@ public class SceneDelegate: NSObject, UIWindowSceneDelegate, Sendable {
} }
private static var observedSceneDelegate: Set<SceneDelegate> = [] private static var observedSceneDelegate: Set<SceneDelegate> = []
private static let observer = Task { private static let observer = Task { @MainActor in
while true { while true {
try? await Task.sleep(for: .seconds(0.1)) try? await Task.sleep(for: .seconds(0.1))
for delegate in observedSceneDelegate { for delegate in observedSceneDelegate {
#if os(visionOS) #if os(visionOS)
let newWidth = delegate.window?.bounds.size.width ?? 0 let newWidth = delegate.window?.bounds.size.width ?? 0
if delegate.windowWidth != newWidth { if delegate.windowWidth != newWidth {
delegate.windowWidth = newWidth delegate.windowWidth = newWidth
} }

View file

@ -1,8 +1,10 @@
import Combine import Combine
import SwiftUI import SwiftUI
@Observable public class Theme { @MainActor
class ThemeStorage { @Observable
public final class Theme {
final class ThemeStorage {
enum ThemeKey: String { enum ThemeKey: String {
case colorScheme, tint, label, primaryBackground, secondaryBackground case colorScheme, tint, label, primaryBackground, secondaryBackground
case avatarPosition2, avatarShape2, statusActionsDisplay, statusDisplayStyle case avatarPosition2, avatarShape2, statusActionsDisplay, statusDisplayStyle

View file

@ -4,7 +4,7 @@ import SwiftUI
#endif #endif
public extension View { public extension View {
func applyTheme(_ theme: Theme) -> some View { @MainActor func applyTheme(_ theme: Theme) -> some View {
modifier(ThemeApplier(theme: theme)) modifier(ThemeApplier(theme: theme))
} }
} }

View file

@ -4,6 +4,7 @@ import Nuke
import NukeUI import NukeUI
import SwiftUI import SwiftUI
@MainActor
struct AccountPopoverView: View { struct AccountPopoverView: View {
let account: Account let account: Account
let theme: Theme // using `@Environment(Theme.self) will crash the SwiftUI preview let theme: Theme // using `@Environment(Theme.self) will crash the SwiftUI preview

View file

@ -33,7 +33,8 @@ public struct AvatarView: View {
self.config = config self.config = config
} }
public struct FrameConfig: Equatable { @MainActor
public struct FrameConfig: Equatable, Sendable {
public let size: CGSize public let size: CGSize
public var width: CGFloat { size.width } public var width: CGFloat { size.width }
public var height: CGFloat { size.height } public var height: CGFloat { size.height }

View file

@ -1,5 +1,6 @@
import SwiftUI import SwiftUI
@MainActor
public struct NextPageView: View { public struct NextPageView: View {
@State private var isLoadingNextPage: Bool = false @State private var isLoadingNextPage: Bool = false
@State private var showRetry: Bool = false @State private var showRetry: Bool = false

View file

@ -1,44 +0,0 @@
/*! @copyright 2021 Medium */
import SwiftUI
// Source: https://www.fivestars.blog/articles/scrollview-offset/
public struct ScrollViewOffsetReader<Content: View>: View {
let onOffsetChange: (CGFloat) -> Void
let content: () -> Content
public init(
onOffsetChange: @escaping (CGFloat) -> Void,
@ViewBuilder content: @escaping () -> Content
) {
self.onOffsetChange = onOffsetChange
self.content = content
}
public var body: some View {
ScrollView {
offsetReader
content()
.padding(.top, -8)
}
.coordinateSpace(name: "frameLayer")
.onPreferenceChange(OffsetPreferenceKey.self, perform: onOffsetChange)
}
var offsetReader: some View {
GeometryReader { proxy in
Color.clear
.preference(
key: OffsetPreferenceKey.self,
value: proxy.frame(in: .named("frameLayer")).minY
)
}
.frame(height: 0)
}
}
private struct OffsetPreferenceKey: PreferenceKey {
static var defaultValue: CGFloat = .zero
static func reduce(value _: inout CGFloat, nextValue _: () -> CGFloat) {}
}

View file

@ -67,6 +67,7 @@ extension Models.Notification.NotificationType {
} }
} }
@MainActor
func tintColor(isPrivate: Bool) -> Color { func tintColor(isPrivate: Bool) -> Color {
if isPrivate { if isPrivate {
return Color.orange.opacity(0.80) return Color.orange.opacity(0.80)

View file

@ -2,6 +2,7 @@ import DesignSystem
import SwiftUI import SwiftUI
import Env import Env
@MainActor
public struct TimelineContentFilterView: View { public struct TimelineContentFilterView: View {
@Environment(Theme.self) private var theme @Environment(Theme.self) private var theme
@Environment(CurrentInstance.self) private var currentInstance @Environment(CurrentInstance.self) private var currentInstance

View file

@ -14,7 +14,7 @@ actor TimelineDatasource {
} }
func getFiltered() async -> [Status] { func getFiltered() async -> [Status] {
let contentFilter = TimelineContentFilter.shared let contentFilter = await TimelineContentFilter.shared
let showReplies = await contentFilter.showReplies let showReplies = await contentFilter.showReplies
let showBoosts = await contentFilter.showBoosts let showBoosts = await contentFilter.showBoosts
let showThreads = await contentFilter.showThreads let showThreads = await contentFilter.showThreads