Skip to content

Commit 874ef85

Browse files
authored
[Bug Fix] Fix transition issue in DynamicContainer (#706)
1 parent e30f180 commit 874ef85

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

Example/OpenSwiftUIUITests/View/DynamicViewContent/ForEachUITests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,34 @@ struct ForEachUITests {
137137
}
138138
openSwiftUIAssertSnapshot(of: ContentView())
139139
}
140+
141+
@Test(
142+
.bug(
143+
"https://github.com/OpenSwiftUIProject/OpenSwiftUI/issues/655",
144+
id: 655
145+
)
146+
)
147+
func transitionAnimation() {
148+
struct ContentView: AnimationTestView {
149+
nonisolated static var model: AnimationTestModel {
150+
AnimationTestModel(duration: 2.0, count: 4)
151+
}
152+
@State private var items = [6]
153+
154+
var body: some View {
155+
VStack(spacing: 10) {
156+
ForEach(items, id: \.self) { item in
157+
Color.blue.opacity(Double(item) / 6.0)
158+
.frame(height: 50)
159+
.transition(.slide)
160+
}
161+
}
162+
.animation(.easeInOut(duration: Self.model.duration), value: items)
163+
.onAppear {
164+
items.removeAll { $0 == 6 }
165+
}
166+
}
167+
}
168+
openSwiftUIAssertAnimationSnapshot(of: ContentView())
169+
}
140170
}

Sources/OpenSwiftUICore/Animation/Transition/MoveTransition.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public struct MoveTransition: Transition {
5353
}
5454

5555
public func _makeContentTransition(transition: inout _Transition_ContentTransition) {
56-
guard case let .effects(style, size) = transition.operation else {
56+
guard case let .effects(_, size) = transition.operation else {
5757
transition.result = .bool(true)
5858
return
5959
}
60-
let effectiveSize = edge.translationOffset(for: size)
60+
let effectiveSize = edge.translationOffset(for: size)
6161
let effect = ContentTransition.Effect(.translation(effectiveSize))
6262
transition.result = .effects([effect])
6363
}

Sources/OpenSwiftUICore/Layout/Dynamic/DynamicLayoutView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ struct DynamicLayoutViewAdaptor: DynamicContainerAdaptor {
226226
var containerID = DynamicContainerID(uniqueId: uniqueId, viewIndex: 0)
227227
let outputs = item.elements.makeAllElements(inputs: inputs) { elementInputs, body in
228228
var elementInputs = elementInputs
229+
containerInputs(&elementInputs)
229230
if elementInputs.needsGeometry {
230231
let childGeometry = Attribute(
231232
DynamicLayoutViewChildGeometry(

0 commit comments

Comments
 (0)