Skip to content

Commit

Permalink
PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Oct 11, 2023
1 parent 7bbe4a4 commit 4e9e8f3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
/* Used for testing */
"untranslated" = "Untranslated";

"screen_app_lock_title" = "%@ is locked";
"common_unlock" = "Unlock";

// MARK: - Soft logout

"soft_logout_signin_title" = "Sign in";
Expand Down
24 changes: 14 additions & 10 deletions ElementX/Sources/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,

observeApplicationState()
observeNetworkState()
observeAppLockChanges()

registerBackgroundAppRefresh()
}
Expand Down Expand Up @@ -194,16 +195,6 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,

func windowManager(_ windowManager: WindowManager, didConfigureWith windowScene: UIWindowScene) {
windowManager.alternateWindow.rootViewController = UIHostingController(rootView: appLockFlowCoordinator.toPresentable())

appLockFlowCoordinator.actions.sink { action in
switch action {
case .lockApp:
windowManager.switchToAlternate()
case .unlockApp:
windowManager.switchToMain()
}
}
.store(in: &cancellables)
}

// MARK: - NotificationManagerDelegate
Expand Down Expand Up @@ -581,6 +572,19 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
.store(in: &cancellables)
}

private func observeAppLockChanges() {
appLockFlowCoordinator.actions.sink { [weak self] action in
guard let self else { return }
switch action {
case .lockApp:
windowManager.switchToAlternate()
case .unlockApp:
windowManager.switchToMain()
}
}
.store(in: &cancellables)
}

private func handleAppRoute(_ appRoute: AppRoute) {
if let userSessionFlowCoordinator {
userSessionFlowCoordinator.handleAppRoute(appRoute, animated: UIApplication.shared.applicationState == .active)
Expand Down
6 changes: 6 additions & 0 deletions ElementX/Sources/Generated/Strings+Untranslated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import Foundation
// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
public enum UntranslatedL10n {
/// Unlock
public static var commonUnlock: String { return UntranslatedL10n.tr("Untranslated", "common_unlock") }
/// %@ is locked
public static func screenAppLockTitle(_ p1: Any) -> String {
return UntranslatedL10n.tr("Untranslated", "screen_app_lock_title", String(describing: p1))
}
/// Clear all data currently stored on this device?
/// Sign in again to access your account data and messages.
public static var softLogoutClearDataDialogContent: String { return UntranslatedL10n.tr("Untranslated", "soft_logout_clear_data_dialog_content") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ struct AppLockScreen: View {
.symbolVariant(.fill)
.padding(.bottom, 8)

Text("\(InfoPlistReader.main.bundleDisplayName) is locked")
Text(UntranslatedL10n.screenAppLockTitle(InfoPlistReader.main.bundleDisplayName))
.font(.compound.headingMDBold)
.multilineTextAlignment(.center)
.foregroundColor(.compound.textPrimary)
}
} bottomContent: {
Button("Unlock") {
Button(UntranslatedL10n.commonUnlock) {
context.send(viewAction: .submitPINCode("0000"))
}
.buttonStyle(.elementAction(.xLarge))
Expand Down

0 comments on commit 4e9e8f3

Please sign in to comment.