Fix passcode layout

This commit is contained in:
Ali
2019-11-04 19:44:25 +04:00
parent 78d7745877
commit 2e2fc91cc2
6 changed files with 68 additions and 28 deletions

View File

@@ -15,12 +15,14 @@ public final class PasscodeEntryControllerPresentationArguments {
let fadeIn: Bool
let lockIconInitialFrame: () -> CGRect
let cancel: (() -> Void)?
let modalPresentation: Bool
public init(animated: Bool = true, fadeIn: Bool = false, lockIconInitialFrame: @escaping () -> CGRect = { return CGRect() }, cancel: (() -> Void)? = nil) {
public init(animated: Bool = true, fadeIn: Bool = false, lockIconInitialFrame: @escaping () -> CGRect = { return CGRect() }, cancel: (() -> Void)? = nil, modalPresentation: Bool = false) {
self.animated = animated
self.fadeIn = fadeIn
self.lockIconInitialFrame = lockIconInitialFrame
self.cancel = cancel
self.modalPresentation = modalPresentation
}
}
@@ -111,18 +113,22 @@ public final class PasscodeEntryController: ViewController {
let biometricsType: LocalAuthBiometricAuthentication?
if case let .enabled(data) = self.biometrics {
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
#if targetEnvironment(simulator)
biometricsType = .touchId
#else
if data == LocalAuth.evaluatedPolicyDomainState || (data == nil && !self.applicationBindings.isMainApp) {
biometricsType = LocalAuth.biometricAuthentication
} else {
biometricsType = nil
}
#endif
} else {
biometricsType = LocalAuth.biometricAuthentication
}
} else {
biometricsType = nil
}
self.displayNode = PasscodeEntryControllerNode(accountManager: self.accountManager, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, passcodeType: passcodeType, biometricsType: biometricsType, arguments: self.arguments, statusBar: self.statusBar)
self.displayNode = PasscodeEntryControllerNode(accountManager: self.accountManager, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, passcodeType: passcodeType, biometricsType: biometricsType, arguments: self.arguments, statusBar: self.statusBar, modalPresentation: self.arguments.modalPresentation)
self.displayNodeDidLoad()
let _ = (self.appLockContext.invalidAttempts

View File

@@ -29,6 +29,8 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
private let statusBar: StatusBar
private let modalPresentation: Bool
private let backgroundNode: ASImageNode
private let iconNode: PasscodeLockIconNode
private let titleNode: PasscodeEntryLabelNode
@@ -50,7 +52,7 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
var checkPasscode: ((String) -> Void)?
var requestBiometrics: (() -> Void)?
init(accountManager: AccountManager, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, passcodeType: PasscodeEntryFieldType, biometricsType: LocalAuthBiometricAuthentication?, arguments: PasscodeEntryControllerPresentationArguments, statusBar: StatusBar) {
init(accountManager: AccountManager, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, passcodeType: PasscodeEntryFieldType, biometricsType: LocalAuthBiometricAuthentication?, arguments: PasscodeEntryControllerPresentationArguments, statusBar: StatusBar, modalPresentation: Bool) {
self.accountManager = accountManager
self.theme = theme
self.strings = strings
@@ -59,6 +61,7 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
self.biometricsType = biometricsType
self.arguments = arguments
self.statusBar = statusBar
self.modalPresentation = modalPresentation
self.backgroundNode = ASImageNode()
self.backgroundNode.contentMode = .scaleToFill
@@ -373,7 +376,7 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
self.iconNode.alpha = 0.0
}
let passcodeLayout = PasscodeLayout(layout: layout)
let passcodeLayout = PasscodeLayout(layout: layout, modalPresentation: self.modalPresentation)
let inputFieldOffset: CGFloat
if isLandscape {
let bottomInset = layout.inputHeight ?? 0.0

View File

@@ -3,18 +3,23 @@ import UIKit
import Display
struct PasscodeKeyboardLayout {
let buttonSize: CGFloat
let horizontalSecond: CGFloat
let horizontalThird: CGFloat
let verticalSecond: CGFloat
let verticalThird: CGFloat
let verticalFourth: CGFloat
let size: CGSize
let topOffset: CGFloat
let biometricsOffset: CGFloat
let deleteOffset: CGFloat
var buttonSize: CGFloat
var horizontalSecond: CGFloat
var horizontalThird: CGFloat
var verticalSecond: CGFloat
var verticalThird: CGFloat
var verticalFourth: CGFloat
var size: CGSize
var topOffset: CGFloat
var biometricsOffset: CGFloat
var deleteOffset: CGFloat
fileprivate init(layout: ContainerViewLayout) {
fileprivate init(layout: ContainerViewLayout, modalPresentation: Bool) {
var modalOffset: CGFloat = 0.0
if modalPresentation {
modalOffset -= 20.0
}
switch layout.deviceMetrics {
case .iPhone4:
self.buttonSize = 75.0
@@ -105,20 +110,28 @@ struct PasscodeKeyboardLayout {
self.biometricsOffset = 30.0
self.deleteOffset = 20.0
}
self.topOffset += modalOffset * 2.0
self.biometricsOffset += modalOffset
}
}
public struct PasscodeLayout {
let layout: ContainerViewLayout
let keyboard: PasscodeKeyboardLayout
let titleOffset: CGFloat
let subtitleOffset: CGFloat
let inputFieldOffset: CGFloat
var layout: ContainerViewLayout
var keyboard: PasscodeKeyboardLayout
var titleOffset: CGFloat
var subtitleOffset: CGFloat
var inputFieldOffset: CGFloat
init(layout: ContainerViewLayout) {
init(layout: ContainerViewLayout, modalPresentation: Bool) {
self.layout = layout
self.keyboard = PasscodeKeyboardLayout(layout: layout)
var modalOffset: CGFloat = 0.0
if modalPresentation {
modalOffset -= 20.0
}
self.keyboard = PasscodeKeyboardLayout(layout: layout, modalPresentation: modalPresentation)
switch layout.deviceMetrics {
case .iPhone4:
self.titleOffset = 30.0
@@ -153,11 +166,15 @@ public struct PasscodeLayout {
self.subtitleOffset = 0.0
self.inputFieldOffset = 140.0
}
self.titleOffset += modalOffset
self.subtitleOffset += modalOffset
self.inputFieldOffset += modalOffset
}
public init(layout: ContainerViewLayout, titleOffset: CGFloat, subtitleOffset: CGFloat, inputFieldOffset: CGFloat) {
public init(layout: ContainerViewLayout, titleOffset: CGFloat, subtitleOffset: CGFloat, inputFieldOffset: CGFloat, modalPresentation: Bool) {
self.layout = layout
self.keyboard = PasscodeKeyboardLayout(layout: layout)
self.keyboard = PasscodeKeyboardLayout(layout: layout, modalPresentation: modalPresentation)
self.titleOffset = titleOffset
self.subtitleOffset = subtitleOffset
self.inputFieldOffset = inputFieldOffset