Merge pull request #3515 from vector-im/element_3514

Polish Pin Screen
This commit is contained in:
ismailgulek
2020-08-06 18:33:58 +03:00
committed by GitHub
6 changed files with 68 additions and 6 deletions
@@ -67,19 +67,34 @@ final class EnterPinCodeViewController: UIViewController {
self.update(theme: self.theme)
self.viewModel.viewDelegate = self
if #available(iOS 13.0, *) {
modalPresentationStyle = .fullScreen
isModalInPresentation = true
}
self.viewModel.process(viewAction: .loadData)
// force orientation to portrait if phone
if UIDevice.current.isPhone {
UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")
}
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return self.theme.statusBarStyle
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
// limit orientation to portrait only for phone
if UIDevice.current.isPhone {
return .portrait
}
return super.supportedInterfaceOrientations
}
override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
if UIDevice.current.isPhone {
return .portrait
}
return super.preferredInterfaceOrientationForPresentation
}
// MARK: - Private
private func update(theme: Theme) {
@@ -281,4 +296,12 @@ extension EnterPinCodeViewController: EnterPinCodeViewModelViewDelegate {
self.renderPlaceholdersCount(count)
}
func enterPinCodeViewModel(_ viewModel: EnterPinCodeViewModelType, didUpdateCancelButtonHidden isHidden: Bool) {
if isHidden {
hideCancelButton()
} else {
showCancelButton()
}
}
}
@@ -143,6 +143,7 @@ final class EnterPinCodeViewModel: EnterPinCodeViewModelType {
switch viewMode {
case .setPin:
update(viewState: .choosePin)
self.viewDelegate?.enterPinCodeViewModel(self, didUpdateCancelButtonHidden: pinCodePreferences.forcePinProtection)
case .unlock:
update(viewState: .unlock)
case .confirmPinToDeactivate:
@@ -21,6 +21,7 @@ import Foundation
protocol EnterPinCodeViewModelViewDelegate: class {
func enterPinCodeViewModel(_ viewModel: EnterPinCodeViewModelType, didUpdateViewState viewSate: EnterPinCodeViewState)
func enterPinCodeViewModel(_ viewModel: EnterPinCodeViewModelType, didUpdatePlaceholdersCount count: Int)
func enterPinCodeViewModel(_ viewModel: EnterPinCodeViewModelType, didUpdateCancelButtonHidden isHidden: Bool)
}
protocol EnterPinCodeViewModelCoordinatorDelegate: class {
@@ -70,7 +70,11 @@ final class SetPinCoordinator: SetPinCoordinatorType {
}
func toPresentable() -> UIViewController {
return self.navigationRouter.toPresentable()
let controller = self.navigationRouter.toPresentable()
if #available(iOS 13.0, *) {
controller.modalPresentationStyle = .fullScreen
}
return controller
}
// MARK: - Private methods