Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/horitaku46/serrata
Slide image viewer library similar to Twitter and LINE.
https://github.com/horitaku46/serrata
carthage cocoapods image-viewer images ios swift-library swift4
Last synced: about 1 month ago
JSON representation
Slide image viewer library similar to Twitter and LINE.
- Host: GitHub
- URL: https://github.com/horitaku46/serrata
- Owner: horitaku46
- License: mit
- Created: 2017-12-14T06:01:57.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-27T05:10:29.000Z (about 6 years ago)
- Last Synced: 2024-04-24T19:04:57.259Z (7 months ago)
- Topics: carthage, cocoapods, image-viewer, images, ios, swift-library, swift4
- Language: Swift
- Homepage:
- Size: 90 MB
- Stars: 324
- Watchers: 7
- Forks: 28
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Platform](http://img.shields.io/badge/platform-iOS-blue.svg?style=flat)](https://developer.apple.com/iphone/index.action)
![Swift](https://img.shields.io/badge/Swift-4.0-orange.svg)
[![Cocoapods](https://img.shields.io/badge/Cocoapods-compatible-brightgreen.svg)](https://img.shields.io/badge/Cocoapods-compatible-brightgreen.svg)
[![Carthage compatible](https://img.shields.io/badge/Carthage-Compatible-brightgreen.svg?style=flat)](https://github.com/Carthage/Carthage)
[![License](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](http://mit-license.org)## 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](https://github.com/onevcat/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](https://github.com/onevcat/Kingfisher) is installed, too!### CocoaPods
```ruby
pod 'Serrata'
```### Carthage
```ruby
github "horitaku46/Serrata"
```## Usage
**See [Example](https://github.com/horitaku46/Serrata/tree/master/Example), for more details.**How to use in Example.
```swift
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()`.
```swift
/// 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`.
```swift
import UIKitpublic 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`.```swift
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
- [Facebook](https://www.facebook.com/profile.php?id=100008388074028)
- [Twitter](https://twitter.com/horitaku_)
- [GitHub](https://github.com/horitaku46)## Example images from
- [Unsplash](https://unsplash.com/)## License
`Serrata` is available under the MIT license. See the [LICENSE](./LICENSE) file for more info.