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>
60 lines
2.1 KiB
Swift
60 lines
2.1 KiB
Swift
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
|
|
}
|
|
}
|