Krisiacik / ImageViewer

An image viewer à la Twitter
MIT License
2.53k stars 385 forks source link

Is it possible to load images from network and use an activity view? #113

Closed Ricardo1980 closed 7 years ago

Ricardo1980 commented 7 years ago

Hello!

Is it possible to use this component when I only have a set of URLs rather the UIImage objects?

Perhaps https://github.com/MailOnline/ImageViewer/blob/master/ImageViewer/Source/GalleryItem.swift Using GalleryItem, custom enumeration

But, in that case, how should I add an activity view while the image is downloaded? Can I combine this library with: https://github.com/rs/SDWebImage and use: [imageView sd_setShowActivityIndicatorView:YES]; [imageView sd_setIndicatorStyle:UIActivityIndicatorViewStyleGray];

Thanks a lot for suggestions.

Ricardo1980 commented 7 years ago

I see we have case spinnerStyle(UIActivityIndicatorViewStyle) case spinnerColor(UIColor) but, how do we connect that with a network request?

antonkiselev commented 7 years ago

You should provide images not directly but with callback, spinner will be displayed until callback is fired. Example with Kingfisher image manager:

extension ScreensTableView: GalleryItemsDataSource {
    func provideGalleryItem(_ index: Int) -> GalleryItem {
        let url = myUrlGetter()
        return GalleryItem.image { callback in
            KingfisherManager.shared.retrieveImage(with: url, options: [], progressBlock: nil, completionHandler: { (image, error, cacheType, url) in
                callback(image)
            })
        }
    }
}
Ricardo1980 commented 7 years ago

Thanks, I already got that using sdWebImage.

I guess when using a network request we should not use the displacement view (a thumbnail of the imag is about to be downloaded). Basically because the UX would be very bad. What do you think.

antonkiselev commented 7 years ago

I am providing displacement view all the time, but when image is not yet loaded ImageViewer won't use it for displacement view and appears without displacement animation, which is kinda bugged due to applying opacity to UIVisualEffectView, but i hope they will fix that in future. And most of the time you should have 2 different urls, one for small image in your controller and another one for fullscreen viewing.

Krisiacik commented 7 years ago

The situation is getting a bit out of hand. ImageViewer cannot function properly (concentually & from UX point of view ) if images are not available, and having an asychronous source means they are not available. Guys (Zeno & Rui) pls do not merge anything unless it is properly considered in terms of future product evolution.

Ricardo1980 commented 7 years ago

@Krisiacik it is very common to have thumbnails (small pictures) and when you tap them, go to the viewer and download a high resolution version of those thumbnails.

Krisiacik commented 7 years ago

@Ricardo1980 isn't that exactly what ImageViewer is doing from the start? I think we did not understand each other in terms of who actually means what. So to recap - I am ok with the idea of having async full image..that's why we have implemented it. However, I don't se much point supporting async thumbnails. What kind of UX would that be? Yuo would tapping on (best case) placeholder image or nothing, only to get another placeholder "something" because the real content is still on the way. But, perhaps it's a matter of imagination/proper use case.