cmtrounce / swurl Goto Github PK
View Code? Open in Web Editor NEWLightweight and customisable async image loading in SwiftUI. Supports on-disk storage, placeholders and more!
License: MIT License
Lightweight and customisable async image loading in SwiftUI. Supports on-disk storage, placeholders and more!
License: MIT License
Here is the view:
var body: some View { VStack(alignment: .center, spacing: 16, content: { Spacer() HStack { Spacer() RemoteImageView(url: contact.iconUrl(), placeholderImage: Image.init("ministry_logo"), transition: .custom(transition: .opacity, animation: .easeOut(duration: 0.5))).frame(width: 100, height: 100, alignment: .center) Spacer() } }) }
When enabling logging, this is the message I get: "Result url not present in handleDownload" which obviously is not obvious at all. What I am missing here?
I'm showing 100 + images in a List and sometimes getting this error. What could be the problem? Can you help me please?
Tested on simulator iPhone 12 (iOS 14.5) and device iPhone 12 Mini (iOS 14.6).
Code is similar to this format
List{
ForEach((0..<500), id: \.self) {
index in
HStack{
RemoteImageView(url: URL(string:"https://picsum.photos/200/300")!)
RemoteImageView(url: URL(string:"https://picsum.photos/200/300")!)
}
}
}
It’s often the case that in the case of a long list we want to start pre-fetching images so users don’t have to see the placeholder view. It would be great to have an imperative way to do that and cache them to the configured cache.
When attempting to use RemoteImageView with 0.4.1 I got the following error, “Static method 'buildBlock' requires that 'SwURL' conform to 'View'”. When I changed to 0.4.0 the error message went away.
Hello ! I just installed the library and created an image but i received this error :
Argument labels '(_:)' do not match any available overloads
This is my code :
import SwiftUI
import SwURL
struct ContentView: View {
var body: some View {
VStack {
Text("Hello World")
RemoteImageView(url: URL("https://placeholder.com/150")) // the error appears here
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Update to compile / run on beta 6
How to control aspect ratio of final image?
Do I need "monkey-patch" TransitioningImage?
Hi,
Thanks for the project. this is not a bug but since i have the same name of images from the network from difference server locations, persistent storage seems to show the same image over. If there can be a way to specify the directory also, it would be helpful.
Like in the file Cache ->PersistentImageCache.swift
private extension PersistentImageCache {
func storageURL(for imageURL: URL) throws -> URL {
return FileManager
.cachesDir()
.appendingPathComponent(imageURL.lastPathComponent)
}
}
to include the directory component also from the URL.
If you use the image inside a navigation item it displays as a blue rectangle. The following modifier is required on the image to prevent this issue .renderingMode(.original),
An example is shown below
TransitioningImage.init(placeholder: placeholderImage?.resizable().renderingMode(.original),
finalImage: remoteImage.load(url: url).image?.resizable().renderingMode(.original),
transitionType: transitionType)
}
To add something like a progression animation circle as a placeholder
Hi,
here's pretty much how I use your lib: https://gist.github.com/benclanet/a5a02e613c344d0af888859c42a16001
What happens is a blank view. When I activate the logs, I do see Image successfully retrieved from url:
...
Any idea what could be wrong?
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.