Skip to content

Commit

Permalink
Link to ProConnect availabiity faq article on home screen and ProConn…
Browse files Browse the repository at this point in the history
…ect screen
  • Loading branch information
NicolasBuquet committed Jan 8, 2025
1 parent 40fb229 commit 7e609c6
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Btchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion DevTchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = [
Expand Down
2 changes: 1 addition & 1 deletion Tchap/Assets/Localizations/fr.lproj/Tchap.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Tchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = [
Expand Down
4 changes: 0 additions & 4 deletions Tchap/Extensions/WebLinks+Tchap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -240,7 +248,11 @@ struct TchapAuthenticationLoginScreen: View {
}

func openProConnectWebsite() {
TchapWebLinks.openProConnectInfo()
presentProConnectInfo = true
}

func openProConnectAvailabilityFaqArticle() {
presentProConnectAvailabilityFaqArticle = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -166,7 +171,7 @@ struct TchapOnboardingSplashScreen: View {
}

func openProConnectWebsite() {
TchapWebLinks.openProConnectInfo()
presentProConnectInfo = true
}
}

Expand Down
17 changes: 17 additions & 0 deletions Tchap/Modules/WebSheet/WebSheetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}

0 comments on commit 7e609c6

Please sign in to comment.