adwaita-swift/Sources/Adwaita/View/Modifiers/ModifierStopper.swift
david-swift 4937c36b3b Improve updating performance
And update docs reflecting the changes in the latest commits
2024-01-27 08:07:05 +01:00

42 lines
1.1 KiB
Swift

//
// ModifierStopper.swift
// Adwaita
//
// Created by david-swift on 11.11.23.
//
/// Remove all of the content modifiers for the wrapped views.
struct ModifierStopper: Widget {
/// The wrapped view.
var content: View
/// Get the content's container.
/// - Parameter modifiers: Modify views before being updated.
/// - Returns: The content's container.
func container(modifiers: [(View) -> View]) -> ViewStorage {
let storage = content.storage(modifiers: [])
return storage
}
/// Update the content.
/// - Parameters:
/// - storage: The content's storage.
/// - modifiers: Modify views before being updated.
/// - updateProperties: Whether to update properties.
func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
content.updateStorage(storage, modifiers: [], updateProperties: updateProperties)
}
}
extension View {
/// Remove all of the content modifiers for the wrapped views.
/// - Returns: A view.
public func stopModifiers() -> View {
ModifierStopper(content: self)
}
}