import SwiftUI struct HabitRowView: View { let habit: Habit let onLog: () async -> Void var accentColor: Color { Color(hex: habit.color ?? "00d4aa") } var isDone: Bool { habit.completedToday == true } var body: some View { HStack(spacing: 14) { // Icon ZStack { Circle().fill(accentColor.opacity(isDone ? 0.3 : 0.1)).frame(width: 44, height: 44) Text(habit.icon ?? "🔥").font(.title3) } VStack(alignment: .leading, spacing: 4) { Text(habit.name).font(.callout.weight(.medium)).foregroundColor(.white) HStack(spacing: 8) { Text(habit.frequency.displayName).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) } }