Skip to content

Instantly share code, notes, and snippets.

View wendyliga's full-sized avatar
👨‍💻
Code in Progress

Wendy Liga wendyliga

👨‍💻
Code in Progress
View GitHub Profile
@wendyliga
wendyliga / texture-tutorial.swift
Created September 24, 2019 09:29
Texture LayoutSpec
node.layoutSpecBlock = {_,_ in
return ASWrapperLayoutSpec(layoutElement: self.titleNode)
}
@wendyliga
wendyliga / texture-tutorial.swift
Created September 24, 2019 09:29
Texture ASStackLayoutSpec Simple Example
let mainStack = ASStackLayoutSpec(direction: .horizontal,
spacing: 6.0,
justifyContent: .start,
alignItems: .center,
children: [titleNode, subtitleNode])
return mainStack
@wendyliga
wendyliga / texture-tutorial.swift
Created September 24, 2019 09:30
Texture ASInsetLayoutSpec Simple Example
let mainStack = ASStackLayoutSpec(direction: .horizontal,
spacing: 6, justifyContent: .start,
alignItems: .center,
children: [self.titleNode, self.subtitleNode])
let padding = ASInsetLayoutSpec(insets: UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15), child: mainStack)
return padding
@wendyliga
wendyliga / texture-tutorial.swift
Created September 24, 2019 09:32
Texture ASOverlaySpecLayout Simple Example
let overlayNode = ASDisplayNode()
overlayNode.backgroundColor = UIColor.black.withAlphaComponent(0.3)
let overlay = ASOverlayLayoutSpec(child: mainStack, overlay: self.overlayNode)
return overlay
@wendyliga
wendyliga / texture-tutorial.swift
Created September 24, 2019 09:33
Texture ASBackgroundLayoutSpec Simple Tutorial
let backgroundNode = ASDisplayNodeWithBackgroundColor(UIColor.red)
let foregroundNode = ASDisplayNodeWithBackgroundColor(UIColor.blue)
return ASBackgroundLayoutSpec(child: foregroundNode, background: backgroundNode)
@wendyliga
wendyliga / texture-tutorial.swift
Created September 24, 2019 09:37
Texture ASCenterLayoutSpec Simple Example
let center = ASCenterLayoutSpec(centeringOptions: .XY,
sizingOptions: .minimumXY,
child: mainStack)
return center
@wendyliga
wendyliga / texture-tutorial.swift
Created September 24, 2019 09:37
Texture ASRatioLayoutSpec Simple Example
let subnode = ASDisplayNodeWithBackgroundColor(UIColor.green, CGSize(width: 100, height: 100.0))
let ratioSpec = ASRatioLayoutSpec(ratio: 0.5, child: subnode)
return ratioSpec
@wendyliga
wendyliga / texture-tutorial.swift
Created September 24, 2019 09:38
Texture ASRelativeLayoutSpec Example
let relativeSpec = ASRelativeLayoutSpec(horizontalPosition: .start,
verticalPosition: .start,
sizingOption: [],
child: foregroundNode)
@wendyliga
wendyliga / texture-tutorial.swift
Created September 24, 2019 09:39
Texture ASAbsoluteLayoutSpec Example
node.style.layoutPosition = CGPoint(x: 0.0, y: maxConstrainedSize.height / 3.0)
node.style.preferredSize = CGSize(width: maxConstrainedSize.width / 2.0, height: maxConstrainedSize.height / 3.0)
return ASAbsoluteLayoutSpec(children: [node])
@wendyliga
wendyliga / texture-tutorial.swift
Last active September 24, 2019 09:39
Texture ASViewController Example
class ViewController: ASViewController<ASDisplayNode> {
init() {
super.init(node: ASDisplayNode())
self.node.backgroundColor = .white
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")