velikanov / SwiftPasscodeLock

An iOS passcode lock with TouchID authentication written in Swift.
MIT License
199 stars 52 forks source link

Orientation support #45

Open bill350 opened 7 years ago

bill350 commented 7 years ago

This PR allows to specify if the lock screen can autorotate and which mask is allowed on it.

The use case: we want to lock the PasscodeLock screen in portrait and our app is rotating. The lock screen appear on a displayed landscape screen (the app is full portrait except one screen) and we want the lock screen on portrait.

This PR also fix the demo project with the TouchIDReason property which is missing in the PasscodeLockConfiguration with the PasscodeLockConfigurationType protocol.

ziogaschr commented 7 years ago

Very nice @bill350.

What if you add a PasscodeLockConfigurationType extension for setting the default values for backward combatibility?

public protocol PasscodeLockConfigurationType {
    var repository: PasscodeRepositoryType {get}
    var passcodeLength: Int {get}
    var isTouchIDAllowed: Bool {get set}
    var shouldRequestTouchIDImmediately: Bool {get}
    var touchIdReason: String? {get set}
    var maximumInccorectPasscodeAttempts: Int {get}
    var supportedInterfaceOrientations: UIInterfaceOrientationMask {get}
    var shouldAutorotate: Bool {get}
}

// set configuration optionals
extension PasscodeLockConfigurationType {
    var passcodeLength: Int {
        return 4
    }

    var maximumInccorectPasscodeAttempts: Int {
        return -1
    }

    var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return .portrait
    }

    var shouldAutorotate: Bool {
        return false
    }
}

Let me know what you think, and after that I will try to also test it in order we merge this.

bill350 commented 7 years ago

Thank you @ziogaschr Yes I think its a good point to propose a default implementation. Go to test it with a default + a custom extension.

ziogaschr commented 7 years ago

Can you @bill350 add the default implementation before I can test this? Thanks

bill350 commented 7 years ago

@ziogaschr Done ;)

ziogaschr commented 7 years ago

Thanks @bill350, will try to check it as soon as possible.

bill350 commented 7 years ago

Hey @ziogaschr, can we merge it ?

ziogaschr commented 7 years ago

Hi @bill350, sorry for taking me so long to test it. I am migrating the code for Swift 4 and I gave a test to your branch too.

The code is good! 👍

Although, I think that we have to do something with the UI too, as it doesn't fit nicely on the screen. Do you have any ideas? I was thinking that we might be able to move the keypad on the right, and the rest info and button on the left of the screen, but not sure without trying.

image

Are you able to pickup this?

Thanks, Chris.

bill350 commented 7 years ago

In a personal project I have created buttons inside a scrollView, and it's working fine. So we juste have to update the demo project ;-)

bill350 commented 7 years ago

I did this because of iPhone 4 & 5 screen limitation. I you agree to switch to a scrollView for the demo ?

ziogaschr commented 7 years ago

@bill350 scrollView sounds as a possible alternative, but I don't think it's optimal as the current elements can fit in screen without a scrollView. Also the above screenshot is from an iPhone6s and the UI is not fitting there too.

With that said, I am just a contributor like you, and I am not the only one to decide about it. So I am happy that you suggested this idea and that you are helping. 👍

Let's see what others believe too. :)

bill350 commented 6 years ago

Hey @ziogaschr So after the Swift 4 migration and because of no more activity on this thread, do you want and updated Swift 4 version ? What's your new opinion since your last one ? Thanks 🍻

ziogaschr commented 6 years ago

Hey @bill350, I really have no clue for what's best about the landscape UI. @velikanov or any other member any ideas?

If we don't find any ideas, I will try to test this better and merge it, later on, someone else might contribute with a better UI.