Swiftpack.co - jasudev/UnsplashProvider as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by jasudev.
jasudev/UnsplashProvider 0.5.0
It is a package that can use the Unsplash API. It was developed as a SwiftUI.
⭐️ 22
🕓 2 years ago
iOS macOS
.package(url: "https://github.com/jasudev/UnsplashProvider.git", from: "0.5.0")

UnsplashProvider for SwiftUI

It is a package that can use the Unsplash API. It was developed as a SwiftUI.

Platforms iOS macOS instagram SPM MIT

Screenshot

https://user-images.githubusercontent.com/1617304/153021842-cb46588f-69be-4df6-a290-e6d92349bb47.mp4

Usage

import UnsplashProvider
// You must enter the application access key.
UPConfiguration.shared.accessKey = "" // <YOUR_ACCESS_KEY>
  • How to use the built-in ObservableObject object

    @StateObject var photo = UPPhotoStore()
    @StateObject var photos = UPPhotosStore()
    @StateObject var randomPhotos = UPRandomPhotosStore()
    @StateObject var searchPhotos = UPSearchPhotosStore()
    @StateObject var searchUsers = UPSearchUsersStore()
    
    ...
    
    List(photos.photos) { photo in
        ...
    }
    List(randomPhotos.photos) { photo in
        ...
    }
    List(searchPhotos.photos) { photo in
        ...
    }
    List(searchUsers.users) { user in
        ...
    }
    
    ...
    
    // func fetchPhoto(id: String)
    photo.fetchPhoto(id: "F3OvjNcF5Xg") 
    
    // func fetchPhotos(page: Int = 1, perPage: Int = 30, orderBy: UPSort = .latest)
    photos.fetchPhotos(orderBy: .popular) 
    
    // func fetchPhotos(collections: String? = nil, topics: String? = nil, username: String? = nil, query: String? = nil, orientation: UPOrientation? = nil, contentFilter: UPContentFilter? = nil, count: Int = 1)
    randomPhotos.fetchPhotos(query: "cat", count: 30) 
    
    // func fetchSearchPhotos(query: String, page: Int = 1, perPage: Int = 30, orderBy: UPSort = .relevant, collections: String? = nil, contentFilter: UPContentFilter? = nil, color: UPColor? = nil, orientation: UPOrientation? = nil)
    searchPhotos.fetchSearchPhotos(query: "colorful", orientation: .squarish) 
    
    // func fetchSearchUsers(query: String, page: Int = 1, perPage: Int = 30)
    searchUsers.fetchSearchUsers(query: "lo") 
    
    
  • How to use Router directly.

    let router = UPAPIRouter.randomPhotos(query: "colorful", orientation: .landscape)
    UnsplashProvider().loadPhotos(router: router) { photos, error in
        guard error == nil else { return }
        if let photos = photos, !photos.isEmpty {
            let photo = photos[0]
            self.currentPhoto = photo
        }
    }
    

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Once you have your Swift package set up, adding UnsplashProvider as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/jasudev/UnsplashProvider.git", .branch("main"))
]

Contact

instagram : @dev.fabula
email : [email protected]

License

UnsplashProvider is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 22
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Release Notes

0.5.0
2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics