fix: remove weird animation on game selection
Disables implicit animation when toggling game selection to prevent visual glitches/morphing effect. Uses both withTransaction to disable animations on the state change and .animation(nil, value:) on the selection indicator and row background. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1252,10 +1252,15 @@ struct TeamSection: View {
|
|||||||
game: game,
|
game: game,
|
||||||
isSelected: selectedIds.contains(game.id),
|
isSelected: selectedIds.contains(game.id),
|
||||||
onTap: {
|
onTap: {
|
||||||
if selectedIds.contains(game.id) {
|
// Disable implicit animation to prevent weird morphing effect
|
||||||
selectedIds.remove(game.id)
|
var transaction = Transaction()
|
||||||
} else {
|
transaction.disablesAnimations = true
|
||||||
selectedIds.insert(game.id)
|
withTransaction(transaction) {
|
||||||
|
if selectedIds.contains(game.id) {
|
||||||
|
selectedIds.remove(game.id)
|
||||||
|
} else {
|
||||||
|
selectedIds.insert(game.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -1286,6 +1291,7 @@ struct GameCalendarRow: View {
|
|||||||
Image(systemName: isSelected ? "checkmark.circle.fill" : "circle")
|
Image(systemName: isSelected ? "checkmark.circle.fill" : "circle")
|
||||||
.font(.title3)
|
.font(.title3)
|
||||||
.foregroundStyle(isSelected ? Theme.warmOrange : Theme.textMuted(colorScheme))
|
.foregroundStyle(isSelected ? Theme.warmOrange : Theme.textMuted(colorScheme))
|
||||||
|
.animation(nil, value: isSelected)
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 2) {
|
VStack(alignment: .leading, spacing: 2) {
|
||||||
Text("vs \(game.awayTeam.name)")
|
Text("vs \(game.awayTeam.name)")
|
||||||
@@ -1312,6 +1318,7 @@ struct GameCalendarRow: View {
|
|||||||
.padding(.vertical, Theme.Spacing.sm)
|
.padding(.vertical, Theme.Spacing.sm)
|
||||||
.padding(.horizontal, Theme.Spacing.md)
|
.padding(.horizontal, Theme.Spacing.md)
|
||||||
.background(isSelected ? Theme.warmOrange.opacity(0.1) : Color.clear)
|
.background(isSelected ? Theme.warmOrange.opacity(0.1) : Color.clear)
|
||||||
|
.animation(nil, value: isSelected)
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user