mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-25 01:31:04 +00:00
StatusRow: Flatify the hierarchy to work around iOS 16.4 issues
This commit is contained in:
parent
87ef2f2a39
commit
43a4551d9b
1 changed files with 87 additions and 90 deletions
|
@ -26,19 +26,16 @@ public struct StatusRowView: View {
|
|||
}
|
||||
|
||||
public var body: some View {
|
||||
if viewModel.isFiltered, let filter = viewModel.filter {
|
||||
switch filter.filter.filterAction {
|
||||
case .warn:
|
||||
makeFilterView(filter: filter.filter)
|
||||
.listRowBackground(viewModel.highlightRowColor)
|
||||
case .hide:
|
||||
EmptyView()
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowInsets(.init())
|
||||
}
|
||||
} else {
|
||||
VStack(alignment: .leading) {
|
||||
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 {
|
||||
StatusRowReblogView(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
|
||||
|
|
Loading…
Reference in a new issue