GithubHelp home page GithubHelp logo

carabina / bdshelfstackviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from norsez/bdshelfstackviewcontroller

0.0 1.0 0.0 2.03 MB

Tables within tables – the easy way. Veritcally scrollables mixed with horizontally scrollables on one page. Built for quick prototyping or releasing apps that needs product or content browsing, e.g. shopping or showcase apps.

License: MIT License

Ruby 5.72% Swift 94.28%

bdshelfstackviewcontroller's Introduction

BDShelfStackViewController

CI Status Version License Platform

What is it for?

Tables within tables – the easy way. Veritcally scrollables mixed with horizontally scrollables on one page. Built for quick prototyping or releasing apps that needs product or content browsing, e.g. shopping or showcase apps.

Demo app

Screen Capture

How to use

BDShelfStackViewController only works programmatically with this release. (No Interface Builder Support). Here's how it works.

BDShelfStackViewController is built based on BDSSVData defining each row - vertically or horizontally scrollable. BDSSVData is based on BDSSVRows which are delegates for each row's displayed items.

import BDShelfStackViewController //import the library

class YourViewController: UIViewController {//A good place to create BDShelfStackViewController is in viewDidLoad
    override func viewDidLoad() {
        //The typical way to use BDShelfStackViewController
        //1. create a BDSSVData made of [BDSSVRow]
        //2. create BDShelfStackViewController with that BDSSVData
        //3. add the BDShelfStackViewController as a child ViewController to your main ViewController. Boom!
        let rows: [BDSSVRow] = [
            self.createDemoRow1(),
            self.createDemoRow2()
            ]
        //create data from the rows
        let data = BDSSVData(withRows: rows)
        //create shelf stack from the data above
        self.demoCtrl = BDShelfStackViewController(withData: data)

        self.view.addSubview(self.demoCtrl)
        self.demoCtrol.view.frame = self.view.bounds
        //add the BDSSVShelfStackViewController as the main view's child viewcontroller
        self.addChildViewController(self.demoCtrl!)
    }
    
    //an example method to create a row
    private func createDemoRow1() {
        //BDSSVRow can be either horizontally or vertically scrollable

        var r = BDSSVRow(withType: .horizontal, 
                    itemCount: 30, 
                    rowHeight: 100)
        //define the size of each item 
        r.itemSize = CGSize(width: 120, height: 100)
        
        //define a block to return a UIView representing each item
        r.viewAtIndex = {
            index in
            let v = CellA(frame: CGRect(x: 0, y: 0, width: 120, height: 100))
            let item = DemoEngine.shared.nextItem
            v.imageView.image = item?.thumbnail
            v.titleLabel.attributedText = "\(item?.name ?? "")".attrText(with: 12)
            v.subtitleLabel.text = item?.artist ?? ""
            return v
        }
        
        //define the action when tapping each item
        r.didTapItem = { index in  }
        
        //there are a few more block variables used to customize each item's behavior and appearance in BDSSVRow
        return r
    }
    //That's it! Check out the sample project for a more detailed sample implementation
    

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

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

pod 'BDShelfStackViewController'

Author

norsez, [email protected]

License

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

bdshelfstackviewcontroller's People

Contributors

norsez avatar

Watchers

 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.