Skip to content

Commit 9f00c3d

Browse files
authored
Merge pull request #49 from willowtreeapps/feature/animate-keyboard-transition
Animate keyboard transition
2 parents 495bb98 + 5ee859b commit 9f00c3d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

EyeSpeak/Features/Presets/PresetUICollectionViewCompositionalLayout.swift

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,34 @@ class PresetUICollectionViewCompositionalLayout: UICollectionViewCompositionalLa
2121
override func initialLayoutAttributesForAppearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
2222
let attr = super.initialLayoutAttributesForAppearingItem(at: itemIndexPath)
2323
// Make animation only happen for preset items
24-
guard let item = dataSource?.itemIdentifier(for: itemIndexPath), case PresetsViewController.ItemWrapper.presetItem(_) = item else {
24+
guard let item = dataSource?.itemIdentifier(for: itemIndexPath) else {
2525
return attr
2626
}
27-
attr?.transform = CGAffineTransform(translationX: 0, y: 500.0)
27+
28+
switch item {
29+
case .presetItem, .keyGroup, .keyboardFunctionButton:
30+
attr?.transform = CGAffineTransform(translationX: 0, y: 500.0)
31+
default:
32+
break
33+
}
34+
2835
return attr
2936
}
3037

3138
override func finalLayoutAttributesForDisappearingItem(at itemIndexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
3239
let attr = super.finalLayoutAttributesForDisappearingItem(at: itemIndexPath)
3340
// Make animation only happen for preset items
34-
guard let item = dataSource?.itemIdentifier(for: itemIndexPath), case PresetsViewController.ItemWrapper.presetItem(_) = item else {
41+
guard let item = dataSource?.itemIdentifier(for: itemIndexPath) else {
3542
return attr
3643
}
37-
attr?.transform = CGAffineTransform(translationX: 0, y: 500.0)
44+
45+
switch item {
46+
case .presetItem, .keyGroup, .keyboardFunctionButton:
47+
attr?.transform = CGAffineTransform(translationX: 0, y: 500.0)
48+
default:
49+
break
50+
}
51+
3852
return attr
3953
}
4054

0 commit comments

Comments
 (0)