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:
@@ -12,13 +12,25 @@ struct AddTaskView: View {
|
||||
@State private var selectedColor = "#0D9488"
|
||||
@State private var hasDueDate = false
|
||||
@State private var dueDate = Date()
|
||||
@State private var isRecurring = false
|
||||
@State private var recurrenceType = "daily"
|
||||
@State private var recurrenceInterval = "1"
|
||||
@State private var hasRecurrenceEnd = false
|
||||
@State private var recurrenceEndDate = Date().addingTimeInterval(86400 * 30)
|
||||
@State private var isLoading = false
|
||||
@State private var errorMessage: String?
|
||||
|
||||
let recurrenceTypes: [(String, String)] = [
|
||||
("daily", "Ежедневно"),
|
||||
("weekly", "Еженедельно"),
|
||||
("monthly", "Ежемесячно"),
|
||||
("custom", "Каждые N дней")
|
||||
]
|
||||
|
||||
let priorities: [(Int, String, String)] = [
|
||||
(1, "Низкий", "8888aa"),
|
||||
(2, "Средний", "ffa502"),
|
||||
(3, "Высокий", "ff4757"),
|
||||
(4, "Срочный", "ff0000")
|
||||
(3, "Высокий", "ff4757")
|
||||
]
|
||||
|
||||
let icons = ["✅","📌","🎯","💼","🏠","🛒","📞","🎓","💊","🚗",
|
||||
@@ -29,21 +41,22 @@ struct AddTaskView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color(hex: "0a0a1a").ignoresSafeArea()
|
||||
Color(hex: "06060f").ignoresSafeArea()
|
||||
VStack(spacing: 0) {
|
||||
RoundedRectangle(cornerRadius: 3)
|
||||
.fill(Color.white.opacity(0.2)).frame(width: 40, height: 4).padding(.top, 12)
|
||||
HStack {
|
||||
Button("Отмена") { isPresented = false }.foregroundColor(Color(hex: "8888aa"))
|
||||
Button("Отмена") { isPresented = false }
|
||||
.font(.callout).foregroundColor(Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
Text("Новая задача").font(.headline).foregroundColor(.white)
|
||||
Spacer()
|
||||
Button(action: save) {
|
||||
if isLoading { ProgressView().tint(Color(hex: "0D9488")).scaleEffect(0.8) }
|
||||
else { Text("Добавить").foregroundColor(title.isEmpty ? Color(hex: "8888aa") : Color(hex: "0D9488")).fontWeight(.semibold) }
|
||||
if isLoading { ProgressView().tint(Theme.teal).scaleEffect(0.8) }
|
||||
else { Text("Готово").font(.callout.bold()).foregroundColor(title.isEmpty ? Color(hex: "8888aa") : Theme.teal) }
|
||||
}.disabled(title.isEmpty || isLoading)
|
||||
}
|
||||
.padding(.horizontal, 20).padding(.vertical, 16)
|
||||
.padding(.horizontal, 16).padding(.vertical, 14)
|
||||
Divider().background(Color.white.opacity(0.1))
|
||||
ScrollView {
|
||||
VStack(spacing: 16) {
|
||||
@@ -106,7 +119,7 @@ struct AddTaskView: View {
|
||||
// Color
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Label("Цвет", systemImage: "paintpalette").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
HStack(spacing: 10) {
|
||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 5), spacing: 10) {
|
||||
ForEach(colors, id: \.self) { c in
|
||||
Button(action: { selectedColor = c }) {
|
||||
Circle().fill(Color(hex: String(c.dropFirst()))).frame(width: 32, height: 32)
|
||||
@@ -116,6 +129,57 @@ struct AddTaskView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Recurrence
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
HStack {
|
||||
Label("Повторение", systemImage: "repeat").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
Toggle("", isOn: $isRecurring).tint(Color(hex: "0D9488")).labelsHidden()
|
||||
}
|
||||
if isRecurring {
|
||||
VStack(spacing: 8) {
|
||||
ForEach(recurrenceTypes, id: \.0) { rt in
|
||||
Button(action: { recurrenceType = rt.0 }) {
|
||||
HStack {
|
||||
Text(rt.1).foregroundColor(recurrenceType == rt.0 ? .white : Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
if recurrenceType == rt.0 { Image(systemName: "checkmark").foregroundColor(Color(hex: "0D9488")) }
|
||||
}
|
||||
.padding(12)
|
||||
.background(RoundedRectangle(cornerRadius: 10).fill(recurrenceType == rt.0 ? Color(hex: "0D9488").opacity(0.15) : Color.white.opacity(0.05)))
|
||||
}
|
||||
}
|
||||
if recurrenceType == "custom" {
|
||||
HStack {
|
||||
Text("Каждые").foregroundColor(Color(hex: "8888aa")).font(.callout)
|
||||
TextField("1", text: $recurrenceInterval).keyboardType(.numberPad)
|
||||
.foregroundColor(.white).frame(width: 50).padding(8)
|
||||
.background(RoundedRectangle(cornerRadius: 8).fill(Color.white.opacity(0.07)))
|
||||
Text("дней").foregroundColor(Color(hex: "8888aa")).font(.callout)
|
||||
}
|
||||
}
|
||||
HStack {
|
||||
Label("Дата окончания", systemImage: "calendar.badge.minus").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
Toggle("", isOn: $hasRecurrenceEnd).tint(Color(hex: "0D9488")).labelsHidden()
|
||||
}
|
||||
if hasRecurrenceEnd {
|
||||
DatePicker("", selection: $recurrenceEndDate, in: Date()..., displayedComponents: .date)
|
||||
.labelsHidden()
|
||||
.colorInvert()
|
||||
.colorMultiply(Color(hex: "0D9488"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -124,20 +188,34 @@ struct AddTaskView: View {
|
||||
|
||||
func save() {
|
||||
isLoading = true
|
||||
errorMessage = nil
|
||||
let df = DateFormatter(); df.dateFormat = "yyyy-MM-dd"
|
||||
let dueDateStr = hasDueDate ? df.string(from: dueDate) : nil
|
||||
let recEndStr = (isRecurring && hasRecurrenceEnd) ? df.string(from: recurrenceEndDate) : nil
|
||||
let interval = recurrenceType == "custom" ? (Int(recurrenceInterval) ?? 1) : nil
|
||||
Task {
|
||||
let req = CreateTaskRequest(
|
||||
title: title,
|
||||
description: description.isEmpty ? nil : description,
|
||||
priority: priority,
|
||||
dueDate: dueDateStr,
|
||||
icon: selectedIcon,
|
||||
color: selectedColor
|
||||
)
|
||||
try? await APIService.shared.createTask(token: authManager.token, request: req)
|
||||
await onAdded()
|
||||
await MainActor.run { isPresented = false }
|
||||
do {
|
||||
let req = CreateTaskRequest(
|
||||
title: title,
|
||||
description: description.isEmpty ? nil : description,
|
||||
priority: priority,
|
||||
dueDate: dueDateStr,
|
||||
icon: selectedIcon,
|
||||
color: selectedColor,
|
||||
isRecurring: isRecurring ? true : nil,
|
||||
recurrenceType: isRecurring ? recurrenceType : nil,
|
||||
recurrenceInterval: interval,
|
||||
recurrenceEndDate: recEndStr
|
||||
)
|
||||
try await APIService.shared.createTask(token: authManager.token, request: req)
|
||||
await onAdded()
|
||||
await MainActor.run { isPresented = false }
|
||||
} catch {
|
||||
await MainActor.run {
|
||||
errorMessage = error.localizedDescription
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,24 @@ struct EditTaskView: View {
|
||||
@State private var selectedColor: String
|
||||
@State private var hasDueDate: Bool
|
||||
@State private var dueDate: Date
|
||||
@State private var isRecurring: Bool
|
||||
@State private var recurrenceType: String
|
||||
@State private var recurrenceInterval: String
|
||||
@State private var hasRecurrenceEnd: Bool
|
||||
@State private var recurrenceEndDate: Date
|
||||
@State private var isLoading = false
|
||||
|
||||
let recurrenceTypes: [(String, String)] = [
|
||||
("daily", "Ежедневно"),
|
||||
("weekly", "Еженедельно"),
|
||||
("monthly", "Ежемесячно"),
|
||||
("custom", "Каждые N дней")
|
||||
]
|
||||
|
||||
let priorities: [(Int, String, String)] = [
|
||||
(1, "Низкий", "8888aa"),
|
||||
(2, "Средний", "ffa502"),
|
||||
(3, "Высокий", "ff4757"),
|
||||
(4, "Срочный", "ff0000")
|
||||
(3, "Высокий", "ff4757")
|
||||
]
|
||||
let icons = ["✅","📌","🎯","💼","🏠","🛒","📞","🎓","💊","🚗",
|
||||
"📅","⚡","🔧","📬","💡","🏋️","🌿","🎵","✍️","🌏"]
|
||||
@@ -42,6 +53,16 @@ struct EditTaskView: View {
|
||||
self._hasDueDate = State(initialValue: false)
|
||||
self._dueDate = State(initialValue: Date())
|
||||
}
|
||||
self._isRecurring = State(initialValue: task.isRecurring ?? false)
|
||||
self._recurrenceType = State(initialValue: task.recurrenceType ?? "daily")
|
||||
self._recurrenceInterval = State(initialValue: String(task.recurrenceInterval ?? 1))
|
||||
if let endStr = task.recurrenceEndDate, let parsed = Self.parseDate(endStr) {
|
||||
self._hasRecurrenceEnd = State(initialValue: true)
|
||||
self._recurrenceEndDate = State(initialValue: parsed)
|
||||
} else {
|
||||
self._hasRecurrenceEnd = State(initialValue: false)
|
||||
self._recurrenceEndDate = State(initialValue: Date().addingTimeInterval(86400 * 30))
|
||||
}
|
||||
}
|
||||
|
||||
static func parseDate(_ str: String) -> Date? {
|
||||
@@ -52,21 +73,22 @@ struct EditTaskView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color(hex: "0a0a1a").ignoresSafeArea()
|
||||
Color(hex: "06060f").ignoresSafeArea()
|
||||
VStack(spacing: 0) {
|
||||
RoundedRectangle(cornerRadius: 3)
|
||||
.fill(Color.white.opacity(0.2)).frame(width: 40, height: 4).padding(.top, 12)
|
||||
HStack {
|
||||
Button("Отмена") { isPresented = false }.foregroundColor(Color(hex: "8888aa"))
|
||||
Button("Отмена") { isPresented = false }
|
||||
.font(.callout).foregroundColor(Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
Text("Редактировать задачу").font(.headline).foregroundColor(.white)
|
||||
Text("Редактировать").font(.headline).foregroundColor(.white)
|
||||
Spacer()
|
||||
Button(action: save) {
|
||||
if isLoading { ProgressView().tint(Color(hex: "0D9488")).scaleEffect(0.8) }
|
||||
else { Text("Сохранить").foregroundColor(title.isEmpty ? Color(hex: "8888aa") : Color(hex: "0D9488")).fontWeight(.semibold) }
|
||||
if isLoading { ProgressView().tint(Theme.teal).scaleEffect(0.8) }
|
||||
else { Text("Готово").font(.callout.bold()).foregroundColor(title.isEmpty ? Color(hex: "8888aa") : Theme.teal) }
|
||||
}.disabled(title.isEmpty || isLoading)
|
||||
}
|
||||
.padding(.horizontal, 20).padding(.vertical, 16)
|
||||
.padding(.horizontal, 16).padding(.vertical, 14)
|
||||
Divider().background(Color.white.opacity(0.1))
|
||||
ScrollView {
|
||||
VStack(spacing: 16) {
|
||||
@@ -123,7 +145,7 @@ struct EditTaskView: View {
|
||||
}
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Label("Цвет", systemImage: "paintpalette").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
HStack(spacing: 10) {
|
||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 5), spacing: 10) {
|
||||
ForEach(colors, id: \.self) { c in
|
||||
Button(action: { selectedColor = c }) {
|
||||
Circle().fill(Color(hex: String(c.dropFirst()))).frame(width: 32, height: 32)
|
||||
@@ -133,6 +155,49 @@ struct EditTaskView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Recurrence
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
HStack {
|
||||
Label("Повторение", systemImage: "repeat").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
Toggle("", isOn: $isRecurring).tint(Color(hex: "0D9488")).labelsHidden()
|
||||
}
|
||||
if isRecurring {
|
||||
VStack(spacing: 8) {
|
||||
ForEach(recurrenceTypes, id: \.0) { rt in
|
||||
Button(action: { recurrenceType = rt.0 }) {
|
||||
HStack {
|
||||
Text(rt.1).foregroundColor(recurrenceType == rt.0 ? .white : Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
if recurrenceType == rt.0 { Image(systemName: "checkmark").foregroundColor(Color(hex: "0D9488")) }
|
||||
}
|
||||
.padding(12)
|
||||
.background(RoundedRectangle(cornerRadius: 10).fill(recurrenceType == rt.0 ? Color(hex: "0D9488").opacity(0.15) : Color.white.opacity(0.05)))
|
||||
}
|
||||
}
|
||||
if recurrenceType == "custom" {
|
||||
HStack {
|
||||
Text("Каждые").foregroundColor(Color(hex: "8888aa")).font(.callout)
|
||||
TextField("1", text: $recurrenceInterval).keyboardType(.numberPad)
|
||||
.foregroundColor(.white).frame(width: 50).padding(8)
|
||||
.background(RoundedRectangle(cornerRadius: 8).fill(Color.white.opacity(0.07)))
|
||||
Text("дней").foregroundColor(Color(hex: "8888aa")).font(.callout)
|
||||
}
|
||||
}
|
||||
HStack {
|
||||
Label("Дата окончания", systemImage: "calendar.badge.minus").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
Toggle("", isOn: $hasRecurrenceEnd).tint(Color(hex: "0D9488")).labelsHidden()
|
||||
}
|
||||
if hasRecurrenceEnd {
|
||||
DatePicker("", selection: $recurrenceEndDate, in: Date()..., displayedComponents: .date)
|
||||
.labelsHidden()
|
||||
.colorInvert()
|
||||
.colorMultiply(Color(hex: "0D9488"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.padding(20)
|
||||
}
|
||||
}
|
||||
@@ -143,13 +208,21 @@ struct EditTaskView: View {
|
||||
isLoading = true
|
||||
let df = DateFormatter(); df.dateFormat = "yyyy-MM-dd"
|
||||
let dueDateStr = hasDueDate ? df.string(from: dueDate) : nil
|
||||
let recEndStr = (isRecurring && hasRecurrenceEnd) ? df.string(from: recurrenceEndDate) : nil
|
||||
let interval = recurrenceType == "custom" ? (Int(recurrenceInterval) ?? 1) : nil
|
||||
Task {
|
||||
let req = UpdateTaskRequest(
|
||||
title: title,
|
||||
description: description.isEmpty ? nil : description,
|
||||
priority: priority,
|
||||
dueDate: dueDateStr,
|
||||
completed: nil
|
||||
completed: nil,
|
||||
icon: selectedIcon,
|
||||
color: selectedColor,
|
||||
isRecurring: isRecurring ? true : nil,
|
||||
recurrenceType: isRecurring ? recurrenceType : nil,
|
||||
recurrenceInterval: interval,
|
||||
recurrenceEndDate: recEndStr
|
||||
)
|
||||
try? await APIService.shared.updateTask(token: authManager.token, id: task.id, request: req)
|
||||
await onSaved()
|
||||
|
||||
@@ -23,7 +23,7 @@ struct TasksView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color(hex: "0a0a1a").ignoresSafeArea()
|
||||
Color(hex: "06060f").ignoresSafeArea()
|
||||
VStack(spacing: 0) {
|
||||
// Header
|
||||
HStack {
|
||||
@@ -76,9 +76,9 @@ struct TasksView: View {
|
||||
}
|
||||
.sheet(isPresented: $showAddTask) {
|
||||
AddTaskView(isPresented: $showAddTask) { await loadTasks() }
|
||||
.presentationDetents([.medium, .large])
|
||||
.presentationDetents([.large])
|
||||
.presentationDragIndicator(.visible)
|
||||
.presentationBackground(Color(hex: "0a0a1a"))
|
||||
.presentationBackground(Color(hex: "06060f"))
|
||||
}
|
||||
.task { await loadTasks() }
|
||||
.refreshable { await loadTasks(refresh: true) }
|
||||
|
||||
Reference in New Issue
Block a user