Skip to content

Commit 308616a

Browse files
committed
Make TabViewGallery init with URLs
1 parent 962ce25 commit 308616a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Modules/Sources/ArticleFeature/Views/Gallery/CustomScrollView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Models
1111

1212
struct CustomScrollView: UIViewRepresentable {
1313

14-
let imageElement: [ImageElement]
14+
let imageElement: [URL]
1515
@Binding var selectedIndex: Int
1616
@Binding var isZooming: Bool
1717
@Binding var isTouched: Bool
@@ -74,7 +74,7 @@ struct CustomScrollView: UIViewRepresentable {
7474

7575
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
7676
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ImageCollectionViewCell", for: indexPath) as! ImageCollectionViewCell
77-
cell.setImage(url: parent.imageElement[indexPath.item].url)
77+
cell.setImage(url: parent.imageElement[indexPath.item])
7878

7979
cell.onZoom = { isZooming in
8080
DispatchQueue.main.async {

Modules/Sources/ArticleFeature/Views/Gallery/TabViewGallery.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import SharedUI
1616

1717
struct TabViewGallery: View {
1818

19-
var gallery: [ImageElement]
19+
var gallery: [URL]
2020
@Binding var showScreenGallery: Bool
2121
@Binding var selectedImageID: Int
2222
@State private var backgroundOpacity: Double = 1.0
@@ -102,7 +102,7 @@ struct TabViewGallery: View {
102102
}
103103

104104
private func saveImage() {
105-
let request = ImageRequest(url: gallery[selectedImageID].url)
105+
let request = ImageRequest(url: gallery[selectedImageID])
106106

107107
Nuke.ImagePipeline.shared.loadImage(with: request) { result in
108108
switch result {
@@ -124,10 +124,10 @@ struct TabViewGallery: View {
124124
}
125125
}
126126

127-
private func preloadImage(for: [ImageElement]) {
127+
private func preloadImage(for: [URL]) {
128128
DispatchQueue.main.async {
129129
for element in gallery.enumerated() {
130-
let imageUrl = gallery[element.offset].url
130+
let imageUrl = gallery[element.offset]
131131
let request = ImageRequest(url: imageUrl)
132132
Nuke.ImagePipeline.shared.loadImage(with: request) { result in
133133
switch result {
@@ -227,9 +227,9 @@ struct BackgroundView: ViewModifier {
227227

228228
#Preview {
229229
TabViewGallery(gallery: [
230-
.init(url: URL(string: "https://i.4pda.ws/static/img/news/63/633610t.jpg")!, width: 480, height: 269),
231-
.init(url: URL(string: "https://i.4pda.ws/static/img/news/63/633618t.jpg")!, width: 480, height: 269),
232-
.init(url: URL(string: "https://i.4pda.ws/static/img/news/63/633610t.jpg")!, width: 480, height: 269)
230+
URL(string: "https://i.4pda.ws/static/img/news/63/633610t.jpg")!,
231+
URL(string: "https://i.4pda.ws/static/img/news/63/633618t.jpg")!,
232+
URL(string: "https://i.4pda.ws/static/img/news/63/633610t.jpg")!
233233
],
234234
showScreenGallery: .constant(false), selectedImageID: .constant(0))
235235
}

0 commit comments

Comments
 (0)