41 lines
988 B
Swift
41 lines
988 B
Swift
//
|
|
// 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)")
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|