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.9 KiB
Swift
134 lines
3.9 KiB
Swift
import Foundation
|
|
|
|
// MARK: - PulseTask
|
|
|
|
struct PulseTask: Codable, Identifiable {
|
|
let id: Int
|
|
var title: String
|
|
var description: String?
|
|
var completed: Bool
|
|
var priority: Int?
|
|
var icon: String?
|
|
var color: String?
|
|
var dueDate: String?
|
|
var reminderTime: String?
|
|
var createdAt: String?
|
|
var isRecurring: Bool?
|
|
var recurrenceType: String?
|
|
var recurrenceInterval: Int?
|
|
var recurrenceEndDate: String?
|
|
|
|
var priorityColor: String {
|
|
switch priority {
|
|
case 3: return "ff4757"
|
|
case 2: return "ffa502"
|
|
default: return "8888aa"
|
|
}
|
|
}
|
|
|
|
var priorityDisplayName: String {
|
|
switch priority {
|
|
case 1: return "Низкий"
|
|
case 2: return "Средний"
|
|
case 3: return "Высокий"
|
|
default: return "Без приоритета"
|
|
}
|
|
}
|
|
|
|
var isOverdue: Bool {
|
|
guard !completed, let due = dueDate else { return false }
|
|
let dateStr = String(due.prefix(10))
|
|
let today = ISO8601DateFormatter().string(from: Date()).prefix(10)
|
|
return dateStr < today
|
|
}
|
|
|
|
var dueDateFormatted: String? {
|
|
guard let due = dueDate else { return nil }
|
|
let dateStr = String(due.prefix(10))
|
|
let todayStr = String(ISO8601DateFormatter().string(from: Date()).prefix(10))
|
|
let tomorrowDate = Calendar.current.date(byAdding: .day, value: 1, to: Date())!
|
|
let tomorrowStr = String(ISO8601DateFormatter().string(from: tomorrowDate).prefix(10))
|
|
if dateStr == todayStr { return "Сегодня" }
|
|
if dateStr == tomorrowStr { return "Завтра" }
|
|
let parts = dateStr.split(separator: "-")
|
|
guard parts.count == 3 else { return dateStr }
|
|
return "\(parts[2]).\(parts[1]).\(parts[0])"
|
|
}
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case id, title, description, completed, priority, icon, color
|
|
case dueDate = "due_date"
|
|
case reminderTime = "reminder_time"
|
|
case createdAt = "created_at"
|
|
case isRecurring = "is_recurring"
|
|
case recurrenceType = "recurrence_type"
|
|
case recurrenceInterval = "recurrence_interval"
|
|
case recurrenceEndDate = "recurrence_end_date"
|
|
}
|
|
}
|
|
|
|
// MARK: - TaskStats
|
|
|
|
struct TaskStats: Codable {
|
|
let totalTasks: Int?
|
|
let completedTasks: Int?
|
|
let todayTasks: Int?
|
|
let todayCompleted: Int?
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case totalTasks = "total_tasks"
|
|
case completedTasks = "completed_tasks"
|
|
case todayTasks = "today_tasks"
|
|
case todayCompleted = "today_completed"
|
|
}
|
|
}
|
|
|
|
// MARK: - CreateTaskRequest
|
|
|
|
struct CreateTaskRequest: Codable {
|
|
var title: String
|
|
var description: String?
|
|
var priority: Int?
|
|
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"
|
|
}
|
|
}
|
|
|
|
// MARK: - UpdateTaskRequest
|
|
|
|
struct UpdateTaskRequest: Codable {
|
|
var title: String?
|
|
var description: String?
|
|
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, icon, color
|
|
case dueDate = "due_date"
|
|
case isRecurring = "is_recurring"
|
|
case recurrenceType = "recurrence_type"
|
|
case recurrenceInterval = "recurrence_interval"
|
|
case recurrenceEndDate = "recurrence_end_date"
|
|
}
|
|
}
|