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>
134 lines
3.3 KiB
Swift
134 lines
3.3 KiB
Swift
import Foundation
|
|
|
|
// MARK: - FinanceTransaction
|
|
|
|
struct FinanceTransaction: Codable, Identifiable {
|
|
let id: Int
|
|
var amount: Double
|
|
var categoryId: Int?
|
|
var description: String?
|
|
var type: String // "income" or "expense"
|
|
var date: String?
|
|
var createdAt: String?
|
|
var categoryName: String?
|
|
var categoryEmoji: String?
|
|
|
|
var isIncome: Bool { type == "income" }
|
|
|
|
var dateFormatted: String {
|
|
guard let d = date else { return "" }
|
|
let parts = String(d.prefix(10)).split(separator: "-")
|
|
guard parts.count == 3 else { return String(d.prefix(10)) }
|
|
return "\(parts[2]).\(parts[1]).\(parts[0])"
|
|
}
|
|
|
|
var dateOnly: String { String(date?.prefix(10) ?? "") }
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case id, amount, description, type, date
|
|
case categoryId = "category_id"
|
|
case createdAt = "created_at"
|
|
case categoryName = "category_name"
|
|
case categoryEmoji = "category_emoji"
|
|
}
|
|
}
|
|
|
|
// MARK: - FinanceCategory
|
|
|
|
struct FinanceCategory: Codable, Identifiable {
|
|
let id: Int
|
|
var name: 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
|
|
|
|
struct FinanceSummary: Codable {
|
|
var totalIncome: Double?
|
|
var totalExpense: Double?
|
|
var balance: Double?
|
|
var carriedOver: Double?
|
|
var month: String?
|
|
var byCategory: [CategorySpend]?
|
|
var daily: [DailySpend]?
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case balance, month
|
|
case totalIncome = "total_income"
|
|
case totalExpense = "total_expense"
|
|
case carriedOver = "carried_over"
|
|
case byCategory = "by_category"
|
|
case daily
|
|
}
|
|
}
|
|
|
|
struct CategorySpend: Codable, Identifiable {
|
|
var id: Int { categoryId ?? 0 }
|
|
var categoryId: Int?
|
|
var categoryName: String?
|
|
var total: Double?
|
|
var emoji: String?
|
|
var color: String?
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case total, emoji, color
|
|
case categoryId = "category_id"
|
|
case categoryName = "category_name"
|
|
}
|
|
}
|
|
|
|
struct DailySpend: Codable, Identifiable {
|
|
var id: String { date }
|
|
let date: String
|
|
let total: Double?
|
|
let income: Double?
|
|
let expense: Double?
|
|
}
|
|
|
|
// MARK: - FinanceAnalytics
|
|
|
|
struct FinanceAnalytics: Codable {
|
|
var currentMonth: FinanceSummary?
|
|
var previousMonth: FinanceSummary?
|
|
var byCategory: [CategorySpend]?
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case currentMonth = "current_month"
|
|
case previousMonth = "previous_month"
|
|
case byCategory = "by_category"
|
|
}
|
|
}
|
|
|
|
// MARK: - CreateTransactionRequest
|
|
|
|
struct CreateTransactionRequest: Codable {
|
|
var amount: Double
|
|
var categoryId: Int?
|
|
var description: String?
|
|
var type: String
|
|
var date: String?
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case amount, description, type, date
|
|
case categoryId = "category_id"
|
|
}
|
|
}
|
|
|
|
// MARK: - CreateFinanceCategoryRequest
|
|
|
|
struct CreateFinanceCategoryRequest: Codable {
|
|
var name: String
|
|
var type: String // "expense" or "income"
|
|
var emoji: String?
|
|
var budget: Double?
|
|
}
|