alexhillc / AXPhotoViewer

An iOS/tvOS photo gallery viewer, useful for viewing a large (or small!) number of photos.
https://www.cocoacontrols.com/controls/axphotoviewer
MIT License
642 stars 120 forks source link

Not loading KingFisher photos when those files are url.isFileURL #62

Open chrisvoronin opened 4 years ago

chrisvoronin commented 4 years ago

KingFisher integration does not work with local files.

KF Integration source uses: KingfisherManager.shared.retrieveImage However that does not use LocalFileProvider (king fisher) to load them which is needed for local files.

chrisvoronin commented 4 years ago

something along those lines fixes it: I fixed it in my Form, with access I can push PR here.

if url.isFileURL {
            let local = LocalFileImageDataProvider(fileURL: url)

            AXDispatchUtils.executeInBackground { [weak self] in
                local.data(handler: { (result) in
                    switch result {
                    case .failure(let error):
                        AXDispatchUtils.executeInBackground { [weak self] in
                            guard let self = self else { return }
                            self.delegate?.networkIntegration(self, loadDidFailWith: error, for: photo)
                        }
                    case .success(let imageData):
                        let image = UIImage(data: imageData)
                        photo.image = image
                        AXDispatchUtils.executeInBackground { [weak self] in
                            guard let self = self else { return }
                            self.delegate?.networkIntegration(self, loadDidFinishWith: photo)
                        }
                    }
                })
            }
            return
        }
alexhillc commented 4 years ago

@chrisvoronin - thanks for the investigation! If you want contribute, you can fork the repo and then open a PR upstream.

Described here: https://help.github.com/en/articles/creating-a-pull-request-from-a-fork