Comments (11)
Interesting. I guess from an ergonomics POV, I'd expect it to feel natural, responding to .contentMode
for example or even better the built-in approach resizable
+ aspectRatio
.
I'll take a look at the code, and feedback at some point when I have some more time. Thanks for responding!
from nukeui.
I've been playing with AsyncImage
the past few days and AFAICT we don't have control over the caching etc... so I'm keen (pun not intended 🤣) to use your library still. Getting this to work nicely would be amazing but I realise I'm not your priority ;)
As an OSS contributor myself, I really appreciate the effort you've put it to your library, its documentation and even this conversation. Thanks for all the hard work!
from nukeui.
I don't have a ton of time atm, I'm working a lot more on some backend/framework implementations where I'm planning to work heavily with your Pulse framework. For the moment I reverted to your original implementation and that's working fine for me.
I absolutely would love to help you out so if I can carve out some time in the near future, I'll get back to you 👍
from nukeui.
Thanks!
This is the part of the API I haven't finished working on yet.
Currently, LazyImage
works differently to Image
.
The image view is lazy and doesn't know the size of the image before it downloads it. Thus, you must specify the view size before loading the image. By default, the image will resize preserving the aspect ratio to fill the available space. You can change this behavior by passing a different content mode.
LazyImage(source: "https://example.com/image.jpeg")
.contentMode(.center) // .aspectFit, .aspectFill, .center, .fill
.frame(height: 300)
In that sense, it acts more like UIImageView
does. So. unlike Image
, it doesn't support aspectRatio
API.
I would appreciate any feedback on these APIs. I'm still not sure how to best design it.
from nukeui.
The main challenge is that LazyImage has to use three different subviews to display an image: one for a regular image, one for animated images, and one for video (and soon more for WebP animated images and APNG). Otherwise, I would've provided an API like that:
LazyImage(source: ..., image: { image in
image
.resizable()
.aspectRatio(1, contentMode: .fit)
}
from nukeui.
Yeah I noticed you've built something more complex. I wonder if perhaps you could just break those other features out where they make more sense.
The new AsyncImage from WWDC for example is a really nice API and matching that could be really great?
from nukeui.
I'm working towards that. I have an idea how I can prove an API similar to AsyncImage while also supporting more advanced features (animated images).
But I'm not sure I agree with AsyncImage default behavior. I think the default should be resizable()
and contentMode: .fill
. What do you think?
from nukeui.
Yeah I guess I don't really mind as long as its changeable tbh.
from nukeui.
So, as a temporary solution we could use something like?
struct CoolImage: View {
var source: URL?
var resizingMode: ImageProcessors.Resize.ContentMode = .aspectFill
var body: some View {
GeometryReader { gp in
LazyImage(source: source)
.processors([ImageProcessors.Resize(size: gp.size, unit: .points, contentMode: resizingMode, crop: true, upscale: true)])
}
}
}
Perhaps I'm not getting how to use library correctly, but this seem to work fine.
from nukeui.
FYI, I've reverted for the moment to the old FetchImage implementation directly and that works fine, but would be great to use this new type as I think its far better from an API POV 👍
I'm trying to wrap my head around how to support these different scaling mods on macOS, but without experience shipping macOS apps (except for the ones written in SwiftUI), it's a bit hard. I would appreciate contributions in this area.
from nukeui.
Happy to close this issue, as recent updates have mostly resolved this I believe?
from nukeui.
Related Issues (20)
- Question: How can we stop animations when image is displayed. HOT 2
- Can we add play and pause buttons to the video playback? HOT 3
- Add support for iOS 13 HOT 1
- Placeholder image always displayed before cached image on iOS 15 when using an animation modifier
- LazyImage and memory usage HOT 2
- LazyImage in List elements HOT 3
- Read Image Data
- Image goes black when using SwiftUI contextMenu HOT 2
- Nothing shows when using content closure & url points to a video HOT 1
- Issue loading gif HOT 1
- Crash IOS 14.4 HOT 2
- Randomly, image does not load HOT 12
- To not set const image height
- Failed to decode image HOT 1
- Unable to change default view/color while image is loading HOT 1
- NukeUI + Introspect issue HOT 5
- MP4 loop stops when app is put in background HOT 2
- [Question] Disk caching between sessions? HOT 2
- Dependency on Gifu HOT 1
- Unable to add package HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nukeui.