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 SwiftUI
@MainActor
@Observable class DisplaySettingsLocalValues {
var tintColor = Theme.shared.tintColor
var primaryBackgroundColor = Theme.shared.primaryBackgroundColor

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,6 +4,7 @@ import Nuke
import NukeUI
import SwiftUI
@MainActor
struct AccountPopoverView: View {
let account: Account
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
}
public struct FrameConfig: Equatable {
@MainActor
public struct FrameConfig: Equatable, Sendable {
public let size: CGSize
public var width: CGFloat { size.width }
public var height: CGFloat { size.height }

View file

@ -1,5 +1,6 @@
import SwiftUI
@MainActor
public struct NextPageView: View {
@State private var isLoadingNextPage: 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 {
if isPrivate {
return Color.orange.opacity(0.80)

View file

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

View file

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