From 8c4acd65bfc0b4cb5f4885ea9adea2ca6039fc00 Mon Sep 17 00:00:00 2001 From: Sebastian Imlay Date: Fri, 12 Apr 2024 14:24:04 -0400 Subject: [PATCH] Fix build after rebase --- .../Coordinators/LiveViewCoordinator.swift | 2 +- Sources/LiveViewNative/Live/LiveElement.swift | 12 ++++++------ .../Controls and Indicators/Links/ShareLink.swift | 14 +++++++------- .../LiveViewNative/Views/Images/ImageView.swift | 4 ++-- .../Collection Containers/List.swift | 6 +++--- .../Views/Text Input and Output/Text.swift | 10 +++++----- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift b/Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift index 9c5b1aaf9..b4b6c3f7d 100644 --- a/Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift +++ b/Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift @@ -388,7 +388,7 @@ public class LiveViewCoordinator: ObservableObject { private func handleJoinPayload(renderedPayload: Payload) { // todo: what should happen if decoding or parsing fails? self.document = try! LiveViewNativeCore.Document.parseFragmentJson(payload: renderedPayload) - self.document?.on(.changed) { [unowned self] doc, nodeRef, nodeData, parent in + self.document?.on(.changed) { nodeRef, nodeData, parent in switch nodeData { case .root: // when the root changes, update the `NavStackEntry` itself. diff --git a/Sources/LiveViewNative/Live/LiveElement.swift b/Sources/LiveViewNative/Live/LiveElement.swift index f6d8e0187..af61fab9a 100644 --- a/Sources/LiveViewNative/Live/LiveElement.swift +++ b/Sources/LiveViewNative/Live/LiveElement.swift @@ -53,22 +53,22 @@ public protocol _LiveElementTrackedContent { public extension _LiveElementTracked { func children(_ predicate: (Node) -> Bool = { node in - !node.attributes.contains(where: { $0.name.namespace == nil && $0.name.name == "template" }) + !node.attributes().contains(where: { $0.name.namespace == nil && $0.name.name == "template" }) }) -> some View { context.coordinator.builder.fromNodes(_element.children.filter(predicate), context: context.storage) } - + func children(in template: Template, default includeDefault: Bool = false) -> some View { children { - $0.attributes.contains(where: { + $0.attributes().contains(where: { $0 == template - }) || (includeDefault && !$0.attributes.contains(where: { $0.name.namespace == nil && $0.name.name == "template" })) + }) || (includeDefault && !$0.attributes().contains(where: { $0.name.namespace == nil && $0.name.name == "template" })) } } - + func hasTemplate(_ template: Template, default includeDefault: Bool = false) -> Bool { _element.children.contains(where: { - for attribute in $0.attributes { + for attribute in $0.attributes() { if attribute == template { return true } else if includeDefault && attribute.name.namespace == nil && attribute.name.name == "template" { diff --git a/Sources/LiveViewNative/Views/Controls and Indicators/Links/ShareLink.swift b/Sources/LiveViewNative/Views/Controls and Indicators/Links/ShareLink.swift index ea5b00291..d1ea2ddad 100644 --- a/Sources/LiveViewNative/Views/Controls and Indicators/Links/ShareLink.swift +++ b/Sources/LiveViewNative/Views/Controls and Indicators/Links/ShareLink.swift @@ -98,24 +98,24 @@ struct ShareLink: View { self.value = try itemsDecoder.decode([String].self, from: data) } } - + /// A string to share. @_documentation(visibility: public) private var item: String? - + public var body: some View { #if !os(tvOS) let useDefaultLabel = $liveElement.childNodes.filter({ - guard case let .element(data) = $0.data else { return true } - return data.tag != "SharePreview" + guard case let .nodeElement(data) = $0.data() else { return true } + return data.name.name != "SharePreview" }).isEmpty - + let subject = self.subject.flatMap(SwiftUI.Text.init) let message = self.message.flatMap(SwiftUI.Text.init) - + if let items = items?.value { let previews = previews(for: items) - + if useDefaultLabel { switch previews { case nil: diff --git a/Sources/LiveViewNative/Views/Images/ImageView.swift b/Sources/LiveViewNative/Views/Images/ImageView.swift index cdaccf979..126fc51a6 100644 --- a/Sources/LiveViewNative/Views/Images/ImageView.swift +++ b/Sources/LiveViewNative/Views/Images/ImageView.swift @@ -128,9 +128,9 @@ struct ImageView: View { } var label: SwiftUI.Text? { - if let labelNode = $liveElement.children().first { + if let labelNode = $liveElement.childNodes.first { switch labelNode.data() { - case let .element(element): + case let .nodeElement(element): return Text(element: ElementNode(node: labelNode, data: element), overrideStylesheet: nil).body case let .leaf(label): return .init(label) diff --git a/Sources/LiveViewNative/Views/Layout Containers/Collection Containers/List.swift b/Sources/LiveViewNative/Views/Layout Containers/Collection Containers/List.swift index 77046a76a..77ad3e023 100644 --- a/Sources/LiveViewNative/Views/Layout Containers/Collection Containers/List.swift +++ b/Sources/LiveViewNative/Views/Layout Containers/Collection Containers/List.swift @@ -167,18 +167,18 @@ struct List: View { } #endif } - + private var content: some View { forEach( nodes: $liveElement.childNodes.filter({ - !$0.attributes.contains(where: { $0.name.namespace == nil && $0.name.name == "template" }) + !$0.attributes().contains(where: { $0.name.namespace == nil && $0.name.name == "template" }) }), context: $liveElement.context.storage ) .onDelete(perform: onDeleteHandler) .onMove(perform: onMoveHandler) } - + private var onDeleteHandler: ((IndexSet) -> Void)? { guard delete.event != nil else { return nil } return { indices in diff --git a/Sources/LiveViewNative/Views/Text Input and Output/Text.swift b/Sources/LiveViewNative/Views/Text Input and Output/Text.swift index 487dd4bca..24a2c4449 100644 --- a/Sources/LiveViewNative/Views/Text Input and Output/Text.swift +++ b/Sources/LiveViewNative/Views/Text Input and Output/Text.swift @@ -213,14 +213,14 @@ struct Text: View { } } else { return $liveElement.childNodes.reduce(into: SwiftUI.Text("")) { prev, next in - switch next.data { - case let .element(data): + switch next.data() { + case let .nodeElement(data): guard !data.attributes.contains(where: { $0.name.namespace == nil && $0.name.name == "template" }) else { return } - + let element = ElementNode(node: next, data: data) - - switch data.tag { + + switch data.name.name { case "Text": prev = prev + Self( element: element,