mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
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:
+20
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user