TextureSwiftSupport is a support library for Texture
It helps writing the code in Texture with Swift's power.
Swiift 5.1+
Swift5.1 has FunctionBuilder(it's not officially)
With this, we can write layout spec with no more commas. (It's like SwiftUI)
Inspiring from SwiftUI.
We can build a node hierarchy with the method chain.
For now, we have only a few methods. (e.g Padding, Overlay, Background)
textNode
.padding([.vertical], padding: 4)
.background(backgroundNode)
Function builders
is a feature in Swift Language.
For example, SwiftUI uses it.
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
ASStackLayoutSpec(
direction: .vertical,
spacing: 0,
justifyContent: .start,
alignItems: .start,
children: [
textNode1,
textNode2,
textNode3,
]
)
}
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
LayoutSpec {
VStackLayout {
textNode1
textNode2
textNode3
}
}
}
More example
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
LayoutSpec {
VStackLayout {
HStackLayout {
InsetLayout {
node1
}
InsetLayout {
node2
}
}
node3
HStackLayout {
node4,
node5,
node6,
}
}
}
}
- VStackLayout
- HStackLayout
- ZStackLayout
- InsetLayout
- OverlayLayout
- BackgroundLayout
- AspectRatioLayout
- VSpacerLayout
- HSpacerLayout
Muukii [email protected]