Skip to content

Commit cff62ca

Browse files
committed
Addressed Asen's Comments
1 parent 7fed656 commit cff62ca

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

Uplift/Views/MainView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct MainView: View {
1616
@State private var selectedTab: Screen = .home
1717
@StateObject var tabBarProp = TabBarProperty()
1818
@StateObject private var viewModel = ViewModel()
19-
19+
2020
// MARK: - UI
2121

2222
var body: some View {

Uplift/Views/WeeklyWorkoutTrackerView.swift

+17-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct WeeklyWorkoutTrackerView: View {
1313
// MARK: - Properties
1414

1515
@ObservedObject var viewModel: ProfileView.ViewModel
16-
@State private var animationProgress: Double = 0
16+
@State private var animationProgress: [Double] = Array(repeating: 0, count: 7)
1717

1818
// Weekday abbreviations
1919
private let weekdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
@@ -22,8 +22,8 @@ struct WeeklyWorkoutTrackerView: View {
2222
@State private var workoutDays: [Bool] = [false, false, false, false, false, false, false]
2323

2424
// Animation timing
25-
private let animationDuration: Double = 0.05
26-
private let delayBetweenDays: Double = 0.2
25+
private let animationDuration: Double = 0.5
26+
private let delayBetweenDays: Double = 0.3
2727

2828
// Circle dimensions
2929
private let circleSize: CGFloat = 24
@@ -80,14 +80,16 @@ struct WeeklyWorkoutTrackerView: View {
8080
Circle()
8181
.fill(Constants.Colors.yellow)
8282
.frame(width: circleSize, height: circleSize)
83-
.opacity(animationProgress > Double(index) ? 1 : 0)
83+
.scaleEffect(animationProgress[index])
84+
.opacity(animationProgress[index])
8485
}
8586

8687
if workoutDays[index] {
8788
Image(systemName: "checkmark")
8889
.font(.system(size: 14, weight: .bold))
8990
.foregroundColor(.black)
90-
.opacity(animationProgress > Double(index) ? 1 : 0)
91+
.scaleEffect(animationProgress[index])
92+
.opacity(animationProgress[index])
9193
}
9294
}
9395
}
@@ -132,23 +134,21 @@ struct WeeklyWorkoutTrackerView: View {
132134
let day = 25 + index
133135
workoutDays[index] = workoutDaysSet.contains(day)
134136
}
137+
138+
// Reset animation progress
139+
animationProgress = Array(repeating: 0, count: 7)
135140
}
136141

137-
/// Animates the workout day indicators sequentially from left to right.
142+
/// Animates the workout day indicators sequentially from left to right with fade-in effect
138143
private func animateWorkouts() async {
139-
animationProgress = 0
140-
141-
for index in weekdays.indices {
142-
do {
143-
try await Task.sleep(for: .seconds(0.25))
144+
for index in weekdays.indices where workoutDays[index] {
145+
// Add delay between animations
146+
try? await Task.sleep(for: .seconds(delayBetweenDays))
144147

145-
await MainActor.run {
146-
withAnimation(.easeInOut(duration: animationDuration)) {
147-
animationProgress = Double(index + 1)
148-
}
148+
await MainActor.run {
149+
withAnimation(.easeIn(duration: animationDuration)) {
150+
animationProgress[index] = 1.0
149151
}
150-
} catch {
151-
print("Error during animation delay: \(error)")
152152
}
153153
}
154154
}

0 commit comments

Comments
 (0)