diff --git a/Sources/OpenSwiftUICore/Layout/Dynamic/DynamicContainer.swift b/Sources/OpenSwiftUICore/Layout/Dynamic/DynamicContainer.swift index 1897b93f2..fda7c2159 100644 --- a/Sources/OpenSwiftUICore/Layout/Dynamic/DynamicContainer.swift +++ b/Sources/OpenSwiftUICore/Layout/Dynamic/DynamicContainer.swift @@ -533,10 +533,10 @@ struct DynamicContainerInfo: 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 } @@ -545,8 +545,8 @@ struct DynamicContainerInfo: 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 } @@ -695,9 +695,9 @@ struct DynamicContainerInfo: 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 diff --git a/Sources/OpenSwiftUICore/Render/OpacityEffect.swift b/Sources/OpenSwiftUICore/Render/OpacityEffect.swift index 17869feb0..edef3940f 100644 --- a/Sources/OpenSwiftUICore/Render/OpacityEffect.swift +++ b/Sources/OpenSwiftUICore/Render/OpacityEffect.swift @@ -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) + } } diff --git a/Sources/OpenSwiftUICore/View/DynamicView.swift b/Sources/OpenSwiftUICore/View/DynamicView.swift index 8c31ad642..36fad7443 100644 --- a/Sources/OpenSwiftUICore/View/DynamicView.swift +++ b/Sources/OpenSwiftUICore/View/DynamicView.swift @@ -237,7 +237,12 @@ private struct DynamicViewList: 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)) + ) } } } diff --git a/Sources/OpenSwiftUICore/View/IDView.swift b/Sources/OpenSwiftUICore/View/IDView.swift index 20bbaa4b8..1781d0f83 100644 --- a/Sources/OpenSwiftUICore/View/IDView.swift +++ b/Sources/OpenSwiftUICore/View/IDView.swift @@ -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) @@ -11,6 +11,7 @@ package import OpenAttributeGraphShims // MARK: - IDView +@available(OpenSwiftUI_v1_0, *) @usableFromInline @frozen package struct IDView: View where Content: View, ID: Hashable { @@ -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) -> some View where ID: Hashable { return IDView(self, id: id) @@ -50,19 +52,19 @@ extension View { // MARK: - IDView + makeView implementation +@available(OpenSwiftUI_v1_0, *) extension IDView { @usableFromInline package static func _makeView(view: _GraphValue, 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) -// } + } } } @@ -87,7 +89,7 @@ private struct IDPhase: StatefulRule, AsyncAttribute where ID: Hashable { typealias Value = _GraphInputs.Phase mutating func updateValue() { - if lastID != id{ + if lastID != id { if lastID != nil { delta &+= 1 } @@ -101,12 +103,14 @@ private struct IDPhase: StatefulRule, AsyncAttribute where ID: Hashable { // MARK: - IDView + makeViewList implementation +@available(OpenSwiftUI_v1_0, *) extension IDView { @usableFromInline package static func _makeViewList(view: _GraphValue, 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) diff --git a/Tests/OpenSwiftUICompatibilityTests/Modifier/ViewModifier/AppearanceActionModifierCompatibilityTests.swift b/Tests/OpenSwiftUICompatibilityTests/Modifier/ViewModifier/AppearanceActionModifierCompatibilityTests.swift index a14084603..2e2b7835e 100644 --- a/Tests/OpenSwiftUICompatibilityTests/Modifier/ViewModifier/AppearanceActionModifierCompatibilityTests.swift +++ b/Tests/OpenSwiftUICompatibilityTests/Modifier/ViewModifier/AppearanceActionModifierCompatibilityTests.swift @@ -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) } @@ -69,7 +71,6 @@ struct AppearanceActionModifierCompatibilityTests { ) ) } - - await #expect(Helper.result == "AADD") + await #expect(Helper.result == "AFATDTDT") } }