Fork me on GitHub

Alex Rupérez

Link: http://j.mp/2GSEiM8
Published: 28 Feb 15:23
I starred GeekTree0101/ASStoryBook at GitHub.
Interactive UI component dev & test built on Texture
View on GitHub


View README


CI Status Version License Platform

Example

1. Create Stroybook

import Foundation
import ASStoryBook

// 1. Inherit ASStoryBookProtocol
struct SampleStorybook: ASStoryBookProtocol {
    static var generate: ASStoryBookGroupCategory = {
        // 2. create mock UI
        let cCellNode1 = CCellNode.init(desc: "Has Description")
        let cCellNode2 = CCellNode.init(desc: nil)
        
        let cCellNodeCategory =
            ASStoryBookSubCategory("CCellNode",
                                   story: .list(["has desc case": cCellNode1,
                                                 "empty desc case": cCellNode2]))
        
        
        let dCellNode1 = DCellNode.init(.large)
        let dCellNode2 = DCellNode.init(.small)
        
        // 3. create sub category
        let dCellNodeCategory =
            ASStoryBookSubCategory("DCellNode",
                                   story: .list(["large case": dCellNode1,
                                                 "small case": dCellNode2]))
        
        // 4. create group category
        return ASStoryBookGroupCategory("Sample Controller",
                                        categories: [cCellNodeCategory,
                                                     dCellNodeCategory])
    }()
}

2. Create Storybook AppDelegate

import UIKit
import ASStoryBook

@UIApplicationMain
class SampleStorybookAppDelegate: UIResponder, UIApplicationDelegate {
    
    var window: UIWindow?
    
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        
        // MARK: - Setup attribute
        ASStorybookManager.manager.setupAppname("Sample") // Optional
        // ASStorybookManager.manager.setupEnableHitTestDebug() // Optionnal
        
        // MARK: - Setup Categories
        ASStorybookManager.manager.setupCategories([ExampleStorybook.generate,
                                                    SampleStorybook.generate,
                                                    ProfileStoryBook.generate])
        
        // MARK: - Run
        window = ASStorybookManager.manager.didFinishLaunching()
        
        return true
    }
}

Requirements

here -> https://github.com/GeekTree0101/ASStoryBook/blob/master/ASStoryBook.podspec

Installation

use_frameworks!

target 'YOUR_PROJECT_TARGET_NAME' do
    ...
end

target 'YOUR_STORY_BOOK_TARGET_NAME' do
    pod 'ASStoryBook', :git => 'https://github.com/GeekTree0101/ASStoryBook.git', :branch => 'master'
end

Author

Geektree0101, h2s1880@gmail.com

License

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