1eb21c71ce
- 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>
72 lines
2.5 KiB
Swift
72 lines
2.5 KiB
Swift
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()
|
|
}
|
|
}
|
|
}
|
|
}
|