39 lines
652 B
Swift
39 lines
652 B
Swift
//
|
|
// SimpleView.swift
|
|
// Meta
|
|
//
|
|
// Created by david-swift on 09.06.24.
|
|
//
|
|
|
|
/// A structure conforming to `SimpleView` is referred to as a view.
|
|
/// It can be part of a body.
|
|
///
|
|
/// ```swift
|
|
/// struct Test: SimpleView {
|
|
///
|
|
/// var view: Body {
|
|
/// AnotherView()
|
|
/// }
|
|
///
|
|
/// }
|
|
/// ```
|
|
///
|
|
/// A simple view cannot save state. Use ``View`` for saving state.
|
|
///
|
|
public protocol SimpleView: AnyView {
|
|
|
|
/// The view's content.
|
|
@ViewBuilder var view: Body { get }
|
|
|
|
}
|
|
|
|
/// Extend the simple view type without state.
|
|
extension SimpleView {
|
|
|
|
/// The view's content.
|
|
public var viewContent: Body {
|
|
view
|
|
}
|
|
|
|
}
|