mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix passcode layout
This commit is contained in:
parent
78d7745877
commit
2e2fc91cc2
@ -17,6 +17,7 @@
|
|||||||
generate_missing_umbrella_headers = true
|
generate_missing_umbrella_headers = true
|
||||||
iphonesimulator_target_sdk_version = 9.0
|
iphonesimulator_target_sdk_version = 9.0
|
||||||
iphoneos_target_sdk_version = 9.0
|
iphoneos_target_sdk_version = 9.0
|
||||||
|
watchos_target_sdk_version = 5.0
|
||||||
provisioning_profile_read_command = security cms -Di
|
provisioning_profile_read_command = security cms -Di
|
||||||
xctool_default_destination_specifier = platform=iOS Simulator,OS=latest
|
xctool_default_destination_specifier = platform=iOS Simulator,OS=latest
|
||||||
xctool_path = tools/xctool/bin/xctool
|
xctool_path = tools/xctool/bin/xctool
|
||||||
|
@ -15,12 +15,14 @@ public final class PasscodeEntryControllerPresentationArguments {
|
|||||||
let fadeIn: Bool
|
let fadeIn: Bool
|
||||||
let lockIconInitialFrame: () -> CGRect
|
let lockIconInitialFrame: () -> CGRect
|
||||||
let cancel: (() -> Void)?
|
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.animated = animated
|
||||||
self.fadeIn = fadeIn
|
self.fadeIn = fadeIn
|
||||||
self.lockIconInitialFrame = lockIconInitialFrame
|
self.lockIconInitialFrame = lockIconInitialFrame
|
||||||
self.cancel = cancel
|
self.cancel = cancel
|
||||||
|
self.modalPresentation = modalPresentation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,18 +113,22 @@ public final class PasscodeEntryController: ViewController {
|
|||||||
let biometricsType: LocalAuthBiometricAuthentication?
|
let biometricsType: LocalAuthBiometricAuthentication?
|
||||||
if case let .enabled(data) = self.biometrics {
|
if case let .enabled(data) = self.biometrics {
|
||||||
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
|
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
|
||||||
|
#if targetEnvironment(simulator)
|
||||||
|
biometricsType = .touchId
|
||||||
|
#else
|
||||||
if data == LocalAuth.evaluatedPolicyDomainState || (data == nil && !self.applicationBindings.isMainApp) {
|
if data == LocalAuth.evaluatedPolicyDomainState || (data == nil && !self.applicationBindings.isMainApp) {
|
||||||
biometricsType = LocalAuth.biometricAuthentication
|
biometricsType = LocalAuth.biometricAuthentication
|
||||||
} else {
|
} else {
|
||||||
biometricsType = nil
|
biometricsType = nil
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
biometricsType = LocalAuth.biometricAuthentication
|
biometricsType = LocalAuth.biometricAuthentication
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
biometricsType = nil
|
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()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
let _ = (self.appLockContext.invalidAttempts
|
let _ = (self.appLockContext.invalidAttempts
|
||||||
|
@ -29,6 +29,8 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
|||||||
|
|
||||||
private let statusBar: StatusBar
|
private let statusBar: StatusBar
|
||||||
|
|
||||||
|
private let modalPresentation: Bool
|
||||||
|
|
||||||
private let backgroundNode: ASImageNode
|
private let backgroundNode: ASImageNode
|
||||||
private let iconNode: PasscodeLockIconNode
|
private let iconNode: PasscodeLockIconNode
|
||||||
private let titleNode: PasscodeEntryLabelNode
|
private let titleNode: PasscodeEntryLabelNode
|
||||||
@ -50,7 +52,7 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
|||||||
var checkPasscode: ((String) -> Void)?
|
var checkPasscode: ((String) -> Void)?
|
||||||
var requestBiometrics: (() -> 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.accountManager = accountManager
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
@ -59,6 +61,7 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
|||||||
self.biometricsType = biometricsType
|
self.biometricsType = biometricsType
|
||||||
self.arguments = arguments
|
self.arguments = arguments
|
||||||
self.statusBar = statusBar
|
self.statusBar = statusBar
|
||||||
|
self.modalPresentation = modalPresentation
|
||||||
|
|
||||||
self.backgroundNode = ASImageNode()
|
self.backgroundNode = ASImageNode()
|
||||||
self.backgroundNode.contentMode = .scaleToFill
|
self.backgroundNode.contentMode = .scaleToFill
|
||||||
@ -373,7 +376,7 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
|||||||
self.iconNode.alpha = 0.0
|
self.iconNode.alpha = 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
let passcodeLayout = PasscodeLayout(layout: layout)
|
let passcodeLayout = PasscodeLayout(layout: layout, modalPresentation: self.modalPresentation)
|
||||||
let inputFieldOffset: CGFloat
|
let inputFieldOffset: CGFloat
|
||||||
if isLandscape {
|
if isLandscape {
|
||||||
let bottomInset = layout.inputHeight ?? 0.0
|
let bottomInset = layout.inputHeight ?? 0.0
|
||||||
|
@ -3,18 +3,23 @@ import UIKit
|
|||||||
import Display
|
import Display
|
||||||
|
|
||||||
struct PasscodeKeyboardLayout {
|
struct PasscodeKeyboardLayout {
|
||||||
let buttonSize: CGFloat
|
var buttonSize: CGFloat
|
||||||
let horizontalSecond: CGFloat
|
var horizontalSecond: CGFloat
|
||||||
let horizontalThird: CGFloat
|
var horizontalThird: CGFloat
|
||||||
let verticalSecond: CGFloat
|
var verticalSecond: CGFloat
|
||||||
let verticalThird: CGFloat
|
var verticalThird: CGFloat
|
||||||
let verticalFourth: CGFloat
|
var verticalFourth: CGFloat
|
||||||
let size: CGSize
|
var size: CGSize
|
||||||
let topOffset: CGFloat
|
var topOffset: CGFloat
|
||||||
let biometricsOffset: CGFloat
|
var biometricsOffset: CGFloat
|
||||||
let deleteOffset: CGFloat
|
var deleteOffset: CGFloat
|
||||||
|
|
||||||
|
fileprivate init(layout: ContainerViewLayout, modalPresentation: Bool) {
|
||||||
|
var modalOffset: CGFloat = 0.0
|
||||||
|
if modalPresentation {
|
||||||
|
modalOffset -= 20.0
|
||||||
|
}
|
||||||
|
|
||||||
fileprivate init(layout: ContainerViewLayout) {
|
|
||||||
switch layout.deviceMetrics {
|
switch layout.deviceMetrics {
|
||||||
case .iPhone4:
|
case .iPhone4:
|
||||||
self.buttonSize = 75.0
|
self.buttonSize = 75.0
|
||||||
@ -105,20 +110,28 @@ struct PasscodeKeyboardLayout {
|
|||||||
self.biometricsOffset = 30.0
|
self.biometricsOffset = 30.0
|
||||||
self.deleteOffset = 20.0
|
self.deleteOffset = 20.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.topOffset += modalOffset * 2.0
|
||||||
|
self.biometricsOffset += modalOffset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct PasscodeLayout {
|
public struct PasscodeLayout {
|
||||||
let layout: ContainerViewLayout
|
var layout: ContainerViewLayout
|
||||||
let keyboard: PasscodeKeyboardLayout
|
var keyboard: PasscodeKeyboardLayout
|
||||||
let titleOffset: CGFloat
|
var titleOffset: CGFloat
|
||||||
let subtitleOffset: CGFloat
|
var subtitleOffset: CGFloat
|
||||||
let inputFieldOffset: CGFloat
|
var inputFieldOffset: CGFloat
|
||||||
|
|
||||||
init(layout: ContainerViewLayout) {
|
init(layout: ContainerViewLayout, modalPresentation: Bool) {
|
||||||
self.layout = layout
|
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 {
|
switch layout.deviceMetrics {
|
||||||
case .iPhone4:
|
case .iPhone4:
|
||||||
self.titleOffset = 30.0
|
self.titleOffset = 30.0
|
||||||
@ -153,11 +166,15 @@ public struct PasscodeLayout {
|
|||||||
self.subtitleOffset = 0.0
|
self.subtitleOffset = 0.0
|
||||||
self.inputFieldOffset = 140.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.layout = layout
|
||||||
self.keyboard = PasscodeKeyboardLayout(layout: layout)
|
self.keyboard = PasscodeKeyboardLayout(layout: layout, modalPresentation: modalPresentation)
|
||||||
self.titleOffset = titleOffset
|
self.titleOffset = titleOffset
|
||||||
self.subtitleOffset = subtitleOffset
|
self.subtitleOffset = subtitleOffset
|
||||||
self.inputFieldOffset = inputFieldOffset
|
self.inputFieldOffset = inputFieldOffset
|
||||||
|
@ -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 context.sharedContext.accountManager.transaction { transaction -> PostboxAccessChallengeData in
|
||||||
return transaction.getAccessChallengeData()
|
return transaction.getAccessChallengeData()
|
||||||
}
|
}
|
||||||
@ -458,14 +458,18 @@ public func passcodeEntryController(context: AccountContext, animateIn: Bool = t
|
|||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
let biometrics: PasscodeEntryControllerBiometricsMode
|
let biometrics: PasscodeEntryControllerBiometricsMode
|
||||||
|
#if targetEnvironment(simulator)
|
||||||
|
biometrics = .enabled(nil)
|
||||||
|
#else
|
||||||
if let passcodeSettings = passcodeSettings, passcodeSettings.enableBiometrics {
|
if let passcodeSettings = passcodeSettings, passcodeSettings.enableBiometrics {
|
||||||
biometrics = .enabled(context.sharedContext.applicationBindings.isMainApp ? passcodeSettings.biometricsDomainState : passcodeSettings.shareBiometricsDomainState)
|
biometrics = .enabled(context.sharedContext.applicationBindings.isMainApp ? passcodeSettings.biometricsDomainState : passcodeSettings.shareBiometricsDomainState)
|
||||||
} else {
|
} else {
|
||||||
biometrics = .none
|
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: {
|
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)
|
completion(false)
|
||||||
}))
|
}, modalPresentation: modalPresentation))
|
||||||
controller.presentationCompleted = { [weak controller] in
|
controller.presentationCompleted = { [weak controller] in
|
||||||
Queue.mainQueue().after(0.5, { [weak controller] in
|
Queue.mainQueue().after(0.5, { [weak controller] in
|
||||||
controller?.requestBiometrics()
|
controller?.requestBiometrics()
|
||||||
|
@ -122,8 +122,10 @@ public class ShareRootControllerImpl {
|
|||||||
mainWindow.hostView.eventView.isHidden = false
|
mainWindow.hostView.eventView.isHidden = false
|
||||||
self.mainWindow = mainWindow
|
self.mainWindow = mainWindow
|
||||||
|
|
||||||
|
let bounds = view.bounds
|
||||||
|
|
||||||
view.addSubview(mainWindow.hostView.containerView)
|
view.addSubview(mainWindow.hostView.containerView)
|
||||||
mainWindow.hostView.containerView.frame = view.bounds
|
mainWindow.hostView.containerView.frame = bounds
|
||||||
|
|
||||||
let rootPath = rootPathForBasePath(self.initializationData.appGroupPath)
|
let rootPath = rootPathForBasePath(self.initializationData.appGroupPath)
|
||||||
performAppGroupUpgrades(appGroupPath: self.initializationData.appGroupPath, rootPath: rootPath)
|
performAppGroupUpgrades(appGroupPath: self.initializationData.appGroupPath, rootPath: rootPath)
|
||||||
@ -340,7 +342,14 @@ public class ShareRootControllerImpl {
|
|||||||
context.account.resetStateManagement()
|
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 {
|
if value {
|
||||||
displayShare()
|
displayShare()
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user