Git Product home page Git Product logo

serrata's Introduction

Platform Swift Cocoapods Carthage compatible License

Overview

You can use it simply by passing the necessary information!
Serrata is a UI library that allows you to intuitively view images.

Features

Kingfisher is a lightweight and pure Swift implemented library.
It is used in the Serrata. I sincerely respect Kingfisher!

  • Support iPhone, iPad and iPhone X! ๐ŸŽ‰
  • It is the almost same as Image Viewer of Twitter and LINE.๐Ÿ˜Ž

Requirements

  • Xcode 9.0+
  • iOS 11+
  • Swift 4.0+

Installation

Caution โš ๏ธ

Kingfisher is installed, too!

CocoaPods

pod 'Serrata'

Carthage

github "horitaku46/Serrata"

Usage

See Example, for more details.

How to use in Example.

guard let selectedCell = collectionView.cellForItem(at: indexPath) as? ImageCell else {
    return
}

let slideLeafs: [SlideLeaf] = images.enumerated().map { SlideLeaf(image: $0.1,
                                                                  title: "Image Title \($0.0)",
                                                                  caption: "Index is \($0.0)") }

let slideImageViewController = SlideLeafViewController.make(leafs: slideLeafs,
                                                            startIndex: indexPath.row,
                                                            fromImageView: selectedCell.imageView)

slideImageViewController.delegate = self // Please watch the following SlideLeafViewControllerDelegate.
present(slideImageViewController, animated: true, completion: nil)

Details of SlideLeafViewController.make().

/// This method generates SlideLeafViewController.
///
/// - Parameters:
///   - leafs: It is array to display it by a slide.
///   - startIndex: It is for initial indication based on array of leafs.
///   - fromImageView: ImageView of the origin of transition. In the case of nil, CrossDissolve.
/// - Returns: Instance of SlideLeafViewController.
open class func make(leafs: [SlideLeaf], startIndex: Int = 0, fromImageView: UIImageView? = nil) -> SlideLeafViewController {
    // code...
}

Details of SlideLeaf.

import UIKit

public final class SlideLeaf: NSObject {

    public var image: UIImage?
    public var imageUrlString: String?

    public var title: String
    public var caption: String


    /// If either title and caption is empty, detailView is not displayed.
    ///
    /// - Parameters:
    ///   - image: To read by a slide.
    ///   - title: Title of the image.
    ///   - caption: Caption of the image.
    public init(image: UIImage?, title: String = "", caption: String = "") {
        self.image = image
        self.title = title
        self.caption = caption
    }

    /// If either title and caption is empty, detailView is not displayed.
    ///
    /// - Parameters:
    ///   - imageUrlString: To read by a slide. It is displayed by Kingfisher.
    ///   - title: Title of the image.
    ///   - caption: Caption of the image.
    public init(imageUrlString: String?, title: String = "", caption: String = "") {
        self.imageUrlString = imageUrlString
        self.title = title
        self.caption = caption
    }
}

delegate

Detail of SlideLeafViewControllerDelegate.

extension ViewController: SlideLeafViewControllerDelegate {

    func tapImageDetailView(slideLeaf: SlideLeaf, pageIndex: Int) {
        // code...
    }

    func longPressImageView(slideLeafViewController: SlideLeafViewController, slideLeaf: SlideLeaf, pageIndex: Int) {
        // code...
    }

    func slideLeafViewControllerDismissed(slideLeaf: SlideLeaf, pageIndex: Int) {
        // code...
    }
}

Author

Takuma Horiuchi

Example images from

License

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

serrata's People

Contributors

horitaku46 avatar

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.