Skip to content

Commit

Permalink
Merge pull request #866 from tchapgouv/864-le-message-derreur-de-conn…
Browse files Browse the repository at this point in the history
…exion-affiche-un-lien-vers-la-page-de-status-des-services

Le message d'erreur de connexion affiche un lien vers la page de stat…
  • Loading branch information
NicolasBuquet authored Sep 13, 2023
2 parents b30cf73 + f6cdac2 commit 114eb3a
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 24 deletions.
1 change: 1 addition & 0 deletions Btchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ final class BuildSettings: NSObject {
static let applicationTermsConditionsUrlString = "https://www.tchap.gouv.fr/tac.html"
static let clientConfigURL = "https://www.tchap.gouv.fr/client/config/preprod/ios"
static let applicationHelpUrlString = "https://www.beta.tchap.gouv.fr/faq"
static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/"
static let applicationAcceptableUsePolicyUrlString = ""

// MARK: - Matrix permalinks
Expand Down
1 change: 1 addition & 0 deletions 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 applicationPrivacyPolicyUrlString = "https://element.io/privacy"
static let applicationAcceptableUsePolicyUrlString = "https://element.io/acceptable-use-policy-terms"
static let applicationHelpUrlString = "https://www.tchap.gouv.fr/faq"
static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/"


// MARK: - Permalinks
Expand Down
1 change: 1 addition & 0 deletions DevTchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ final class BuildSettings: NSObject {
static let applicationTermsConditionsUrlString = "https://www.tchap.incubateur.net/tac.html"
static let clientConfigURL = "https://www.tchap.incubateur.net/client/config/agent/ios"
static let applicationHelpUrlString = "https://www.tchap.incubateur.net/faq"
static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/"
static let applicationAcceptableUsePolicyUrlString = ""


Expand Down
2 changes: 1 addition & 1 deletion Riot/Assets/fr.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,7 @@
"create_room_suggest_room_footer" = "Les salons recommandés sont suggérés aux membres de l’espace comme salons de qualité.";
"create_room_show_in_directory_footer" = "Ceci aidera les gens à le trouver et le rejoindre.";
"network_offline_message" = "Vous êtes déconnecté, merci de vérifier votre connexion.";
"network_offline_title" = "Vous êtes déconnecté";
"network_offline_title" = "La connexion à Tchap n’est pas disponible pour le moment.\n\nTaper pour voir l’état du service."; // Tchap
"room_access_settings_screen_upgrade_alert_upgrading" = "Mise à niveau du salon";
"room_access_settings_screen_upgrade_alert_upgrade_button" = "Mettre à niveau";
"room_access_settings_screen_upgrade_alert_note" = "Veuillez noter que la mise à niveau va créer une nouvelle version de ce salon. Tous les messages actuels vont rester dans ce salon archivé.";
Expand Down
20 changes: 19 additions & 1 deletion Riot/Modules/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Intents
import MatrixSDK
import CommonKit
import UIKit
import SafariServices

#if DEBUG
import FLEX
Expand Down Expand Up @@ -122,7 +123,10 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
guard let self = self else { return }

if AppDelegate.theDelegate().isOffline {
self.splitViewCoordinator?.showAppStateIndicator(with: VectorL10n.networkOfflineTitle, icon: UIImage(systemName: "wifi.slash"))
// Tchap : add tap action
self.splitViewCoordinator?.showAppStateIndicator(with: VectorL10n.networkOfflineTitle, icon: UIImage(systemName: "wifi.slash")) {
self.showServiceStatus()
}
} else {
self.splitViewCoordinator?.hideAppStateIndicator()
}
Expand All @@ -148,6 +152,20 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
}
}

// Tchap functionality
private func showServiceStatus() {
guard let helpURL = URL(string: BuildSettings.applicationServicesStatusUrlString),
let presenter = self.splitViewCoordinator?.toPresentable() else {
return
}

let safariViewController = SFSafariViewController(url: helpURL)

// Show in fullscreen to animate presentation along side menu dismiss
safariViewController.modalPresentationStyle = .automatic
presenter.present(safariViewController, animated: true, completion: nil)
}

