Skip to content

Commit

Permalink
Update ViewList.ID.Views
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Feb 6, 2025
1 parent 409ef4d commit 0366592
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions Sources/OpenSwiftUICore/View/Input/ViewList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ public struct _ViewList_ID: Hashable {
package let count: Int

package init(_ views: [Views], isDataDependent: Bool) {
// FIXME
var offset = 0
var result: [(views: Views, endOffset: Int)] = []
for view in views {
Expand All @@ -802,11 +801,27 @@ public struct _ViewList_ID: Hashable {
override package var endIndex: Int { count }

override package subscript(index: Int) -> ViewList.ID {
preconditionFailure("TODO")
// FIXME: targetIndex
let targetIndex = 0

return views[targetIndex].views[index]
}

override package func isEqual(to other: _ViewList_ID.Views) -> Bool {
preconditionFailure("TODO")
override package func isEqual(to other: ViewList.ID.Views) -> Bool {
guard let other = other as? JoinedViews,
count == other.count
else {
return false
}
guard !views.isEmpty else {
return true
}
for index in views.indices {
guard views[index].views.isEqual(to: other.views[index].views) else {
return false
}
}
return true
}
}
}
Expand All @@ -815,7 +830,7 @@ public struct _ViewList_ID: Hashable {
@available(*, unavailable)
extension _ViewList_ID: Sendable {}

// MARK: - ViewList.ID.View
// MARK: - ViewList.ID.Views

@_spi(ForOpenSwiftUIOnly)
open class _ViewList_ID_Views: RandomAccessCollection, Equatable {
Expand All @@ -834,7 +849,11 @@ open class _ViewList_ID_Views: RandomAccessCollection, Equatable {
}

package func withDataDependency() -> ViewList.ID.Views {
ViewList.ID._Views(self, isDataDependent: true)
if isDataDependent {
self
} else {
ViewList.ID._Views(self, isDataDependent: true)
}
}

public static func == (lhs: _ViewList_ID_Views, rhs: _ViewList_ID_Views) -> Bool {
Expand Down

0 comments on commit 0366592

Please sign in to comment.