Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent the Pin entry screen from being overlapped. #6249

Merged
merged 1 commit into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Riot/Modules/Application/LegacyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ - (void)applicationWillResignActive:(UIApplication *)application
}
self.setPinCoordinatorBridgePresenter = [[SetPinCoordinatorBridgePresenter alloc] initWithSession:mxSessionArray.firstObject viewMode:SetPinCoordinatorViewModeInactive];
self.setPinCoordinatorBridgePresenter.delegate = self;
[self.setPinCoordinatorBridgePresenter presentIn:self.window];
[self.setPinCoordinatorBridgePresenter presentWithMainAppWindow:self.window];
}
}

Expand Down Expand Up @@ -663,12 +663,12 @@ - (void)configurePinCodeScreenFor:(UIApplication *)application
{
self.setPinCoordinatorBridgePresenter = [[SetPinCoordinatorBridgePresenter alloc] initWithSession:mxSessionArray.firstObject viewMode:SetPinCoordinatorViewModeUnlock];
self.setPinCoordinatorBridgePresenter.delegate = self;
[self.setPinCoordinatorBridgePresenter presentIn:self.window];
[self.setPinCoordinatorBridgePresenter presentWithMainAppWindow:self.window];
}
}
else
{
[self.setPinCoordinatorBridgePresenter dismiss];
[self.setPinCoordinatorBridgePresenter dismissWithMainAppWindow:self.window];
self.setPinCoordinatorBridgePresenter = nil;
[self afterAppUnlockedByPin:application];
}
Expand Down Expand Up @@ -4611,7 +4611,7 @@ - (void)showMajorUpdate

- (void)setPinCoordinatorBridgePresenterDelegateDidComplete:(SetPinCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
[coordinatorBridgePresenter dismiss];
[coordinatorBridgePresenter dismissWithMainAppWindow:self.window];
self.setPinCoordinatorBridgePresenter = nil;
[self afterAppUnlockedByPin:[UIApplication sharedApplication]];
}
Expand All @@ -4625,7 +4625,7 @@ - (void)setPinCoordinatorBridgePresenterDelegateDidCompleteWithReset:(SetPinCoor
}
else
{
[coordinatorBridgePresenter dismiss];
[coordinatorBridgePresenter dismissWithMainAppWindow:self.window];
self.setPinCoordinatorBridgePresenter = nil;
[self logoutWithConfirmation:NO completion:nil];
}
Expand Down
30 changes: 19 additions & 11 deletions Riot/Modules/SetPinCode/SetPinCoordinatorBridgePresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

import Foundation
import UIKit

@objc enum SetPinCoordinatorViewMode: Int {
case setPin
Expand Down Expand Up @@ -49,6 +50,8 @@ final class SetPinCoordinatorBridgePresenter: NSObject {

// MARK: Private

private var pinCoordinatorWindow: UIWindow?

private let session: MXSession?
private var coordinator: SetPinCoordinator?
var viewMode: SetPinCoordinatorViewMode {
Expand Down Expand Up @@ -87,25 +90,31 @@ final class SetPinCoordinatorBridgePresenter: NSObject {
self.coordinator = setPinCoordinator
}

func present(in window: UIWindow) {
func presentWithMainAppWindow(_ window: UIWindow) {
let pinCoordinatorWindow = UIWindow(frame: window.bounds)

let setPinCoordinator = SetPinCoordinator(session: self.session, viewMode: self.viewMode, pinCodePreferences: .shared)
setPinCoordinator.delegate = self
guard let view = setPinCoordinator.toPresentable().view else { return }
window.addSubview(view)
view.leadingAnchor.constraint(equalTo: window.leadingAnchor, constant: 0).isActive = true
view.trailingAnchor.constraint(equalTo: window.trailingAnchor, constant: 0).isActive = true
view.topAnchor.constraint(equalTo: window.topAnchor, constant: 0).isActive = true
view.bottomAnchor.constraint(equalTo: window.bottomAnchor, constant: 0).isActive = true
pinCoordinatorWindow.addSubview(view)
view.leadingAnchor.constraint(equalTo: pinCoordinatorWindow.leadingAnchor, constant: 0).isActive = true
view.trailingAnchor.constraint(equalTo: pinCoordinatorWindow.trailingAnchor, constant: 0).isActive = true
view.topAnchor.constraint(equalTo: pinCoordinatorWindow.topAnchor, constant: 0).isActive = true
view.bottomAnchor.constraint(equalTo: pinCoordinatorWindow.bottomAnchor, constant: 0).isActive = true

pinCoordinatorWindow.makeKeyAndVisible()

setPinCoordinator.start()

self.pinCoordinatorWindow = pinCoordinatorWindow
self.coordinator = setPinCoordinator
}

func dismiss(animated: Bool, completion: (() -> Void)?) {
guard let coordinator = self.coordinator else {
return
}

coordinator.toPresentable().dismiss(animated: animated) {
self.coordinator = nil

Expand All @@ -115,11 +124,10 @@ final class SetPinCoordinatorBridgePresenter: NSObject {
}
}

func dismiss() {
guard let coordinator = self.coordinator else {
return
}
coordinator.toPresentable().view.removeFromSuperview()
func dismissWithMainAppWindow(_ window: UIWindow) {
window.makeKeyAndVisible()
stefanceriu marked this conversation as resolved.
Show resolved Hide resolved
pinCoordinatorWindow = nil
coordinator = nil
}
}

Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-6249.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent the Pin entry screen from being overlapped by other views.