commit f9bfa9dfa54f8e36bf8bbdbe1cc732d74fca3179
parent 71b33fcd0be45aeeb3bcfbe32816e2c1b078433f
Author: kernelkind <kernelkind@gmail.com>
Date: Mon, 22 Jan 2024 11:35:45 -0500
carousel: save current viewed image index when switching to fullscreen
When scrolling through the media carousel, the currently viewed media
should persist between fullscreen and carousel view instead of resetting
to the first index.
Closes: https://github.com/damus-io/damus/issues/1329
Changelog-Fixed: Save current viewed image index when switching to fullscreen
Lightning-url: LNURL1DP68GURN8GHJ7EM9W3SKCCNE9E3K7MF0D3H82UNVWQHKWUN9V4HXGCTHDC6RZVGR8SW3G
Signed-off-by: kernelkind <kernelkind@gmail.com>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/damus/Components/ImageCarousel.swift b/damus/Components/ImageCarousel.swift
@@ -201,7 +201,7 @@ struct ImageCarousel: View {
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
.fullScreenCover(isPresented: $model.open_sheet) {
- ImageView(video_controller: state.video, urls: urls, settings: state.settings)
+ ImageView(video_controller: state.video, urls: urls, settings: state.settings, selectedIndex: $model.selectedIndex)
}
.frame(height: height)
.onChange(of: model.selectedIndex) { value in
diff --git a/damus/Views/Images/ImageView.swift b/damus/Views/Images/ImageView.swift
@@ -13,10 +13,10 @@ struct ImageView: View {
@Environment(\.presentationMode) var presentationMode
- @State private var selectedIndex = 0
@State var showMenu = true
let settings: UserSettingsStore
+ @Binding var selectedIndex: Int
var tabViewIndicator: some View {
HStack(spacing: 10) {
@@ -85,6 +85,6 @@ struct ImageView: View {
struct ImageView_Previews: PreviewProvider {
static var previews: some View {
let url: MediaUrl = .image(URL(string: "https://jb55.com/red-me.jpg")!)
- ImageView(video_controller: test_damus_state.video, urls: [url], settings: test_damus_state.settings)
+ ImageView(video_controller: test_damus_state.video, urls: [url], settings: test_damus_state.settings, selectedIndex: Binding.constant(0))
}
}