Add HStack
All checks were successful
Deploy Docs / publish (push) Successful in 2m51s
SwiftLint / SwiftLint (push) Successful in 5s

This commit is contained in:
david-swift 2024-12-05 21:28:38 +01:00
parent e51dc2b5c5
commit 71cd433a8f

View File

@ -0,0 +1,40 @@
//
// HStack.swift
// MacBackend
//
// Created by david-swift on 05.12.2024.
//
import SwiftUI
/// A `HStack` view.
public struct HStack: SwiftUIWidget {
/// The content view.
var content: Body
/// The wrapped views.
public var wrappedViews: [String: Meta.AnyView] {
content.enumerated().reduce(into: [:]) { partialResult, element in
partialResult["\(element.offset)"] = element.element
}
}
/// Initialize the ``HStack``.
/// - Parameter content: The content.
public init(@Meta.ViewBuilder content: @escaping () -> Body) {
self.content = content()
}
/// Get the SwiftUI view.
/// - Parameter properties: The widget data.
/// - Returns: The SwiftUI view.
public static func view(properties: Self) -> some SwiftUI.View {
SwiftUI.HStack {
ForEach(properties.content.indices, id: \.self) { index in
MacBackendView("\(index)")
}
}
}
}