Skip to content

Commit 5de86bb

Browse files
fixed bug with jumping while scrolling the images in gallery
1 parent 03ee4ef commit 5de86bb

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Gallery/GalleryView.swift

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,25 @@ struct GalleryView: View {
6161
.tabViewStyle(.page(indexDisplayMode: .never))
6262
.background(Color(colors.background1))
6363

64-
if let image = loadedImages[selected] {
65-
HStack {
66-
ShareButtonView(content: [image])
67-
.standardPadding()
68-
69-
Spacer()
70-
71-
Text("\(selected + 1) of \(sources.count)")
72-
.font(fonts.bodyBold)
73-
74-
Spacer()
75-
76-
Button {
77-
gridShown = true
78-
} label: {
79-
Image(systemName: "square.grid.3x3.fill")
80-
}
64+
HStack {
65+
ShareButtonView(content: sharingContent)
8166
.standardPadding()
67+
68+
Spacer()
69+
70+
Text("\(selected + 1) of \(sources.count)")
71+
.font(fonts.bodyBold)
72+
73+
Spacer()
74+
75+
Button {
76+
gridShown = true
77+
} label: {
78+
Image(systemName: "square.grid.3x3.fill")
8279
}
83-
.foregroundColor(Color(colors.text))
80+
.standardPadding()
8481
}
82+
.foregroundColor(Color(colors.text))
8583
}
8684
.sheet(isPresented: $gridShown) {
8785
GridPhotosView(
@@ -92,6 +90,14 @@ struct GalleryView: View {
9290
}
9391
}
9492

93+
private var sharingContent: [UIImage] {
94+
if let image = loadedImages[selected] {
95+
return [image]
96+
} else {
97+
return []
98+
}
99+
}
100+
95101
private var sources: [URL] {
96102
message.imageAttachments.map { attachment in
97103
attachment.imageURL

0 commit comments

Comments
 (0)