From 7e609c66ac19180f0c7e12f1c0c33323198ef513 Mon Sep 17 00:00:00 2001 From: Nicolas Buquet Date: Wed, 8 Jan 2025 15:55:39 +0100 Subject: [PATCH] Link to ProConnect availabiity faq article on home screen and ProConnect screen --- Btchap/Config/BuildSettings.swift | 3 ++- DevTchap/Config/BuildSettings.swift | 3 ++- .../Localizations/fr.lproj/Tchap.strings | 2 +- Tchap/Config/BuildSettings.swift | 3 ++- Tchap/Extensions/WebLinks+Tchap.swift | 4 ---- .../View/TchapAuthenticationLoginScreen.swift | 22 ++++++++++++++----- .../View/TchapOnboardingSplashScreen.swift | 7 +++++- .../WebSheet/WebSheetViewController.swift | 17 ++++++++++++++ 8 files changed, 47 insertions(+), 14 deletions(-) diff --git a/Btchap/Config/BuildSettings.swift b/Btchap/Config/BuildSettings.swift index d873f79d1..0fffd896e 100644 --- a/Btchap/Config/BuildSettings.swift +++ b/Btchap/Config/BuildSettings.swift @@ -124,6 +124,7 @@ final class BuildSettings: NSObject { static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/" static let applicationAcceptableUsePolicyUrlString = "" static let proConnectInfoUrlString = "https://proconnect.gouv.fr/" + static let proConnectAvailabilityFaqArticleUrlString = "https://aide.tchap.beta.gouv.fr/fr/article/se-connecter-a-tchap-avec-proconnect-1dh1peg" // MARK: - Matrix permalinks // Hosts/Paths for URLs that will considered as valid permalinks. Those permalinks are opened within the app. @@ -244,7 +245,7 @@ final class BuildSettings: NSObject { ] // Tchap: handle SSO feature flag. Presents SSO button on Onboarding screen and give priority to SSO on UIA. - static let tchapFeatureHandleSSO = false + static let tchapFeatureHandleSSO = true // MARK: - Side Menu static let enableSideMenu: Bool = true && !newAppLayoutEnabled diff --git a/DevTchap/Config/BuildSettings.swift b/DevTchap/Config/BuildSettings.swift index 3b0e39924..5e5881deb 100644 --- a/DevTchap/Config/BuildSettings.swift +++ b/DevTchap/Config/BuildSettings.swift @@ -124,7 +124,8 @@ final class BuildSettings: NSObject { static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/" static let applicationAcceptableUsePolicyUrlString = "" static let proConnectInfoUrlString = "https://proconnect.gouv.fr/" - + static let proConnectAvailabilityFaqArticleUrlString = "https://aide.tchap.beta.gouv.fr/fr/article/se-connecter-a-tchap-avec-proconnect-1dh1peg" + // MARK: - Matrix permalinks // Hosts/Paths for URLs that will considered as valid permalinks. Those permalinks are opened within the app. static let permalinkSupportedHosts: [String: [String]] = [ diff --git a/Tchap/Assets/Localizations/fr.lproj/Tchap.strings b/Tchap/Assets/Localizations/fr.lproj/Tchap.strings index d855601ae..8ac288a11 100644 --- a/Tchap/Assets/Localizations/fr.lproj/Tchap.strings +++ b/Tchap/Assets/Localizations/fr.lproj/Tchap.strings @@ -42,7 +42,7 @@ "authentication_error_limit_exceeded" = "Vos trois dernières tentatives de connexion ont échoué. Veuillez réessayer dans 30 minutes"; "authentication_choose_password_signout_all_devices" = "Déconnecter mes appareils et verrouiller mes messages (en cas de piratage de votre compte ou de la perte d'un appareil)"; -"authentication_sso_warning" = "**Attention** : la connexion à Tchap avec **ProConnect** n'est actuellement disponible que sur les instances suivantes :\n     - DINUM\n     - Agents\n     - Éducation"; // Markdown string for SwiftUI Text() +"authentication_sso_warning" = "→ Est-ce que ProConnect est activé pour mon administration ?"; //////////////////////////////////////////////////////////////////////////////// // MARK: Forgot password diff --git a/Tchap/Config/BuildSettings.swift b/Tchap/Config/BuildSettings.swift index cba961d82..6f946c1dc 100644 --- a/Tchap/Config/BuildSettings.swift +++ b/Tchap/Config/BuildSettings.swift @@ -138,7 +138,8 @@ final class BuildSettings: NSObject { static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/" static let applicationAcceptableUsePolicyUrlString = "" static let proConnectInfoUrlString = "https://proconnect.gouv.fr/" - + static let proConnectAvailabilityFaqArticleUrlString = "https://aide.tchap.beta.gouv.fr/fr/article/se-connecter-a-tchap-avec-proconnect-1dh1peg" + // MARK: - Matrix permalinks // Hosts/Paths for URLs that will considered as valid permalinks. Those permalinks are opened within the app. static let permalinkSupportedHosts: [String: [String]] = [ diff --git a/Tchap/Extensions/WebLinks+Tchap.swift b/Tchap/Extensions/WebLinks+Tchap.swift index 38bc858ac..ce7cb4602 100644 --- a/Tchap/Extensions/WebLinks+Tchap.swift +++ b/Tchap/Extensions/WebLinks+Tchap.swift @@ -20,10 +20,6 @@ import Foundation // becasue UIApplication.shared is not available for extension. @available(iOSApplicationExtension, unavailable) struct TchapWebLinks { - static func openProConnectInfo() { - self.openWebsite(urlString: BuildSettings.proConnectInfoUrlString) - } - static private func openWebsite(urlString: String) { guard let websiteUrl = URL(string: urlString) else { return diff --git a/Tchap/Modules/Authentication/Login/View/TchapAuthenticationLoginScreen.swift b/Tchap/Modules/Authentication/Login/View/TchapAuthenticationLoginScreen.swift index 50d90eb9d..20f37d047 100644 --- a/Tchap/Modules/Authentication/Login/View/TchapAuthenticationLoginScreen.swift +++ b/Tchap/Modules/Authentication/Login/View/TchapAuthenticationLoginScreen.swift @@ -26,7 +26,9 @@ struct TchapAuthenticationLoginScreen: View { /// A boolean that can be toggled to give focus to the password text field. /// This must be manually set back to `false` when the text field finishes editing. @State private var isPasswordFocused = false - + @State private var presentProConnectInfo = false + @State private var presentProConnectAvailabilityFaqArticle = false + // MARK: Public @ObservedObject var viewModel: AuthenticationLoginViewModel.Context @@ -50,6 +52,12 @@ struct TchapAuthenticationLoginScreen: View { .background(theme.colors.background.ignoresSafeArea()) .alert(item: $viewModel.alertInfo) { $0.alert } .accentColor(theme.colors.accent) + .sheet(isPresented: $presentProConnectAvailabilityFaqArticle) { + WebSheetView(targetUrl: URL(string: BuildSettings.proConnectAvailabilityFaqArticleUrlString)!) + } + .sheet(isPresented: $presentProConnectInfo) { + WebSheetView(targetUrl: URL(string: BuildSettings.proConnectInfoUrlString)!) + } } /// The header containing a Welcome Back title. @@ -151,10 +159,10 @@ struct TchapAuthenticationLoginScreen: View { } var ssoInformation: some View { - Text(LocalizedStringKey(TchapL10n.authenticationSsoWarning)) + Button(action: { openProConnectAvailabilityFaqArticle() }, label: { + Text(TchapL10n.authenticationSsoWarning) + }) .padding(.horizontal, 16.0) - .font(.footnote) - .foregroundColor(Color(UIColor(rgb: 0x000091))) } /// Parses the username for a homeserver. @@ -240,7 +248,11 @@ struct TchapAuthenticationLoginScreen: View { } func openProConnectWebsite() { - TchapWebLinks.openProConnectInfo() + presentProConnectInfo = true + } + + func openProConnectAvailabilityFaqArticle() { + presentProConnectAvailabilityFaqArticle = true } } diff --git a/Tchap/Modules/Onboarding/SplashScreen/View/TchapOnboardingSplashScreen.swift b/Tchap/Modules/Onboarding/SplashScreen/View/TchapOnboardingSplashScreen.swift index f936b0567..9778ece9a 100644 --- a/Tchap/Modules/Onboarding/SplashScreen/View/TchapOnboardingSplashScreen.swift +++ b/Tchap/Modules/Onboarding/SplashScreen/View/TchapOnboardingSplashScreen.swift @@ -30,6 +30,7 @@ struct TchapOnboardingSplashScreen: View { @ObservedObject var viewModel: OnboardingSplashScreenViewModel.Context @State var appTheme = ThemeService.shared() + @State var presentProConnectInfo = false var body: some View { GeometryReader { geometry in @@ -59,6 +60,10 @@ struct TchapOnboardingSplashScreen: View { .accentColor(theme.colors.accent) .navigationBarHidden(true) .track(screen: .welcome) + .sheet(isPresented: $presentProConnectInfo) { + WebSheetView(targetUrl: URL(string: BuildSettings.proConnectInfoUrlString)!) + } + } var header: some View { @@ -166,7 +171,7 @@ struct TchapOnboardingSplashScreen: View { } func openProConnectWebsite() { - TchapWebLinks.openProConnectInfo() + presentProConnectInfo = true } } diff --git a/Tchap/Modules/WebSheet/WebSheetViewController.swift b/Tchap/Modules/WebSheet/WebSheetViewController.swift index 347b522c1..857186fd5 100644 --- a/Tchap/Modules/WebSheet/WebSheetViewController.swift +++ b/Tchap/Modules/WebSheet/WebSheetViewController.swift @@ -195,3 +195,20 @@ extension WebSheetViewController: WKNavigationDelegate { // Called when the web view’s web content process is terminated. } } + +import SwiftUI + +struct WebSheetView: UIViewControllerRepresentable { + typealias UIViewControllerType = WebSheetViewController + let targetUrl: URL + + func makeUIViewController(context: Context) -> WebSheetViewController { + let vc = WebSheetViewController(targetUrl: targetUrl) + // Do some configurations here if needed. + return vc + } + + func updateUIViewController(_ uiViewController: WebSheetViewController, context: Context) { + // Updates the state of the specified view controller with new information from SwiftUI. + } +}