From 133a4b02dabf92e9c4469b41aab7e8d3160c327d Mon Sep 17 00:00:00 2001 From: david-swift Date: Mon, 17 Jun 2024 17:05:26 +0200 Subject: [PATCH] Fix style --- Sources/Model/Extensions/Array.swift | 7 ++++++- Sources/Model/User Interface/View/AnyView.swift | 12 ++++++++++-- Sources/Model/User Interface/View/Widget.swift | 7 ++++++- Sources/View/StateWrapper.swift | 7 ++++++- Sources/View/Wrapper.swift | 7 ++++++- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Sources/Model/Extensions/Array.swift b/Sources/Model/Extensions/Array.swift index 2c93d24..f1c0629 100644 --- a/Sources/Model/Extensions/Array.swift +++ b/Sources/Model/Extensions/Array.swift @@ -55,7 +55,12 @@ extension Array: AnyView where Element == AnyView { /// - modifiers: Modify views before being updated. /// - updateProperties: Whether to update properties. /// - type: The type of the widgets. - public func update(_ storage: [ViewStorage], modifiers: [(AnyView) -> AnyView], updateProperties: Bool, type: WidgetType.Type) { + public func update( + _ storage: [ViewStorage], + modifiers: [(AnyView) -> AnyView], + updateProperties: Bool, + type: WidgetType.Type + ) { for (index, element) in enumerated() where element.renderable(type: type) { if let storage = storage[safe: index] { element diff --git a/Sources/Model/User Interface/View/AnyView.swift b/Sources/Model/User Interface/View/AnyView.swift index 6659e06..44328f4 100644 --- a/Sources/Model/User Interface/View/AnyView.swift +++ b/Sources/Model/User Interface/View/AnyView.swift @@ -43,7 +43,12 @@ extension AnyView { /// - modifiers: Modify views before being updated. /// - updateProperties: Whether to update properties. /// - type: The type of the widgets. - public func updateStorage(_ storage: ViewStorage, modifiers: [(AnyView) -> AnyView], updateProperties: Bool, type: WidgetType.Type) { + public func updateStorage( + _ storage: ViewStorage, + modifiers: [(AnyView) -> AnyView], + updateProperties: Bool, + type: WidgetType.Type + ) { let modified = getModified(modifiers: modifiers) if let widget = modified as? Widget { widget.update(storage, modifiers: modifiers, updateProperties: updateProperties, type: type) @@ -75,7 +80,10 @@ extension AnyView { /// Whether the view can be rendered in a certain environment. func renderable(type: WidgetType.Type) -> Bool { - self as? WidgetType != nil || self as? SimpleView != nil || self as? View != nil || self as? ConvenienceWidget != nil + self as? WidgetType != nil + || self as? SimpleView != nil + || self as? View != nil + || self as? ConvenienceWidget != nil } } diff --git a/Sources/Model/User Interface/View/Widget.swift b/Sources/Model/User Interface/View/Widget.swift index 9ff74c2..f63a2d2 100644 --- a/Sources/Model/User Interface/View/Widget.swift +++ b/Sources/Model/User Interface/View/Widget.swift @@ -23,7 +23,12 @@ public protocol Widget: AnyView { /// - modifiers: Modify views before being updated /// - updateProperties: Whether to update the view's properties. /// - type: The type of the widgets. - func update(_ storage: ViewStorage, modifiers: [(AnyView) -> AnyView], updateProperties: Bool, type: WidgetType.Type) + func update( + _ storage: ViewStorage, + modifiers: [(AnyView) -> AnyView], + updateProperties: Bool, + type: WidgetType.Type + ) } diff --git a/Sources/View/StateWrapper.swift b/Sources/View/StateWrapper.swift index cc05b46..3ab7300 100644 --- a/Sources/View/StateWrapper.swift +++ b/Sources/View/StateWrapper.swift @@ -51,7 +51,12 @@ public struct StateWrapper: ConvenienceWidget { /// - modifiers: Modify views before being updated. /// - updateProperties: Whether to update properties. /// - type: The type of the widgets. - public func update(_ storage: ViewStorage, modifiers: [(AnyView) -> AnyView], updateProperties: Bool, type: WidgetType.Type) { + public func update( + _ storage: ViewStorage, + modifiers: [(AnyView) -> AnyView], + updateProperties: Bool, + type: WidgetType.Type + ) { var updateProperties = storage.fields[updateID] as? Bool ?? false storage.fields[updateID] = false for property in state { diff --git a/Sources/View/Wrapper.swift b/Sources/View/Wrapper.swift index e9748a0..229f653 100644 --- a/Sources/View/Wrapper.swift +++ b/Sources/View/Wrapper.swift @@ -33,7 +33,12 @@ public struct Wrapper: ConvenienceWidget { /// - modifiers: Modify views before being updated. /// - updateProperties: Whether to update properties. /// - type: The widget types. - public func update(_ storage: ViewStorage, modifiers: [(AnyView) -> AnyView], updateProperties: Bool, type: WidgetType.Type) { + public func update( + _ storage: ViewStorage, + modifiers: [(AnyView) -> AnyView], + updateProperties: Bool, + type: WidgetType.Type + ) { guard let storages = storage.content[.mainContent] else { return }