feat: major app overhaul — API fixes, glassmorphism UI, health dashboard, notifications
API Integration: - Fix logHabit: send "date" instead of "completed_at" - Fix FinanceCategory: "icon" → "emoji" to match API - Fix task priorities: remove level 4, keep 1-3 matching API - Fix habit frequencies: map monthly/interval → "custom" for API - Add token refresh (401 → auto retry with new token) - Add proper error handling (remove try? in save functions, show errors in UI) - Add date field to savings transactions - Add MonthlyPaymentDetail and OverduePayment models - Fix habit completedToday: compute on client from logs (API doesn't return it) - Filter habits by day of week on client (daily/weekly/monthly/interval) Design System (glassmorphism): - New DesignSystem.swift: Theme colors, GlassCard modifier, GlowIcon, GlowStatCard - Custom tab bar with per-tab glow colors (VStack layout, not ZStack overlay) - Deep dark background #06060f across all views - Glass cards with gradient fill + stroke throughout app - App icon: glassmorphism style with teal glow Health Dashboard: - Compact ReadinessBanner with recommendation text - 8 metric tiles: sleep, HR, HRV, steps, SpO2, respiratory rate, energy, distance - Each tile with status indicator (good/ok/bad) and hint text - Heart rate card (min/avg/max) - Weekly trends card (averages) - Recovery score (weighted: 40% sleep, 35% HRV, 25% RHR) - Tips card with actionable recommendations - Sleep detail view with hypnogram (step chart of phases) - Sleep segments timeline from HealthKit (deep/rem/core/awake with exact times) - Line chart replacing bar chart for weekly data - Collect respiratory_rate and sleep phases with timestamps from HealthKit - Background sync every ~30min via BGProcessingTask Notifications: - NotificationService for local push notifications - Morning/evening reminders with native DatePicker (wheel) - Payment reminders: 5 days, 1 day, and day-of for recurring savings - Notification settings in Settings tab UI Fixes: - Fix color picker overflow: HStack → LazyVGrid 5 columns - Fix sheet headers: shorter text, proper padding - Fix task/habit toggle: separate tap zones (checkbox vs edit) - Fix deprecated onChange syntax for iOS 17+ - Savings overview: real monthly payments and detailed overdues from API - Settings: timezone as Menu picker, removed Telegram/server notifications sections - All sheets use .presentationDetents([.large]) Config: - project.yml: real DEVELOPMENT_TEAM, HealthKit + BackgroundModes capabilities - Info.plist: BGTaskScheduler + UIBackgroundModes - Assets.xcassets with AppIcon - CLAUDE.md project documentation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,19 +5,21 @@ struct AddTransactionView: View {
|
||||
@EnvironmentObject var authManager: AuthManager
|
||||
let categories: [FinanceCategory]
|
||||
let onAdded: () async -> Void
|
||||
|
||||
|
||||
@State private var amount = ""
|
||||
@State private var description = ""
|
||||
@State private var type = "expense"
|
||||
@State private var selectedCategoryId: Int? = nil
|
||||
@State private var date = Date()
|
||||
@State private var isLoading = false
|
||||
@State private var errorMessage: String?
|
||||
|
||||
var filteredCategories: [FinanceCategory] { categories.filter { $0.type == type } }
|
||||
var isExpense: Bool { type == "expense" }
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color(hex: "0a0a1a").ignoresSafeArea()
|
||||
Color(hex: "06060f").ignoresSafeArea()
|
||||
|
||||
VStack(spacing: 0) {
|
||||
// Handle
|
||||
@@ -91,7 +93,16 @@ struct AddTransactionView: View {
|
||||
.foregroundColor(.white).padding(14)
|
||||
.background(RoundedRectangle(cornerRadius: 12).fill(Color.white.opacity(0.07)))
|
||||
}
|
||||
|
||||
|
||||
// Date
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Label("Дата", systemImage: "calendar").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
DatePicker("", selection: $date, displayedComponents: .date)
|
||||
.labelsHidden()
|
||||
.colorInvert()
|
||||
.colorMultiply(Color(hex: "0D9488"))
|
||||
}
|
||||
|
||||
// Categories
|
||||
if !filteredCategories.isEmpty {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
@@ -100,7 +111,7 @@ struct AddTransactionView: View {
|
||||
ForEach(filteredCategories) { cat in
|
||||
Button(action: { selectedCategoryId = selectedCategoryId == cat.id ? nil : cat.id }) {
|
||||
HStack(spacing: 6) {
|
||||
Text(cat.icon ?? "").font(.callout)
|
||||
Text(cat.emoji ?? "").font(.callout)
|
||||
Text(cat.name).font(.caption).lineLimit(1)
|
||||
}
|
||||
.foregroundColor(selectedCategoryId == cat.id ? .black : .white)
|
||||
@@ -115,21 +126,38 @@ struct AddTransactionView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let err = errorMessage {
|
||||
Text(err)
|
||||
.font(.caption).foregroundColor(Color(hex: "ff4757"))
|
||||
.padding(10)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(RoundedRectangle(cornerRadius: 10).fill(Color(hex: "ff4757").opacity(0.1)))
|
||||
}
|
||||
}
|
||||
.padding(20)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func save() {
|
||||
guard let a = Double(amount.replacingOccurrences(of: ",", with: ".")) else { return }
|
||||
isLoading = true
|
||||
errorMessage = nil
|
||||
let df = DateFormatter(); df.dateFormat = "yyyy-MM-dd"
|
||||
let dateStr = df.string(from: date)
|
||||
Task {
|
||||
let req = CreateTransactionRequest(amount: a, categoryId: selectedCategoryId, description: description.isEmpty ? nil : description, type: type)
|
||||
try? await APIService.shared.createTransaction(token: authManager.token, request: req)
|
||||
await onAdded()
|
||||
await MainActor.run { isPresented = false }
|
||||
do {
|
||||
let req = CreateTransactionRequest(amount: a, categoryId: selectedCategoryId, description: description.isEmpty ? nil : description, type: type, date: dateStr)
|
||||
try await APIService.shared.createTransaction(token: authManager.token, request: req)
|
||||
await onAdded()
|
||||
await MainActor.run { isPresented = false }
|
||||
} catch {
|
||||
await MainActor.run {
|
||||
errorMessage = error.localizedDescription
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user