diff --git a/Sources/Model/User Interface/View/AnyView.swift b/Sources/Model/User Interface/View/AnyView.swift index eddd5ea..379f5e8 100644 --- a/Sources/Model/User Interface/View/AnyView.swift +++ b/Sources/Model/User Interface/View/AnyView.swift @@ -20,9 +20,6 @@ extension AnyView { for modifier in modifiers { modified = modifier(modified) } - if let dummy = modified as? DummyEitherView { - modified = type.EitherViewType(dummy.condition) { dummy.view1 ?? [] } else: { dummy.view2 ?? [] } - } return modified } diff --git a/Sources/View/DummyEitherView.swift b/Sources/View/DummyEitherView.swift index 6a1e83b..d15919b 100644 --- a/Sources/View/DummyEitherView.swift +++ b/Sources/View/DummyEitherView.swift @@ -6,7 +6,7 @@ // /// A dummy either view. This will be replaced by the platform-specific either view. -struct DummyEitherView: SimpleView { +struct DummyEitherView: Widget { /// Whether to present the first view. var condition: Bool @@ -15,7 +15,34 @@ struct DummyEitherView: SimpleView { /// The second view. var view2: Body? - /// By default, show the first view. - var view: Body { view1 ?? view2 ?? [] } + /// The view storage. + /// - Parameters: + /// - modifiers: Modify views before being updated. + /// - type: The type of the app storage. + /// - Returns: The view storage. + func container( + modifiers: [(any AnyView) -> any AnyView], + type: Data.Type + ) -> ViewStorage where Data: ViewRenderData { + let content = type.EitherViewType(condition) { view1 ?? [] } else: { view2 ?? [] } + let storage = content.storage(modifiers: modifiers, type: type) + return storage + } + + /// 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 app storage. + func update( + _ storage: ViewStorage, + modifiers: [(any AnyView) -> any AnyView], + updateProperties: Bool, + type: Data.Type + ) where Data: ViewRenderData { + let content = type.EitherViewType(condition) { view1 ?? [] } else: { view2 ?? [] } + content.updateStorage(storage, modifiers: modifiers, updateProperties: updateProperties, type: type) + } }