Add modify function for views
This commit is contained in:
parent
8da8115172
commit
b8f36b7600
@ -75,6 +75,15 @@ extension AnyView {
|
||||
|| result as? Body != nil
|
||||
}
|
||||
|
||||
/// Apply a modification onto a view.
|
||||
/// - Parameter action: The modifications.
|
||||
/// - Returns: The modified view.
|
||||
public func modify(action: (inout Self) -> Void) -> Self {
|
||||
var newSelf = self
|
||||
action(&newSelf)
|
||||
return newSelf
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// `Body` is an array of views.
|
||||
|
||||
@ -90,7 +90,7 @@ public enum Backend1 {
|
||||
|
||||
public func container<Storage>(modifiers: [(any AnyView) -> any AnyView], type: Storage.Type) -> ViewStorage where Storage: AppStorage {
|
||||
let storage = ViewStorage(nil)
|
||||
storage.renderableContent[.mainContent] = (content as [Renderable]).storages(type: MenuElement.self, fields: [:]) ?? []
|
||||
storage.renderableContent[.mainContent] = (content as [Renderable]).storages(type: MenuElement.self, fields: [:])
|
||||
return storage
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user