From 59cc78fa26160478d8991c21d7679eab9de63a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Tr=C3=A9guier?= Date: Fri, 23 Aug 2024 12:58:46 +0200 Subject: [PATCH] Fix incorrect form section margin --- Fyreplace/Views/Screens/LoginScreen.swift | 24 +++++++++---------- .../Views/Screens/LoginScreenProtocol.swift | 7 ++++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Fyreplace/Views/Screens/LoginScreen.swift b/Fyreplace/Views/Screens/LoginScreen.swift index 444de1a..ecaf1ed 100644 --- a/Fyreplace/Views/Screens/LoginScreen.swift +++ b/Fyreplace/Views/Screens/LoginScreen.swift @@ -36,27 +36,25 @@ struct LoginScreen: View, LoginScreenProtocol { .disabled(!canSubmit) .matchedGeometryEffect(id: "submit", in: namespace) - let cancelButton = Button(role: .cancel) { - withAnimation { - isWaitingForRandomCode = false - randomCode = "" - } - } label: { + let cancelButton = Button(role: .cancel, action: cancel) { Text("Cancel").padding(.horizontal) } .disabled(!isWaitingForRandomCode) + let footer = isWaitingForRandomCode + ? VStack { + if isWaitingForRandomCode { + Text("Login.Help.RandomCode") + } + } + : nil + DynamicForm { Section( header: LogoHeader(text: "Login.Header", namespace: namespace), - footer: VStack { - if isWaitingForRandomCode { - Text("Login.Help.RandomCode") - } - } + footer: footer ) { - EnvironmentPicker(namespace: namespace) - .disabled(isWaitingForRandomCode) + EnvironmentPicker(namespace: namespace).disabled(isWaitingForRandomCode) TextField("Login.Identifier", text: $identifier, prompt: Text("Login.Identifier.Prompt")) .autocorrectionDisabled() diff --git a/Fyreplace/Views/Screens/LoginScreenProtocol.swift b/Fyreplace/Views/Screens/LoginScreenProtocol.swift index ec40f94..e0e5f9d 100644 --- a/Fyreplace/Views/Screens/LoginScreenProtocol.swift +++ b/Fyreplace/Views/Screens/LoginScreenProtocol.swift @@ -28,6 +28,13 @@ extension LoginScreenProtocol { } } + func cancel() { + withAnimation { + isWaitingForRandomCode = false + randomCode = "" + } + } + func sendEmail() async throws -> Bool { let response = try await client.createNewToken(body: .json(.init(identifier: identifier)))