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:
@@ -1,77 +1,13 @@
|
||||
import SwiftUI
|
||||
|
||||
// ProfileView is now replaced by SettingsView in MainTabView.
|
||||
// This file is kept for legacy support (ChangePasswordView is here).
|
||||
|
||||
struct ProfileView: View {
|
||||
@EnvironmentObject var authManager: AuthManager
|
||||
@State private var showChangePassword = false
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color(hex: "0a0a1a").ignoresSafeArea()
|
||||
VStack(spacing: 0) {
|
||||
// Header
|
||||
VStack(spacing: 12) {
|
||||
ZStack {
|
||||
Circle().fill(Color(hex: "00d4aa").opacity(0.2)).frame(width: 80, height: 80)
|
||||
Text(String(authManager.userName.prefix(1)).uppercased())
|
||||
.font(.largeTitle.bold()).foregroundColor(Color(hex: "00d4aa"))
|
||||
}
|
||||
Text(authManager.userName).font(.title2.bold()).foregroundColor(.white)
|
||||
}
|
||||
.padding(.top, 40).padding(.bottom, 32)
|
||||
|
||||
// Settings list
|
||||
VStack(spacing: 2) {
|
||||
ProfileRow(icon: "lock.fill", title: "Сменить пароль", color: "7c3aed") {
|
||||
showChangePassword = true
|
||||
}
|
||||
ProfileRow(icon: "heart.fill", title: "Health API ключ", subtitle: authManager.healthApiKey, color: "ff4757") {}
|
||||
Divider().background(Color.white.opacity(0.1)).padding(.vertical, 8)
|
||||
ProfileRow(icon: "rectangle.portrait.and.arrow.right", title: "Выйти", color: "ff4757", isDestructive: true) {
|
||||
authManager.logout()
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
|
||||
Spacer()
|
||||
|
||||
Text("Pulse v1.0").font(.caption).foregroundColor(Color(hex: "8888aa")).padding(.bottom, 20)
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showChangePassword) {
|
||||
ChangePasswordView(isPresented: $showChangePassword)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ProfileRow: View {
|
||||
let icon: String
|
||||
let title: String
|
||||
var subtitle: String? = nil
|
||||
let color: String
|
||||
var isDestructive: Bool = false
|
||||
let action: () -> Void
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
HStack(spacing: 14) {
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: 8).fill(Color(hex: color).opacity(0.2)).frame(width: 36, height: 36)
|
||||
Image(systemName: icon).foregroundColor(Color(hex: color)).font(.subheadline)
|
||||
}
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(title).foregroundColor(isDestructive ? Color(hex: "ff4757") : .white).font(.callout)
|
||||
if let sub = subtitle {
|
||||
Text(sub).font(.caption).foregroundColor(Color(hex: "8888aa"))
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
if !isDestructive {
|
||||
Image(systemName: "chevron.right").foregroundColor(Color(hex: "8888aa")).font(.caption)
|
||||
}
|
||||
}
|
||||
.padding(14)
|
||||
.background(RoundedRectangle(cornerRadius: 12).fill(Color.white.opacity(0.05)))
|
||||
}
|
||||
SettingsView()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,17 +22,19 @@ struct ChangePasswordView: View {
|
||||
@State private var success = false
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack {
|
||||
Color(hex: "0a0a1a").ignoresSafeArea()
|
||||
VStack(spacing: 16) {
|
||||
if success {
|
||||
VStack(spacing: 12) {
|
||||
Text("✅").font(.system(size: 50))
|
||||
Text("Пароль изменён!").font(.title2.bold()).foregroundColor(.white)
|
||||
}.padding(.top, 40)
|
||||
Button("Закрыть") { isPresented = false }.foregroundColor(Color(hex: "00d4aa"))
|
||||
} else {
|
||||
ZStack {
|
||||
Color(hex: "0a0a1a").ignoresSafeArea()
|
||||
VStack(spacing: 16) {
|
||||
RoundedRectangle(cornerRadius: 3).fill(Color.white.opacity(0.2)).frame(width: 40, height: 4).padding(.top, 12)
|
||||
Text("Смена пароля").font(.title3.bold()).foregroundColor(.white).padding(.top, 4)
|
||||
if success {
|
||||
VStack(spacing: 12) {
|
||||
Text("✅").font(.system(size: 50))
|
||||
Text("Пароль изменён!").font(.title2.bold()).foregroundColor(.white)
|
||||
}.padding(.top, 40)
|
||||
Button("Закрыть") { isPresented = false }.foregroundColor(Color(hex: "0D9488"))
|
||||
} else {
|
||||
VStack(spacing: 12) {
|
||||
SecureField("Текущий пароль", text: $oldPassword)
|
||||
.padding().background(Color.white.opacity(0.08)).cornerRadius(12).foregroundColor(.white)
|
||||
SecureField("Новый пароль", text: $newPassword)
|
||||
@@ -111,16 +49,14 @@ struct ChangePasswordView: View {
|
||||
else { Text("Сменить").font(.headline).foregroundColor(.black) }
|
||||
}
|
||||
.frame(maxWidth: .infinity).padding()
|
||||
.background(Color(hex: "00d4aa")).cornerRadius(12)
|
||||
.background(Color(hex: "0D9488")).cornerRadius(12)
|
||||
.disabled(oldPassword.isEmpty || newPassword.isEmpty || isLoading)
|
||||
}
|
||||
Spacer()
|
||||
}.padding()
|
||||
}
|
||||
.navigationTitle("Смена пароля")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar { ToolbarItem(placement: .cancellationAction) { Button("Отмена") { isPresented = false } } }
|
||||
.preferredColorScheme(.dark)
|
||||
Button("Отмена") { isPresented = false }
|
||||
.foregroundColor(Color(hex: "8888aa")).padding(.top, 4)
|
||||
}
|
||||
Spacer()
|
||||
}.padding()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,11 +72,8 @@ struct ChangePasswordView: View {
|
||||
req.httpBody = try? JSONEncoder().encode(["old_password": oldPassword, "new_password": newPassword])
|
||||
let (_, response) = (try? await URLSession.shared.data(for: req)) ?? (Data(), nil)
|
||||
await MainActor.run {
|
||||
if (response as? HTTPURLResponse)?.statusCode == 200 {
|
||||
success = true
|
||||
} else {
|
||||
errorMessage = "Неверный текущий пароль"
|
||||
}
|
||||
if (response as? HTTPURLResponse)?.statusCode == 200 { success = true }
|
||||
else { errorMessage = "Неверный текущий пароль" }
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user