Demo animation improvements: grid visibility, smooth scroll, fluid fill
- Fix grid visibility: show gray background cells always, animate mood colors on top with scale 2x->1x effect - Add smooth auto-scroll for MonthView: starts after first month is 50% filled, scrolls at constant speed to match fill rate - Remove pause between months for fluid continuous animation - Add currentAnimatingMonthIndex tracking to DemoAnimationManager Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -757,26 +757,40 @@ struct DemoYearHeatmapCell: View {
|
||||
@State private var randomMood: Mood = .great
|
||||
|
||||
var body: some View {
|
||||
RoundedRectangle(cornerRadius: 2)
|
||||
.fill(cellColor)
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
.scaleEffect(cellScale)
|
||||
.opacity(cellOpacity)
|
||||
.animation(.spring(response: 0.35, dampingFraction: 0.5), value: isVisible)
|
||||
.onAppear {
|
||||
// Generate random mood once when cell appears
|
||||
randomMood = DemoAnimationManager.randomPositiveMood()
|
||||
ZStack {
|
||||
// Background: Gray grid cell always visible at 1x scale
|
||||
RoundedRectangle(cornerRadius: 2)
|
||||
.fill(Color.gray.opacity(0.3))
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
|
||||
// Foreground: Animated mood color that scales 2x -> 1x
|
||||
if demoManager.isDemoMode {
|
||||
RoundedRectangle(cornerRadius: 2)
|
||||
.fill(moodTint.color(forMood: randomMood))
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
.scaleEffect(isAnimated ? 1.0 : 2.0)
|
||||
.opacity(isAnimated ? 1.0 : 0.0)
|
||||
.animation(.spring(response: 0.3, dampingFraction: 0.7), value: isAnimated)
|
||||
} else {
|
||||
// Normal mode - just show the actual color
|
||||
RoundedRectangle(cornerRadius: 2)
|
||||
.fill(normalCellColor)
|
||||
.aspectRatio(1, contentMode: .fit)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
// Generate random mood once when cell appears
|
||||
randomMood = DemoAnimationManager.randomPositiveMood()
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether this cell should be visible in demo mode
|
||||
/// For year view, we animate column by column (left to right), then row by row within each column
|
||||
private var isVisible: Bool {
|
||||
/// Whether this cell has been animated (filled with color)
|
||||
private var isAnimated: Bool {
|
||||
if !demoManager.isDemoMode {
|
||||
return true // Normal mode - always visible
|
||||
return true // Normal mode - always show
|
||||
}
|
||||
if !demoManager.animationStarted {
|
||||
return false // Demo mode but animation hasn't started - hide all
|
||||
return false // Demo mode but animation hasn't started
|
||||
}
|
||||
|
||||
return demoManager.isCellVisibleForYear(
|
||||
@@ -788,28 +802,8 @@ struct DemoYearHeatmapCell: View {
|
||||
)
|
||||
}
|
||||
|
||||
private var cellScale: CGFloat {
|
||||
isVisible ? 1.0 : 0.0
|
||||
}
|
||||
|
||||
private var cellOpacity: Double {
|
||||
isVisible ? 1.0 : 0.0
|
||||
}
|
||||
|
||||
private var cellColor: Color {
|
||||
if demoManager.isDemoMode {
|
||||
// In demo mode, show random positive mood colors
|
||||
if !isVisible {
|
||||
return Color.gray.opacity(0.1)
|
||||
}
|
||||
// Skip placeholder/empty cells
|
||||
if color == Mood.placeholder.color || color == Mood.missing.color {
|
||||
return Color.gray.opacity(0.1)
|
||||
}
|
||||
return moodTint.color(forMood: randomMood)
|
||||
}
|
||||
|
||||
// Normal mode - use actual colors
|
||||
/// Color for normal (non-demo) mode
|
||||
private var normalCellColor: Color {
|
||||
if !isFiltered {
|
||||
return Color.gray.opacity(0.1)
|
||||
} else if color == Mood.placeholder.color || color == Mood.missing.color {
|
||||
|
||||
Reference in New Issue
Block a user