Make dummy either view a convenience widget
This commit is contained in:
parent
4e205397ca
commit
5b2c68aaf7
@ -112,6 +112,7 @@ public struct Binding<Value> {
|
||||
|
||||
}
|
||||
|
||||
/// Extend bindings.
|
||||
extension Binding where Value: MutableCollection {
|
||||
|
||||
/// Get a child at a certain index of the array as a binding.
|
||||
@ -134,6 +135,7 @@ extension Binding where Value: MutableCollection {
|
||||
|
||||
}
|
||||
|
||||
/// Extend bindings.
|
||||
extension Binding where Value: MutableCollection, Value.Element: Identifiable {
|
||||
|
||||
/// Get a child of the array with a certain id as a binding.
|
||||
@ -147,6 +149,7 @@ extension Binding where Value: MutableCollection, Value.Element: Identifiable {
|
||||
|
||||
}
|
||||
|
||||
/// Extend bindings.
|
||||
extension Binding: CustomStringConvertible where Value: CustomStringConvertible {
|
||||
|
||||
/// A textual description of the wrapped value.
|
||||
|
||||
@ -67,6 +67,7 @@ public struct ModelData {
|
||||
|
||||
}
|
||||
|
||||
/// Extend the model.
|
||||
extension Model {
|
||||
|
||||
/// Get the value as a binding using the `$` prefix.
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Extend arrays.
|
||||
extension Array: AnyView where Element == AnyView {
|
||||
|
||||
/// The array's view body is the array itself.
|
||||
@ -69,6 +70,7 @@ extension Array: AnyView where Element == AnyView {
|
||||
|
||||
}
|
||||
|
||||
/// Extend arrays.
|
||||
extension Array {
|
||||
|
||||
/// Accesses the element at the specified position safely.
|
||||
@ -96,6 +98,7 @@ extension Array {
|
||||
|
||||
}
|
||||
|
||||
/// Extend arrays.
|
||||
extension Array where Element: Identifiable {
|
||||
|
||||
/// Accesses the element with a certain id safely.
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
// Created by david-swift on 09.06.24.
|
||||
//
|
||||
|
||||
/// Extend strings.
|
||||
extension String {
|
||||
|
||||
/// An identifier for main content in a view storage.
|
||||
|
||||
@ -40,6 +40,7 @@ public protocol App {
|
||||
|
||||
}
|
||||
|
||||
/// Extend the app.
|
||||
extension App {
|
||||
|
||||
/// The application's entry point.
|
||||
@ -91,6 +92,8 @@ extension App {
|
||||
return appInstance
|
||||
}
|
||||
|
||||
/// Get the state from the properties.
|
||||
/// - Returns: The state.
|
||||
func getState() -> [String: StateProtocol] {
|
||||
var state: [String: StateProtocol] = [:]
|
||||
for property in Mirror(reflecting: self).children {
|
||||
|
||||
@ -27,6 +27,7 @@ public protocol AppStorage: AnyObject {
|
||||
|
||||
}
|
||||
|
||||
/// Extend the app storage.
|
||||
extension AppStorage {
|
||||
|
||||
/// Focus the scene element with a certain id (if supported). Create the element if it doesn't already exist.
|
||||
|
||||
@ -13,8 +13,12 @@ public protocol AnyView {
|
||||
|
||||
}
|
||||
|
||||
/// Extend any view.
|
||||
extension AnyView {
|
||||
|
||||
/// Get the view with modifications applied.
|
||||
/// - Parameters:
|
||||
/// - data:
|
||||
func getModified<Data>(data: WidgetData, type: Data.Type) -> AnyView where Data: ViewRenderData {
|
||||
var modified: AnyView = self
|
||||
for modifier in data.modifiers {
|
||||
|
||||
@ -27,6 +27,7 @@ public protocol SimpleView: AnyView {
|
||||
|
||||
}
|
||||
|
||||
/// Extend the simple view type without state.
|
||||
extension SimpleView {
|
||||
|
||||
/// The view's content.
|
||||
|
||||
@ -27,6 +27,7 @@ public protocol View: AnyView {
|
||||
|
||||
}
|
||||
|
||||
/// Extend the view type with state.
|
||||
extension View {
|
||||
|
||||
/// The view's content.
|
||||
@ -34,6 +35,8 @@ extension View {
|
||||
[StateWrapper(content: { view }, state: getState())]
|
||||
}
|
||||
|
||||
/// Get the state from the properties.
|
||||
/// - Returns: The state.
|
||||
func getState() -> [String: StateProtocol] {
|
||||
var state: [String: StateProtocol] = [:]
|
||||
for property in Mirror(reflecting: self).children {
|
||||
|
||||
@ -36,6 +36,7 @@ public protocol Widget: AnyView {
|
||||
|
||||
}
|
||||
|
||||
/// Extend the widget type.
|
||||
extension Widget {
|
||||
|
||||
/// A widget's view is empty.
|
||||
|
||||
@ -44,6 +44,7 @@ struct AppearObserver: ConvenienceWidget {
|
||||
|
||||
}
|
||||
|
||||
/// Extend any view.
|
||||
extension AnyView {
|
||||
|
||||
/// Run a function on the widget when it appears for the first time.
|
||||
|
||||
@ -58,6 +58,7 @@ struct ContentModifier<Content>: ConvenienceWidget where Content: AnyView {
|
||||
|
||||
}
|
||||
|
||||
/// Extend any view.
|
||||
extension AnyView {
|
||||
|
||||
/// Replace every occurrence of a certain view type in the content.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
/// A dummy either view. This will be replaced by the platform-specific either view.
|
||||
struct DummyEitherView: Widget {
|
||||
struct DummyEitherView: ConvenienceWidget {
|
||||
|
||||
/// Whether to present the first view.
|
||||
var condition: Bool
|
||||
|
||||
@ -45,6 +45,7 @@ struct Freeze: ConvenienceWidget {
|
||||
|
||||
}
|
||||
|
||||
/// Extend any view.
|
||||
extension AnyView {
|
||||
|
||||
/// Prevent a view from being updated.
|
||||
|
||||
@ -45,6 +45,7 @@ struct InspectorWrapper: ConvenienceWidget {
|
||||
|
||||
}
|
||||
|
||||
/// Extend any view.
|
||||
extension AnyView {
|
||||
|
||||
/// Run a custom code accessing the view's storage when initializing and updating the view.
|
||||
|
||||
@ -40,6 +40,7 @@ struct ModifierStopper: ConvenienceWidget {
|
||||
|
||||
}
|
||||
|
||||
/// Extend any view.
|
||||
extension AnyView {
|
||||
|
||||
/// Remove all of the content data for the wrapped views.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user