diff --git a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift index 0e3ce244..7327fc5f 100644 --- a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift @@ -37,7 +37,7 @@ struct DisplaySettingsView: View { ZStack(alignment: .top) { Form { #if !os(visionOS) - StatusRowView(viewModel: previewStatusViewModel) + StatusRowExternalView(viewModel: previewStatusViewModel) .allowsHitTesting(false) .opacity(0) .hidden() @@ -85,7 +85,7 @@ struct DisplaySettingsView: View { private var examplePost: some View { VStack(spacing: 0) { - StatusRowView(viewModel: previewStatusViewModel) + StatusRowExternalView(viewModel: previewStatusViewModel) .allowsHitTesting(false) .padding(.layoutPadding) .background(theme.primaryBackgroundColor) diff --git a/Packages/Account/Sources/Account/AccountDetailView.swift b/Packages/Account/Sources/Account/AccountDetailView.swift index 9bf02fbd..85119479 100644 --- a/Packages/Account/Sources/Account/AccountDetailView.swift +++ b/Packages/Account/Sources/Account/AccountDetailView.swift @@ -242,7 +242,7 @@ public struct AccountDetailView: View { .listRowBackground(theme.primaryBackgroundColor) #endif ForEach(viewModel.pinned) { status in - StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath)) + StatusRowExternalView(viewModel: .init(status: status, client: client, routerPath: routerPath)) } Rectangle() #if os(visionOS) diff --git a/Packages/Explore/Sources/Explore/ExploreView.swift b/Packages/Explore/Sources/Explore/ExploreView.swift index be1d3ae5..0675cde5 100644 --- a/Packages/Explore/Sources/Explore/ExploreView.swift +++ b/Packages/Explore/Sources/Explore/ExploreView.swift @@ -155,7 +155,7 @@ public struct ExploreView: View { private var loadingView: some View { ForEach(Status.placeholders()) { status in - StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath)) + StatusRowExternalView(viewModel: .init(status: status, client: client, routerPath: routerPath)) .padding(.vertical, 8) .redacted(reason: .placeholder) .allowsHitTesting(false) @@ -201,7 +201,7 @@ public struct ExploreView: View { if !results.statuses.isEmpty, viewModel.searchScope == .all || viewModel.searchScope == .posts { Section("explore.section.posts") { ForEach(results.statuses) { status in - StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath)) + StatusRowExternalView(viewModel: .init(status: status, client: client, routerPath: routerPath)) #if !os(visionOS) .listRowBackground(theme.primaryBackgroundColor) #else @@ -279,7 +279,7 @@ public struct ExploreView: View { ForEach(viewModel.trendingStatuses .prefix(upTo: viewModel.trendingStatuses.count > 3 ? 3 : viewModel.trendingStatuses.count)) { status in - StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath)) + StatusRowExternalView(viewModel: .init(status: status, client: client, routerPath: routerPath)) #if !os(visionOS) .listRowBackground(theme.primaryBackgroundColor) #else diff --git a/Packages/Notifications/Sources/Notifications/NotificationRowView.swift b/Packages/Notifications/Sources/Notifications/NotificationRowView.swift index b512c039..e180fb53 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationRowView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationRowView.swift @@ -156,17 +156,17 @@ struct NotificationRowView: View { if let status = notification.status { HStack { if type == .mention { - StatusRowView(viewModel: .init(status: status, - client: client, - routerPath: routerPath, - showActions: true)) + StatusRowExternalView(viewModel: .init(status: status, + client: client, + routerPath: routerPath, + showActions: true)) .environment(\.isMediaCompact, false) } else { - StatusRowView(viewModel: .init(status: status, - client: client, - routerPath: routerPath, - showActions: false, - textDisabled: true)) + StatusRowExternalView(viewModel: .init(status: status, + client: client, + routerPath: routerPath, + showActions: false, + textDisabled: true)) .lineLimit(4) .environment(\.isMediaCompact, true) } diff --git a/Packages/StatusKit/Sources/StatusKit/Detail/StatusDetailView.swift b/Packages/StatusKit/Sources/StatusKit/Detail/StatusDetailView.swift index ee5bbe11..648d0bb5 100644 --- a/Packages/StatusKit/Sources/StatusKit/Detail/StatusDetailView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Detail/StatusDetailView.swift @@ -155,7 +155,7 @@ public struct StatusDetailView: View { private var loadingDetailView: some View { ForEach(Status.placeholders()) { status in - StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath)) + StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath), context: .timeline) .redacted(reason: .placeholder) .allowsHitTesting(false) } diff --git a/Packages/StatusKit/Sources/StatusKit/Editor/EditorView.swift b/Packages/StatusKit/Sources/StatusKit/Editor/EditorView.swift index a445cc61..70b56db1 100644 --- a/Packages/StatusKit/Sources/StatusKit/Editor/EditorView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Editor/EditorView.swift @@ -129,7 +129,8 @@ extension StatusEditor { StatusRowView(viewModel: .init(status: status, client: client, routerPath: RouterPath(), - showActions: false)) + showActions: false), + context: .timeline) .accessibilityLabel(status.content.asRawText) .environment(RouterPath()) .allowsHitTesting(false) diff --git a/Packages/StatusKit/Sources/StatusKit/Embed/StatusEmbeddedView.swift b/Packages/StatusKit/Sources/StatusKit/Embed/StatusEmbeddedView.swift index df96a64b..86343216 100644 --- a/Packages/StatusKit/Sources/StatusKit/Embed/StatusEmbeddedView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Embed/StatusEmbeddedView.swift @@ -26,7 +26,8 @@ public struct StatusEmbeddedView: View { StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath, - showActions: false)) + showActions: false), + context: .timeline) .accessibilityLabel(status.content.asRawText) .environment(\.isCompact, true) .environment(\.isMediaCompact, true) diff --git a/Packages/StatusKit/Sources/StatusKit/List/StatusesListView.swift b/Packages/StatusKit/Sources/StatusKit/List/StatusesListView.swift index 09c47706..c9ac217e 100644 --- a/Packages/StatusKit/Sources/StatusKit/List/StatusesListView.swift +++ b/Packages/StatusKit/Sources/StatusKit/List/StatusesListView.swift @@ -29,7 +29,8 @@ public struct StatusesListView: View where Fetcher: StatusesFetcher { switch fetcher.statusesState { case .loading: ForEach(Status.placeholders()) { status in - StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath)) + StatusRowView(viewModel: .init(status: status, client: client, routerPath: routerPath), + context: .timeline) .redacted(reason: .placeholder) .allowsHitTesting(false) } @@ -48,7 +49,8 @@ public struct StatusesListView: View where Fetcher: StatusesFetcher { StatusRowView(viewModel: StatusRowViewModel(status: status, client: client, routerPath: routerPath, - isRemote: isRemote)) + isRemote: isRemote), + context: .timeline) .onAppear { fetcher.statusDidAppear(status: status) } diff --git a/Packages/StatusKit/Sources/StatusKit/Row/StatusRowExternalView.swift b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowExternalView.swift new file mode 100644 index 00000000..4f75e536 --- /dev/null +++ b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowExternalView.swift @@ -0,0 +1,15 @@ +import SwiftUI + +public struct StatusRowExternalView: View { + @State private var viewModel: StatusRowViewModel + private let context: StatusRowView.Context + + public init(viewModel: StatusRowViewModel, context: StatusRowView.Context = .timeline) { + _viewModel = .init(initialValue: viewModel) + self.context = context + } + + public var body: some View { + StatusRowView(viewModel: viewModel, context: context) + } +} diff --git a/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift index 7cc5981d..8d30e8a9 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/StatusRowView.swift @@ -23,17 +23,13 @@ public struct StatusRowView: View { @Environment(Theme.self) private var theme @Environment(Client.self) private var client - @State private var viewModel: StatusRowViewModel @State private var showSelectableText: Bool = false @State private var isBlockConfirmationPresented = false public enum Context { case timeline, detail } - private let context: Context - - public init(viewModel: StatusRowViewModel, context: Context = .timeline) { - _viewModel = .init(initialValue: viewModel) - self.context = context - } + + @State public var viewModel: StatusRowViewModel + public let context: Context var contextMenu: some View { StatusRowContextMenu(viewModel: viewModel, @@ -42,6 +38,7 @@ public struct StatusRowView: View { } public var body: some View { + let _ = Self._printChanges() HStack(spacing: 0) { if !isCompact { HStack(spacing: 3) { diff --git a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowContextMenu.swift b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowContextMenu.swift index 8d2c4301..e44ae4b9 100644 --- a/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowContextMenu.swift +++ b/Packages/StatusKit/Sources/StatusKit/Row/Subviews/StatusRowContextMenu.swift @@ -104,7 +104,7 @@ struct StatusRowContextMenu: View { Button { let view = HStack { - StatusRowView(viewModel: viewModel) + StatusRowView(viewModel: viewModel, context: .timeline) .padding(16) } .environment(\.isInCaptureMode, true)