40 lines
1.1 KiB
Swift
40 lines
1.1 KiB
Swift
//
|
|
// Widget.swift
|
|
// Meta
|
|
//
|
|
// Created by david-swift on 26.05.24.
|
|
//
|
|
|
|
/// A widget is a view that know about its native backend widget.
|
|
///
|
|
/// It enables the translation from the declarative definition to the creation
|
|
/// and updating of widgets in an imperative way.
|
|
public protocol Widget: AnyView {
|
|
|
|
/// The view storage.
|
|
/// - Parameters:
|
|
/// - modifiers: Modify views before being updated.
|
|
/// - type: The type of the widgets.
|
|
func container<WidgetType>(modifiers: [(AnyView) -> AnyView], type: WidgetType.Type) -> ViewStorage
|
|
/// Update the stored content.
|
|
/// - Parameters:
|
|
/// - storage: The storage to update.
|
|
/// - modifiers: Modify views before being updated
|
|
/// - updateProperties: Whether to update the view's properties.
|
|
/// - type: The type of the widgets.
|
|
func update<WidgetType>(
|
|
_ storage: ViewStorage,
|
|
modifiers: [(AnyView) -> AnyView],
|
|
updateProperties: Bool,
|
|
type: WidgetType.Type
|
|
)
|
|
|
|
}
|
|
|
|
extension Widget {
|
|
|
|
/// A widget's view is empty.
|
|
public var viewContent: Body { [] }
|
|
|
|
}
|