Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat: avoid double dismiss/presentation of sensitive data cover #113 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
ParideBifulco committed Jun 1, 2020
1 parent c77edae commit 47630f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 7 additions & 2 deletions App/Application/AppNavigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ extension TabbarVC: RoutableWithConfiguration {
vc.modalTransitionStyle = .crossDissolve
return vc
},
.hide(Screen.sensitiveDataCover): .dismissModally(behaviour: .hard),

// Loading
.show(Screen.loading): .presentModally { [unowned self] context in
Expand Down Expand Up @@ -250,10 +249,16 @@ extension TabbarVC: RoutableWithConfiguration {

// MARK: SensitiveDataCover

extension SensitiveDataCoverVC: Routable {
extension SensitiveDataCoverVC: RoutableWithConfiguration {
var routeIdentifier: RouteElementIdentifier {
return Screen.sensitiveDataCover.rawValue
}

var navigationConfiguration: [NavigationRequest: NavigationInstruction] {
return [
.hide(Screen.sensitiveDataCover): .dismissModally(behaviour: .soft),
]
}
}

// MARK: - Common
Expand Down
15 changes: 12 additions & 3 deletions App/Logic/SharedLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,26 @@ extension Logic.Shared {

/// Show sensitive data cover.
struct ShowSensitiveDataCoverIfNeeded: AppSideEffect {
/// The list of screens that can present the cover.
static let possiblePresenters: [String] = [Screen.tabBar.rawValue, Screen.onboardingStep.rawValue]
/// The list of screens that, if present, will block the presentation of a cover.
static let possibleBlockers: [String] = [
// avoid double presentation
Screen.sensitiveDataCover.rawValue,
// avoid when a native alert presentation is needed
Screen.permissionOverlay.rawValue
]

func sideEffect(_ context: SideEffectContext<AppState, AppDependencies>) throws {
guard
context.dependencies.application.currentRoutableIdentifiers
.contains(where: { Self.possiblePresenters.contains($0) }) else {
return
}
// avoid to cover permission overlay screen when presenting native permission alert.
guard !context.dependencies.application.currentRoutableIdentifiers.contains(Screen.permissionOverlay.rawValue) else {
return
guard
!context.dependencies.application.currentRoutableIdentifiers
.contains(where: { Self.possibleBlockers.contains($0) }) else {
return
}

context.dispatch(Show(Screen.sensitiveDataCover, animated: true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class OnboardingContainerNC: UINavigationController {
vc.modalTransitionStyle = .crossDissolve
return vc
},
.hide(Screen.sensitiveDataCover): .dismissModally(behaviour: .hard),

.show(Screen.onboardingStep): .custom { _, _, animated, context, completion in
let navContext = context as? OnboardingContainerNC.NavigationContext ?? AppLogger.fatalError("Invalid Context")
Expand Down

0 comments on commit 47630f1

Please sign in to comment.