Skip to content

Latest commit

 

History

History
131 lines (106 loc) · 3.7 KB

README.md

File metadata and controls

131 lines (106 loc) · 3.7 KB

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.