diff --git a/Sources/Core/View/HStack.swift b/Sources/Core/View/HStack.swift new file mode 100644 index 0000000..458e2f1 --- /dev/null +++ b/Sources/Core/View/HStack.swift @@ -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)") + } + } + } + +}