feat: add complete Mayday iOS Xcode project

- Swift 6, SwiftUI, MVVM + async/await architecture
- iOS 17.0 minimum deployment target
- Two targets: Mayday app + MaydayLiveActivity widget extension
- Models: UserResponse, TokenPair, AppNotification, SessionResponse, AlertAttributes
- Services: HTTPClient (actor), AuthService, KeychainService, NotificationsAPIService, PushNotificationService
- ViewModels: AuthViewModel, NotificationsViewModel, SettingsViewModel
- Views: Login/Register/VerifyEmail, NotificationsList/Detail, Settings/ChangePassword/Sessions
- APNs push notifications with UIApplicationDelegate
- ActivityKit Live Activities for Dynamic Island + Lock Screen
- Keychain (Security framework) token storage
- 30-second polling with pagination for notifications
- Xcode project file (project.pbxproj) with correct build phases for both targets

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-13 23:04:35 +00:00
parent 0bb4d89a09
commit 1eb21c71ce
33 changed files with 2605 additions and 0 deletions
@@ -0,0 +1,59 @@
import SwiftUI
struct ChangePasswordView: View {
@StateObject private var viewModel = SettingsViewModel()
@Environment(\.dismiss) var dismiss
@State private var currentPassword = ""
@State private var newPassword = ""
@State private var confirmPassword = ""
var body: some View {
NavigationStack {
Form {
Section {
SecureField("Текущий пароль", text: $currentPassword)
.textContentType(.password)
SecureField("Новый пароль", text: $newPassword)
.textContentType(.newPassword)
SecureField("Подтвердите новый пароль", text: $confirmPassword)
.textContentType(.newPassword)
}
if let error = viewModel.error {
Section {
Text(error).foregroundStyle(.red)
}
}
if let success = viewModel.successMessage {
Section {
Text(success).foregroundStyle(.green)
}
}
Section {
Button("Сохранить") {
Task {
let success = await viewModel.changePassword(current: currentPassword, new: newPassword)
if success { dismiss() }
}
}
.disabled(!isFormValid || viewModel.isLoading)
.frame(maxWidth: .infinity)
}
}
.navigationTitle("Сменить пароль")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button("Отмена") { dismiss() }
}
}
}
}
var isFormValid: Bool {
!currentPassword.isEmpty && newPassword.count >= 8 && newPassword == confirmPassword
}
}
+53
View File
@@ -0,0 +1,53 @@
import SwiftUI
struct SessionsView: View {
@EnvironmentObject var viewModel: SettingsViewModel
@Environment(\.dismiss) var dismiss
var body: some View {
NavigationStack {
List {
ForEach(viewModel.sessions) { session in
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(session.userAgent)
.font(.body)
.lineLimit(1)
if session.isCurrent {
Text("Текущая")
.font(.caption)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(Color.green.opacity(0.2))
.foregroundStyle(.green)
.cornerRadius(4)
}
}
Text(session.ipAddress)
.font(.caption)
.foregroundStyle(.secondary)
Text("Создана: \(session.createdAt.formatted(date: .abbreviated, time: .shortened))")
.font(.caption2)
.foregroundStyle(.secondary)
}
.swipeActions(edge: .trailing) {
if !session.isCurrent {
Button(role: .destructive) {
Task { await viewModel.deleteSession(session) }
} label: {
Label("Удалить", systemImage: "trash")
}
}
}
}
}
.navigationTitle("Активные сессии")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Готово") { dismiss() }
}
}
}
}
}
+96
View File
@@ -0,0 +1,96 @@
import SwiftUI
struct SettingsView: View {
@EnvironmentObject var authViewModel: AuthViewModel
@StateObject private var viewModel = SettingsViewModel()
@Environment(\.dismiss) var dismiss
@State private var showChangePassword = false
@State private var showSessions = false
@State private var showLogoutAllConfirm = false
var body: some View {
NavigationStack {
Form {
Section("Аккаунт") {
if let user = authViewModel.currentUser {
LabeledContent("Email", value: user.email)
}
}
Section {
Button("Сменить пароль") {
showChangePassword = true
}
Toggle(isOn: .constant(true)) {
Label("Push-уведомления", systemImage: "bell.badge")
}
.onChange(of: true) { _, _ in
// Open system settings
if let url = URL(string: UIApplication.openNotificationSettingsURLString) {
UIApplication.shared.open(url)
}
}
}
Section {
Button {
showSessions = true
} label: {
HStack {
Text("Активные сессии")
Spacer()
if !viewModel.sessions.isEmpty {
Text("(\(viewModel.sessions.count))")
.foregroundStyle(.secondary)
}
Image(systemName: "chevron.right")
.foregroundStyle(.secondary)
}
}
.foregroundStyle(.primary)
}
Section {
Button("Выйти из аккаунта", role: .destructive) {
Task { await authViewModel.logout() }
}
Button("Выйти на всех устройствах", role: .destructive) {
showLogoutAllConfirm = true
}
}
}
.navigationTitle("Настройки")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Готово") { dismiss() }
}
}
.sheet(isPresented: $showChangePassword) {
ChangePasswordView()
}
.sheet(isPresented: $showSessions) {
SessionsView()
.environmentObject(viewModel)
}
.confirmationDialog(
"Выйти на всех устройствах?",
isPresented: $showLogoutAllConfirm,
titleVisibility: .visible
) {
Button("Выйти везде", role: .destructive) {
Task {
_ = try? await NotificationsAPIService.shared.logoutAll()
await authViewModel.logout()
}
}
Button("Отмена", role: .cancel) {}
}
.task {
await viewModel.loadSessions()
}
}
}
}