Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct ContentView: View {
Text("Error")
}
}
.id(basePhotoURLString)

HStack {
Button("1") {
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/kean/Nuke.git", from: "11.2.1"),
.package(url: "https://github.com/FluidGroup/swiftui-support.git", from: "0.1.0")
.package(url: "https://github.com/FluidGroup/swiftui-support.git", from: "0.2.3")
],
targets: [
.target(
Expand Down
28 changes: 17 additions & 11 deletions Sources/AsyncMultiplexImage/AsyncMultiplexImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,23 @@ public struct AsyncMultiplexImage<Content: View, Downloader: AsyncMultiplexImage

public var body: some View {
GeometryReader { proxy in
internalView
.onChangeWithPrevious(of: proxy.size, emitsInitial: true, perform: { newValue, oldValue in

let urls = urlsProvider(newValue)

let candidates = urls.enumerated().map { i, e in AsyncMultiplexImageCandidate(index: i, urlRequest: .init(url: e)) }

self.candidates = candidates
self.internalView = .init(candidates: candidates, downloader: downloader, content: content)
})
.id(candidates) // to make distinct views for each image-set.
Group {
if let internalView {
internalView
} else {
// for <= iOS 14
Color.clear
}
}
.onChangeWithPrevious(of: proxy.size, emitsInitial: true, perform: { newValue, oldValue in

let urls = urlsProvider(newValue)

let candidates = urls.enumerated().map { i, e in AsyncMultiplexImageCandidate(index: i, urlRequest: .init(url: e)) }

self.candidates = candidates
self.internalView = .init(candidates: candidates, downloader: downloader, content: content)
})
}
}

Expand Down