Files
MatchLiveTv/native/ios/MatchLiveTv/UI/Login/ForgotPasswordScreen.swift
T
Emiliano FrascaroandCursor 50b8a8c8e2 Allinea iOS ad Android sul dialog Configura/Più tardi e porta l'app a 2.0.12.
Aggiunge UI test sul simulatore (hub, lingue, wizard, diretta) e identificatori di accessibilità per poterli ripetere su collaudo e produzione.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-31 17:54:33 +02:00

94 lines
3.6 KiB
Swift

import SwiftUI
struct ForgotPasswordScreen: View {
@ObservedObject var container: AppContainer
let onBack: () -> Void
@State private var email = ""
@State private var loading = false
@State private var error: String?
@State private var success = false
@State private var languageTick = 0
var body: some View {
MatchScreenScaffold(
topBar: {
HStack {
Button(action: onBack) {
Image(systemName: "chevron.left")
.foregroundStyle(MatchColors.textSecondary)
}
.accessibilityIdentifier("forgot.back")
Text(L10n.t("forgot.password.title"))
.font(MatchTypography.headlineMedium)
.foregroundStyle(.white)
Spacer()
}
.padding(.horizontal, 16)
.padding(.vertical, 8)
},
content: {
ScrollView {
VStack(spacing: 16) {
Text(L10n.t("forgot.password.lead"))
.font(MatchTypography.bodyMedium)
.foregroundStyle(MatchColors.textSecondary)
.multilineTextAlignment(.center)
VStack(alignment: .leading, spacing: 6) {
Text(L10n.t("login.email"))
.font(MatchTypography.bodyMedium)
.foregroundStyle(MatchColors.textSecondary)
TextField("", text: $email)
.textInputAutocapitalization(.never)
.keyboardType(.emailAddress)
.autocorrectionDisabled()
.disabled(success)
.padding(12)
.overlay(RoundedRectangle(cornerRadius: 8).stroke(MatchColors.outline))
}
if let error {
Text(error)
.foregroundStyle(MatchColors.primaryRed)
.multilineTextAlignment(.center)
}
if success {
Text(L10n.t("forgot.password.success"))
.foregroundStyle(MatchColors.textSecondary)
.multilineTextAlignment(.center)
}
MatchPrimaryButton(
label: L10n.t("forgot.password.submit"),
action: submit,
enabled: !email.trimmingCharacters(in: .whitespaces).isEmpty && !loading && !success,
loading: loading
)
.accessibilityIdentifier("forgot.submit")
}
.padding(24)
}
}
)
.onReceive(NotificationCenter.default.publisher(for: .appLanguageDidChange)) { _ in
languageTick += 1
}
.id(languageTick)
}
private func submit() {
loading = true
error = nil
Task {
do {
_ = try await container.authRepository.forgotPassword(email: email)
success = true
} catch {
self.error = UserFacingError.message(for: error) ?? L10n.t("common.error.generic")
}
loading = false
}
}
}