mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-26 09:00:37 +00:00
Remove external init for StatusRowView
This commit is contained in:
parent
3f2fbeeec4
commit
54768772b5
11 changed files with 44 additions and 28 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -29,7 +29,8 @@ public struct StatusesListView<Fetcher>: 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<Fetcher>: View where Fetcher: StatusesFetcher {
|
|||
StatusRowView(viewModel: StatusRowViewModel(status: status,
|
||||
client: client,
|
||||
routerPath: routerPath,
|
||||
isRemote: isRemote))
|
||||
isRemote: isRemote),
|
||||
context: .timeline)
|
||||
.onAppear {
|
||||
fetcher.statusDidAppear(status: status)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -104,7 +104,7 @@ struct StatusRowContextMenu: View {
|
|||
|
||||
Button {
|
||||
let view = HStack {
|
||||
StatusRowView(viewModel: viewModel)
|
||||
StatusRowView(viewModel: viewModel, context: .timeline)
|
||||
.padding(16)
|
||||
}
|
||||
.environment(\.isInCaptureMode, true)
|
||||
|
|
Loading…
Reference in a new issue