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:
@@ -14,17 +14,41 @@ struct RegisterRequest: Codable {
|
||||
struct AuthResponse: Codable {
|
||||
let token: String?
|
||||
let accessToken: String?
|
||||
let refreshToken: String?
|
||||
let user: UserInfo
|
||||
|
||||
|
||||
var authToken: String { token ?? accessToken ?? "" }
|
||||
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case token
|
||||
case accessToken = "access_token"
|
||||
case refreshToken = "refresh_token"
|
||||
case user
|
||||
}
|
||||
}
|
||||
|
||||
struct RefreshRequest: Codable {
|
||||
let refreshToken: String
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case refreshToken = "refresh_token"
|
||||
}
|
||||
}
|
||||
|
||||
struct RefreshResponse: Codable {
|
||||
let accessToken: String?
|
||||
let refreshToken: String?
|
||||
let token: String?
|
||||
|
||||
var authToken: String { accessToken ?? token ?? "" }
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case accessToken = "access_token"
|
||||
case refreshToken = "refresh_token"
|
||||
case token
|
||||
}
|
||||
}
|
||||
|
||||
struct UserInfo: Codable {
|
||||
let id: Int
|
||||
let email: String
|
||||
|
||||
@@ -10,6 +10,8 @@ struct FinanceTransaction: Codable, Identifiable {
|
||||
var type: String // "income" or "expense"
|
||||
var date: String?
|
||||
var createdAt: String?
|
||||
var categoryName: String?
|
||||
var categoryEmoji: String?
|
||||
|
||||
var isIncome: Bool { type == "income" }
|
||||
|
||||
@@ -26,6 +28,8 @@ struct FinanceTransaction: Codable, Identifiable {
|
||||
case id, amount, description, type, date
|
||||
case categoryId = "category_id"
|
||||
case createdAt = "created_at"
|
||||
case categoryName = "category_name"
|
||||
case categoryEmoji = "category_emoji"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +38,16 @@ struct FinanceTransaction: Codable, Identifiable {
|
||||
struct FinanceCategory: Codable, Identifiable {
|
||||
let id: Int
|
||||
var name: String
|
||||
var icon: String?
|
||||
var emoji: String?
|
||||
var color: String?
|
||||
var type: String
|
||||
var budget: Double?
|
||||
var sortOrder: Int?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, name, emoji, color, type, budget
|
||||
case sortOrder = "sort_order"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - FinanceSummary
|
||||
@@ -65,11 +76,11 @@ struct CategorySpend: Codable, Identifiable {
|
||||
var categoryId: Int?
|
||||
var categoryName: String?
|
||||
var total: Double?
|
||||
var icon: String?
|
||||
var emoji: String?
|
||||
var color: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case total, icon, color
|
||||
case total, emoji, color
|
||||
case categoryId = "category_id"
|
||||
case categoryName = "category_name"
|
||||
}
|
||||
@@ -111,3 +122,12 @@ struct CreateTransactionRequest: Codable {
|
||||
case categoryId = "category_id"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CreateFinanceCategoryRequest
|
||||
|
||||
struct CreateFinanceCategoryRequest: Codable {
|
||||
var name: String
|
||||
var type: String // "expense" or "income"
|
||||
var emoji: String?
|
||||
var budget: Double?
|
||||
}
|
||||
|
||||
@@ -28,6 +28,33 @@ struct LatestHealthResponse: Codable {
|
||||
let hrv: HRVData?
|
||||
let steps: StepsData?
|
||||
let activeEnergy: EnergyData?
|
||||
let bloodOxygen: BloodOxygenData?
|
||||
let respiratoryRate: RespiratoryRateData?
|
||||
let distance: DistanceData?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case sleep, steps, hrv, distance
|
||||
case heartRate = "heartRate"
|
||||
case restingHeartRate = "restingHeartRate"
|
||||
case activeEnergy = "activeEnergy"
|
||||
case bloodOxygen = "spo2"
|
||||
case respiratoryRate = "respiratoryRate"
|
||||
}
|
||||
}
|
||||
|
||||
struct BloodOxygenData: Codable {
|
||||
let avg: Double?
|
||||
let min: Double?
|
||||
let max: Double?
|
||||
}
|
||||
|
||||
struct RespiratoryRateData: Codable {
|
||||
let avg: Double?
|
||||
}
|
||||
|
||||
struct DistanceData: Codable {
|
||||
let total: Double?
|
||||
let units: String?
|
||||
}
|
||||
|
||||
struct SleepData: Codable {
|
||||
@@ -37,6 +64,42 @@ struct SleepData: Codable {
|
||||
let core: Double?
|
||||
}
|
||||
|
||||
// Local-only model for sleep timeline (not from API)
|
||||
struct SleepSegment: Identifiable {
|
||||
let id = UUID()
|
||||
let phase: SleepPhaseType
|
||||
let start: Date
|
||||
let end: Date
|
||||
var duration: TimeInterval { end.timeIntervalSince(start) }
|
||||
}
|
||||
|
||||
enum SleepPhaseType: String {
|
||||
case deep = "Глубокий"
|
||||
case rem = "REM"
|
||||
case core = "Базовый"
|
||||
case awake = "Пробуждение"
|
||||
|
||||
var color: Color {
|
||||
switch self {
|
||||
case .deep: return Color(hex: "7c3aed")
|
||||
case .rem: return Color(hex: "a78bfa")
|
||||
case .core: return Color(hex: "c4b5fd")
|
||||
case .awake: return Color(hex: "ff4757")
|
||||
}
|
||||
}
|
||||
|
||||
var icon: String {
|
||||
switch self {
|
||||
case .deep: return "moon.zzz.fill"
|
||||
case .rem: return "brain.head.profile"
|
||||
case .core: return "moon.fill"
|
||||
case .awake: return "eye.fill"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct HeartRateData: Codable {
|
||||
let avg: Int?
|
||||
let min: Int?
|
||||
|
||||
@@ -107,8 +107,10 @@ struct SavingsStats: Codable {
|
||||
var totalWithdrawals: Double?
|
||||
var categoriesCount: Int?
|
||||
var monthlyPayments: Double?
|
||||
var monthlyPaymentDetails: [MonthlyPaymentDetail]?
|
||||
var overdueAmount: Double?
|
||||
var overdueCount: Int?
|
||||
var overdues: [OverduePayment]?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case totalBalance = "total_balance"
|
||||
@@ -116,8 +118,47 @@ struct SavingsStats: Codable {
|
||||
case totalWithdrawals = "total_withdrawals"
|
||||
case categoriesCount = "categories_count"
|
||||
case monthlyPayments = "monthly_payments"
|
||||
case monthlyPaymentDetails = "monthly_payment_details"
|
||||
case overdueAmount = "overdue_amount"
|
||||
case overdueCount = "overdue_count"
|
||||
case overdues
|
||||
}
|
||||
}
|
||||
|
||||
struct MonthlyPaymentDetail: Codable, Identifiable {
|
||||
var id: Int { categoryId }
|
||||
var categoryId: Int
|
||||
var categoryName: String
|
||||
var amount: Double
|
||||
var day: Int
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case categoryId = "category_id"
|
||||
case categoryName = "category_name"
|
||||
case amount, day
|
||||
}
|
||||
}
|
||||
|
||||
struct OverduePayment: Codable, Identifiable {
|
||||
var id: String { "\(categoryId)-\(month)" }
|
||||
var categoryId: Int
|
||||
var categoryName: String
|
||||
var userId: Int?
|
||||
var userName: String?
|
||||
var amount: Double
|
||||
var dueDay: Int
|
||||
var daysOverdue: Int
|
||||
var month: String
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case categoryId = "category_id"
|
||||
case categoryName = "category_name"
|
||||
case userId = "user_id"
|
||||
case userName = "user_name"
|
||||
case amount
|
||||
case dueDay = "due_day"
|
||||
case daysOverdue = "days_overdue"
|
||||
case month
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,3 +174,35 @@ struct CreateSavingsTransactionRequest: Codable {
|
||||
case categoryId = "category_id"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - SavingsRecurringPlan
|
||||
|
||||
struct SavingsRecurringPlan: Codable, Identifiable {
|
||||
let id: Int
|
||||
var categoryId: Int?
|
||||
var userId: Int?
|
||||
var effective: String?
|
||||
var amount: Double
|
||||
var day: Int?
|
||||
var createdAt: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, amount, day
|
||||
case categoryId = "category_id"
|
||||
case userId = "user_id"
|
||||
case effective
|
||||
case createdAt = "created_at"
|
||||
}
|
||||
}
|
||||
|
||||
struct CreateRecurringPlanRequest: Codable {
|
||||
var effective: String
|
||||
var amount: Double
|
||||
var day: Int?
|
||||
}
|
||||
|
||||
struct UpdateRecurringPlanRequest: Codable {
|
||||
var effective: String?
|
||||
var amount: Double?
|
||||
var day: Int?
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ struct PulseTask: Codable, Identifiable {
|
||||
var isRecurring: Bool?
|
||||
var recurrenceType: String?
|
||||
var recurrenceInterval: Int?
|
||||
var recurrenceEndDate: String?
|
||||
|
||||
var priorityColor: String {
|
||||
switch priority {
|
||||
case 4: return "ff0000"
|
||||
case 3: return "ff4757"
|
||||
case 2: return "ffa502"
|
||||
default: return "8888aa"
|
||||
@@ -31,7 +31,6 @@ struct PulseTask: Codable, Identifiable {
|
||||
case 1: return "Низкий"
|
||||
case 2: return "Средний"
|
||||
case 3: return "Высокий"
|
||||
case 4: return "Срочный"
|
||||
default: return "Без приоритета"
|
||||
}
|
||||
}
|
||||
@@ -64,6 +63,7 @@ struct PulseTask: Codable, Identifiable {
|
||||
case isRecurring = "is_recurring"
|
||||
case recurrenceType = "recurrence_type"
|
||||
case recurrenceInterval = "recurrence_interval"
|
||||
case recurrenceEndDate = "recurrence_end_date"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,10 +92,18 @@ struct CreateTaskRequest: Codable {
|
||||
var dueDate: String?
|
||||
var icon: String?
|
||||
var color: String?
|
||||
var isRecurring: Bool?
|
||||
var recurrenceType: String?
|
||||
var recurrenceInterval: Int?
|
||||
var recurrenceEndDate: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case title, description, priority, icon, color
|
||||
case dueDate = "due_date"
|
||||
case isRecurring = "is_recurring"
|
||||
case recurrenceType = "recurrence_type"
|
||||
case recurrenceInterval = "recurrence_interval"
|
||||
case recurrenceEndDate = "recurrence_end_date"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +115,19 @@ struct UpdateTaskRequest: Codable {
|
||||
var priority: Int?
|
||||
var dueDate: String?
|
||||
var completed: Bool?
|
||||
var icon: String?
|
||||
var color: String?
|
||||
var isRecurring: Bool?
|
||||
var recurrenceType: String?
|
||||
var recurrenceInterval: Int?
|
||||
var recurrenceEndDate: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case title, description, priority, completed
|
||||
case title, description, priority, completed, icon, color
|
||||
case dueDate = "due_date"
|
||||
case isRecurring = "is_recurring"
|
||||
case recurrenceType = "recurrence_type"
|
||||
case recurrenceInterval = "recurrence_interval"
|
||||
case recurrenceEndDate = "recurrence_end_date"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user