- Phase 0: project.yml fixes (CODE_SIGN_ENTITLEMENTS confirmed) - Phase 1: Enhanced models (HabitModels, TaskModels, FinanceModels, SavingsModels, UserModels) - Phase 1: Enhanced APIService with all endpoints (habits/log/stats, tasks/uncomplete, finance/analytics, savings/*) - Phase 2: DashboardView rewrite - day progress bar, 4 stat cards, habit/task lists with Undo (3 sec) - Phase 3: TrackerView - HabitListView (streak badge, swipe delete, archive), TaskListView (priority, overdue), StatisticsView (heatmap 84 days, line chart, bar chart via Swift Charts) - Phase 4: FinanceView rewrite - month picker, summary card, top expenses progress bars, pie chart, line chart, transactions by day, analytics tab with bar chart + month comparison - Phase 5: SavingsView rewrite - overview with overdue block, categories tab with type icons, operations tab with category filter + add sheet - Phase 6: SettingsView - dark/light theme, profile edit, telegram chat id, notifications toggle + time, timezone picker, logout - Added: AddHabitView with weekly day selector + interval days - Added: AddTaskView with icon/color/due date picker - Haptic feedback on all toggle actions
42 lines
1.7 KiB
Swift
42 lines
1.7 KiB
Swift
import SwiftUI
|
|
|
|
struct HabitRowView: View {
|
|
let habit: Habit
|
|
let onLog: () async -> Void
|
|
|
|
var accentColor: Color { Color(hex: habit.accentColorHex.replacingOccurrences(of: "#", with: "")) }
|
|
var isDone: Bool { habit.completedToday == true }
|
|
|
|
var body: some View {
|
|
HStack(spacing: 14) {
|
|
ZStack {
|
|
Circle().fill(accentColor.opacity(isDone ? 0.3 : 0.1)).frame(width: 44, height: 44)
|
|
Text(habit.displayIcon).font(.title3)
|
|
}
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text(habit.name).font(.callout.weight(.medium)).foregroundColor(.white)
|
|
HStack(spacing: 8) {
|
|
Text(habit.frequencyLabel).font(.caption).foregroundColor(Color(hex: "8888aa"))
|
|
if let streak = habit.currentStreak, streak > 0 {
|
|
Text("🔥 \(streak)").font(.caption).foregroundColor(Color(hex: "ffa502"))
|
|
}
|
|
}
|
|
}
|
|
Spacer()
|
|
Button(action: { guard !isDone else { return }; Task { await onLog() } }) {
|
|
Image(systemName: isDone ? "checkmark.circle.fill" : "circle")
|
|
.font(.title2)
|
|
.foregroundColor(isDone ? accentColor : Color(hex: "8888aa"))
|
|
}
|
|
}
|
|
.padding(14)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
.fill(isDone ? accentColor.opacity(0.08) : Color.white.opacity(0.04))
|
|
.overlay(RoundedRectangle(cornerRadius: 16).stroke(isDone ? accentColor.opacity(0.3) : Color.clear, lineWidth: 1))
|
|
)
|
|
.padding(.horizontal)
|
|
.padding(.vertical, 3)
|
|
}
|
|
}
|