• Stars
    star
    212
  • Rank 185,021 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 7 years ago
  • Updated 5 months ago

Reviews

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

Repository Details

water-fall layout in iOS

WaterfallLayout

Waterfall layout in iOS

GitHub release Language Carthage Compatible CocoaPods CocoaPodsDL

Features

  • Can select flow/waterfall layout per section.
  • Self-Sizing cell available

How to use

class ViewController: UIViewController {

    @IBOutlet private weak var collectionView: UICollectionView! {
        didSet {
            let layout = WaterfallLayout()
            layout.delegate = self
            layout.sectionInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
            layout.minimumLineSpacing = 8.0
            layout.minimumInteritemSpacing = 8.0
            layout.headerHeight = 50.0
            collectionView.collectionViewLayout = layout
            collectionView.register(...)
            collectionView.dataSource = self
            collectionView.delegate = self
        }
    }
}

extension ViewController: UICollectionDataSource {
    ...
}

extension ViewController: WaterfallLayoutDelegate {
    func collectionViewLayout(for section: Int) -> WaterfallLayout.Layout {
        switch section {
        case 0: return .flow(column: 1) // single column flow layout
        case 1: return .waterfall(column: 3) // three waterfall layout
        default: return .flow(column: 2)
        }
    }

    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(...)
    }    
}

Properties

public var minimumLineSpacing: CGFloat { get set }

public var minimumInteritemSpacing: CGFloat { get set }

public var sectionInset: UIEdgeInsets  { get set }

public var headerHeight: CGFloat  { get set }

public var headerInset: UIEdgeInsets { get set }

public var footerHeight: CGFloat { get set }

public var footerInset: UIEdgeInsets { get set }

public var estimatedItemSize: CGSize { get set }

Layout delegte

public protocol WaterfallLayoutDelegate: class {
    // MARK: - Required
    func collectionViewLayout(for section: Int) -> WaterfallLayout.Layout
    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sizeForItemAt indexPath: IndexPath) -> CGSize

    // MARK: - Optional
    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, minimumInteritemSpacingFor section: Int) -> CGFloat?
    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, minimumLineSpacingFor section: Int) -> CGFloat?
    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sectionInsetFor section: Int) -> UIEdgeInsets?
    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, headerHeightFor section: Int) -> CGFloat?
    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, headerInsetFor section: Int) -> UIEdgeInsets?
    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, footerHeightFor section: Int) -> CGFloat?
    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, footerInsetFor section: Int) -> UIEdgeInsets?
    func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, estimatedSizeForItemAt indexPath: IndexPath) -> CGSize?
}

Requirements

  • iOS 9.0+
  • Xcode 9+
  • Swift 4+

Installation

Carthage

  • Add the following to your Cartfile:
github "sgr-ksmt/WaterfallLayout" ~> 0.1
  • Run carthage update
  • Add the framework as described.
    Details: Carthage Readme

CocoaPods

WaterfallLayout is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'WaterfallLayout', '~> 0.1'

and run pod install

Manually Install

Download all *.swift files and put your project.

Change log

Change log is here.

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.💪

License

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

More Repositories

1

PDFGenerator

A simple generator of PDF written in Swift.
Swift
754
star
2

PullToDismiss

You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.
Swift
485
star
3

FireTodo

Simple Todo Application using SwiftUI / Firebase / Redux.
Swift
369
star
4

Alertift

Swifty, modern UIAlertController wrapper.
Swift
283
star
5

FormToolbar

Simple, movable and powerful toolbar for UITextField and UITextView.
Swift
86
star
6

Lobster

🦐 Type-safe Firebase-RemoteConfig helper library 🦐
Swift
77
star
7

firebase-ec-demo

E-commerce data model, security rules example using Cloud Firestore.
58
star
8

FireSnapshot

A useful Firebase-Cloud-Firestore Wrapper with Codable.
Swift
56
star
9

Shopping-Cart

Swift
45
star
10

SwiftUI-Firebase-Todo

Swift
35
star
11

BeautifulGridLayout

UICollectionView extension for showing beautiful grid!
Swift
32
star
12

SNSShare

Text/Image/URL share to Twitter/Facebook/LINE from App in Swift.
Swift
25
star
13

Once

Execute closure just once!!! Once is a micro framework.
Objective-C
19
star
14

FirstAppearing

[Swift] Helper Protocol-Extension for UIViewController's viewWillAppear/viewDidAppear.
Swift
17
star
15

Curriculum-Vitae

16
star
16

SwiftUI-Todo

Todo application example using SwiftUI
Swift
16
star
17

flutter-github-repo-explorer

This is an example application with Flutter using river_pod, state_notifier, and freezed.
Dart
16
star
18

firestore-like-feature-example

An example of like feature such as Twitter, Instagram with Cloud Firestore
TypeScript
15
star
19

TwitterLikeHeaderExample

Swift
15
star
20

Shrimp

Shrimp is Firebase-RemoteConfig helper library.
Swift
14
star
21

BlendingCulturesExample

Example for "Blending Cultures" of try! Swift's Presentation
Swift
12
star
22

cloud-functions-practical-configuration

TypeScript
11
star
23

RxFirebaseAuth

Combination of RxSwift and Firebase Authentication
Swift
11
star
24

DTFont

DynamicTypeFont helper. Easy creation, custom font etc.
Swift
10
star
25

firebase-recommended-template

The recommended template for developing with Firebase
HTML
9
star
26

Quiche

Type-safe Firestore query helper for Swift.
Swift
7
star
27

firestore-emulator-rules-test

Test Firestore rules using jest and firestore-emulator
TypeScript
6
star
28

RxPlayground

Xcode Playground with RxSwift
Swift
6
star
29

APIKitWithDecodableSample

APIKit x Swift.Decodable sample
Swift
5
star
30

Border

Border is CloudFunction libarry that connect Firebase and Stripe.
JavaScript
5
star
31

ApplicationEventObserver

Application notification event handling in Swift
Swift
5
star
32

i18nSwift

i18n for Swift
Swift
4
star
33

firebase-storage-rule-test-example

An Example of writing the test of storage.rules
TypeScript
4
star
34

firestore-rules-test-example

TypeScript
4
star
35

dotfiles

Shell
3
star
36

ElastiQ

Generate ElasticSearch query in Swift
Swift
3
star
37

SourceryDemo

Demo using Sourcery for auto-generating boiler-plate of `LogEvent`.
Swift
3
star
38

FDLBuilder

Firebase Dynamic Links builder
Swift
3
star
39

FormChangeable

Easy to move from UITextField/UITextView to next UITextField/UITextView written in Swift.
Swift
2
star
40

CloudFirestoreTestExample

Example for Cloud Firestore online test with jest.
TypeScript
2
star
41

EnhancedAutoReleasePool

EnhancedAutoReleasePool is μ-Library for autoreleasepool.
Swift
2
star
42

Pick

Protocol-Oriented PickerViewController
Swift
2
star
43

SUCheckButton

light-weight check button in Swift.
Swift
1
star
44

EnvToSwift

Config file generator from `.env`
Shell
1
star
45

FirebaseABTestingExample

Firebase A/B Testing Example
Swift
1
star
46

flutter_test_report_on_github_action_example

Dart
1
star
47

plain-emulator-sandbox

TypeScript
1
star
48

CloudFunctionsAPI

Provides secure request between client and Cloud Functions
Swift
1
star
49

my-styleguide

My coding styleguide
1
star
50

AutoIncrement_id_Realm_Example

Example of auto increment `id` in Realm
Ruby
1
star