• Stars
    star
    216
  • Rank 183,179 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The collectionView library which is scaling, scrolling and stopping comfortably like Snapchat and Instagram.

👻 SnapLikeCollectionView 👻

platform ios swift license tw

About

The collectionView library which is scaling, scrolling and stopping comfortably like Snapchat and Instagram.

Demo1

Comparison with Instagram and Snapchat.

👻 This 👻 Instagram Snapchat

Demo2

You can change cell height since ver. 1.1.0

Requirements

Swift 4.2. Ready for use on iOS 11.0+

Installation

via Cocoapods

pod 'SnapLikeCollectionView'

Usage

Cell

You should use SnapLikeCell protocol.

Item is associatedtype. You can apply any model you want.

This Item becomes dataSource's items.

public protocol SnapLikeCell: class {
    associatedtype Item
    var item: Item? { get set }
}

Below is example.

import UIKit
import SnapLikeCollectionView

class SampleCell: UICollectionViewCell, SnapLikeCell {
    @IBOutlet weak var titleLabel: UILabel!
    
    var item: String? {
        didSet {
            titleLabel.text = item
        }
    }
}

ViewController

import UIKit
import SnapLikeCollectionView

class ViewController: UIViewController {
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var collectionView: UICollectionView!
    
    // set your original Cell to <SampleCell>
    private var dataSource: SnapLikeDataSource<SampleCell>?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // setup size of cells
        let cellSize = SnapLikeCellSize(normalWidth: 100, centerWidth: 160)
        
        // create dataSource
        dataSource = SnapLikeDataSource<SampleCell>(collectionView: collectionView, cellSize: cellSize)
        dataSource?.delegate = self
        
        // create FlowLayout
        let layout = SnapLikeCollectionViewFlowLayout(cellSize: cellSize)
        collectionView.collectionViewLayout = layout
        
        // setup collectionView like this
        collectionView.registerNib(SampleCell.self)
        collectionView.showsHorizontalScrollIndicator = false
        collectionView.decelerationRate = .fast
        collectionView.delegate = dataSource
        collectionView.dataSource = dataSource
        
        // pass arrays which type is decided `Item` in the SampleCell.
        dataSource?.items = ["A", "B", "C", "D", "E"]
    }
}

// listen selected listener
extension ViewController: SnapLikeDataDelegate {
    func cellSelected(_ index: Int) {
        DispatchQueue.main.async { [weak self] in
            let selectedItem: String = self?.dataSource?.items[index] ?? ""
            self?.titleLabel.text = selectedItem
        }
    }
}

Check how to use from Demo 👍👍

Welcome to your PR

This library is not perfect, so welcome to your PR 🤲🤲🤲

Author 👻

KBOY (Kei Fujikawa)

iOS Developer in Tokyo Japan.

License

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

More Repositories

1

ARKit-Emperor

Power! Unlimited power for ARKit 2.0!
Swift
540
star
2

ARCore-Kotlin-Sampler

Sample code for ARCore written in Kotlin
Kotlin
46
star
3

screen_time_api_ios

A Flutter plugin for using iOS ScreenTime API
Dart
28
star
4

SnapKitSample-iOS

The unofficial demo app of the Snapchat's Snap Kit
Swift
26
star
5

stripe-payments-firebase

Sample code for stripe payments with firebase on iOS.
Swift
20
star
6

ARCore-Swift-Sampler

ARCore Cloud Anchors sample code in Swift.
Swift
19
star
7

ScreenTimeAPIDemo

ScreenTime API Demo App
Swift
15
star
8

BeerKit

The framework for MultipeerConnectivity inspired by PeerKit
Swift
12
star
9

coriander

Flutter大学の解説用サンプルコード
Dart
12
star
10

Kinniku.kt-iOS

The app for 筋肉.kt.
Swift
10
star
11

MLKitSample

Firebase MLKit Sample for Swift (iOS) & Android (Kotlin)
Swift
8
star
12

SnapKitSample-Android

The unofficial demo app of the Snapchat's Snap Kit
Kotlin
6
star
13

FirebaseCloudFunctions-for-NewsApp

Firebase Cloud Functions & App Engine code for the news app I developed by myself.
JavaScript
6
star
14

3DMath-For-ARKit

Sample code for studying 3D Programming using ARKit.
Swift
5
star
15

barberry_iOS

筋トレ記録アプリ「バーベリー」の公開verです。たまに更新します。
Makefile
4
star
16

Tinder-With-FacePlusPlus

Auto evaluation and swipe on tinder using Face++ API
Swift
4
star
17

Aiseki-Scraping

Scraping Aiseki-Rounge information on firebase cloud functions
TypeScript
3
star
18

AisekiBlueOcean

Flutter app aggregates 'Aiseki' rounge
Dart
2
star
19

Kinniku.kt-Android

The app for 筋肉.kt (Event).
Kotlin
1
star
20

JankenApp

Flutterの教科書の課題「じゃんけん」
Dart
1
star
21

ARCameraApp

ARCameraApp Sample
Swift
1
star
22

CloudFunctions-Push-Sample

Firebase Cloud Functions Push Notification Sample
TypeScript
1
star
23

ios-mentor.github.io

1
star
24

kboy-silvergym

1
star
25

flutter_web3_sample

HTML
1
star
26

GmailTraceFlutter

10分でトレースしたGmailアプリ。
C++
1
star