Skip to content
/ Ubud Public

🏞 Carousel photo browser library for iOS.

License

Notifications You must be signed in to change notification settings

lufzi/Ubud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

fcf6874 Β· Feb 2, 2018

History

69 Commits
Feb 2, 2018
Dec 21, 2017
Dec 21, 2017
Dec 28, 2017
Oct 22, 2017
Dec 11, 2017
Oct 22, 2017
Oct 22, 2017
Dec 21, 2017
Dec 21, 2017
Dec 28, 2017
Nov 1, 2017
Feb 2, 2018
Dec 28, 2017

Repository files navigation

Ubud

BuddyBuild Build Status CocoaPods Compatible Carthage Compatible Swift Xcode MIT Contributions Welcome

Requirements

iOS 9 or later

Installation

To integrate Ubud using CocoaPods, add the following to your Podfile:

pod 'Ubud'

To integrate Ubud using Carthage, add the following to your Cartfile:

github 'lkmfz/Ubud'

Run carthage update to build the framework and drag the built Ubud.framework into your Xcode project.

Usage

To present the UbudController view, just put this one line code.

UbudController.show(presentedBy: self, dataSource: self, paginationDelegate: self, atIndex: indexPath.item)

UbudControllerDataSource

enum PhotoDataSource {
    case image(UIImage)
    case url(String)
}

To display images from list of URLString

// MARK: - UbudControllerDataSource

func numberOfOPhotos(in controller: UbudController) -> Int {
  return urls.count
}

func imageSourceForItem(in controller: UbudController, atIndex index: Int) -> PhotoDataSource {
  let imageURL = urls[index].url.absoluteString
  return .url(imageURL)
}

To display images from list of UIImage

// MARK: - UbudControllerDataSource

func numberOfOPhotos(in controller: UbudController) -> Int {
    return images.count
}

func imageSourceForItem(in controller: UbudController, atIndex index: Int) -> PhotoDataSource {
    let image = images[index]
    return .image(image)
}

UbudControllerDelegate

Customize the UbudController style

// MARK: - UbudControllerDelegate

func statusBarHidden(in controller: UbudController) -> Bool {
    return false
}

func statusBarStyle(in controller: UbudController) -> UIStatusBarStyle {
    return .lightContent
}

func dismissButtonContent(in controller: UbudController) -> DismissButtonContent {
    return .text("Dismiss")
}

UbudControllerPaginationDelegate

enum ImagesPaginationStyle {
    case textIndicator
    case dotIndicator
}

Customize the pagination indicator style

// MARK: - UbudControllerPaginationDelegate

func imagesPaginationStyle(in controller: UbudController) -> ImagesPaginationStyle? {
    return .dotIndicator
}

func imagesPaginationDidChange(in controller: UbudController, atIndex index: Int) {
    /// Do anything on tapped image page content
}

License

Ubud is released under the MIT License.

About

🏞 Carousel photo browser library for iOS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published