in ComponentKit/LayoutComponents/CKZStackComponent.h [71:132]
class __attribute__((__may_alias__)) ZStackComponentBuilder
: public BuilderBase<ZStackComponentBuilder, PropsBitmap> {
public:
ZStackComponentBuilder() = default;
ZStackComponentBuilder(const CK::ComponentSpecContext &context) : BuilderBase<ZStackComponentBuilder, PropsBitmap>{context} { }
~ZStackComponentBuilder() = default;
/**
Adds a child component with default gravity to this stack.
@param c component to add.
@note Nil components are ignored and are not added to the stack.
*/
auto &child(NS_RELEASES_ARGUMENT CKComponent *_Nullable c)
{
if (c != nil) {
auto const stackChild = [[CKZStackComponentChild alloc] initWithComponent:c];
[_children addObject:stackChild];
}
return reinterpret_cast<
ZStackComponentBuilder<PropsBitmap | ZStackComponentPropId::children> &>(*this);
}
/**
Adds a child component with the specified gravity to this stack.
@param c component to add.
@param g gravity that will be used to position the component.
@note Nil components are ignored and are not added to the stack.
*/
auto &child(NS_RELEASES_ARGUMENT CKComponent *_Nullable c, CKZStackComponentGravity g)
{
if (c != nil) {
auto const stackChild = [[CKZStackComponentChild alloc] initWithComponent:c gravity:g];
[_children addObject:stackChild];
}
return reinterpret_cast<
ZStackComponentBuilder<PropsBitmap | ZStackComponentPropId::children> &>(*this);
}
private:
friend BuilderBase<ZStackComponentBuilder, PropsBitmap>;
/**
Creates a new component instance with specified properties.
@note This method must @b not be called more than once on a given component builder instance.
*/
NS_RETURNS_RETAINED auto _build() noexcept -> CKZStackComponent *_Nonnull
{
constexpr auto hasChildren = PropBitmap::isSet(PropsBitmap, ZStackComponentPropId::children);
static_assert(hasChildren, "At least one child must be added to the stack using .child().");
return [[CKZStackComponent alloc] initWithChildren:_children];
}
private:
NSMutableArray<CKZStackComponentChild *> *_Nonnull _children = [NSMutableArray array];
};