MediaTimelinePreviewDetails can now be opened by long pressing in the media timeline (#4474)

* presenting media actions from the media timeline

* implemented view in timeline and fixed an issue that made dark mode being when trying to delete the file

* pr suggestions
This commit is contained in:
Mauro
2025-09-05 15:30:36 +02:00
committed by GitHub
parent 5be7967f94
commit eee11ed67c
12 changed files with 148 additions and 48 deletions
@@ -10,6 +10,7 @@ import SwiftUI
struct MediaEventsTimelineScreen: View {
@ObservedObject var context: MediaEventsTimelineScreenViewModel.Context
@State private var sheetHeight = CGFloat.zero
var body: some View {
mainContent
@@ -24,6 +25,15 @@ struct MediaEventsTimelineScreen: View {
context.send(viewAction: .changedScreenMode)
}
.timelineMediaPreview(viewModel: $context.mediaPreviewViewModel)
.sheet(item: $context.mediaPreviewSheetViewModel) { sheet in
if case let .media(media) = sheet.state.currentItem {
TimelineMediaPreviewDetailsView(item: media,
context: sheet.context,
preferredColorScheme: nil,
sheetHeight: $sheetHeight)
.presentationDetents([.height(sheetHeight)])
}
}
}
// The scale effects do the following:
@@ -66,6 +76,9 @@ struct MediaEventsTimelineScreen: View {
viewForTimelineItem(item)
.scaleEffect(CGSize(width: -1, height: -1))
}
.accessibleLongPress(named: L10n.actionOpenContextMenu) {
context.send(viewAction: .longPressedItem(item: item))
}
}
} footer: {
// Use a footer as the header because the scrollView is flipped
@@ -96,6 +109,9 @@ struct MediaEventsTimelineScreen: View {
.accessibilityRepresentation {
viewForTimelineItem(item)
}
.accessibleLongPress(named: L10n.actionOpenContextMenu) {
context.send(viewAction: .longPressedItem(item: item))
}
}
.accessibilityElement(children: .combine)
.padding(.horizontal, 16)
@@ -230,6 +246,10 @@ struct MediaEventsTimelineScreen: View {
}
}
extension TimelineMediaPreviewViewModel: Identifiable {
var id: UUID { instanceID }
}
// MARK: - Previews
struct MediaEventsTimelineScreen_Previews: PreviewProvider, TestablePreview {