Add convenience widgets

This commit is contained in:
david-swift 2024-06-17 09:23:50 +02:00
parent c15839de3b
commit d244fce038
4 changed files with 12 additions and 3 deletions

View File

@ -75,7 +75,7 @@ extension AnyView {
/// Whether the view can be rendered in a certain environment. /// Whether the view can be rendered in a certain environment.
func renderable<WidgetType>(type: WidgetType.Type) -> Bool { func renderable<WidgetType>(type: WidgetType.Type) -> Bool {
self as? WidgetType != nil || self as? SimpleView != nil || self as? View != nil self as? WidgetType != nil || self as? SimpleView != nil || self as? View != nil || self as? ConvenienceWidget != nil
} }
} }

View File

@ -0,0 +1,9 @@
//
// ConvenienceWidget.swift
// Meta
//
// Created by david-swift on 17.06.24.
//
/// A widget that does not interact with a platform-specific framework.
public protocol ConvenienceWidget: Widget { }

View File

@ -8,7 +8,7 @@
import Observation import Observation
/// A storage for `@State` properties. /// A storage for `@State` properties.
public struct StateWrapper: Widget { public struct StateWrapper: ConvenienceWidget {
/// The content. /// The content.
var content: () -> Body var content: () -> Body

View File

@ -6,7 +6,7 @@
// //
/// Wrap a view into a single widget. /// Wrap a view into a single widget.
public struct Wrapper: Widget { public struct Wrapper: ConvenienceWidget {
/// The content. /// The content.
var content: Body var content: Body