47 lines
1.2 KiB
Swift
47 lines
1.2 KiB
Swift
//
|
|
// ToolbarView.swift
|
|
// MacBackend
|
|
//
|
|
// Created by david-swift on 08.12.2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// The padding view.
|
|
public struct ToolbarView: SwiftUIWidget {
|
|
|
|
/// The wrapped view.
|
|
var child: Meta.AnyView
|
|
/// The toolbar views.
|
|
var toolbarViews: Body
|
|
|
|
/// The wrapped views.
|
|
public var wrappedViews: [String: Meta.AnyView] {
|
|
[.mainContent: child].merging(toolbarViews.enumerated().reduce(into: [:]) { partialResult, view in
|
|
partialResult["\(view.offset)"] = view.element
|
|
}) { $1 }
|
|
}
|
|
|
|
/// Initialize the padding view.
|
|
/// - Parameters:
|
|
/// - child: The wrapped view.
|
|
/// - toolbarViews: The views in the toolbar.
|
|
public init(child: Meta.AnyView, @Meta.ViewBuilder toolbarViews: () -> Body) {
|
|
self.child = child
|
|
self.toolbarViews = toolbarViews()
|
|
}
|
|
|
|
/// Get the SwiftUI view.
|
|
/// - Parameter properties: The widget data.
|
|
/// - Returns: The SwiftUI view.
|
|
public static func view(properties: Self) -> some SwiftUI.View {
|
|
MacBackendView(.mainContent)
|
|
.toolbar {
|
|
ForEach(properties.toolbarViews.indices, id: \.self) { index in
|
|
MacBackendView("\(index)")
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|