Skip to content

Commit

Permalink
Fix build after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
simlay committed Apr 12, 2024
1 parent a31e66c commit 8c4acd6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public class LiveViewCoordinator<R: RootRegistry>: 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.
Expand Down
12 changes: 6 additions & 6 deletions Sources/LiveViewNative/Live/LiveElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,24 @@ struct ShareLink<Root: RootRegistry>: 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:
Expand Down
4 changes: 2 additions & 2 deletions Sources/LiveViewNative/Views/Images/ImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ struct ImageView<Root: RootRegistry>: 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<Root>(element: ElementNode(node: labelNode, data: element), overrideStylesheet: nil).body
case let .leaf(label):
return .init(label)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,18 @@ struct List<Root: RootRegistry>: 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
Expand Down
10 changes: 5 additions & 5 deletions Sources/LiveViewNative/Views/Text Input and Output/Text.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ struct Text<Root: RootRegistry>: 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,
Expand Down

0 comments on commit 8c4acd6

Please sign in to comment.