Fix comments of Steve

This commit is contained in:
ismailgulek
2020-07-22 17:47:45 +03:00
parent 9be4d599c5
commit 409dd2eb5a
6 changed files with 93 additions and 21 deletions

View File

@@ -39,12 +39,14 @@ final class EnterPinCodeViewModel: EnterPinCodeViewModelType {
weak var viewDelegate: EnterPinCodeViewModelViewDelegate?
weak var coordinatorDelegate: EnterPinCodeViewModelCoordinatorDelegate?
var pinCodePreferences: PinCodePreferences
// MARK: - Setup
init(session: MXSession?, viewMode: SetPinCoordinatorViewMode) {
init(session: MXSession?, viewMode: SetPinCoordinatorViewMode, pinCodePreferences: PinCodePreferences) {
self.session = session
self.viewMode = viewMode
self.pinCodePreferences = pinCodePreferences
}
// MARK: - Public
@@ -84,7 +86,7 @@ final class EnterPinCodeViewModel: EnterPinCodeViewModelType {
// a digit tapped
currentPin += String(tag)
if currentPin.count == PinCodePreferences.shared.numberOfDigits {
if currentPin.count == pinCodePreferences.numberOfDigits {
switch viewMode {
case .setPin:
// choosing pin
@@ -106,10 +108,10 @@ final class EnterPinCodeViewModel: EnterPinCodeViewModelType {
}
case .unlockByPin, .confirmPinToDeactivate:
// unlocking
if currentPin != PinCodePreferences.shared.pin {
if currentPin != pinCodePreferences.pin {
// no match
numberOfFailuresDuringEnterPIN += 1
if numberOfFailuresDuringEnterPIN < PinCodePreferences.shared.allowedNumberOfTrialsBeforeAlert {
if numberOfFailuresDuringEnterPIN < pinCodePreferences.allowedNumberOfTrialsBeforeAlert {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.viewDelegate?.enterPinCodeViewModel(self, didUpdateViewState: .wrongPin)
self.currentPin.removeAll()