Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Sources/OpenSwiftUICore/Layout/Dynamic/DynamicContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,10 @@ struct DynamicContainerInfo<Adapter>: StatefulRule, AsyncAttribute, ObservedAttr
var reusedIndex = -1
var foundMatch = false
for index in target ..< count {
let inforItem = info.items[index].for(Adapter.self)
guard inforItem.item.matchesIdentity(of: item) else {
if reusedIndex < 0, inforItem.phase == nil {
reusedIndex = inforItem.item.canBeReused(by: item) ? index : reusedIndex
let infoItem = info.items[index].for(Adapter.self)
guard infoItem.item.matchesIdentity(of: item) else {
if reusedIndex < 0, infoItem.phase == nil {
reusedIndex = infoItem.item.canBeReused(by: item) ? index : reusedIndex
}
continue
}
Expand All @@ -545,8 +545,8 @@ struct DynamicContainerInfo<Adapter>: StatefulRule, AsyncAttribute, ObservedAttr
info.items.swapAt(target, index)
changed = true
}
inforItem.item = item
if inforItem.phase != .identity {
infoItem.item = item
if infoItem.phase != .identity {
unremoveItem(at: target)
changed = true
}
Expand Down Expand Up @@ -695,9 +695,9 @@ struct DynamicContainerInfo<Adapter>: StatefulRule, AsyncAttribute, ObservedAttr
mutating func eraseItem(at index: Int) {
let phase = info.items[index].phase
switch phase {
case .identity, nil:
case .willAppear, nil:
preconditionFailure("")
case .willAppear:
case .identity:
break
case .didDisappear:
info.removedCount &-= 1
Expand Down
15 changes: 14 additions & 1 deletion Sources/OpenSwiftUICore/Render/OpacityEffect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,18 @@

extension AnyTransition {
// FIXME
public static let opacity: AnyTransition = .identity
public static let opacity: AnyTransition = .init(OpacityTransition())
}

extension View {
func opacity(_ value: Double) -> some View {
// FIXME
modifier(EmptyModifier())
}
}

struct OpacityTransition: Transition {
func body(content: Content, phase: TransitionPhase) -> some View {
content.opacity(1)
}
}
7 changes: 6 additions & 1 deletion Sources/OpenSwiftUICore/View/DynamicView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ private struct DynamicViewList<V>: StatefulRule, AsyncAttribute where V: Dynamic
}

func bindID(_ id: inout ViewList.ID) {
id.bind(explicitID: id, owner: owner, isUnary: isUnary, reuseID: Int(bitPattern: ObjectIdentifier(Int.self)))
id.bind(
explicitID: self.id,
owner: owner,
isUnary: isUnary,
reuseID: Int(bitPattern: ObjectIdentifier(Int.self))
)
}
}
}
Expand Down
18 changes: 11 additions & 7 deletions Sources/OpenSwiftUICore/View/IDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// IDView.swift
// OpenSwiftUICore
//
// Audited for 6.0.87
// Audited for 6.5.4
// Status: Complete
// ID: D4C7BC89F06A89A4754FA9F578FD2C57 (SwiftUI)
// ID: ADF2FC9997986A8A2C672C0F3AA33367 (SwiftUICore)
Expand All @@ -11,6 +11,7 @@ package import OpenAttributeGraphShims

// MARK: - IDView

@available(OpenSwiftUI_v1_0, *)
@usableFromInline
@frozen
package struct IDView<Content, ID>: View where Content: View, ID: Hashable {
Expand Down Expand Up @@ -42,6 +43,7 @@ extension View {
///
/// When the proxy value specified by the `id` parameter changes, the
/// identity of the view — for example, its state — is reset.
@available(OpenSwiftUI_v1_0, *)
@inlinable
nonisolated public func id<ID>(_ id: ID) -> some View where ID: Hashable {
return IDView(self, id: id)
Expand All @@ -50,19 +52,19 @@ extension View {

// MARK: - IDView + makeView implementation

@available(OpenSwiftUI_v1_0, *)
extension IDView {
@usableFromInline
package static func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
// FIXME: makeImplicitRoot is not implemented yet
// if _SemanticFeature_v2.isEnabled {
// return makeImplicitRoot(view: view, inputs: inputs)
// } else {
if _SemanticFeature_v2.isEnabled {
return makeImplicitRoot(view: view, inputs: inputs)
} else {
let id = view.value[offset: { .of(&$0.id) }]
let phase = IDPhase(id: id, phase: inputs.viewPhase, lastID: nil, delta: 0)
var inputs = inputs
inputs.viewPhase = Attribute(phase)
return Content.makeDebuggableView(view: view[offset: { .of(&$0.content)}], inputs: inputs)
// }
}
}
}

Expand All @@ -87,7 +89,7 @@ private struct IDPhase<ID>: StatefulRule, AsyncAttribute where ID: Hashable {
typealias Value = _GraphInputs.Phase

mutating func updateValue() {
if lastID != id{
if lastID != id {
if lastID != nil {
delta &+= 1
}
Expand All @@ -101,12 +103,14 @@ private struct IDPhase<ID>: StatefulRule, AsyncAttribute where ID: Hashable {

// MARK: - IDView + makeViewList implementation

@available(OpenSwiftUI_v1_0, *)
extension IDView {
@usableFromInline
package static func _makeViewList(view: _GraphValue<Self>, inputs: _ViewListInputs) -> _ViewListOutputs {
makeDynamicViewList(metadata: (), view: view, inputs: inputs)
}

@available(OpenSwiftUI_v2_0, *)
@usableFromInline
package static func _viewListCount(inputs: _ViewListCountInputs) -> Int? {
Content._viewListCount(inputs: inputs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ struct AppearanceActionModifierCompatibilityTests {
}
}
Helper.result += "A"
Helper.result += toggle ? "T" : "F"
}
.onDisappear {
Helper.result += "D"
Helper.result += toggle ? "T" : "F"
}
.id(toggle)
}
Expand All @@ -69,7 +71,6 @@ struct AppearanceActionModifierCompatibilityTests {
)
)
}

await #expect(Helper.result == "AADD")
await #expect(Helper.result == "AFATDTDT")
}
}