func checkMinAppVersionRequirements() {
guard self.pendingCheckAppVersionOperation == nil else {
return
Expand Down
32 changes: 28 additions & 4 deletions Riot/Modules/Common/Toasts/RoundedToastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class RoundedToastView: UIView, Themable {
static let imageViewSize = CGFloat(15)
static let lightShadow = ShadowStyle(offset: .init(width: 0, height: 4), radius: 12, opacity: 0.1)
static let darkShadow = ShadowStyle(offset: .init(width: 0, height: 4), radius: 4, opacity: 0.2)
static let cornerRadius = CGFloat(16.0) // Tchap
}

private lazy var activityIndicator: UIActivityIndicatorView = {
Expand All @@ -54,15 +55,24 @@ class RoundedToastView: UIView, Themable {
private let stackView: UIStackView = {
let stack = UIStackView()
stack.axis = .horizontal
stack.alignment = .center
stack.alignment = .top // Tchap
stack.spacing = 5
return stack
}()

private let label: UILabel = {
return UILabel()
private lazy var label: UILabel = {
// Tchap : allow multiline text
let lbl = UILabel()
lbl.numberOfLines = 0
lbl.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
lbl.widthAnchor.constraint(lessThanOrEqualToConstant: UIScreen.main.bounds.width * 0.67)
])
return lbl
}()

private var action: ToastViewState.Action? // Tchap tap action

init(viewState: ToastViewState) {
super.init(frame: .zero)
setup(viewState: viewState)
Expand All @@ -77,6 +87,20 @@ class RoundedToastView: UIView, Themable {
stackView.addArrangedSubview(toastView(for: viewState.style))
stackView.addArrangedSubview(label)
label.text = viewState.label

// Tchap : handle tap action
action = viewState.action

if let _ = viewState.action {
let tapAction = UITapGestureRecognizer(target: self, action: #selector(tapAction))
self.addGestureRecognizer(tapAction)
}
}

// Tchap : handle tap action
@objc private func tapAction() {
guard let action = self.action else { return }
action()
}

private func setupStackView() {
Expand All @@ -92,7 +116,7 @@ class RoundedToastView: UIView, Themable {

override func layoutSubviews() {
super.layoutSubviews()
layer.cornerRadius = layer.frame.height / 2
layer.cornerRadius = Constants.cornerRadius // Tchap : don't rely on box height to evaluate corner radius.
}

override func willMove(toSuperview newSuperview: UIView?) {
Expand Down
3 changes: 3 additions & 0 deletions Riot/Modules/Common/Toasts/ToastViewState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import Foundation

struct ToastViewState {
typealias Action = () -> Void // Tchap : action type

enum Style {
case loading
case success
Expand All @@ -26,4 +28,5 @@ struct ToastViewState {

let style: Style
let label: String
let action: Action? // Tchap action
}
22 changes: 14 additions & 8 deletions Riot/Modules/Common/UserIndicators/UserIndicatorPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ enum UserIndicatorType {
case loading(label: String, isInteractionBlocking: Bool)
case success(label: String)
case failure(label: String)
case custom(label: String, icon: UIImage?)
case custom(label: String, icon: UIImage?, action: ToastViewState.Action?) // Tchap : add tap action
}

/// A presenter which can handle `UserIndicatorType` by creating the underlying `UserIndicator`
Expand Down Expand Up @@ -67,6 +67,7 @@ class UserIndicatorTypePresenter: UserIndicatorTypePresenterProtocol {
return queue.add(request)
}

// Tchap : add tap action
private func userIndicatorRequest(for type: UserIndicatorType) -> UserIndicatorRequest {
switch type {
case .loading(let label, let isInteractionBlocking):
Expand All @@ -79,16 +80,17 @@ class UserIndicatorTypePresenter: UserIndicatorTypePresenterProtocol {
return successRequest(label: label)
case .failure(let label):
return failureRequest(label: label)
case .custom(let label, let icon):
return customRequest(label: label, icon: icon)
case .custom(let label, let icon, let action): // Tchap : add tap action
return customRequest(label: label, icon: icon, action: action)
}
}

private func loadingRequest(label: String) -> UserIndicatorRequest {
let presenter = ToastViewPresenter(
viewState: .init(
style: .loading,
label: label
label: label,
action: nil // Tchap : add tap action
),
presentationContext: presentationContext
)
Expand All @@ -113,7 +115,8 @@ class UserIndicatorTypePresenter: UserIndicatorTypePresenterProtocol {
let presenter = ToastViewPresenter(
viewState: .init(
style: .success,
label: label
label: label,
action: nil // Tchap : add tap action
),
presentationContext: presentationContext
)
Expand All @@ -127,7 +130,8 @@ class UserIndicatorTypePresenter: UserIndicatorTypePresenterProtocol {
let presenter = ToastViewPresenter(
viewState: .init(
style: .failure,
label: label
label: label,
action: nil // Tchap : add tap action
),
presentationContext: presentationContext
)
Expand All @@ -137,11 +141,13 @@ class UserIndicatorTypePresenter: UserIndicatorTypePresenterProtocol {
)
}

private func customRequest(label: String, icon: UIImage?) -> UserIndicatorRequest {
// Tchap : add tap action
private func customRequest(label: String, icon: UIImage?, action: ToastViewState.Action?) -> UserIndicatorRequest {
let presenter = ToastViewPresenter(
viewState: .init(
style: .custom(icon: icon),
label: label
label: label,
action: action // Tchap : add tap action
),
presentationContext: presentationContext
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import CommonKit
///
/// Note: This is a convenience function callable by objective-c code
@objc func presentCustom(label: String, icon: UIImage?) -> UserIndicatorCancel {
let indicator = presenter.present(.custom(label: label, icon: icon))
let indicator = presenter.present(.custom(label: label, icon: icon, action: nil)) // Tchap : add tap action
indicators.append(indicator)
return {
indicator.cancel()
Expand Down
5 changes: 3 additions & 2 deletions Riot/Modules/Home/AllChats/AllChatsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,10 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
indicators.append(self.indicatorPresenter.present(.failure(label: title)))
}

func showAppStateIndicator(with text: String, icon: UIImage?) {
// Tchap : add tap action
func showAppStateIndicator(with text: String, icon: UIImage?, action: ToastViewState.Action? = nil) {
hideAppStateIndicator()
appSateIndicator = self.indicatorPresenter.present(.custom(label: text, icon: icon))
appSateIndicator = self.indicatorPresenter.present(.custom(label: text, icon: icon, action: action)) // Tchap : add tap action
}

func hideAppStateIndicator() {
Expand Down
5 changes: 3 additions & 2 deletions Riot/Modules/SplitView/SplitViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType {
masterCoordinator?.hideAppStateIndicator()
}

func showAppStateIndicator(with text: String, icon: UIImage?) {
masterCoordinator?.showAppStateIndicator(with: text, icon: icon)
// Tchap : add tap action
func showAppStateIndicator(with text: String, icon: UIImage?, action: ToastViewState.Action? = nil) {
masterCoordinator?.showAppStateIndicator(with: text, icon: icon, action: action) // Tchap : add tap action
}

func presentInvitePeople() {
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/SplitView/SplitViewCoordinatorType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protocol SplitViewCoordinatorType: Coordinator, Presentable {
func showErroIndicator(with error: Error)

/// Displays an message related to the application state using a `UserIndicator`. The message must be dimissed by calling the method `hideAppStateIndicator()`
func showAppStateIndicator(with text: String, icon: UIImage?)
func showAppStateIndicator(with text: String, icon: UIImage?, action: ToastViewState.Action?) // Tchap : add tap action

/// Hide the message related to the application state currently displayed.
func hideAppStateIndicator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protocol SplitViewMasterCoordinatorProtocol: Coordinator, SplitViewMasterPresent
func showErroIndicator(with error: Error)

/// Displays an message related to the application state using a `UserIndicator`. The message must be dimissed by calling the method `hideAppStateIndicator()`
func showAppStateIndicator(with text: String, icon: UIImage?)
func showAppStateIndicator(with text: String, icon: UIImage?, action: ToastViewState.Action?) // Tchap : add tap action

/// Hide the message related to the application state currently displayed.
func hideAppStateIndicator()
Expand Down
5 changes: 3 additions & 2 deletions Riot/Modules/TabBar/TabBarCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,10 @@ final class TabBarCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
indicators.append(self.indicatorPresenter.present(.failure(label: title)))
}

func showAppStateIndicator(with text: String, icon: UIImage?) {
// Tchap : add tap action
func showAppStateIndicator(with text: String, icon: UIImage?, action: ToastViewState.Action? = nil) {
hideAppStateIndicator()
appSateIndicator = self.indicatorPresenter.present(.custom(label: text, icon: icon))
appSateIndicator = self.indicatorPresenter.present(.custom(label: text, icon: icon, action: action)) // Tchap : add tap action
}

func hideAppStateIndicator() {
Expand Down
1 change: 1 addition & 0 deletions RiotNSE/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ final class BuildSettings: NSObject {
static let applicationTermsConditionsUrlString = "https://www.tchap.gouv.fr/tac.html"
static let clientConfigURL = "https://www.tchap.gouv.fr/client/config/agent/ios"
static let applicationHelpUrlString = "https://www.tchap.gouv.fr/faq"
static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/"
static let applicationAcceptableUsePolicyUrlString = ""


Expand Down
1 change: 1 addition & 0 deletions RiotShareExtension/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ final class BuildSettings: NSObject {
static let applicationTermsConditionsUrlString = "https://www.tchap.gouv.fr/tac.html"
static let clientConfigURL = "https://www.tchap.gouv.fr/client/config/agent/ios"
static let applicationHelpUrlString = "https://www.tchap.gouv.fr/faq"
static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/"
static let applicationAcceptableUsePolicyUrlString = ""


Expand Down
1 change: 1 addition & 0 deletions Tchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ final class BuildSettings: NSObject {
static let applicationTermsConditionsUrlString = "https://www.tchap.gouv.fr/tac.html"
static let clientConfigURL = "https://www.tchap.gouv.fr/client/config/agent/ios"
static let applicationHelpUrlString = "https://www.tchap.gouv.fr/faq"
static let applicationServicesStatusUrlString = "https://status.tchap.numerique.gouv.fr/"
static let applicationAcceptableUsePolicyUrlString = ""


Expand Down
1 change: 1 addition & 0 deletions changelog.d/864.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Le message d'erreur de connexion affiche un lien vers la page de status des services
2 changes: 1 addition & 1 deletion fastlane/Pluginfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

gem 'fastlane-plugin-versioning'
gem 'fastlane-plugin-xcodegen'
gem 'fastlane-plugin-diawi', git: 'https://github.com/mhtranbn/fastlane-plugin-diawi.git'
gem 'fastlane-plugin-diawireborn'
gem 'fastlane-plugin-sentry'

0 comments on commit 114eb3a

Please sign in to comment.