feat: full Pulse Mobile implementation - all modules
- Phase 0: project.yml fixes (CODE_SIGN_ENTITLEMENTS confirmed) - Phase 1: Enhanced models (HabitModels, TaskModels, FinanceModels, SavingsModels, UserModels) - Phase 1: Enhanced APIService with all endpoints (habits/log/stats, tasks/uncomplete, finance/analytics, savings/*) - Phase 2: DashboardView rewrite - day progress bar, 4 stat cards, habit/task lists with Undo (3 sec) - Phase 3: TrackerView - HabitListView (streak badge, swipe delete, archive), TaskListView (priority, overdue), StatisticsView (heatmap 84 days, line chart, bar chart via Swift Charts) - Phase 4: FinanceView rewrite - month picker, summary card, top expenses progress bars, pie chart, line chart, transactions by day, analytics tab with bar chart + month comparison - Phase 5: SavingsView rewrite - overview with overdue block, categories tab with type icons, operations tab with category filter + add sheet - Phase 6: SettingsView - dark/light theme, profile edit, telegram chat id, notifications toggle + time, timezone picker, logout - Added: AddHabitView with weekly day selector + interval days - Added: AddTaskView with icon/color/due date picker - Haptic feedback on all toggle actions
This commit is contained in:
@@ -4,103 +4,136 @@ struct AddTaskView: View {
|
||||
@Binding var isPresented: Bool
|
||||
@EnvironmentObject var authManager: AuthManager
|
||||
let onAdded: () async -> Void
|
||||
|
||||
|
||||
@State private var title = ""
|
||||
@State private var description = ""
|
||||
@State private var priority: Int = 2
|
||||
@State private var selectedIcon = "✅"
|
||||
@State private var selectedColor = "#0D9488"
|
||||
@State private var hasDueDate = false
|
||||
@State private var dueDate = Date()
|
||||
@State private var isLoading = false
|
||||
|
||||
|
||||
let priorities: [(Int, String, String)] = [
|
||||
(1, "Низкий", "8888aa"),
|
||||
(2, "Средний", "ffa502"),
|
||||
(3, "Высокий", "ff4757"),
|
||||
(4, "Срочный", "ff0000")
|
||||
]
|
||||
|
||||
|
||||
let icons = ["✅","📌","🎯","💼","🏠","🛒","📞","🎓","💊","🚗",
|
||||
"📅","⚡","🔧","📬","💡","🏋️","🌿","🎵","✍️","🌏"]
|
||||
|
||||
let colors = ["#0D9488","#7c3aed","#ff4757","#ffa502","#6366f1",
|
||||
"#ec4899","#14b8a6","#f59e0b","#10b981","#3b82f6"]
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color(hex: "0a0a1a").ignoresSafeArea()
|
||||
|
||||
VStack(spacing: 0) {
|
||||
// Handle
|
||||
RoundedRectangle(cornerRadius: 3)
|
||||
.fill(Color.white.opacity(0.2))
|
||||
.frame(width: 40, height: 4)
|
||||
.padding(.top, 12)
|
||||
|
||||
// Header
|
||||
.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 }.foregroundColor(Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
Text("Новая задача").font(.headline).foregroundColor(.white)
|
||||
Spacer()
|
||||
Button(action: save) {
|
||||
if isLoading { ProgressView().tint(Color(hex: "00d4aa")).scaleEffect(0.8) }
|
||||
else { Text("Добавить").foregroundColor(title.isEmpty ? Color(hex: "8888aa") : Color(hex: "00d4aa")).fontWeight(.semibold) }
|
||||
}
|
||||
.disabled(title.isEmpty || isLoading)
|
||||
if isLoading { ProgressView().tint(Color(hex: "0D9488")).scaleEffect(0.8) }
|
||||
else { Text("Добавить").foregroundColor(title.isEmpty ? Color(hex: "8888aa") : Color(hex: "0D9488")).fontWeight(.semibold) }
|
||||
}.disabled(title.isEmpty || isLoading)
|
||||
}
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 16)
|
||||
|
||||
.padding(.horizontal, 20).padding(.vertical, 16)
|
||||
Divider().background(Color.white.opacity(0.1))
|
||||
|
||||
ScrollView {
|
||||
VStack(spacing: 16) {
|
||||
// Title field
|
||||
// Title
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Label("Название", systemImage: "pencil").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
TextField("Что нужно сделать?", text: $title, axis: .vertical)
|
||||
.lineLimit(1...3)
|
||||
.foregroundColor(.white)
|
||||
.padding(14)
|
||||
.lineLimit(1...3).foregroundColor(.white).padding(14)
|
||||
.background(RoundedRectangle(cornerRadius: 12).fill(Color.white.opacity(0.07)))
|
||||
}
|
||||
|
||||
// Description field
|
||||
// Description
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Label("Описание", systemImage: "text.alignleft").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
TextField("Дополнительные детали...", text: $description, axis: .vertical)
|
||||
.lineLimit(2...5)
|
||||
.foregroundColor(.white)
|
||||
.padding(14)
|
||||
TextField("Детали...", text: $description, axis: .vertical)
|
||||
.lineLimit(2...4).foregroundColor(.white).padding(14)
|
||||
.background(RoundedRectangle(cornerRadius: 12).fill(Color.white.opacity(0.07)))
|
||||
}
|
||||
|
||||
// Priority selector
|
||||
// Priority
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Label("Приоритет", systemImage: "flag.fill").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
HStack(spacing: 8) {
|
||||
ForEach(priorities, id: \.0) { p in
|
||||
Button(action: { priority = p.0 }) {
|
||||
Text(p.1)
|
||||
.font(.caption.bold())
|
||||
Text(p.1).font(.caption.bold())
|
||||
.foregroundColor(priority == p.0 ? .black : Color(hex: p.2))
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 8)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 20)
|
||||
.fill(priority == p.0 ? Color(hex: p.2) : Color(hex: p.2).opacity(0.15))
|
||||
)
|
||||
.padding(.horizontal, 12).padding(.vertical, 8)
|
||||
.background(RoundedRectangle(cornerRadius: 20).fill(priority == p.0 ? Color(hex: p.2) : Color(hex: p.2).opacity(0.15)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(20)
|
||||
// Due Date
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack {
|
||||
Label("Срок выполнения", systemImage: "calendar").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
Spacer()
|
||||
Toggle("", isOn: $hasDueDate).tint(Color(hex: "0D9488")).labelsHidden()
|
||||
}
|
||||
if hasDueDate {
|
||||
DatePicker("", selection: $dueDate, in: Date()..., displayedComponents: .date)
|
||||
.datePickerStyle(.compact)
|
||||
.colorInvert()
|
||||
.colorMultiply(Color(hex: "0D9488"))
|
||||
}
|
||||
}
|
||||
// Icon
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Label("Иконка", systemImage: "face.smiling").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 5), spacing: 8) {
|
||||
ForEach(icons, id: \.self) { icon in
|
||||
Button(action: { selectedIcon = icon }) {
|
||||
Text(icon).font(.title3)
|
||||
.frame(width: 44, height: 44)
|
||||
.background(Circle().fill(selectedIcon == icon ? Color(hex: "0D9488").opacity(0.25) : Color.white.opacity(0.05)))
|
||||
.overlay(Circle().stroke(selectedIcon == icon ? Color(hex: "0D9488") : Color.clear, lineWidth: 2))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Color
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Label("Цвет", systemImage: "paintpalette").font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
HStack(spacing: 10) {
|
||||
ForEach(colors, id: \.self) { c in
|
||||
Button(action: { selectedColor = c }) {
|
||||
Circle().fill(Color(hex: String(c.dropFirst()))).frame(width: 32, height: 32)
|
||||
.overlay(Circle().stroke(.white, lineWidth: selectedColor == c ? 2 : 0))
|
||||
.scaleEffect(selectedColor == c ? 1.15 : 1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.padding(20)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func save() {
|
||||
isLoading = true
|
||||
let df = DateFormatter(); df.dateFormat = "yyyy-MM-dd"
|
||||
let dueDateStr = hasDueDate ? df.string(from: dueDate) : nil
|
||||
Task {
|
||||
let req = CreateTaskRequest(
|
||||
title: title,
|
||||
description: description.isEmpty ? nil : description,
|
||||
priority: priority
|
||||
priority: priority,
|
||||
dueDate: dueDateStr,
|
||||
icon: selectedIcon,
|
||||
color: selectedColor
|
||||
)
|
||||
try? await APIService.shared.createTask(token: authManager.token, request: req)
|
||||
await onAdded()
|
||||
|
||||
Reference in New Issue
Block a user