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

@ -17,6 +17,7 @@
generate_missing_umbrella_headers = true
iphonesimulator_target_sdk_version = 9.0
iphoneos_target_sdk_version = 9.0
watchos_target_sdk_version = 5.0
provisioning_profile_read_command = security cms -Di
xctool_default_destination_specifier = platform=iOS Simulator,OS=latest
xctool_path = tools/xctool/bin/xctool

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

View File

@ -441,7 +441,7 @@ public func passcodeOptionsAccessController(context: AccountContext, animateIn:
}
}
public func passcodeEntryController(context: AccountContext, animateIn: Bool = true, completion: @escaping (Bool) -> Void) -> Signal<ViewController?, NoError> {
public func passcodeEntryController(context: AccountContext, animateIn: Bool = true, modalPresentation: Bool = false, completion: @escaping (Bool) -> Void) -> Signal<ViewController?, NoError> {
return context.sharedContext.accountManager.transaction { transaction -> PostboxAccessChallengeData in
return transaction.getAccessChallengeData()
}
@ -458,14 +458,18 @@ public func passcodeEntryController(context: AccountContext, animateIn: Bool = t
return nil
} else {
let biometrics: PasscodeEntryControllerBiometricsMode
#if targetEnvironment(simulator)
biometrics = .enabled(nil)
#else
if let passcodeSettings = passcodeSettings, passcodeSettings.enableBiometrics {
biometrics = .enabled(context.sharedContext.applicationBindings.isMainApp ? passcodeSettings.biometricsDomainState : passcodeSettings.shareBiometricsDomainState)
} else {
biometrics = .none
}
#endif
let controller = PasscodeEntryController(applicationBindings: context.sharedContext.applicationBindings, accountManager: context.sharedContext.accountManager, appLockContext: context.sharedContext.appLockContext, presentationData: context.sharedContext.currentPresentationData.with { $0 }, presentationDataSignal: context.sharedContext.presentationData, challengeData: challenge, biometrics: biometrics, arguments: PasscodeEntryControllerPresentationArguments(animated: false, fadeIn: true, cancel: {
completion(false)
}))
}, modalPresentation: modalPresentation))
controller.presentationCompleted = { [weak controller] in
Queue.mainQueue().after(0.5, { [weak controller] in
controller?.requestBiometrics()

View File

@ -122,8 +122,10 @@ public class ShareRootControllerImpl {
mainWindow.hostView.eventView.isHidden = false
self.mainWindow = mainWindow
let bounds = view.bounds
view.addSubview(mainWindow.hostView.containerView)
mainWindow.hostView.containerView.frame = view.bounds
mainWindow.hostView.containerView.frame = bounds
let rootPath = rootPathForBasePath(self.initializationData.appGroupPath)
performAppGroupUpgrades(appGroupPath: self.initializationData.appGroupPath, rootPath: rootPath)
@ -340,7 +342,14 @@ public class ShareRootControllerImpl {
context.account.resetStateManagement()
}
let _ = passcodeEntryController(context: context, animateIn: true, completion: { value in
let modalPresentation: Bool
if #available(iOSApplicationExtension 13.0, iOS 13.0, *) {
modalPresentation = true
} else {
modalPresentation = false
}
let _ = passcodeEntryController(context: context, animateIn: true, modalPresentation: modalPresentation, completion: { value in
if value {
displayShare()
} else {