diff --git a/IceCubesApp/App/AppRouter.swift b/IceCubesApp/App/AppRouter.swift index bd8c1c0e..e1f54aa8 100644 --- a/IceCubesApp/App/AppRouter.swift +++ b/IceCubesApp/App/AppRouter.swift @@ -115,7 +115,7 @@ extension View { environment(CurrentAccount.shared) .environmentObject(UserPreferences.shared) .environment(CurrentInstance.shared) - .environmentObject(Theme.shared) + .environment(Theme.shared) .environment(AppAccountsManager.shared) .environment(PushNotificationsService.shared) .environment(AppAccountsManager.shared.currentClient) diff --git a/IceCubesApp/App/IceCubesApp.swift b/IceCubesApp/App/IceCubesApp.swift index 24863765..c30e7eaf 100644 --- a/IceCubesApp/App/IceCubesApp.swift +++ b/IceCubesApp/App/IceCubesApp.swift @@ -22,7 +22,7 @@ struct IceCubesApp: App { @State private var pushNotificationsService = PushNotificationsService.shared @State private var watcher = StreamWatcher() @State private var quickLook = QuickLook() - @StateObject private var theme = Theme.shared + @State private var theme = Theme.shared @State private var sidebarRouterPath = RouterPath() @State private var selectedTab: Tab = .timeline @@ -49,7 +49,7 @@ struct IceCubesApp: App { .environment(currentAccount) .environment(currentInstance) .environmentObject(userPreferences) - .environmentObject(theme) + .environment(theme) .environment(watcher) .environment(pushNotificationsService) .environment(\.isSupporter, isSupporter) diff --git a/IceCubesApp/App/Report/ReportView.swift b/IceCubesApp/App/Report/ReportView.swift index 30a360d3..92d470b3 100644 --- a/IceCubesApp/App/Report/ReportView.swift +++ b/IceCubesApp/App/Report/ReportView.swift @@ -8,7 +8,7 @@ import SwiftUI public struct ReportView: View { @Environment(\.dismiss) private var dismiss - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client let status: Status diff --git a/IceCubesApp/App/SafariRouter.swift b/IceCubesApp/App/SafariRouter.swift index acefaa9a..5d3feb52 100644 --- a/IceCubesApp/App/SafariRouter.swift +++ b/IceCubesApp/App/SafariRouter.swift @@ -12,7 +12,7 @@ extension View { @MainActor private struct SafariRouter: ViewModifier { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @EnvironmentObject private var preferences: UserPreferences @Environment(RouterPath.self) private var routerPath diff --git a/IceCubesApp/App/SideBarView.swift b/IceCubesApp/App/SideBarView.swift index ddd6e032..6036e910 100644 --- a/IceCubesApp/App/SideBarView.swift +++ b/IceCubesApp/App/SideBarView.swift @@ -8,7 +8,7 @@ import SwiftUI struct SideBarView: View { @Environment(AppAccountsManager.self) private var appAccounts @Environment(CurrentAccount.self) private var currentAccount - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(StreamWatcher.self) private var watcher @EnvironmentObject private var userPreferences: UserPreferences @Environment(RouterPath.self) private var routerPath @@ -155,7 +155,7 @@ struct SideBarView: View { } private struct SideBarIcon: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme let systemIconName: String let isSelected: Bool diff --git a/IceCubesApp/App/Tabs/ExploreTab.swift b/IceCubesApp/App/Tabs/ExploreTab.swift index 4449e917..9e959104 100644 --- a/IceCubesApp/App/Tabs/ExploreTab.swift +++ b/IceCubesApp/App/Tabs/ExploreTab.swift @@ -8,7 +8,7 @@ import Shimmer import SwiftUI struct ExploreTab: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @EnvironmentObject private var preferences: UserPreferences @Environment(CurrentAccount.self) private var currentAccount @Environment(Client.self) private var client diff --git a/IceCubesApp/App/Tabs/MessagesTab.swift b/IceCubesApp/App/Tabs/MessagesTab.swift index 1a2198bc..8aca6224 100644 --- a/IceCubesApp/App/Tabs/MessagesTab.swift +++ b/IceCubesApp/App/Tabs/MessagesTab.swift @@ -8,8 +8,9 @@ import Network import Shimmer import SwiftUI +@MainActor struct MessagesTab: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(StreamWatcher.self) private var watcher @Environment(Client.self) private var client @Environment(CurrentAccount.self) private var currentAccount diff --git a/IceCubesApp/App/Tabs/NotificationTab.swift b/IceCubesApp/App/Tabs/NotificationTab.swift index c86546b9..5e76fb0c 100644 --- a/IceCubesApp/App/Tabs/NotificationTab.swift +++ b/IceCubesApp/App/Tabs/NotificationTab.swift @@ -11,7 +11,7 @@ struct NotificationsTab: View { @Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool @Environment(\.scenePhase) private var scenePhase - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client @Environment(StreamWatcher.self) private var watcher @Environment(AppAccountsManager.self) private var appAccount diff --git a/IceCubesApp/App/Tabs/ProfileTab.swift b/IceCubesApp/App/Tabs/ProfileTab.swift index 66a7745a..253f7432 100644 --- a/IceCubesApp/App/Tabs/ProfileTab.swift +++ b/IceCubesApp/App/Tabs/ProfileTab.swift @@ -8,9 +8,10 @@ import Network import Shimmer import SwiftUI +@MainActor struct ProfileTab: View { @Environment(AppAccountsManager.self) private var appAccount - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client @Environment(CurrentAccount.self) private var currentAccount @State private var routerPath = RouterPath() diff --git a/IceCubesApp/App/Tabs/Settings/AboutView.swift b/IceCubesApp/App/Tabs/Settings/AboutView.swift index fe18d78c..0f632f54 100644 --- a/IceCubesApp/App/Tabs/Settings/AboutView.swift +++ b/IceCubesApp/App/Tabs/Settings/AboutView.swift @@ -2,9 +2,10 @@ import DesignSystem import Env import SwiftUI +@MainActor struct AboutView: View { @Environment(RouterPath.self) private var routerPath - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme let versionNumber: String @@ -101,6 +102,6 @@ struct AboutView: View { struct AboutView_Previews: PreviewProvider { static var previews: some View { AboutView() - .environmentObject(Theme.shared) + .environment(Theme.shared) } } diff --git a/IceCubesApp/App/Tabs/Settings/AccountSettingView.swift b/IceCubesApp/App/Tabs/Settings/AccountSettingView.swift index a1610a88..ac25b1e3 100644 --- a/IceCubesApp/App/Tabs/Settings/AccountSettingView.swift +++ b/IceCubesApp/App/Tabs/Settings/AccountSettingView.swift @@ -14,7 +14,7 @@ struct AccountSettingsView: View { @Environment(PushNotificationsService.self) private var pushNotifications @Environment(CurrentAccount.self) private var currentAccount @Environment(CurrentInstance.self) private var currentInstance - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(AppAccountsManager.self) private var appAccountsManager @Environment(Client.self) private var client diff --git a/IceCubesApp/App/Tabs/Settings/AddAccountsView.swift b/IceCubesApp/App/Tabs/Settings/AddAccountsView.swift index 1d37f034..30a8876c 100644 --- a/IceCubesApp/App/Tabs/Settings/AddAccountsView.swift +++ b/IceCubesApp/App/Tabs/Settings/AddAccountsView.swift @@ -9,6 +9,7 @@ import SafariServices import Shimmer import SwiftUI +@MainActor struct AddAccountView: View { @Environment(\.dismiss) private var dismiss @Environment(\.scenePhase) private var scenePhase @@ -17,7 +18,7 @@ struct AddAccountView: View { @Environment(CurrentAccount.self) private var currentAccount @Environment(CurrentInstance.self) private var currentInstance @Environment(PushNotificationsService.self) private var pushNotifications - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var instanceName: String = "" @State private var instance: Instance? diff --git a/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift b/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift index 40808b19..2a955a20 100644 --- a/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift @@ -9,7 +9,7 @@ import UserNotifications struct ContentSettingsView: View { @EnvironmentObject private var userPreferences: UserPreferences - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme var body: some View { Form { diff --git a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift index 77d73067..6d775691 100644 --- a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift @@ -15,15 +15,14 @@ import SwiftUI var lineSpacing = Theme.shared.lineSpacing var fontSizeScale = Theme.shared.fontSizeScale - - init() { } + init() {} } struct DisplaySettingsView: View { typealias FontState = Theme.FontState @Environment(\.colorScheme) private var colorScheme - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @EnvironmentObject private var userPreferences: UserPreferences @State private var localValues = DisplaySettingsLocalValues() @@ -51,27 +50,27 @@ struct DisplaySettingsView: View { .scrollContentBackground(.hidden) .background(theme.secondaryBackgroundColor) .task(id: localValues.tintColor) { - do { try await Task.sleep(for: .microseconds(500)) } catch { } + do { try await Task.sleep(for: .microseconds(500)) } catch {} Theme.shared.tintColor = localValues.tintColor } .task(id: localValues.primaryBackgroundColor) { - do { try await Task.sleep(for: .microseconds(500)) } catch { } + do { try await Task.sleep(for: .microseconds(500)) } catch {} Theme.shared.primaryBackgroundColor = localValues.primaryBackgroundColor } .task(id: localValues.secondaryBackgroundColor) { - do { try await Task.sleep(for: .microseconds(500)) } catch { } + do { try await Task.sleep(for: .microseconds(500)) } catch {} Theme.shared.secondaryBackgroundColor = localValues.secondaryBackgroundColor } .task(id: localValues.labelColor) { - do { try await Task.sleep(for: .microseconds(500)) } catch { } + do { try await Task.sleep(for: .microseconds(500)) } catch {} Theme.shared.labelColor = localValues.labelColor } .task(id: localValues.lineSpacing) { - do { try await Task.sleep(for: .microseconds(500)) } catch { } + do { try await Task.sleep(for: .microseconds(500)) } catch {} Theme.shared.lineSpacing = localValues.lineSpacing } .task(id: localValues.fontSizeScale) { - do { try await Task.sleep(for: .microseconds(500)) } catch { } + do { try await Task.sleep(for: .microseconds(500)) } catch {} Theme.shared.fontSizeScale = localValues.fontSizeScale } examplePost @@ -96,7 +95,9 @@ struct DisplaySettingsView: View { } } + @ViewBuilder private var themeSection: some View { + @Bindable var theme = theme Section { Toggle("settings.display.theme.systemColor", isOn: $theme.followSystemColorScheme) themeSelectorButton @@ -176,7 +177,9 @@ struct DisplaySettingsView: View { .listRowBackground(theme.primaryBackgroundColor) } + @ViewBuilder private var layoutSection: some View { + @Bindable var theme = theme Section("settings.display.section.display") { Picker("settings.display.avatar.position", selection: $theme.avatarPosition) { ForEach(Theme.AvatarPosition.allCases, id: \.rawValue) { position in diff --git a/IceCubesApp/App/Tabs/Settings/HapticSettingsView.swift b/IceCubesApp/App/Tabs/Settings/HapticSettingsView.swift index fce9fb82..fefe6e49 100644 --- a/IceCubesApp/App/Tabs/Settings/HapticSettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/HapticSettingsView.swift @@ -5,7 +5,7 @@ import Status import SwiftUI struct HapticSettingsView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @EnvironmentObject private var userPreferences: UserPreferences var body: some View { diff --git a/IceCubesApp/App/Tabs/Settings/IconSelectorView.swift b/IceCubesApp/App/Tabs/Settings/IconSelectorView.swift index 7a2d798b..b74c6657 100644 --- a/IceCubesApp/App/Tabs/Settings/IconSelectorView.swift +++ b/IceCubesApp/App/Tabs/Settings/IconSelectorView.swift @@ -1,6 +1,7 @@ import DesignSystem import SwiftUI +@MainActor struct IconSelectorView: View { enum Icon: Int, CaseIterable, Identifiable { var id: String { @@ -62,7 +63,7 @@ struct IconSelectorView: View { ] } - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var currentIcon = UIApplication.shared.alternateIconName ?? Icon.primary.appIconName private let columns = [GridItem(.adaptive(minimum: 125, maximum: 1024))] diff --git a/IceCubesApp/App/Tabs/Settings/InstanceInfoView.swift b/IceCubesApp/App/Tabs/Settings/InstanceInfoView.swift index ab91b107..68f5f698 100644 --- a/IceCubesApp/App/Tabs/Settings/InstanceInfoView.swift +++ b/IceCubesApp/App/Tabs/Settings/InstanceInfoView.swift @@ -4,7 +4,7 @@ import NukeUI import SwiftUI struct InstanceInfoView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme let instance: Instance @@ -19,7 +19,7 @@ struct InstanceInfoView: View { } public struct InstanceInfoSection: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme let instance: Instance diff --git a/IceCubesApp/App/Tabs/Settings/PushNotificationsView.swift b/IceCubesApp/App/Tabs/Settings/PushNotificationsView.swift index c37eb556..78b27aec 100644 --- a/IceCubesApp/App/Tabs/Settings/PushNotificationsView.swift +++ b/IceCubesApp/App/Tabs/Settings/PushNotificationsView.swift @@ -7,8 +7,9 @@ import NukeUI import SwiftUI import UserNotifications +@MainActor struct PushNotificationsView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(AppAccountsManager.self) private var appAccountsManager @Environment(PushNotificationsService.self) private var pushNotifications diff --git a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift index 730343d4..ec972421 100644 --- a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift +++ b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift @@ -17,7 +17,7 @@ struct SettingsTabs: View { @Environment(Client.self) private var client @Environment(CurrentInstance.self) private var currentInstance @Environment(AppAccountsManager.self) private var appAccountsManager - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var routerPath = RouterPath() @State private var addAccountSheetPresented = false diff --git a/IceCubesApp/App/Tabs/Settings/SupportAppView.swift b/IceCubesApp/App/Tabs/Settings/SupportAppView.swift index 3adab52f..00d4a7e9 100644 --- a/IceCubesApp/App/Tabs/Settings/SupportAppView.swift +++ b/IceCubesApp/App/Tabs/Settings/SupportAppView.swift @@ -4,6 +4,7 @@ import RevenueCat import Shimmer import SwiftUI +@MainActor struct SupportAppView: View { enum Tip: String, CaseIterable { case one, two, three, four, supporter @@ -47,7 +48,7 @@ struct SupportAppView: View { } } - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(\.openURL) private var openURL diff --git a/IceCubesApp/App/Tabs/Settings/SwipeActionsSettingsView.swift b/IceCubesApp/App/Tabs/Settings/SwipeActionsSettingsView.swift index f5395177..35d64909 100644 --- a/IceCubesApp/App/Tabs/Settings/SwipeActionsSettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/SwipeActionsSettingsView.swift @@ -3,7 +3,7 @@ import Env import SwiftUI struct SwipeActionsSettingsView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @EnvironmentObject private var userPreferences: UserPreferences var body: some View { diff --git a/IceCubesApp/App/Tabs/Settings/TranslationSettingsView.swift b/IceCubesApp/App/Tabs/Settings/TranslationSettingsView.swift index 5de53e2e..f20eaaa8 100644 --- a/IceCubesApp/App/Tabs/Settings/TranslationSettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/TranslationSettingsView.swift @@ -4,7 +4,7 @@ import SwiftUI struct TranslationSettingsView: View { @EnvironmentObject private var preferences: UserPreferences - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var apiKey: String = "" diff --git a/IceCubesApp/App/Tabs/Timeline/AddRemoteTimelineView.swift b/IceCubesApp/App/Tabs/Timeline/AddRemoteTimelineView.swift index 228e9fe6..868195e9 100644 --- a/IceCubesApp/App/Tabs/Timeline/AddRemoteTimelineView.swift +++ b/IceCubesApp/App/Tabs/Timeline/AddRemoteTimelineView.swift @@ -11,7 +11,7 @@ struct AddRemoteTimelineView: View { @Environment(\.dismiss) private var dismiss @EnvironmentObject private var preferences: UserPreferences - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var instanceName: String = "" @State private var instance: Instance? diff --git a/IceCubesApp/App/Tabs/Timeline/EditTagGroupView.swift b/IceCubesApp/App/Tabs/Timeline/EditTagGroupView.swift index 99095801..08824188 100644 --- a/IceCubesApp/App/Tabs/Timeline/EditTagGroupView.swift +++ b/IceCubesApp/App/Tabs/Timeline/EditTagGroupView.swift @@ -11,7 +11,7 @@ struct EditTagGroupView: View { @Environment(\.dismiss) private var dismiss @EnvironmentObject private var preferences: UserPreferences - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var title: String = "" @State private var sfSymbolName: String = "" diff --git a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift index 8a99c10c..70308398 100644 --- a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift +++ b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift @@ -9,7 +9,7 @@ import Timeline struct TimelineTab: View { @Environment(AppAccountsManager.self) private var appAccount - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentAccount.self) private var currentAccount @EnvironmentObject private var preferences: UserPreferences @Environment(Client.self) private var client diff --git a/IceCubesShareExtension/ShareViewController.swift b/IceCubesShareExtension/ShareViewController.swift index b9a8ed8c..e66c77ec 100644 --- a/IceCubesShareExtension/ShareViewController.swift +++ b/IceCubesShareExtension/ShareViewController.swift @@ -31,7 +31,7 @@ class ShareViewController: UIViewController { .environment(appAccountsManager) .environment(client) .environment(account) - .environmentObject(theme) + .environment(theme) .environment(instance) .tint(theme.tintColor) .preferredColorScheme(colorScheme == .light ? .light : .dark) diff --git a/Packages/Account/Sources/Account/AccountDetailHeaderView.swift b/Packages/Account/Sources/Account/AccountDetailHeaderView.swift index 5180a853..0cde2f16 100644 --- a/Packages/Account/Sources/Account/AccountDetailHeaderView.swift +++ b/Packages/Account/Sources/Account/AccountDetailHeaderView.swift @@ -6,12 +6,13 @@ import NukeUI import Shimmer import SwiftUI +@MainActor struct AccountDetailHeaderView: View { enum Constants { static let headerHeight: CGFloat = 200 } - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(QuickLook.self) private var quickLook @Environment(RouterPath.self) private var routerPath @Environment(CurrentAccount.self) private var currentAccount diff --git a/Packages/Account/Sources/Account/AccountDetailView.swift b/Packages/Account/Sources/Account/AccountDetailView.swift index fa5f6900..f161f6fe 100644 --- a/Packages/Account/Sources/Account/AccountDetailView.swift +++ b/Packages/Account/Sources/Account/AccountDetailView.swift @@ -15,7 +15,7 @@ public struct AccountDetailView: View { @Environment(CurrentAccount.self) private var currentAccount @Environment(CurrentInstance.self) private var currentInstance @EnvironmentObject private var preferences: UserPreferences - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client @Environment(RouterPath.self) private var routerPath diff --git a/Packages/Account/Sources/Account/AccountsList/AccountsListRow.swift b/Packages/Account/Sources/Account/AccountsList/AccountsListRow.swift index e9272c0f..28a4f6a5 100644 --- a/Packages/Account/Sources/Account/AccountsList/AccountsListRow.swift +++ b/Packages/Account/Sources/Account/AccountsList/AccountsListRow.swift @@ -20,8 +20,9 @@ import SwiftUI } } +@MainActor public struct AccountsListRow: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentAccount.self) private var currentAccount @Environment(RouterPath.self) private var routerPath @Environment(Client.self) private var client @@ -117,7 +118,7 @@ public struct AccountsListRow: View { .listStyle(.plain) .scrollContentBackground(.hidden) .background(theme.primaryBackgroundColor) - .environmentObject(theme) + .environment(theme) .environment(currentAccount) .environment(client) } diff --git a/Packages/Account/Sources/Account/AccountsList/AccountsListView.swift b/Packages/Account/Sources/Account/AccountsList/AccountsListView.swift index 8800dce7..098a3a64 100644 --- a/Packages/Account/Sources/Account/AccountsList/AccountsListView.swift +++ b/Packages/Account/Sources/Account/AccountsList/AccountsListView.swift @@ -5,8 +5,9 @@ import Network import Shimmer import SwiftUI +@MainActor public struct AccountsListView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client @Environment(CurrentAccount.self) private var currentAccount @State private var viewModel: AccountsListViewModel diff --git a/Packages/Account/Sources/Account/Edit/EditAccountView.swift b/Packages/Account/Sources/Account/Edit/EditAccountView.swift index 76551951..c945d9d4 100644 --- a/Packages/Account/Sources/Account/Edit/EditAccountView.swift +++ b/Packages/Account/Sources/Account/Edit/EditAccountView.swift @@ -3,10 +3,11 @@ import Models import Network import SwiftUI +@MainActor public struct EditAccountView: View { @Environment(\.dismiss) private var dismiss @Environment(Client.self) private var client - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var viewModel = EditAccountViewModel() diff --git a/Packages/Account/Sources/Account/Edit/EditRelationshipNoteView.swift b/Packages/Account/Sources/Account/Edit/EditRelationshipNoteView.swift index 53926b40..629d9fd6 100644 --- a/Packages/Account/Sources/Account/Edit/EditRelationshipNoteView.swift +++ b/Packages/Account/Sources/Account/Edit/EditRelationshipNoteView.swift @@ -2,9 +2,10 @@ import DesignSystem import Network import SwiftUI +@MainActor public struct EditRelationshipNoteView: View { @Environment(\.dismiss) private var dismiss - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client @State var accountDetailViewModel: AccountDetailViewModel diff --git a/Packages/Account/Sources/Account/Filters/EditFilterView.swift b/Packages/Account/Sources/Account/Filters/EditFilterView.swift index 9384cd56..889b3805 100644 --- a/Packages/Account/Sources/Account/Filters/EditFilterView.swift +++ b/Packages/Account/Sources/Account/Filters/EditFilterView.swift @@ -4,10 +4,11 @@ import Models import Network import SwiftUI +@MainActor struct EditFilterView: View { @Environment(\.dismiss) private var dismiss - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentAccount.self) private var account @Environment(Client.self) private var client diff --git a/Packages/Account/Sources/Account/Filters/FiltersListView.swift b/Packages/Account/Sources/Account/Filters/FiltersListView.swift index fd1ed815..56bfcabd 100644 --- a/Packages/Account/Sources/Account/Filters/FiltersListView.swift +++ b/Packages/Account/Sources/Account/Filters/FiltersListView.swift @@ -7,7 +7,7 @@ import SwiftUI public struct FiltersListView: View { @Environment(\.dismiss) private var dismiss - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentAccount.self) private var account @Environment(Client.self) private var client diff --git a/Packages/AppAccount/Sources/AppAccount/AppAccountView.swift b/Packages/AppAccount/Sources/AppAccount/AppAccountView.swift index 112fd452..09729768 100644 --- a/Packages/AppAccount/Sources/AppAccount/AppAccountView.swift +++ b/Packages/AppAccount/Sources/AppAccount/AppAccountView.swift @@ -4,7 +4,7 @@ import Env import SwiftUI public struct AppAccountView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(RouterPath.self) private var routerPath @Environment(AppAccountsManager.self) private var appAccounts @EnvironmentObject private var preferences: UserPreferences diff --git a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift index c116ce73..785f5085 100644 --- a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift +++ b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift @@ -6,7 +6,7 @@ public struct AppAccountsSelectorView: View { @EnvironmentObject private var preferences: UserPreferences @Environment(CurrentAccount.self) private var currentAccount @Environment(AppAccountsManager.self) private var appAccounts - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme var routerPath: RouterPath diff --git a/Packages/Conversations/Sources/Conversations/Detail/ConversationDetailView.swift b/Packages/Conversations/Sources/Conversations/Detail/ConversationDetailView.swift index 07990c0e..fc25bdd8 100644 --- a/Packages/Conversations/Sources/Conversations/Detail/ConversationDetailView.swift +++ b/Packages/Conversations/Sources/Conversations/Detail/ConversationDetailView.swift @@ -5,6 +5,7 @@ import Network import NukeUI import SwiftUI +@MainActor public struct ConversationDetailView: View { private enum Constants { static let bottomAnchor = "bottom" @@ -14,7 +15,7 @@ public struct ConversationDetailView: View { @Environment(RouterPath.self) private var routerPath @Environment(CurrentAccount.self) private var currentAccount @Environment(Client.self) private var client - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(StreamWatcher.self) private var watcher @State private var viewModel: ConversationDetailViewModel diff --git a/Packages/Conversations/Sources/Conversations/Detail/ConversationMessageView.swift b/Packages/Conversations/Sources/Conversations/Detail/ConversationMessageView.swift index 6d718784..d79709bb 100644 --- a/Packages/Conversations/Sources/Conversations/Detail/ConversationMessageView.swift +++ b/Packages/Conversations/Sources/Conversations/Detail/ConversationMessageView.swift @@ -5,12 +5,13 @@ import Network import NukeUI import SwiftUI +@MainActor struct ConversationMessageView: View { @Environment(QuickLook.self) private var quickLook @Environment(RouterPath.self) private var routerPath @Environment(CurrentAccount.self) private var currentAccount @Environment(Client.self) private var client - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme let message: Status let conversation: Conversation diff --git a/Packages/Conversations/Sources/Conversations/List/ConversationsListRow.swift b/Packages/Conversations/Sources/Conversations/List/ConversationsListRow.swift index 581ff694..cb189cc5 100644 --- a/Packages/Conversations/Sources/Conversations/List/ConversationsListRow.swift +++ b/Packages/Conversations/Sources/Conversations/List/ConversationsListRow.swift @@ -5,10 +5,11 @@ import Models import Network import SwiftUI +@MainActor struct ConversationsListRow: View { @Environment(Client.self) private var client @Environment(RouterPath.self) private var routerPath - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentAccount.self) private var currentAccount @Binding var conversation: Conversation diff --git a/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift b/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift index 3ece0487..df09d28f 100644 --- a/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift +++ b/Packages/Conversations/Sources/Conversations/List/ConversationsListView.swift @@ -10,7 +10,7 @@ public struct ConversationsListView: View { @Environment(RouterPath.self) private var routerPath @Environment(StreamWatcher.self) private var watcher @Environment(Client.self) private var client - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var viewModel = ConversationsListViewModel() diff --git a/Packages/DesignSystem/.swiftpm/xcode/xcshareddata/xcschemes/DesignSystem.xcscheme b/Packages/DesignSystem/.swiftpm/xcode/xcshareddata/xcschemes/DesignSystem.xcscheme new file mode 100644 index 00000000..8581f687 --- /dev/null +++ b/Packages/DesignSystem/.swiftpm/xcode/xcshareddata/xcschemes/DesignSystem.xcscheme @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift index 6ff63d71..6fdbf151 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift @@ -1,14 +1,35 @@ import Combine import SwiftUI -public class Theme: ObservableObject { - enum ThemeKey: String { - case colorScheme, tint, label, primaryBackground, secondaryBackground - case avatarPosition, avatarShape, statusActionsDisplay, statusDisplayStyle - case selectedSet, selectedScheme - case followSystemColorSchme - case displayFullUsernameTimeline - case lineSpacing +@Observable public class Theme { + class ThemeStorage { + enum ThemeKey: String { + case colorScheme, tint, label, primaryBackground, secondaryBackground + case avatarPosition, avatarShape, statusActionsDisplay, statusDisplayStyle + case selectedSet, selectedScheme + case followSystemColorSchme + case displayFullUsernameTimeline + case lineSpacing + } + + @AppStorage("is_previously_set") public var isThemePreviouslySet: Bool = false + @AppStorage(ThemeKey.selectedScheme.rawValue) public var selectedScheme: ColorScheme = .dark + @AppStorage(ThemeKey.tint.rawValue) public var tintColor: Color = .black + @AppStorage(ThemeKey.primaryBackground.rawValue) public var primaryBackgroundColor: Color = .white + @AppStorage(ThemeKey.secondaryBackground.rawValue) public var secondaryBackgroundColor: Color = .gray + @AppStorage(ThemeKey.label.rawValue) public var labelColor: Color = .black + @AppStorage(ThemeKey.avatarPosition.rawValue) var rawAvatarPosition: String = AvatarPosition.top.rawValue + @AppStorage(ThemeKey.avatarShape.rawValue) var rawAvatarShape: String = AvatarShape.rounded.rawValue + @AppStorage(ThemeKey.selectedSet.rawValue) var storedSet: ColorSetName = .iceCubeDark + @AppStorage(ThemeKey.statusActionsDisplay.rawValue) public var statusActionsDisplay: StatusActionsDisplay = .full + @AppStorage(ThemeKey.statusDisplayStyle.rawValue) public var statusDisplayStyle: StatusDisplayStyle = .large + @AppStorage(ThemeKey.followSystemColorSchme.rawValue) public var followSystemColorScheme: Bool = true + @AppStorage(ThemeKey.displayFullUsernameTimeline.rawValue) public var displayFullUsername: Bool = true + @AppStorage(ThemeKey.lineSpacing.rawValue) public var lineSpacing: Double = 0.8 + @AppStorage("font_size_scale") public var fontSizeScale: Double = 1 + @AppStorage("chosen_font") public var chosenFontData: Data? + + init() {} } public enum FontState: Int, CaseIterable { @@ -18,7 +39,6 @@ public class Theme: ObservableObject { case SFRounded case custom - @MainActor public var title: LocalizedStringKey { switch self { case .system: @@ -115,60 +135,144 @@ public class Theme: ObservableObject { } } - @AppStorage("is_previously_set") public var isThemePreviouslySet: Bool = false - @AppStorage(ThemeKey.selectedScheme.rawValue) public var selectedScheme: ColorScheme = .dark - @AppStorage(ThemeKey.tint.rawValue) public var tintColor: Color = .black - @AppStorage(ThemeKey.primaryBackground.rawValue) public var primaryBackgroundColor: Color = .white - @AppStorage(ThemeKey.secondaryBackground.rawValue) public var secondaryBackgroundColor: Color = .gray - @AppStorage(ThemeKey.label.rawValue) public var labelColor: Color = .black - @AppStorage(ThemeKey.avatarPosition.rawValue) var rawAvatarPosition: String = AvatarPosition.top.rawValue - @AppStorage(ThemeKey.avatarShape.rawValue) var rawAvatarShape: String = AvatarShape.rounded.rawValue - @AppStorage(ThemeKey.selectedSet.rawValue) var storedSet: ColorSetName = .iceCubeDark - @AppStorage(ThemeKey.statusActionsDisplay.rawValue) public var statusActionsDisplay: StatusActionsDisplay = .full - @AppStorage(ThemeKey.statusDisplayStyle.rawValue) public var statusDisplayStyle: StatusDisplayStyle = .large - @AppStorage(ThemeKey.followSystemColorSchme.rawValue) public var followSystemColorScheme: Bool = true - @AppStorage(ThemeKey.displayFullUsernameTimeline.rawValue) public var displayFullUsername: Bool = true - @AppStorage(ThemeKey.lineSpacing.rawValue) public var lineSpacing: Double = 0.8 - @AppStorage("font_size_scale") public var fontSizeScale: Double = 1 - @AppStorage("chosen_font") public private(set) var chosenFontData: Data? + let themeStorage = ThemeStorage() - @Published public var avatarPosition: AvatarPosition = .top - @Published public var avatarShape: AvatarShape = .rounded - @Published public var selectedSet: ColorSetName = .iceCubeDark + public var isThemePreviouslySet: Bool { + didSet { + themeStorage.isThemePreviouslySet = isThemePreviouslySet + } + } - private var cancellables = Set() + public var selectedScheme: ColorScheme { + didSet { + themeStorage.selectedScheme = selectedScheme + } + } + + public var tintColor: Color { + didSet { + themeStorage.tintColor = tintColor + } + } + + public var primaryBackgroundColor: Color { + didSet { + themeStorage.primaryBackgroundColor = primaryBackgroundColor + } + } + + public var secondaryBackgroundColor: Color { + didSet { + themeStorage.secondaryBackgroundColor = secondaryBackgroundColor + } + } + + public var labelColor: Color { + didSet { + themeStorage.labelColor = labelColor + } + } + + private var rawAvatarPosition: String { + didSet { + themeStorage.rawAvatarPosition = rawAvatarPosition + } + } + + private var rawAvatarShape: String { + didSet { + themeStorage.rawAvatarShape = rawAvatarShape + } + } + + private var storedSet: ColorSetName { + didSet { + themeStorage.storedSet = storedSet + } + } + + public var statusActionsDisplay: StatusActionsDisplay { + didSet { + themeStorage.statusActionsDisplay = statusActionsDisplay + } + } + + public var statusDisplayStyle: StatusDisplayStyle { + didSet { + themeStorage.statusDisplayStyle = statusDisplayStyle + } + } + + public var followSystemColorScheme: Bool { + didSet { + themeStorage.followSystemColorScheme = followSystemColorScheme + } + } + + public var displayFullUsername: Bool { + didSet { + themeStorage.displayFullUsername = displayFullUsername + } + } + + public var lineSpacing: Double { + didSet { + themeStorage.lineSpacing = lineSpacing + } + } + + public var fontSizeScale: Double { + didSet { + themeStorage.fontSizeScale = fontSizeScale + } + } + + public private(set) var chosenFontData: Data? { + didSet { + themeStorage.chosenFontData = chosenFontData + } + } + + public var avatarPosition: AvatarPosition = .top { + didSet { + rawAvatarPosition = avatarShape.rawValue + } + } + + public var avatarShape: AvatarShape = .rounded { + didSet { + rawAvatarShape = avatarShape.rawValue + } + } + + public var selectedSet: ColorSetName = .iceCubeDark { + didSet { + setColor(withName: selectedSet) + } + } public static let shared = Theme() private init() { + isThemePreviouslySet = themeStorage.isThemePreviouslySet + selectedScheme = themeStorage.selectedScheme + tintColor = themeStorage.tintColor + primaryBackgroundColor = themeStorage.primaryBackgroundColor + secondaryBackgroundColor = themeStorage.secondaryBackgroundColor + labelColor = themeStorage.labelColor + rawAvatarPosition = themeStorage.rawAvatarPosition + rawAvatarShape = themeStorage.rawAvatarShape + storedSet = themeStorage.storedSet + statusActionsDisplay = themeStorage.statusActionsDisplay + statusDisplayStyle = themeStorage.statusDisplayStyle + followSystemColorScheme = themeStorage.followSystemColorScheme + displayFullUsername = themeStorage.displayFullUsername + lineSpacing = themeStorage.lineSpacing + fontSizeScale = themeStorage.fontSizeScale + chosenFontData = themeStorage.chosenFontData selectedSet = storedSet - avatarPosition = AvatarPosition(rawValue: rawAvatarPosition) ?? .top avatarShape = AvatarShape(rawValue: rawAvatarShape) ?? .rounded - - $avatarPosition - .dropFirst() - .map(\.rawValue) - .sink { [weak self] position in - self?.rawAvatarPosition = position - } - .store(in: &cancellables) - - $avatarShape - .dropFirst() - .map(\.rawValue) - .sink { [weak self] shape in - self?.rawAvatarShape = shape - } - .store(in: &cancellables) - - // Workaround, since @AppStorage can't be directly observed - $selectedSet - .dropFirst() - .sink { [weak self] colorSetName in - self?.setColor(withName: colorSetName) - } - .store(in: &cancellables) } public static var allColorSet: [ColorSet] { diff --git a/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift b/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift index e8f6c202..4a0fe40a 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift @@ -9,10 +9,11 @@ public extension View { } } +@MainActor struct ThemeApplier: ViewModifier { @Environment(\EnvironmentValues.colorScheme) var colorScheme - @ObservedObject var theme: Theme + var theme: Theme var actualColorScheme: SwiftUI.ColorScheme? { if theme.followSystemColorScheme { diff --git a/Packages/DesignSystem/Sources/DesignSystem/ThemeStorage.swift b/Packages/DesignSystem/Sources/DesignSystem/ThemeStorage.swift new file mode 100644 index 00000000..e6c6d46c --- /dev/null +++ b/Packages/DesignSystem/Sources/DesignSystem/ThemeStorage.swift @@ -0,0 +1 @@ +import SwiftUI diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift index 1622abeb..74abfbf9 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/AvatarView.swift @@ -6,7 +6,7 @@ import SwiftUI @MainActor public struct AvatarView: View { @Environment(\.redactionReasons) private var reasons - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme public enum Size { case account, status, embed, badge, list, boost diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/ThemePreviewView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/ThemePreviewView.swift index 54941829..3776b917 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/ThemePreviewView.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/ThemePreviewView.swift @@ -3,7 +3,7 @@ import SwiftUI public struct ThemePreviewView: View { private let gutterSpace: Double = 8 - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(\.dismiss) var dismiss public init() {} @@ -25,7 +25,7 @@ public struct ThemePreviewView: View { } struct ThemeBoxView: View { - @EnvironmentObject var theme: Theme + @Environment(Theme.self) private var theme private let gutterSpace = 8.0 @State private var isSelected = false diff --git a/Packages/Env/Sources/Env/CustomEnvValues.swift b/Packages/Env/Sources/Env/CustomEnvValues.swift index 9b298ce5..ee682808 100644 --- a/Packages/Env/Sources/Env/CustomEnvValues.swift +++ b/Packages/Env/Sources/Env/CustomEnvValues.swift @@ -59,7 +59,7 @@ public extension EnvironmentValues { get { self[IsStatusFocused.self] } set { self[IsStatusFocused.self] = newValue } } - + var isStatusReplyToPrevious: Bool { get { self[IsStatusReplyToPrevious.self] } set { self[IsStatusReplyToPrevious.self] = newValue } diff --git a/Packages/Explore/Sources/Explore/ExploreView.swift b/Packages/Explore/Sources/Explore/ExploreView.swift index 51dc3b60..0ef711b3 100644 --- a/Packages/Explore/Sources/Explore/ExploreView.swift +++ b/Packages/Explore/Sources/Explore/ExploreView.swift @@ -7,8 +7,9 @@ import Shimmer import Status import SwiftUI +@MainActor public struct ExploreView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client @Environment(RouterPath.self) private var routerPath diff --git a/Packages/Explore/Sources/Explore/TagsListView.swift b/Packages/Explore/Sources/Explore/TagsListView.swift index f8856efc..bbf54d1d 100644 --- a/Packages/Explore/Sources/Explore/TagsListView.swift +++ b/Packages/Explore/Sources/Explore/TagsListView.swift @@ -3,7 +3,7 @@ import Models import SwiftUI public struct TagsListView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme let tags: [Tag] diff --git a/Packages/Lists/Sources/Lists/AddAccounts/ListAddAccountView.swift b/Packages/Lists/Sources/Lists/AddAccounts/ListAddAccountView.swift index 670da7ad..fdcd180d 100644 --- a/Packages/Lists/Sources/Lists/AddAccounts/ListAddAccountView.swift +++ b/Packages/Lists/Sources/Lists/AddAccounts/ListAddAccountView.swift @@ -4,10 +4,11 @@ import Models import Network import SwiftUI +@MainActor public struct ListAddAccountView: View { @Environment(\.dismiss) private var dismiss @Environment(Client.self) private var client - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentAccount.self) private var currentAccount @State private var viewModel: ListAddAccountViewModel diff --git a/Packages/Lists/Sources/Lists/Edit/ListEditView.swift b/Packages/Lists/Sources/Lists/Edit/ListEditView.swift index 5c7dc8db..126c83fc 100644 --- a/Packages/Lists/Sources/Lists/Edit/ListEditView.swift +++ b/Packages/Lists/Sources/Lists/Edit/ListEditView.swift @@ -4,9 +4,10 @@ import Models import Network import SwiftUI +@MainActor public struct ListEditView: View { @Environment(\.dismiss) private var dismiss - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client @State private var viewModel: ListEditViewModel diff --git a/Packages/Notifications/Sources/Notifications/NotificationRowView.swift b/Packages/Notifications/Sources/Notifications/NotificationRowView.swift index f0c8cde4..7119591b 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationRowView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationRowView.swift @@ -6,8 +6,9 @@ import Network import Status import SwiftUI +@MainActor struct NotificationRowView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(\.redactionReasons) private var reasons let notification: ConsolidatedNotification diff --git a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift index ba996f14..196d3a6a 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift @@ -5,9 +5,10 @@ import Network import Shimmer import SwiftUI +@MainActor public struct NotificationsListView: View { @Environment(\.scenePhase) private var scenePhase - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(StreamWatcher.self) private var watcher @Environment(Client.self) private var client @Environment(RouterPath.self) private var routerPath diff --git a/Packages/Status/Sources/Status/Detail/StatusDetailView.swift b/Packages/Status/Sources/Status/Detail/StatusDetailView.swift index 9a844f03..25a3ebf2 100644 --- a/Packages/Status/Sources/Status/Detail/StatusDetailView.swift +++ b/Packages/Status/Sources/Status/Detail/StatusDetailView.swift @@ -5,8 +5,9 @@ import Network import Shimmer import SwiftUI +@MainActor public struct StatusDetailView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentAccount.self) private var currentAccount @Environment(StreamWatcher.self) private var watcher @Environment(Client.self) private var client diff --git a/Packages/Status/Sources/Status/Detail/StatusDetailViewModel.swift b/Packages/Status/Sources/Status/Detail/StatusDetailViewModel.swift index d7e9c0e2..ca44a36e 100644 --- a/Packages/Status/Sources/Status/Detail/StatusDetailViewModel.swift +++ b/Packages/Status/Sources/Status/Detail/StatusDetailViewModel.swift @@ -19,7 +19,7 @@ import SwiftUI var state: State = .loading var title: LocalizedStringKey = "" var scrollToId: String? - + @ObservationIgnored var isReplyToPreviousCache: [String: Bool] = [:] @@ -127,7 +127,7 @@ import SwiftUI isReplyToPreviousCache[status.id] = isReplyToPrevious } } - + func handleEvent(event: any StreamEvent, currentAccount: Account?) { Task { if let event = event as? StreamEventUpdate, diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift index 9e2a3372..3373d02c 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift @@ -7,7 +7,7 @@ import SwiftUI struct StatusEditorAccessoryView: View { @EnvironmentObject private var preferences: UserPreferences - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentInstance.self) private var currentInstance @Environment(\.colorScheme) private var colorScheme diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAutoCompleteView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAutoCompleteView.swift index 6db70d9f..249976a4 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAutoCompleteView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAutoCompleteView.swift @@ -3,8 +3,9 @@ import EmojiText import Foundation import SwiftUI +@MainActor struct StatusEditorAutoCompleteView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme var viewModel: StatusEditorViewModel var body: some View { diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaEditView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaEditView.swift index 7da7cce6..afdd24fe 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaEditView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaEditView.swift @@ -6,7 +6,7 @@ import SwiftUI struct StatusEditorMediaEditView: View { @Environment(\.dismiss) private var dismiss - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentInstance.self) private var currentInstance var viewModel: StatusEditorViewModel let container: StatusEditorMediaContainer diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaView.swift index de37cc92..3a3a7b28 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorMediaView.swift @@ -5,8 +5,9 @@ import Models import NukeUI import SwiftUI +@MainActor struct StatusEditorMediaView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentInstance.self) private var currentInstance var viewModel: StatusEditorViewModel @State private var editingContainer: StatusEditorMediaContainer? diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorPollView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorPollView.swift index c3dbd108..b4e526ad 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorPollView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorPollView.swift @@ -2,6 +2,7 @@ import DesignSystem import Env import SwiftUI +@MainActor struct StatusEditorPollView: View { enum FocusField: Hashable { case option(Int) @@ -11,7 +12,7 @@ struct StatusEditorPollView: View { @State private var currentFocusIndex: Int = 0 - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentInstance.self) private var currentInstance var viewModel: StatusEditorViewModel diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorView.swift b/Packages/Status/Sources/Status/Editor/StatusEditorView.swift index b3d176b5..535dea18 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorView.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorView.swift @@ -11,10 +11,11 @@ import StoreKit import SwiftUI import UIKit +@MainActor public struct StatusEditorView: View { @Environment(AppAccountsManager.self) private var appAccounts @EnvironmentObject private var preferences: UserPreferences - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client @Environment(CurrentAccount.self) private var currentAccount @Environment(RouterPath.self) private var routerPath @@ -238,7 +239,7 @@ public struct StatusEditorView: View { avatarSize: .status) } else { AvatarView(url: account.avatar, size: .status) - .environmentObject(theme) + .environment(theme) .accessibilityHidden(true) } VStack(alignment: .leading, spacing: 4) { diff --git a/Packages/Status/Sources/Status/Embed/StatusEmbeddedView.swift b/Packages/Status/Sources/Status/Embed/StatusEmbeddedView.swift index f35507d5..e601d6fc 100644 --- a/Packages/Status/Sources/Status/Embed/StatusEmbeddedView.swift +++ b/Packages/Status/Sources/Status/Embed/StatusEmbeddedView.swift @@ -7,7 +7,7 @@ import SwiftUI @MainActor public struct StatusEmbeddedView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme public let status: Status public let client: Client diff --git a/Packages/Status/Sources/Status/History/StatusEditHistoryView.swift b/Packages/Status/Sources/Status/History/StatusEditHistoryView.swift index 40777ccd..aae4dd1c 100644 --- a/Packages/Status/Sources/Status/History/StatusEditHistoryView.swift +++ b/Packages/Status/Sources/Status/History/StatusEditHistoryView.swift @@ -7,7 +7,7 @@ public struct StatusEditHistoryView: View { @Environment(\.dismiss) private var dismiss @Environment(Client.self) private var client - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme private let statusId: String diff --git a/Packages/Status/Sources/Status/List/StatusesListView.swift b/Packages/Status/Sources/Status/List/StatusesListView.swift index 7b91066b..e970881e 100644 --- a/Packages/Status/Sources/Status/List/StatusesListView.swift +++ b/Packages/Status/Sources/Status/List/StatusesListView.swift @@ -5,8 +5,9 @@ import Network import Shimmer import SwiftUI +@MainActor public struct StatusesListView: View where Fetcher: StatusesFetcher { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var fetcher: Fetcher // Whether this status is on a remote local timeline (many actions are unavailable if so) diff --git a/Packages/Status/Sources/Status/Media/VideoPlayerView.swift b/Packages/Status/Sources/Status/Media/VideoPlayerView.swift index 7e6e86fb..98e7e700 100644 --- a/Packages/Status/Sources/Status/Media/VideoPlayerView.swift +++ b/Packages/Status/Sources/Status/Media/VideoPlayerView.swift @@ -52,7 +52,7 @@ struct VideoPlayerView: View { @Environment(\.scenePhase) private var scenePhase @Environment(\.isCompact) private var isCompact @EnvironmentObject private var preferences: UserPreferences - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State var viewModel: VideoPlayerViewModel diff --git a/Packages/Status/Sources/Status/Poll/StatusPollView.swift b/Packages/Status/Sources/Status/Poll/StatusPollView.swift index c43ce1bf..609c012a 100644 --- a/Packages/Status/Sources/Status/Poll/StatusPollView.swift +++ b/Packages/Status/Sources/Status/Poll/StatusPollView.swift @@ -4,8 +4,9 @@ import Models import Network import SwiftUI +@MainActor public struct StatusPollView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(Client.self) private var client @Environment(CurrentInstance.self) private var currentInstance @Environment(CurrentAccount.self) private var currentAccount diff --git a/Packages/Status/Sources/Status/Row/StatusRowView.swift b/Packages/Status/Sources/Status/Row/StatusRowView.swift index 11510830..2eb2a2d9 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowView.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowView.swift @@ -7,6 +7,7 @@ import Network import Shimmer import SwiftUI +@MainActor public struct StatusRowView: View { @Environment(\.isInCaptureMode) private var isInCaptureMode: Bool @Environment(\.redactionReasons) private var reasons @@ -16,7 +17,7 @@ public struct StatusRowView: View { @Environment(\.isStatusReplyToPrevious) private var isStatusReplyToPrevious @Environment(QuickLook.self) private var quickLook - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @State private var viewModel: StatusRowViewModel @@ -95,7 +96,7 @@ public struct StatusRowView: View { viewModel.navigateToDetail() } } - + if isFocused { StatusRowDetailView(viewModel: viewModel) } diff --git a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift index dc940540..9b80fa67 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift @@ -15,10 +15,10 @@ import SwiftUI let showActions: Bool let textDisabled: Bool let finalStatus: AnyStatus - + let client: Client let routerPath: RouterPath - + private let theme = Theme.shared private let userMentionned: Bool diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowActionsView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowActionsView.swift index 948b602a..4d8dd09a 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowActionsView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowActionsView.swift @@ -5,7 +5,7 @@ import Network import SwiftUI struct StatusRowActionsView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentAccount.self) private var currentAccount @Environment(StatusDataController.self) private var statusDataController @EnvironmentObject private var userPreferences: UserPreferences @@ -13,7 +13,7 @@ struct StatusRowActionsView: View { @Environment(\.isStatusFocused) private var isFocused var viewModel: StatusRowViewModel - + func privateBoost() -> Bool { viewModel.status.visibility == .priv && viewModel.status.account.id == currentAccount.account?.id } diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowCardView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowCardView.swift index 68979f74..640f40bb 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowCardView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowCardView.swift @@ -9,7 +9,7 @@ public struct StatusRowCardView: View { @Environment(\.openURL) private var openURL @Environment(\.isInCaptureMode) private var isInCaptureMode: Bool - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme let card: Card diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContentView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContentView.swift index f54a3055..a81b3769 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContentView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContentView.swift @@ -8,7 +8,7 @@ struct StatusRowContentView: View { @Environment(\.isCompact) private var isCompact @Environment(\.isStatusFocused) private var isFocused - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme var viewModel: StatusRowViewModel diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift index 11aeea50..4a2c5943 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowContextMenu.swift @@ -4,6 +4,7 @@ import Foundation import Network import SwiftUI +@MainActor struct StatusRowContextMenu: View { @Environment(\.displayScale) var displayScale @@ -85,7 +86,7 @@ struct StatusRowContextMenu: View { .padding(16) } .environment(\.isInCaptureMode, true) - .environmentObject(Theme.shared) + .environment(Theme.shared) .environmentObject(preferences) .environment(account) .environment(currentInstance) diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowDetailView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowDetailView.swift index 7e742943..710b3007 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowDetailView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowDetailView.swift @@ -75,7 +75,7 @@ struct StatusRowDetailView: View { .buttonStyle(.borderless) .transition(.move(edge: .leading)) } - + if viewModel.actionsAccountsFetched, statusDataController.reblogsCount > 0 { Divider() Button { diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowHeaderView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowHeaderView.swift index ba41a64e..4e3fc5f7 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowHeaderView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowHeaderView.swift @@ -3,11 +3,12 @@ import Env import Models import SwiftUI +@MainActor struct StatusRowHeaderView: View { @Environment(\.isInCaptureMode) private var isInCaptureMode: Bool @Environment(\.isStatusFocused) private var isFocused - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme let viewModel: StatusRowViewModel diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift index edc20186..17cae19b 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowMediaPreviewView.swift @@ -14,7 +14,7 @@ public struct StatusRowMediaPreviewView: View { @Environment(SceneDelegate.self) private var sceneDelegate @EnvironmentObject private var preferences: UserPreferences @Environment(QuickLook.self) private var quickLook - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme public let attachments: [MediaAttachment] public let sensitive: Bool diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowSwipeView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowSwipeView.swift index dcb38176..68578a4f 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowSwipeView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowSwipeView.swift @@ -4,7 +4,7 @@ import Models import SwiftUI struct StatusRowSwipeView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @EnvironmentObject private var preferences: UserPreferences @Environment(CurrentAccount.self) private var currentAccount @Environment(StatusDataController.self) private var statusDataController diff --git a/Packages/Status/Sources/Status/Row/Subviews/StatusRowTextView.swift b/Packages/Status/Sources/Status/Row/Subviews/StatusRowTextView.swift index 06fc4d71..80edc07f 100644 --- a/Packages/Status/Sources/Status/Row/Subviews/StatusRowTextView.swift +++ b/Packages/Status/Sources/Status/Row/Subviews/StatusRowTextView.swift @@ -3,8 +3,9 @@ import Env import Models import SwiftUI +@MainActor struct StatusRowTextView: View { - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(\.isStatusFocused) private var isFocused var viewModel: StatusRowViewModel diff --git a/Packages/Timeline/Sources/Timeline/TimelineView.swift b/Packages/Timeline/Sources/Timeline/TimelineView.swift index f9838a22..aa995314 100644 --- a/Packages/Timeline/Sources/Timeline/TimelineView.swift +++ b/Packages/Timeline/Sources/Timeline/TimelineView.swift @@ -7,13 +7,14 @@ import Status import SwiftUI import SwiftUIIntrospect +@MainActor public struct TimelineView: View { private enum Constants { static let scrollToTop = "top" } @Environment(\.scenePhase) private var scenePhase - @EnvironmentObject private var theme: Theme + @Environment(Theme.self) private var theme @Environment(CurrentAccount.self) private var account @Environment(StreamWatcher.self) private var watcher @Environment(Client.self) private var client