Giter Club home page Giter Club logo

Comments (6)

lisindima avatar lisindima commented on June 8, 2024 3

Hi, I was able to run this component on SwiftUI and it works fine)

import SwiftUI
import UnsplashPhotoPicker

struct UnsplashImagePicker: UIViewControllerRepresentable {
    
    var urlUnsplashImage = [UnsplashPhoto]()
    
    let configuration = UnsplashPhotoPickerConfiguration(
        accessKey: "accessKey",
        secretKey: "accessKey",
        allowsMultipleSelection: false)
    
    func makeUIViewController(context: UIViewControllerRepresentableContext<UnsplashImagePicker>) -> UnsplashPhotoPicker {
        let unsplashPhotoPicker = UnsplashPhotoPicker(configuration: configuration)
        unsplashPhotoPicker.photoPickerDelegate = context.coordinator
        return unsplashPhotoPicker
    }
    
    func makeCoordinator() -> UnsplashImagePicker.Coordinator {
        return Coordinator(self)
    }
    
    class Coordinator: UnsplashPhotoPickerDelegate {
        
        var parent: UnsplashImagePicker
        
        init(_ parent: UnsplashImagePicker) {
            self.parent = parent
        }
        
        func unsplashPhotoPicker(_ photoPicker: UnsplashPhotoPicker, didSelectPhotos photos: [UnsplashPhoto]) {
            print(photos)
        }
        
        func unsplashPhotoPickerDidCancel(_ photoPicker: UnsplashPhotoPicker) {
            print("Unsplash photo picker did cancel")
        }
    }
    
    func updateUIViewController(_ uiViewController: UnsplashPhotoPicker, context: UIViewControllerRepresentableContext<UnsplashImagePicker>) {
        
    }
}

from unsplash-photopicker-ios.

lisindima avatar lisindima commented on June 8, 2024 1

and yet there is a problem with this code, the unsplashPhotoPicker function does not work completely, respectively, it is not possible to select an image and nil always returns

Update:
Returning to this problem, I found a small error, now everything works, all the information about the photo is also returned. I updated the code above, suddenly it will be needed!

from unsplash-photopicker-ios.

ocollet avatar ocollet commented on June 8, 2024

@lisindima I have yet to dive into SwiftUI, so I'm not sure I understand the issue.

  1. Do you mean that you'd like the component to be built with SwiftUI?
  2. Do you mean the component cannot be used in a SwiftUI project?
  3. What would be required to add support?

from unsplash-photopicker-ios.

lisindima avatar lisindima commented on June 8, 2024

Thanks for the answer, I would like to see instructions on how to run this component in swiftui, I'm not sure if this can be done using UIViewControllerRepresentable

from unsplash-photopicker-ios.

ocollet avatar ocollet commented on June 8, 2024

Makes sense, I will see if I can test it this week.

from unsplash-photopicker-ios.

ocollet avatar ocollet commented on June 8, 2024

Great! Thank you for taking a shot at it! 👏

from unsplash-photopicker-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.