feat: add habit creation, savings tabs, fix dashboard, fix tab order

This commit is contained in:
Cosmo
2026-03-25 12:32:55 +00:00
parent 4c54467b5e
commit 17b82a874f
6 changed files with 339 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ struct HabitsView: View {
@EnvironmentObject var authManager: AuthManager
@State private var habits: [Habit] = []
@State private var isLoading = true
@State private var showAddHabit = false
var completedCount: Int { habits.filter { $0.completedToday == true }.count }
@@ -17,6 +18,9 @@ struct HabitsView: View {
Text("\(completedCount)/\(habits.count) выполнено").font(.subheadline).foregroundColor(Color(hex: "8888aa"))
}
Spacer()
Button(action: { showAddHabit = true }) {
Image(systemName: "plus.circle.fill").font(.title2).foregroundColor(Color(hex: "00d4aa"))
}
}.padding()
// Progress bar
@@ -57,6 +61,12 @@ struct HabitsView: View {
}
.task { await loadHabits() }
.refreshable { await loadHabits(refresh: true) }
.sheet(isPresented: $showAddHabit) {
AddHabitView(isPresented: $showAddHabit) { await loadHabits(refresh: true) }
.presentationDetents([.large])
.presentationDragIndicator(.visible)
.presentationBackground(Color(hex: "0a0a1a"))
}
}
func loadHabits(refresh: Bool = false) async {