feat: add habit creation, savings tabs, fix dashboard, fix tab order
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user