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
+71
View File
@@ -0,0 +1,71 @@
import SwiftUI
struct LoginView: View {
@EnvironmentObject var authViewModel: AuthViewModel
@State private var email = ""
@State private var password = ""
@State private var showRegister = false
var body: some View {
NavigationStack {
VStack(spacing: 24) {
Spacer()
VStack(spacing: 8) {
Image(systemName: "bell.badge.fill")
.font(.system(size: 60))
.foregroundStyle(.red)
Text("Mayday")
.font(.largeTitle.bold())
Text("Мониторинг и уведомления")
.font(.subheadline)
.foregroundStyle(.secondary)
}
VStack(spacing: 16) {
TextField("Email", text: $email)
.textFieldStyle(.roundedBorder)
.textContentType(.emailAddress)
.keyboardType(.emailAddress)
.autocorrectionDisabled()
.textInputAutocapitalization(.never)
SecureField("Пароль", text: $password)
.textFieldStyle(.roundedBorder)
.textContentType(.password)
}
if let error = authViewModel.error {
Text(error)
.foregroundStyle(.red)
.font(.footnote)
.multilineTextAlignment(.center)
}
Button {
Task { await authViewModel.login(email: email, password: password) }
} label: {
if authViewModel.isLoading {
ProgressView()
.frame(maxWidth: .infinity)
} else {
Text("Войти")
.frame(maxWidth: .infinity)
}
}
.buttonStyle(.borderedProminent)
.disabled(email.isEmpty || password.isEmpty || authViewModel.isLoading)
Button("Нет аккаунта? Зарегистрироваться") {
showRegister = true
}
.font(.footnote)
Spacer()
}
.padding()
.navigationDestination(isPresented: $showRegister) {
RegisterView()
}
}
}
}
+90
View File
@@ -0,0 +1,90 @@
import SwiftUI
struct RegisterView: View {
@EnvironmentObject var authViewModel: AuthViewModel
@Environment(\.dismiss) var dismiss
@State private var email = ""
@State private var password = ""
@State private var confirmPassword = ""
@State private var showVerify = false
@State private var registeredEmail = ""
var body: some View {
VStack(spacing: 24) {
Spacer()
Text("Регистрация")
.font(.largeTitle.bold())
VStack(spacing: 16) {
TextField("Email", text: $email)
.textFieldStyle(.roundedBorder)
.textContentType(.emailAddress)
.keyboardType(.emailAddress)
.autocorrectionDisabled()
.textInputAutocapitalization(.never)
SecureField("Пароль", text: $password)
.textFieldStyle(.roundedBorder)
.textContentType(.newPassword)
SecureField("Подтвердите пароль", text: $confirmPassword)
.textFieldStyle(.roundedBorder)
.textContentType(.newPassword)
}
if password.count > 0 && password.count < 8 {
Text("Пароль должен содержать не менее 8 символов")
.foregroundStyle(.red)
.font(.footnote)
}
if confirmPassword.count > 0 && password != confirmPassword {
Text("Пароли не совпадают")
.foregroundStyle(.red)
.font(.footnote)
}
if let error = authViewModel.error {
Text(error)
.foregroundStyle(.red)
.font(.footnote)
.multilineTextAlignment(.center)
}
Button {
Task {
let success = await authViewModel.register(email: email, password: password)
if success {
registeredEmail = email
showVerify = true
}
}
} label: {
if authViewModel.isLoading {
ProgressView().frame(maxWidth: .infinity)
} else {
Text("Создать аккаунт").frame(maxWidth: .infinity)
}
}
.buttonStyle(.borderedProminent)
.disabled(!isFormValid || authViewModel.isLoading)
Button("Уже есть аккаунт?") { dismiss() }
.font(.footnote)
Spacer()
}
.padding()
.navigationDestination(isPresented: $showVerify) {
VerifyEmailView(email: registeredEmail)
}
.navigationTitle("Регистрация")
.navigationBarTitleDisplayMode(.inline)
}
var isFormValid: Bool {
!email.isEmpty && password.count >= 8 && password == confirmPassword
}
}
+119
View File
@@ -0,0 +1,119 @@
import SwiftUI
struct VerifyEmailView: View {
let email: String
@EnvironmentObject var authViewModel: AuthViewModel
@State private var codeDigits: [String] = Array(repeating: "", count: 6)
@State private var resendCooldown = 0
@FocusState private var focusedIndex: Int?
@State private var resendTimer: Timer?
var body: some View {
VStack(spacing: 32) {
Spacer()
VStack(spacing: 8) {
Text("Подтвердите email")
.font(.largeTitle.bold())
Text("Код отправлен на")
.foregroundStyle(.secondary)
Text(email)
.fontWeight(.semibold)
}
HStack(spacing: 12) {
ForEach(0..<6, id: \.self) { index in
TextField("", text: $codeDigits[index])
.frame(width: 44, height: 52)
.multilineTextAlignment(.center)
.font(.title2.bold())
.keyboardType(.numberPad)
.textContentType(.oneTimeCode)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(focusedIndex == index ? Color.accentColor : Color.secondary, lineWidth: 2)
)
.focused($focusedIndex, equals: index)
.onChange(of: codeDigits[index]) { _, newValue in
handleDigitChange(index: index, value: newValue)
}
}
}
if let error = authViewModel.error {
Text(error)
.foregroundStyle(.red)
.font(.footnote)
}
Button {
Task { await resendCode() }
} label: {
if resendCooldown > 0 {
Text("Отправить повторно (\(resendCooldown) сек)")
} else {
Text("Отправить повторно")
}
}
.disabled(resendCooldown > 0)
Spacer()
}
.padding()
.navigationTitle("Подтверждение")
.navigationBarTitleDisplayMode(.inline)
.onAppear { focusedIndex = 0 }
}
private func handleDigitChange(index: Int, value: String) {
let filtered = value.filter { $0.isNumber }
if filtered.count > 1 {
// Paste handling
let digits = Array(filtered.prefix(6))
for (i, d) in digits.enumerated() where i < 6 {
codeDigits[i] = String(d)
}
focusedIndex = min(digits.count, 5)
} else {
codeDigits[index] = filtered.isEmpty ? "" : String(filtered.last!)
if !filtered.isEmpty && index < 5 {
focusedIndex = index + 1
}
}
let code = codeDigits.joined()
if code.count == 6 {
Task { await submitCode(code) }
}
}
private func submitCode(_ code: String) async {
await authViewModel.verifyEmail(email: email, code: code)
if authViewModel.error == nil {
// Auto-login after verification - in a real flow we'd re-login here
// since verify doesn't return tokens
}
}
private func resendCode() async {
do {
try await AuthService.shared.resendCode(email: email)
resendCooldown = 60
startCooldownTimer()
} catch {
authViewModel.error = error.localizedDescription
}
}
private func startCooldownTimer() {
resendTimer?.invalidate()
resendTimer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
if resendCooldown > 0 {
resendCooldown -= 1
} else {
resendTimer?.invalidate()
}
}
}
}