This commit is contained in:
@@ -2,6 +2,23 @@
|
||||
///
|
||||
/// This allows you to group content together, which can optionally be
|
||||
/// styled.
|
||||
///
|
||||
/// ### Example:
|
||||
///
|
||||
/// ```swift
|
||||
/// let group = Group {
|
||||
/// "My headline."
|
||||
/// "\n"
|
||||
/// "Some content".color(.green)
|
||||
/// "\n"
|
||||
/// "Foo Bar".italic()
|
||||
/// }
|
||||
///
|
||||
/// print(group.render())
|
||||
/// ```
|
||||
///
|
||||
/// 
|
||||
///
|
||||
public struct Group<Content: TextNode>: TextNode {
|
||||
|
||||
@usableFromInline
|
||||
|
||||
@@ -59,7 +59,7 @@ public extension HStack {
|
||||
/// Style a ``HStack`` by creating a type that conforms to ``HStackStyle`` and use the
|
||||
/// style by calling the ``HStack/style(_:)`` method on your instance.
|
||||
///
|
||||
public protocol HStackStyle: TextModifier where Content == StackConfiguration {}
|
||||
public protocol HStackStyle: TextModifier where Content == _StackConfiguration {}
|
||||
|
||||
public extension HStackStyle where Self == HStackSeparatorStyle {
|
||||
/// Apply the given separator on a ``HStack``.
|
||||
@@ -88,7 +88,7 @@ public struct HStackSeparatorStyle: HStackStyle {
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func render(content: StackConfiguration) -> some TextNode {
|
||||
public func render(content: _StackConfiguration) -> some TextNode {
|
||||
AnySeparatableStackNode(content: content, separator: separator)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
// swiftlint:disable type_name
|
||||
/// Represents the content of an ``HStack`` or a ``VStack``.
|
||||
///
|
||||
///
|
||||
public struct StackConfiguration {
|
||||
/// This is an internal convenience type, but needs to remain public
|
||||
/// for protcol conformances to work properly.
|
||||
public struct _StackConfiguration {
|
||||
public let content: [any TextNode]
|
||||
}
|
||||
|
||||
// swiftlint:enable type_name
|
||||
|
||||
/// A helper type that removes empty text nodes, and applies a separtor between
|
||||
/// the array of text nodes.
|
||||
///
|
||||
@@ -18,7 +22,7 @@ struct AnySeparatableStackNode<Separator: TextNode>: TextNode {
|
||||
let separator: Separator
|
||||
|
||||
@usableFromInline
|
||||
init(content: StackConfiguration, separator: Separator) {
|
||||
init(content: _StackConfiguration, separator: Separator) {
|
||||
self.content = content.content
|
||||
self.separator = separator
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public extension VStack {
|
||||
/// Style a ``VStack`` by creating a type that conforms to ``VStackStyle`` and use the
|
||||
/// style by calling the ``VStack/style(_:)`` method on your instance.
|
||||
///
|
||||
public protocol VStackStyle: TextModifier where Content == StackConfiguration {}
|
||||
public protocol VStackStyle: TextModifier where Content == _StackConfiguration {}
|
||||
|
||||
public extension VStackStyle where Self == VStackSeparatorStyle {
|
||||
|
||||
@@ -92,7 +92,7 @@ public struct VStackSeparatorStyle: VStackStyle {
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func render(content: StackConfiguration) -> some TextNode {
|
||||
public func render(content: _StackConfiguration) -> some TextNode {
|
||||
AnySeparatableStackNode(content: content, separator: separator)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user