feat: полноценное Pulse приложение с TabBar

- Auth: переключено на Pulse API (api.digital-home.site) вместо health
- TabBar: Главная, Задачи, Привычки, Здоровье, Финансы
- Models: TaskModels, HabitModels, FinanceModels, обновлённые AuthModels
- Services: APIService (Pulse API), HealthAPIService (health отдельно)
- Dashboard: обзор дня с задачами, привычками, readiness, балансом
- Tasks: список, фильтр, создание, выполнение, удаление
- Habits: список с прогресс-баром, отметка выполнения, стрики
- Health: бывший DashboardView, HealthKit sync через health API key
- Finance: баланс, список транзакций, добавление расхода/дохода
- Health данные через x-api-key вместо JWT токена health сервиса
This commit is contained in:
Cosmo
2026-03-25 11:49:52 +00:00
parent cf0e535639
commit c015824b36
23 changed files with 1090 additions and 202 deletions

View File

@@ -0,0 +1,45 @@
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)
}
}

View File

@@ -0,0 +1,73 @@
import SwiftUI
struct HabitsView: View {
@EnvironmentObject var authManager: AuthManager
@State private var habits: [Habit] = []
@State private var isLoading = true
var completedCount: Int { habits.filter { $0.completedToday == true }.count }
var body: some View {
ZStack {
Color(hex: "0a0a1a").ignoresSafeArea()
VStack(spacing: 0) {
HStack {
VStack(alignment: .leading) {
Text("Привычки").font(.title.bold()).foregroundColor(.white)
Text("\(completedCount)/\(habits.count) выполнено").font(.subheadline).foregroundColor(Color(hex: "8888aa"))
}
Spacer()
}.padding()
// Progress bar
if !habits.isEmpty {
GeometryReader { geo in
ZStack(alignment: .leading) {
RoundedRectangle(cornerRadius: 4).fill(Color.white.opacity(0.1))
RoundedRectangle(cornerRadius: 4).fill(Color(hex: "00d4aa"))
.frame(width: geo.size.width * CGFloat(completedCount) / CGFloat(max(habits.count, 1)))
}
}
.frame(height: 6)
.padding(.horizontal)
.padding(.bottom, 16)
}
if isLoading {
ProgressView().tint(Color(hex: "00d4aa")).padding(.top, 40)
Spacer()
} else if habits.isEmpty {
VStack(spacing: 12) {
Text("🔥").font(.system(size: 50))
Text("Нет привычек").foregroundColor(Color(hex: "8888aa"))
}.padding(.top, 60)
Spacer()
} else {
List {
ForEach(habits) { habit in
HabitRowView(habit: habit) { await logHabit(habit) }
.listRowBackground(Color.clear)
.listRowSeparator(.hidden)
}
}
.listStyle(.plain)
.scrollContentBackground(.hidden)
}
}
}
.task { await loadHabits() }
.refreshable { await loadHabits() }
}
func loadHabits() async {
isLoading = true
habits = (try? await APIService.shared.getHabits(token: authManager.token)) ?? []
isLoading = false
}
func logHabit(_ habit: Habit) async {
try? await APIService.shared.logHabit(token: authManager.token, id: habit.id)
await loadHabits()
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
}
}