StatusRow: Flatify the hierarchy to work around iOS 16.4 issues

This commit is contained in:
Thomas Ricouard 2023-03-01 17:34:03 +01:00
parent 87ef2f2a39
commit 43a4551d9b

View file

@ -26,19 +26,16 @@ public struct StatusRowView: View {
} }
public var body: some View { public var body: some View {
if viewModel.isFiltered, let filter = viewModel.filter { VStack(alignment: .leading) {
switch filter.filter.filterAction {
case .warn:
makeFilterView(filter: filter.filter)
.listRowBackground(viewModel.highlightRowColor)
case .hide:
EmptyView()
.listRowSeparator(.hidden)
.listRowInsets(.init())
}
} else {
let status: AnyStatus = viewModel.status.reblog ?? viewModel.status let status: AnyStatus = viewModel.status.reblog ?? viewModel.status
VStack(alignment: .leading) { if viewModel.isFiltered, let filter = viewModel.filter {
switch filter.filter.filterAction {
case .warn:
makeFilterView(filter: filter.filter)
case .hide:
EmptyView()
}
} else {
if !isCompact, theme.avatarPosition == .leading { if !isCompact, theme.avatarPosition == .leading {
StatusRowReblogView(viewModel: viewModel) StatusRowReblogView(viewModel: viewModel)
StatusRowReplyView(viewModel: viewModel) StatusRowReplyView(viewModel: viewModel)
@ -85,74 +82,74 @@ public struct StatusRowView: View {
} }
} }
} }
.onAppear {
viewModel.markSeen()
if reasons.isEmpty {
if !isCompact, viewModel.embeddedStatus == nil {
Task {
await viewModel.loadEmbeddedStatus()
}
}
}
}
.contextMenu {
contextMenu
}
.swipeActions(edge: .trailing) {
if !isCompact {
StatusRowSwipeView(viewModel: viewModel, mode: .trailing)
}
}
.swipeActions(edge: .leading) {
if !isCompact {
StatusRowSwipeView(viewModel: viewModel, mode: .leading)
}
}
.listRowBackground(viewModel.highlightRowColor)
.listRowInsets(.init(top: 12,
leading: .layoutPadding,
bottom: 12,
trailing: .layoutPadding))
.accessibilityElement(children: viewModel.isFocused ? .contain : .combine)
.accessibilityActions {
if UIAccessibility.isVoiceOverRunning {
accesibilityActions
}
}
.background {
Color.clear
.contentShape(Rectangle())
.onTapGesture {
viewModel.navigateToDetail()
}
}
.overlay {
if viewModel.isLoadingRemoteContent {
remoteContentLoadingView
}
}
.alert(isPresented: $viewModel.showDeleteAlert, content: {
Alert(
title: Text("status.action.delete.confirm.title"),
message: Text("status.action.delete.confirm.message"),
primaryButton: .destructive(
Text("status.action.delete"))
{
Task {
await viewModel.delete()
}
},
secondaryButton: .cancel()
)
})
.alignmentGuide(.listRowSeparatorLeading) { _ in
-100
}
.environmentObject(
StatusDataControllerProvider.shared.dataController(for: viewModel.status.reblog ?? viewModel.status,
client: client)
)
} }
.onAppear {
viewModel.markSeen()
if reasons.isEmpty {
if !isCompact, viewModel.embeddedStatus == nil {
Task {
await viewModel.loadEmbeddedStatus()
}
}
}
}
.contextMenu {
contextMenu
}
.swipeActions(edge: .trailing) {
if !isCompact {
StatusRowSwipeView(viewModel: viewModel, mode: .trailing)
}
}
.swipeActions(edge: .leading) {
if !isCompact {
StatusRowSwipeView(viewModel: viewModel, mode: .leading)
}
}
.listRowBackground(viewModel.highlightRowColor)
.listRowInsets(.init(top: 12,
leading: .layoutPadding,
bottom: 12,
trailing: .layoutPadding))
.accessibilityElement(children: viewModel.isFocused ? .contain : .combine)
.accessibilityActions {
if UIAccessibility.isVoiceOverRunning {
accesibilityActions
}
}
.background {
Color.clear
.contentShape(Rectangle())
.onTapGesture {
viewModel.navigateToDetail()
}
}
.overlay {
if viewModel.isLoadingRemoteContent {
remoteContentLoadingView
}
}
.alert(isPresented: $viewModel.showDeleteAlert, content: {
Alert(
title: Text("status.action.delete.confirm.title"),
message: Text("status.action.delete.confirm.message"),
primaryButton: .destructive(
Text("status.action.delete"))
{
Task {
await viewModel.delete()
}
},
secondaryButton: .cancel()
)
})
.alignmentGuide(.listRowSeparatorLeading) { _ in
-100
}
.environmentObject(
StatusDataControllerProvider.shared.dataController(for: viewModel.status.reblog ?? viewModel.status,
client: client)
)
} }
@ViewBuilder @ViewBuilder