Add HStack
This commit is contained in:
parent
e51dc2b5c5
commit
71cd433a8f
40
Sources/Core/View/HStack.swift
Normal file
40
Sources/Core/View/HStack.swift
Normal 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)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user