This is a library to gain Texture(AsyncDisplayKit) more power in Swift.
And you might need to use TextureBridging
to integrate with AutoLayout world in your applications.
Swiift 5.3+
Using resultBuilders
, ASLayoutSpec
can be more simply and readable it's like SwiftUI's decralations.
πΊπ» You want to use this in AutoLayout?
Before
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
ASStackLayoutSpec(
direction: .vertical,
spacing: 0,
justifyContent: .start,
alignItems: .start,
children: [
self.textNode1,
self.textNode2,
self.textNode3,
]
)
}
After
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
LayoutSpec {
VStackLayout {
self.textNode1
self.textNode2
self.textNode3
}
}
}
Wrapping with LayoutSpec
enables us to write DSL inside this block.
More complicated example
LayoutSpec {
if flag {
VStackLayout {
HStackLayout(justifyContent: .center) {
iconNode
.padding(.top, 24)
.padding(.bottom, 16)
}
.background(gradientNode)
}
} else {
gradientNode
}
}
β οΈ Please take care of the differences between this DSL and SwiftUI.
This DSL just describes the node's layout. You should avoid to create a new node inside layout.
SincelayoutSpecThatFits
would be called multiple times.
Basic Layouts
Advanced Layouts
TextureSwiftSupport
provides us a lot of components that help to create a new component with compositioning from small components.
Technically, composing increases a number of view or layer in run-time. It might reduce the performance a bit.
But most of the cases, that won't be matters.
Muukii [email protected]
link |
Stars: 227 |
Last commit: 2 weeks ago |
Full Changelog: https://github.com/FluidGroup/TextureSwiftSupport/compare/3.20.0...3.20.1
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics