Files
pulse-mobile/PulseHealth/Views/Tasks/AddTaskView.swift
Cosmo c015824b36 feat: полноценное Pulse приложение с TabBar
- Auth: переключено на Pulse API (api.digital-home.site) вместо health
- TabBar: Главная, Задачи, Привычки, Здоровье, Финансы
- Models: TaskModels, HabitModels, FinanceModels, обновлённые AuthModels
- Services: APIService (Pulse API), HealthAPIService (health отдельно)
- Dashboard: обзор дня с задачами, привычками, readiness, балансом
- Tasks: список, фильтр, создание, выполнение, удаление
- Habits: список с прогресс-баром, отметка выполнения, стрики
- Health: бывший DashboardView, HealthKit sync через health API key
- Finance: баланс, список транзакций, добавление расхода/дохода
- Health данные через x-api-key вместо JWT токена health сервиса
2026-03-25 11:49:52 +00:00

56 lines
2.3 KiB
Swift

import SwiftUI
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: TaskPriority = .medium
@State private var isLoading = false
var body: some View {
NavigationView {
ZStack {
Color(hex: "0a0a1a").ignoresSafeArea()
VStack(spacing: 20) {
TextField("Название задачи", text: $title)
.padding().background(Color.white.opacity(0.08)).cornerRadius(12).foregroundColor(.white)
TextField("Описание (необязательно)", text: $description)
.padding().background(Color.white.opacity(0.08)).cornerRadius(12).foregroundColor(.white)
Picker("Приоритет", selection: $priority) {
ForEach(TaskPriority.allCases, id: \.self) { p in Text(p.displayName).tag(p) }
}
.pickerStyle(.segmented)
Spacer()
}.padding()
}
.navigationTitle("Новая задача")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Отмена") { isPresented = false }
}
ToolbarItem(placement: .confirmationAction) {
Button("Добавить") {
isLoading = true
Task {
let req = CreateTaskRequest(
title: title,
description: description.isEmpty ? nil : description,
priority: priority
)
try? await APIService.shared.createTask(token: authManager.token, request: req)
await onAdded()
await MainActor.run { isPresented = false }
}
}
.disabled(title.isEmpty || isLoading)
}
}
.preferredColorScheme(.dark)
}
}
}