Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Texture Overview (社内向け)

aboy
June 26, 2018

Texture Overview (社内向け)

Textureの概要をざっくりと。

aboy

June 26, 2018
Tweet

More Decks by aboy

Other Decks in Technology

Transcript

  1. ASTableNode replaces UITableView's required method. Texture does not use cell

    reuse does not calculate height of cell automatically or LayoutSpec in Cell node blocks be thread-safe func tableNode(_ tableNode: ASTableNode, nodeBlockForRowAt indexPath: IndexPath) let cellNodeBlock = { () -> ASCellNode in return SampleCellNode(item: item) } return cellNodeBlock }
  2. Layout: sample code override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec

    let stackSpec = ASStackLayoutSpec( direction: .horizontal, spacing: 11.0, justifyContent: .start, alignItems: .center, children: [self.imageNode, self.titleNode] ) let insetSpec = ASInsetLayoutSpec( insets: UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8), child: stackSpec ) print(insetSpec.asciiArtString()) return insetSpec }
  3. Layout Debugging ASLayoutSpec has asciiArtString() property. ------------------------------------------ASInsetLayoutSpec--------------------------- | ---------------------------------------ASStackLayoutSpec--------------------------- |

    | --------------------------ASStackLayoutSpec----------------- | | | ASTextNode | | | ASLayoutSpec | | ASNetworkImageNode | -----------------------ASStackLayoutSpec----------------- | | | | ASNetworkImageNode ASLayoutSpec ASImageNode ASTextN | | | --------------------------------------------------------- | | ------------------------------------------------------------ | ----------------------------------------------------------------------------------- --------------------------------------------------------------------------------------
  4. In nitely scrolling class ViewController: ASViewController<ASTableNode> { fileprivate func loadPageWithContext(context:

    ASBatchContext) { // insert logic self.tableNode.reloadData() context.completeBatchFetching(true) } } extension ViewController: ASTableDataSource, ASTableDelegate { func tableNode(_ tableNode: ASTableNode, willBeginBatchFetchWith context: ASBatchC context.beginBatchFetching() loadPageWithContext(context: context) } }
  5. In nitely scrolling (with RxSwift) class ViewController: ASViewController<ASTableNode> { fileprivate

    func loadPageWithContext(context: ASBatchContext) { fetch().subscribe(onNext: { (elements) in self.addRowsIntoTableNode(newElementsCount: elements.count) context.completeBatchFetching(true) }).disposed(by: disposeBag) } func addRowsIntoTableNode(newElementsCount newElements: Int) { let indexRange = (elements.count - newElements..<elements.count) let indexPaths = indexRange.map { IndexPath(row: $0, section: 0) } node.insertRows(at: indexPaths, with: .none) } } extension ViewController: ASTableDataSource, ASTableDelegate { func tableNode(_ tableNode: ASTableNode, willBeginBatchFetchWith context: ASBatchC