mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 11:50:56 +00:00
Passcode UI fixes
This commit is contained in:
parent
d442361ab2
commit
2463fcf0b7
@ -73,7 +73,7 @@ private var serviceBackgroundColorForWallpaper: (TelegramWallpaper, UIColor)?
|
|||||||
|
|
||||||
func chatControllerBackgroundImage(wallpaper: TelegramWallpaper, mediaBox: MediaBox, composed: Bool = true) -> UIImage? {
|
func chatControllerBackgroundImage(wallpaper: TelegramWallpaper, mediaBox: MediaBox, composed: Bool = true) -> UIImage? {
|
||||||
var backgroundImage: UIImage?
|
var backgroundImage: UIImage?
|
||||||
if wallpaper == backgroundImageForWallpaper?.0, (wallpaper.settings?.blur ?? false) == backgroundImageForWallpaper?.1 {
|
if composed && wallpaper == backgroundImageForWallpaper?.0, (wallpaper.settings?.blur ?? false) == backgroundImageForWallpaper?.1 {
|
||||||
backgroundImage = backgroundImageForWallpaper?.2
|
backgroundImage = backgroundImageForWallpaper?.2
|
||||||
} else {
|
} else {
|
||||||
switch wallpaper {
|
switch wallpaper {
|
||||||
@ -125,7 +125,7 @@ func chatControllerBackgroundImage(wallpaper: TelegramWallpaper, mediaBox: Media
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let backgroundImage = backgroundImage {
|
if let backgroundImage = backgroundImage, composed {
|
||||||
backgroundImageForWallpaper = (wallpaper, (wallpaper.settings?.blur ?? false), backgroundImage)
|
backgroundImageForWallpaper = (wallpaper, (wallpaper.settings?.blur ?? false), backgroundImage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,8 +162,8 @@ private let readIcon = ItemListRevealOptionIcon.animation(animation: "anim_read"
|
|||||||
private let unreadIcon = ItemListRevealOptionIcon.animation(animation: "anim_unread", scale: 0.33333, offset: 0.0, keysToColor: ["Oval.Oval.Stroke 1"], flip: false)
|
private let unreadIcon = ItemListRevealOptionIcon.animation(animation: "anim_unread", scale: 0.33333, offset: 0.0, keysToColor: ["Oval.Oval.Stroke 1"], flip: false)
|
||||||
private let archiveIcon = ItemListRevealOptionIcon.animation(animation: "anim_archive", scale: 0.33333, offset: 2.0, keysToColor: ["box2.box2.Fill 1"], flip: false)
|
private let archiveIcon = ItemListRevealOptionIcon.animation(animation: "anim_archive", scale: 0.33333, offset: 2.0, keysToColor: ["box2.box2.Fill 1"], flip: false)
|
||||||
private let unarchiveIcon = ItemListRevealOptionIcon.animation(animation: "anim_unarchive", scale: 0.16214, offset: -9.0, keysToColor: ["box2.box2.Fill 1"], flip: false)
|
private let unarchiveIcon = ItemListRevealOptionIcon.animation(animation: "anim_unarchive", scale: 0.16214, offset: -9.0, keysToColor: ["box2.box2.Fill 1"], flip: false)
|
||||||
private let hideIcon = ItemListRevealOptionIcon.animation(animation: "anim_hide", scale: 0.33333, offset: 0.0, keysToColor: ["Path 2.Path 2.Fill 1"], flip: false)
|
private let hideIcon = ItemListRevealOptionIcon.animation(animation: "anim_hide", scale: 0.33333, offset: 2.0, keysToColor: ["Path 2.Path 2.Fill 1"], flip: false)
|
||||||
private let unhideIcon = ItemListRevealOptionIcon.animation(animation: "anim_hide", scale: 0.33333, offset: 0.0, keysToColor: ["Path 2.Path 2.Fill 1"], flip: true)
|
private let unhideIcon = ItemListRevealOptionIcon.animation(animation: "anim_hide", scale: 0.33333, offset: -20.0, keysToColor: ["Path 2.Path 2.Fill 1"], flip: true)
|
||||||
|
|
||||||
private enum RevealOptionKey: Int32 {
|
private enum RevealOptionKey: Int32 {
|
||||||
case pin
|
case pin
|
||||||
|
|||||||
@ -28,6 +28,7 @@ final public class PasscodeEntryController: ViewController {
|
|||||||
private let arguments: PasscodeEntryControllerPresentationArguments
|
private let arguments: PasscodeEntryControllerPresentationArguments
|
||||||
|
|
||||||
public var presentationCompleted: (() -> Void)?
|
public var presentationCompleted: (() -> Void)?
|
||||||
|
public var completed: (() -> Void)?
|
||||||
|
|
||||||
private let biometricsDisposable = MetaDisposable()
|
private let biometricsDisposable = MetaDisposable()
|
||||||
|
|
||||||
@ -102,6 +103,9 @@ final public class PasscodeEntryController: ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if succeed {
|
if succeed {
|
||||||
|
if let completed = strongSelf.completed {
|
||||||
|
completed()
|
||||||
|
} else {
|
||||||
let _ = (strongSelf.context.sharedContext.accountManager.transaction { transaction -> Void in
|
let _ = (strongSelf.context.sharedContext.accountManager.transaction { transaction -> Void in
|
||||||
var data = transaction.getAccessChallengeData().withUpdatedAutolockDeadline(nil)
|
var data = transaction.getAccessChallengeData().withUpdatedAutolockDeadline(nil)
|
||||||
switch data {
|
switch data {
|
||||||
@ -114,6 +118,7 @@ final public class PasscodeEntryController: ViewController {
|
|||||||
}
|
}
|
||||||
transaction.setAccessChallengeData(data)
|
transaction.setAccessChallengeData(data)
|
||||||
}).start()
|
}).start()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let _ = (strongSelf.context.sharedContext.accountManager.transaction({ transaction -> AccessChallengeAttempts in
|
let _ = (strongSelf.context.sharedContext.accountManager.transaction({ transaction -> AccessChallengeAttempts in
|
||||||
var data = transaction.getAccessChallengeData()
|
var data = transaction.getAccessChallengeData()
|
||||||
@ -160,11 +165,14 @@ final public class PasscodeEntryController: ViewController {
|
|||||||
|
|
||||||
self.controllerNode.activateInput()
|
self.controllerNode.activateInput()
|
||||||
if self.arguments.animated {
|
if self.arguments.animated {
|
||||||
|
let iconFrame = self.arguments.lockIconInitialFrame()
|
||||||
|
if !iconFrame.isEmpty {
|
||||||
Queue.mainQueue().after(0.5) {
|
Queue.mainQueue().after(0.5) {
|
||||||
serviceSoundManager.playLockSound()
|
serviceSoundManager.playLockSound()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.controllerNode.animateIn(iconFrame: self.arguments.lockIconInitialFrame(), completion: { [weak self] in
|
self.controllerNode.animateIn(iconFrame: iconFrame, completion: { [weak self] in
|
||||||
self?.presentationCompleted?()
|
self?.presentationCompleted?()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import Postbox
|
|||||||
import TelegramCore
|
import TelegramCore
|
||||||
|
|
||||||
private let titleFont = Font.regular(20.0)
|
private let titleFont = Font.regular(20.0)
|
||||||
private let subtitleFont = Font.regular(17.0)
|
private let subtitleFont = Font.regular(15.0)
|
||||||
private let buttonFont = Font.regular(17.0)
|
private let buttonFont = Font.regular(17.0)
|
||||||
|
|
||||||
final class PasscodeEntryControllerNode: ASDisplayNode {
|
final class PasscodeEntryControllerNode: ASDisplayNode {
|
||||||
@ -177,15 +177,9 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
|||||||
func updateInvalidAttempts(_ attempts: AccessChallengeAttempts?, animated: Bool = false) {
|
func updateInvalidAttempts(_ attempts: AccessChallengeAttempts?, animated: Bool = false) {
|
||||||
self.invalidAttempts = attempts
|
self.invalidAttempts = attempts
|
||||||
if let attempts = attempts {
|
if let attempts = attempts {
|
||||||
let text: NSAttributedString
|
var text = NSAttributedString(string: "")
|
||||||
if attempts.count >= 6 {
|
if attempts.count >= 6 && self.shouldWaitBeforeNextAttempt() {
|
||||||
if self.shouldWaitBeforeNextAttempt() {
|
|
||||||
text = NSAttributedString(string: self.strings.PasscodeSettings_TryAgainIn1Minute, font: subtitleFont, textColor: .white)
|
text = NSAttributedString(string: self.strings.PasscodeSettings_TryAgainIn1Minute, font: subtitleFont, textColor: .white)
|
||||||
} else {
|
|
||||||
text = NSAttributedString(string: "")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
text = NSAttributedString(string: self.strings.PasscodeSettings_FailedAttempts(attempts.count), font: subtitleFont, textColor: .white)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.subtitleNode.setAttributedText(text, animation: animated ? .crossFade : .none, completion: {})
|
self.subtitleNode.setAttributedText(text, animation: animated ? .crossFade : .none, completion: {})
|
||||||
@ -212,8 +206,10 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
self.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||||
|
if !iconFrame.isEmpty {
|
||||||
self.iconNode.animateIn(fromScale: 0.416)
|
self.iconNode.animateIn(fromScale: 0.416)
|
||||||
self.iconNode.layer.animatePosition(from: iconFrame.center.offsetBy(dx: 6.0, dy: 6.0), to: self.iconNode.layer.position, duration: 0.45)
|
self.iconNode.layer.animatePosition(from: iconFrame.center.offsetBy(dx: 6.0, dy: 6.0), to: self.iconNode.layer.position, duration: 0.45)
|
||||||
|
}
|
||||||
|
|
||||||
self.statusBar.layer.removeAnimation(forKey: "opacity")
|
self.statusBar.layer.removeAnimation(forKey: "opacity")
|
||||||
self.statusBar.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
self.statusBar.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||||
@ -274,6 +270,10 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
|||||||
self.updateBackground()
|
self.updateBackground()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if layout.size.width == 320.0 {
|
||||||
|
self.iconNode.alpha = 0.0
|
||||||
|
}
|
||||||
|
|
||||||
let bounds = CGRect(origin: CGPoint(), size: layout.size)
|
let bounds = CGRect(origin: CGPoint(), size: layout.size)
|
||||||
transition.updateFrame(node: self.backgroundNode, frame: bounds)
|
transition.updateFrame(node: self.backgroundNode, frame: bounds)
|
||||||
transition.updateFrame(view: self.effectView, frame: bounds)
|
transition.updateFrame(view: self.effectView, frame: bounds)
|
||||||
@ -289,8 +289,12 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
|||||||
let titleSize = self.titleNode.updateLayout(layout: layout, transition: transition)
|
let titleSize = self.titleNode.updateLayout(layout: layout, transition: transition)
|
||||||
transition.updateFrame(node: self.titleNode, frame: CGRect(origin: CGPoint(x: 0.0, y: passcodeLayout.titleOffset), size: titleSize))
|
transition.updateFrame(node: self.titleNode, frame: CGRect(origin: CGPoint(x: 0.0, y: passcodeLayout.titleOffset), size: titleSize))
|
||||||
|
|
||||||
|
var subtitleOffset = passcodeLayout.subtitleOffset
|
||||||
|
if case .alphanumeric = self.passcodeType {
|
||||||
|
subtitleOffset = 16.0
|
||||||
|
}
|
||||||
let subtitleSize = self.subtitleNode.updateLayout(layout: layout, transition: transition)
|
let subtitleSize = self.subtitleNode.updateLayout(layout: layout, transition: transition)
|
||||||
transition.updateFrame(node: self.subtitleNode, frame: CGRect(origin: CGPoint(x: 0.0, y: inputFieldFrame.maxY + passcodeLayout.subtitleOffset), size: subtitleSize))
|
transition.updateFrame(node: self.subtitleNode, frame: CGRect(origin: CGPoint(x: 0.0, y: inputFieldFrame.maxY + subtitleOffset), size: subtitleSize))
|
||||||
|
|
||||||
let (keyboardFrame, keyboardButtonSize) = self.keyboardNode.updateLayout(layout: passcodeLayout, transition: transition)
|
let (keyboardFrame, keyboardButtonSize) = self.keyboardNode.updateLayout(layout: passcodeLayout, transition: transition)
|
||||||
transition.updateFrame(node: self.keyboardNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
transition.updateFrame(node: self.keyboardNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
||||||
@ -311,7 +315,7 @@ final class PasscodeEntryControllerNode: ASDisplayNode {
|
|||||||
if bottomInset > 0 && self.keyboardNode.alpha < 1.0 {
|
if bottomInset > 0 && self.keyboardNode.alpha < 1.0 {
|
||||||
biometricY = inputFieldFrame.maxY + floor((layout.size.height - bottomInset - inputFieldFrame.maxY - biometricIcon.size.height) / 2.0)
|
biometricY = inputFieldFrame.maxY + floor((layout.size.height - bottomInset - inputFieldFrame.maxY - biometricIcon.size.height) / 2.0)
|
||||||
} else {
|
} else {
|
||||||
biometricY = keyboardFrame.maxY + 30.0
|
biometricY = keyboardFrame.maxY + passcodeLayout.keyboard.biometricsOffset
|
||||||
}
|
}
|
||||||
transition.updateFrame(node: self.biometricButtonNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - biometricIcon.size.width) / 2.0), y: biometricY), size: biometricIcon.size))
|
transition.updateFrame(node: self.biometricButtonNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - biometricIcon.size.width) / 2.0), y: biometricY), size: biometricIcon.size))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -309,7 +309,10 @@ final class PasscodeEntryInputFieldNode: ASDisplayNode, UITextFieldDelegate {
|
|||||||
transition.updateFrame(node: node, frame: dotFrame)
|
transition.updateFrame(node: node, frame: dotFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
let inset: CGFloat = 50.0
|
var inset: CGFloat = 50.0
|
||||||
|
if !self.useCustomNumpad {
|
||||||
|
inset = 16.0
|
||||||
|
}
|
||||||
let fieldFrame = CGRect(x: inset, y: origin.y, width: layout.layout.size.width - inset * 2.0, height: fieldHeight)
|
let fieldFrame = CGRect(x: inset, y: origin.y, width: layout.layout.size.width - inset * 2.0, height: fieldHeight)
|
||||||
transition.updateFrame(node: self.borderNode, frame: fieldFrame)
|
transition.updateFrame(node: self.borderNode, frame: fieldFrame)
|
||||||
transition.updateFrame(node: self.textFieldNode, frame: fieldFrame.insetBy(dx: 13.0, dy: 0.0))
|
transition.updateFrame(node: self.textFieldNode, frame: fieldFrame.insetBy(dx: 13.0, dy: 0.0))
|
||||||
|
|||||||
@ -10,6 +10,7 @@ struct PasscodeKeyboardLayout {
|
|||||||
let verticalFourth: CGFloat
|
let verticalFourth: CGFloat
|
||||||
let size: CGSize
|
let size: CGSize
|
||||||
let topOffset: CGFloat
|
let topOffset: CGFloat
|
||||||
|
let biometricsOffset: CGFloat
|
||||||
|
|
||||||
fileprivate init(metrics: DeviceMetrics?) {
|
fileprivate init(metrics: DeviceMetrics?) {
|
||||||
if let metrics = metrics {
|
if let metrics = metrics {
|
||||||
@ -23,6 +24,7 @@ struct PasscodeKeyboardLayout {
|
|||||||
self.verticalFourth = 264.0
|
self.verticalFourth = 264.0
|
||||||
self.size = CGSize(width: 265.0, height: 339.0)
|
self.size = CGSize(width: 265.0, height: 339.0)
|
||||||
self.topOffset = 0.0
|
self.topOffset = 0.0
|
||||||
|
self.biometricsOffset = 0.0
|
||||||
case .iPhone5:
|
case .iPhone5:
|
||||||
self.buttonSize = 75.0
|
self.buttonSize = 75.0
|
||||||
self.horizontalSecond = 95.0
|
self.horizontalSecond = 95.0
|
||||||
@ -31,7 +33,8 @@ struct PasscodeKeyboardLayout {
|
|||||||
self.verticalThird = 176.0
|
self.verticalThird = 176.0
|
||||||
self.verticalFourth = 264.0
|
self.verticalFourth = 264.0
|
||||||
self.size = CGSize(width: 265.0, height: 339.0)
|
self.size = CGSize(width: 265.0, height: 339.0)
|
||||||
self.topOffset = 0.0
|
self.topOffset = 155.0
|
||||||
|
self.biometricsOffset = 23.0
|
||||||
case .iPhone6:
|
case .iPhone6:
|
||||||
self.buttonSize = 75.0
|
self.buttonSize = 75.0
|
||||||
self.horizontalSecond = 103.0
|
self.horizontalSecond = 103.0
|
||||||
@ -40,7 +43,8 @@ struct PasscodeKeyboardLayout {
|
|||||||
self.verticalThird = 180.0
|
self.verticalThird = 180.0
|
||||||
self.verticalFourth = 270.0
|
self.verticalFourth = 270.0
|
||||||
self.size = CGSize(width: 281.0, height: 348.0)
|
self.size = CGSize(width: 281.0, height: 348.0)
|
||||||
self.topOffset = 0.0
|
self.topOffset = 221.0
|
||||||
|
self.biometricsOffset = 30.0
|
||||||
case .iPhone6Plus:
|
case .iPhone6Plus:
|
||||||
self.buttonSize = 85.0
|
self.buttonSize = 85.0
|
||||||
self.horizontalSecond = 115.0
|
self.horizontalSecond = 115.0
|
||||||
@ -50,6 +54,7 @@ struct PasscodeKeyboardLayout {
|
|||||||
self.verticalFourth = 300.0
|
self.verticalFourth = 300.0
|
||||||
self.size = CGSize(width: 315.0, height: 385.0)
|
self.size = CGSize(width: 315.0, height: 385.0)
|
||||||
self.topOffset = 226.0
|
self.topOffset = 226.0
|
||||||
|
self.biometricsOffset = 30.0
|
||||||
case .iPhoneX:
|
case .iPhoneX:
|
||||||
self.buttonSize = 75.0
|
self.buttonSize = 75.0
|
||||||
self.horizontalSecond = 103.0
|
self.horizontalSecond = 103.0
|
||||||
@ -59,6 +64,7 @@ struct PasscodeKeyboardLayout {
|
|||||||
self.verticalFourth = 273.0
|
self.verticalFourth = 273.0
|
||||||
self.size = CGSize(width: 281.0, height: 348.0)
|
self.size = CGSize(width: 281.0, height: 348.0)
|
||||||
self.topOffset = 294.0
|
self.topOffset = 294.0
|
||||||
|
self.biometricsOffset = 30.0
|
||||||
case .iPhoneXSMax:
|
case .iPhoneXSMax:
|
||||||
self.buttonSize = 85.0
|
self.buttonSize = 85.0
|
||||||
self.horizontalSecond = 115.0
|
self.horizontalSecond = 115.0
|
||||||
@ -68,6 +74,7 @@ struct PasscodeKeyboardLayout {
|
|||||||
self.verticalFourth = 300.0
|
self.verticalFourth = 300.0
|
||||||
self.size = CGSize(width: 315.0, height: 385.0)
|
self.size = CGSize(width: 315.0, height: 385.0)
|
||||||
self.topOffset = 329.0
|
self.topOffset = 329.0
|
||||||
|
self.biometricsOffset = 30.0
|
||||||
case .iPad, .iPadPro10Inch, .iPadPro11Inch, .iPadPro, .iPadPro3rdGen:
|
case .iPad, .iPadPro10Inch, .iPadPro11Inch, .iPadPro, .iPadPro3rdGen:
|
||||||
self.buttonSize = 81.0
|
self.buttonSize = 81.0
|
||||||
self.horizontalSecond = 106.0
|
self.horizontalSecond = 106.0
|
||||||
@ -77,6 +84,7 @@ struct PasscodeKeyboardLayout {
|
|||||||
self.verticalFourth = 303.0
|
self.verticalFourth = 303.0
|
||||||
self.size = CGSize(width: 293.0, height: 384.0)
|
self.size = CGSize(width: 293.0, height: 384.0)
|
||||||
self.topOffset = 0.0
|
self.topOffset = 0.0
|
||||||
|
self.biometricsOffset = 30.0
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.buttonSize = 75.0
|
self.buttonSize = 75.0
|
||||||
@ -87,6 +95,7 @@ struct PasscodeKeyboardLayout {
|
|||||||
self.verticalFourth = 264.0
|
self.verticalFourth = 264.0
|
||||||
self.size = CGSize(width: 265.0, height: 339.0)
|
self.size = CGSize(width: 265.0, height: 339.0)
|
||||||
self.topOffset = 0.0
|
self.topOffset = 0.0
|
||||||
|
self.biometricsOffset = 30.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,17 +115,17 @@ struct PasscodeLayout {
|
|||||||
if let metrics = metrics {
|
if let metrics = metrics {
|
||||||
switch metrics {
|
switch metrics {
|
||||||
case .iPhone4:
|
case .iPhone4:
|
||||||
self.titleOffset = 0.0
|
self.titleOffset = 30.0
|
||||||
self.subtitleOffset = 0.0
|
self.subtitleOffset = 0.0
|
||||||
self.inputFieldOffset = 0.0
|
self.inputFieldOffset = 70.0
|
||||||
case .iPhone5:
|
case .iPhone5:
|
||||||
self.titleOffset = 0.0
|
self.titleOffset = 50.0
|
||||||
self.subtitleOffset = 0.0
|
self.subtitleOffset = -7.0
|
||||||
self.inputFieldOffset = 0.0
|
self.inputFieldOffset = 90.0
|
||||||
case .iPhone6:
|
case .iPhone6:
|
||||||
self.titleOffset = 0.0
|
self.titleOffset = 100.0
|
||||||
self.subtitleOffset = 0.0
|
self.subtitleOffset = -3.0
|
||||||
self.inputFieldOffset = 0.0
|
self.inputFieldOffset = 144.0
|
||||||
case .iPhone6Plus:
|
case .iPhone6Plus:
|
||||||
self.titleOffset = 112.0
|
self.titleOffset = 112.0
|
||||||
self.subtitleOffset = -6.0
|
self.subtitleOffset = -6.0
|
||||||
|
|||||||
@ -7,20 +7,16 @@ import LegacyComponents
|
|||||||
import LocalAuthentication
|
import LocalAuthentication
|
||||||
|
|
||||||
private final class PasscodeOptionsControllerArguments {
|
private final class PasscodeOptionsControllerArguments {
|
||||||
let turnPasscodeOn: () -> Void
|
|
||||||
let turnPasscodeOff: () -> Void
|
let turnPasscodeOff: () -> Void
|
||||||
let changePasscode: () -> Void
|
let changePasscode: () -> Void
|
||||||
let changePasscodeTimeout: () -> Void
|
let changePasscodeTimeout: () -> Void
|
||||||
let changeTouchId: (Bool) -> Void
|
let changeTouchId: (Bool) -> Void
|
||||||
let toggleSimplePasscode: (Bool) -> Void
|
|
||||||
|
|
||||||
init(turnPasscodeOn: @escaping () -> Void, turnPasscodeOff: @escaping () -> Void, changePasscode: @escaping () -> Void, changePasscodeTimeout: @escaping () -> Void, changeTouchId: @escaping (Bool) -> Void, toggleSimplePasscode: @escaping (Bool) -> Void) {
|
init(turnPasscodeOff: @escaping () -> Void, changePasscode: @escaping () -> Void, changePasscodeTimeout: @escaping () -> Void, changeTouchId: @escaping (Bool) -> Void) {
|
||||||
self.turnPasscodeOn = turnPasscodeOn
|
|
||||||
self.turnPasscodeOff = turnPasscodeOff
|
self.turnPasscodeOff = turnPasscodeOff
|
||||||
self.changePasscode = changePasscode
|
self.changePasscode = changePasscode
|
||||||
self.changePasscodeTimeout = changePasscodeTimeout
|
self.changePasscodeTimeout = changePasscodeTimeout
|
||||||
self.changeTouchId = changeTouchId
|
self.changeTouchId = changeTouchId
|
||||||
self.toggleSimplePasscode = toggleSimplePasscode
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,13 +32,12 @@ private enum PasscodeOptionsEntry: ItemListNodeEntry {
|
|||||||
|
|
||||||
case autoLock(PresentationTheme, String, String)
|
case autoLock(PresentationTheme, String, String)
|
||||||
case touchId(PresentationTheme, String, Bool)
|
case touchId(PresentationTheme, String, Bool)
|
||||||
case simplePasscode(PresentationTheme, String, Bool)
|
|
||||||
|
|
||||||
var section: ItemListSectionId {
|
var section: ItemListSectionId {
|
||||||
switch self {
|
switch self {
|
||||||
case .togglePasscode, .changePasscode, .settingInfo:
|
case .togglePasscode, .changePasscode, .settingInfo:
|
||||||
return PasscodeOptionsSection.setting.rawValue
|
return PasscodeOptionsSection.setting.rawValue
|
||||||
case .autoLock, .touchId, .simplePasscode:
|
case .autoLock, .touchId:
|
||||||
return PasscodeOptionsSection.options.rawValue
|
return PasscodeOptionsSection.options.rawValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,8 +54,6 @@ private enum PasscodeOptionsEntry: ItemListNodeEntry {
|
|||||||
return 3
|
return 3
|
||||||
case .touchId:
|
case .touchId:
|
||||||
return 4
|
return 4
|
||||||
case .simplePasscode:
|
|
||||||
return 5
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,12 +89,6 @@ private enum PasscodeOptionsEntry: ItemListNodeEntry {
|
|||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case let .simplePasscode(lhsTheme, lhsText, lhsValue):
|
|
||||||
if case let .simplePasscode(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +102,6 @@ private enum PasscodeOptionsEntry: ItemListNodeEntry {
|
|||||||
return ItemListActionItem(theme: theme, title: title, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
return ItemListActionItem(theme: theme, title: title, kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||||
if value {
|
if value {
|
||||||
arguments.turnPasscodeOff()
|
arguments.turnPasscodeOff()
|
||||||
} else {
|
|
||||||
arguments.turnPasscodeOn()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
case let .changePasscode(theme, title):
|
case let .changePasscode(theme, title):
|
||||||
@ -133,10 +118,6 @@ private enum PasscodeOptionsEntry: ItemListNodeEntry {
|
|||||||
return ItemListSwitchItem(theme: theme, title: title, value: value, sectionId: self.section, style: .blocks, updated: { value in
|
return ItemListSwitchItem(theme: theme, title: title, value: value, sectionId: self.section, style: .blocks, updated: { value in
|
||||||
arguments.changeTouchId(value)
|
arguments.changeTouchId(value)
|
||||||
})
|
})
|
||||||
case let .simplePasscode(theme, title, value):
|
|
||||||
return ItemListSwitchItem(theme: theme, title: title, value: value, enableInteractiveChanges: false, sectionId: self.section, style: .blocks, updated: { value in
|
|
||||||
arguments.toggleSimplePasscode(value)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,6 +206,7 @@ func passcodeOptionsController(context: AccountContext) -> ViewController {
|
|||||||
|
|
||||||
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments) -> Void)?
|
var presentControllerImpl: ((ViewController, ViewControllerPresentationArguments) -> Void)?
|
||||||
var pushControllerImpl: ((ViewController) -> Void)?
|
var pushControllerImpl: ((ViewController) -> Void)?
|
||||||
|
var popControllerImpl: (() -> Void)?
|
||||||
var replaceTopControllerImpl: ((ViewController, Bool) -> Void)?
|
var replaceTopControllerImpl: ((ViewController, Bool) -> Void)?
|
||||||
|
|
||||||
let actionsDisposable = DisposableSet()
|
let actionsDisposable = DisposableSet()
|
||||||
@ -238,40 +220,7 @@ func passcodeOptionsController(context: AccountContext) -> ViewController {
|
|||||||
return PasscodeOptionsData(accessChallenge: accessChallenge, presentationSettings: passcodeSettings)
|
return PasscodeOptionsData(accessChallenge: accessChallenge, presentationSettings: passcodeSettings)
|
||||||
})
|
})
|
||||||
|
|
||||||
let arguments = PasscodeOptionsControllerArguments(turnPasscodeOn: {
|
let arguments = PasscodeOptionsControllerArguments(turnPasscodeOff: {
|
||||||
var dismissImpl: (() -> Void)?
|
|
||||||
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
|
||||||
|
|
||||||
let legacyController = LegacyController(presentation: LegacyControllerPresentation.modal(animateIn: true), theme: presentationData.theme)
|
|
||||||
let controller = TGPasscodeEntryController(context: legacyController.context, style: TGPasscodeEntryControllerStyleDefault, mode: TGPasscodeEntryControllerModeSetupSimple, cancelEnabled: true, allowTouchId: false, attemptData: nil, completion: { result in
|
|
||||||
if let result = result {
|
|
||||||
let challenge = PostboxAccessChallengeData.numericalPassword(value: result, timeout: nil, attempts: nil)
|
|
||||||
let _ = (context.sharedContext.accountManager.transaction { transaction -> Void in
|
|
||||||
transaction.setAccessChallengeData(challenge)
|
|
||||||
updatePresentationPasscodeSettingsInternal(transaction: transaction, { current in
|
|
||||||
return current.withUpdatedAutolockTimeout(1 * 60 * 60)
|
|
||||||
})
|
|
||||||
}).start()
|
|
||||||
|
|
||||||
let _ = (passcodeOptionsDataPromise.get()
|
|
||||||
|> take(1)).start(next: { [weak passcodeOptionsDataPromise] data in
|
|
||||||
passcodeOptionsDataPromise?.set(.single(data.withUpdatedAccessChallenge(challenge).withUpdatedPresentationSettings(data.presentationSettings.withUpdatedAutolockTimeout(1 * 60 * 60))))
|
|
||||||
})
|
|
||||||
|
|
||||||
dismissImpl?()
|
|
||||||
} else {
|
|
||||||
dismissImpl?()
|
|
||||||
}
|
|
||||||
})!
|
|
||||||
legacyController.bind(controller: controller)
|
|
||||||
legacyController.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .portrait, compactSize: .portrait)
|
|
||||||
legacyController.statusBar.statusBarStyle = .White
|
|
||||||
presentControllerImpl?(legacyController, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
|
||||||
dismissImpl = { [weak legacyController] in
|
|
||||||
legacyController?.dismiss()
|
|
||||||
}
|
|
||||||
}, turnPasscodeOff: {
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
let actionSheet = ActionSheetController(presentationTheme: presentationData.theme)
|
let actionSheet = ActionSheetController(presentationTheme: presentationData.theme)
|
||||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: [
|
actionSheet.setItemGroups([ActionSheetItemGroup(items: [
|
||||||
@ -289,7 +238,7 @@ func passcodeOptionsController(context: AccountContext) -> ViewController {
|
|||||||
|
|
||||||
var innerReplaceTopControllerImpl: ((ViewController, Bool) -> Void)?
|
var innerReplaceTopControllerImpl: ((ViewController, Bool) -> Void)?
|
||||||
let controller = PrivacyIntroController(context: context, mode: .passcode, proceedAction: {
|
let controller = PrivacyIntroController(context: context, mode: .passcode, proceedAction: {
|
||||||
let setupController = PasscodeSetupController(context: context, mode: .setup(.digits6))
|
let setupController = PasscodeSetupController(context: context, mode: .setup(change: false, .digits6))
|
||||||
setupController.complete = { passcode, numerical in
|
setupController.complete = { passcode, numerical in
|
||||||
let _ = (context.sharedContext.accountManager.transaction({ transaction -> Void in
|
let _ = (context.sharedContext.accountManager.transaction({ transaction -> Void in
|
||||||
var data = transaction.getAccessChallengeData()
|
var data = transaction.getAccessChallengeData()
|
||||||
@ -299,6 +248,8 @@ func passcodeOptionsController(context: AccountContext) -> ViewController {
|
|||||||
data = PostboxAccessChallengeData.plaintextPassword(value: passcode, timeout: data.autolockDeadline, attempts: nil)
|
data = PostboxAccessChallengeData.plaintextPassword(value: passcode, timeout: data.autolockDeadline, attempts: nil)
|
||||||
}
|
}
|
||||||
transaction.setAccessChallengeData(data)
|
transaction.setAccessChallengeData(data)
|
||||||
|
|
||||||
|
updatePresentationPasscodeSettingsInternal(transaction: transaction, { $0.withUpdatedAutolockTimeout(1 * 60 * 60) })
|
||||||
}) |> deliverOnMainQueue).start(next: { _ in
|
}) |> deliverOnMainQueue).start(next: { _ in
|
||||||
}, error: { _ in
|
}, error: { _ in
|
||||||
}, completed: {
|
}, completed: {
|
||||||
@ -331,35 +282,23 @@ func passcodeOptionsController(context: AccountContext) -> ViewController {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|> deliverOnMainQueue).start(next: { isSimple in
|
|> deliverOnMainQueue).start(next: { isSimple in
|
||||||
var dismissImpl: (() -> Void)?
|
let setupController = PasscodeSetupController(context: context, mode: .setup(change: true, .digits6))
|
||||||
|
setupController.complete = { passcode, numerical in
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let _ = (context.sharedContext.accountManager.transaction({ transaction -> Void in
|
||||||
|
|
||||||
let legacyController = LegacyController(presentation: LegacyControllerPresentation.modal(animateIn: true), theme: presentationData.theme)
|
|
||||||
let controller = TGPasscodeEntryController(context: legacyController.context, style: TGPasscodeEntryControllerStyleDefault, mode: isSimple ? TGPasscodeEntryControllerModeSetupSimple : TGPasscodeEntryControllerModeSetupComplex, cancelEnabled: true, allowTouchId: false, attemptData: nil, completion: { result in
|
|
||||||
if let result = result {
|
|
||||||
let _ = context.sharedContext.accountManager.transaction({ transaction -> Void in
|
|
||||||
var data = transaction.getAccessChallengeData()
|
var data = transaction.getAccessChallengeData()
|
||||||
data = PostboxAccessChallengeData.numericalPassword(value: result, timeout: data.autolockDeadline, attempts: nil)
|
if numerical {
|
||||||
transaction.setAccessChallengeData(data)
|
data = PostboxAccessChallengeData.numericalPassword(value: passcode, timeout: data.autolockDeadline, attempts: nil)
|
||||||
}).start()
|
|
||||||
|
|
||||||
let _ = (passcodeOptionsDataPromise.get() |> take(1)).start(next: { [weak passcodeOptionsDataPromise] data in
|
|
||||||
passcodeOptionsDataPromise?.set(.single(data.withUpdatedAccessChallenge(PostboxAccessChallengeData.numericalPassword(value: result, timeout: nil, attempts: nil))))
|
|
||||||
})
|
|
||||||
|
|
||||||
dismissImpl?()
|
|
||||||
} else {
|
} else {
|
||||||
dismissImpl?()
|
data = PostboxAccessChallengeData.plaintextPassword(value: passcode, timeout: data.autolockDeadline, attempts: nil)
|
||||||
}
|
}
|
||||||
})!
|
transaction.setAccessChallengeData(data)
|
||||||
legacyController.bind(controller: controller)
|
}) |> deliverOnMainQueue).start(next: { _ in
|
||||||
legacyController.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .portrait, compactSize: .portrait)
|
}, error: { _ in
|
||||||
legacyController.statusBar.statusBarStyle = .White
|
}, completed: {
|
||||||
presentControllerImpl?(legacyController, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
popControllerImpl?()
|
||||||
dismissImpl = { [weak legacyController] in
|
})
|
||||||
legacyController?.dismiss()
|
|
||||||
}
|
}
|
||||||
|
pushControllerImpl?(setupController)
|
||||||
})
|
})
|
||||||
}, changePasscodeTimeout: {
|
}, changePasscodeTimeout: {
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
@ -408,38 +347,6 @@ func passcodeOptionsController(context: AccountContext) -> ViewController {
|
|||||||
return current.withUpdatedEnableBiometrics(value)
|
return current.withUpdatedEnableBiometrics(value)
|
||||||
}).start()
|
}).start()
|
||||||
})
|
})
|
||||||
}, toggleSimplePasscode: { value in
|
|
||||||
var dismissImpl: (() -> Void)?
|
|
||||||
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
|
||||||
|
|
||||||
let legacyController = LegacyController(presentation: LegacyControllerPresentation.modal(animateIn: true), theme: presentationData.theme)
|
|
||||||
let controller = TGPasscodeEntryController(context: legacyController.context, style: TGPasscodeEntryControllerStyleDefault, mode: value ? TGPasscodeEntryControllerModeSetupSimple : TGPasscodeEntryControllerModeSetupComplex, cancelEnabled: true, allowTouchId: false, attemptData: nil, completion: { result in
|
|
||||||
if let result = result {
|
|
||||||
let challenge = value ? PostboxAccessChallengeData.numericalPassword(value: result, timeout: nil, attempts: nil) : PostboxAccessChallengeData.plaintextPassword(value: result, timeout: nil, attempts: nil)
|
|
||||||
let _ = (context.sharedContext.accountManager.transaction { transaction -> Void in
|
|
||||||
transaction.setAccessChallengeData(challenge)
|
|
||||||
updatePresentationPasscodeSettingsInternal(transaction: transaction, { current in
|
|
||||||
return current.withUpdatedAutolockTimeout(1 * 60 * 60)
|
|
||||||
})
|
|
||||||
}).start()
|
|
||||||
|
|
||||||
let _ = (passcodeOptionsDataPromise.get() |> take(1)).start(next: { [weak passcodeOptionsDataPromise] data in
|
|
||||||
passcodeOptionsDataPromise?.set(.single(data.withUpdatedAccessChallenge(challenge).withUpdatedPresentationSettings(data.presentationSettings.withUpdatedAutolockTimeout(1 * 60 * 60))))
|
|
||||||
})
|
|
||||||
|
|
||||||
dismissImpl?()
|
|
||||||
} else {
|
|
||||||
dismissImpl?()
|
|
||||||
}
|
|
||||||
})!
|
|
||||||
legacyController.bind(controller: controller)
|
|
||||||
legacyController.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .portrait, compactSize: .portrait)
|
|
||||||
legacyController.statusBar.statusBarStyle = .White
|
|
||||||
presentControllerImpl?(legacyController, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
|
||||||
dismissImpl = { [weak legacyController] in
|
|
||||||
legacyController?.dismiss()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
let signal = combineLatest(context.sharedContext.presentationData, statePromise.get(), passcodeOptionsDataPromise.get()) |> deliverOnMainQueue
|
let signal = combineLatest(context.sharedContext.presentationData, statePromise.get(), passcodeOptionsDataPromise.get()) |> deliverOnMainQueue
|
||||||
@ -462,6 +369,9 @@ func passcodeOptionsController(context: AccountContext) -> ViewController {
|
|||||||
pushControllerImpl = { [weak controller] c in
|
pushControllerImpl = { [weak controller] c in
|
||||||
(controller?.navigationController as? NavigationController)?.pushViewController(c)
|
(controller?.navigationController as? NavigationController)?.pushViewController(c)
|
||||||
}
|
}
|
||||||
|
popControllerImpl = { [weak controller] in
|
||||||
|
let _ = (controller?.navigationController as? NavigationController)?.popViewController(animated: true)
|
||||||
|
}
|
||||||
replaceTopControllerImpl = { [weak controller] c, animated in
|
replaceTopControllerImpl = { [weak controller] c, animated in
|
||||||
(controller?.navigationController as? NavigationController)?.replaceTopController(c, animated: animated)
|
(controller?.navigationController as? NavigationController)?.replaceTopController(c, animated: animated)
|
||||||
}
|
}
|
||||||
@ -477,7 +387,7 @@ public func passcodeOptionsAccessController(context: AccountContext, animateIn:
|
|||||||
|> map { challenge -> ViewController? in
|
|> map { challenge -> ViewController? in
|
||||||
if case .none = challenge {
|
if case .none = challenge {
|
||||||
let controller = PrivacyIntroController(context: context, mode: .passcode, proceedAction: {
|
let controller = PrivacyIntroController(context: context, mode: .passcode, proceedAction: {
|
||||||
let setupController = PasscodeSetupController(context: context, mode: .setup(.digits6))
|
let setupController = PasscodeSetupController(context: context, mode: .setup(change: false, .digits6))
|
||||||
setupController.complete = { passcode, numerical in
|
setupController.complete = { passcode, numerical in
|
||||||
let _ = (context.sharedContext.accountManager.transaction({ transaction -> Void in
|
let _ = (context.sharedContext.accountManager.transaction({ transaction -> Void in
|
||||||
var data = transaction.getAccessChallengeData()
|
var data = transaction.getAccessChallengeData()
|
||||||
@ -487,6 +397,8 @@ public func passcodeOptionsAccessController(context: AccountContext, animateIn:
|
|||||||
data = PostboxAccessChallengeData.plaintextPassword(value: passcode, timeout: data.autolockDeadline, attempts: nil)
|
data = PostboxAccessChallengeData.plaintextPassword(value: passcode, timeout: data.autolockDeadline, attempts: nil)
|
||||||
}
|
}
|
||||||
transaction.setAccessChallengeData(data)
|
transaction.setAccessChallengeData(data)
|
||||||
|
|
||||||
|
updatePresentationPasscodeSettingsInternal(transaction: transaction, { $0.withUpdatedAutolockTimeout(1 * 60 * 60) })
|
||||||
}) |> deliverOnMainQueue).start(next: { _ in
|
}) |> deliverOnMainQueue).start(next: { _ in
|
||||||
}, error: { _ in
|
}, error: { _ in
|
||||||
}, completed: {
|
}, completed: {
|
||||||
@ -534,76 +446,17 @@ public func passcodeEntryController(context: AccountContext, animateIn: Bool = t
|
|||||||
completion(true)
|
completion(true)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
var attemptData: TGPasscodeEntryAttemptData?
|
let controller = PasscodeEntryController(context: context, challengeData: challenge, enableBiometrics: passcodeSettings?.enableBiometrics ?? false, arguments: PasscodeEntryControllerPresentationArguments(animated: animateIn, lockIconInitialFrame: {
|
||||||
if let attempts = challenge.attempts {
|
return CGRect()
|
||||||
attemptData = TGPasscodeEntryAttemptData(numberOfInvalidAttempts: Int(attempts.count), dateOfLastInvalidAttempt: Double(attempts.timestamp))
|
}))
|
||||||
|
controller.presentationCompleted = { [weak controller] in
|
||||||
|
controller?.requestBiometrics()
|
||||||
}
|
}
|
||||||
var dismissImpl: (() -> Void)?
|
controller.completed = { [weak controller] in
|
||||||
|
controller?.dismiss(completion: nil)
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
|
||||||
|
|
||||||
let legacyController = LegacyController(presentation: LegacyControllerPresentation.modal(animateIn: true), theme: presentationData.theme)
|
|
||||||
let mode: TGPasscodeEntryControllerMode
|
|
||||||
switch challenge {
|
|
||||||
case .none, .numericalPassword:
|
|
||||||
mode = TGPasscodeEntryControllerModeVerifySimple
|
|
||||||
case .plaintextPassword:
|
|
||||||
mode = TGPasscodeEntryControllerModeVerifyComplex
|
|
||||||
}
|
|
||||||
let controller = TGPasscodeEntryController(context: legacyController.context, style: TGPasscodeEntryControllerStyleDefault, mode: mode, cancelEnabled: true, allowTouchId: passcodeSettings?.enableBiometrics ?? false, attemptData: attemptData, completion: { value in
|
|
||||||
completion(value != nil)
|
|
||||||
dismissImpl?()
|
|
||||||
})!
|
|
||||||
if passcodeSettings?.enableBiometrics ?? false {
|
|
||||||
controller.touchIdCompletion = {
|
|
||||||
completion(true)
|
completion(true)
|
||||||
dismissImpl?()
|
|
||||||
}
|
}
|
||||||
}
|
return controller
|
||||||
controller.checkCurrentPasscode = { value in
|
|
||||||
if let value = value {
|
|
||||||
switch challenge {
|
|
||||||
case .none:
|
|
||||||
return true
|
|
||||||
case let .numericalPassword(code, _, _):
|
|
||||||
return value == code
|
|
||||||
case let .plaintextPassword(code, _, _):
|
|
||||||
return value == code
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
controller.updateAttemptData = { attemptData in
|
|
||||||
let _ = context.sharedContext.accountManager.transaction({ transaction -> Void in
|
|
||||||
var attempts: AccessChallengeAttempts?
|
|
||||||
if let attemptData = attemptData {
|
|
||||||
attempts = AccessChallengeAttempts(count: Int32(attemptData.numberOfInvalidAttempts), timestamp: Int32(attemptData.dateOfLastInvalidAttempt))
|
|
||||||
}
|
|
||||||
var data = transaction.getAccessChallengeData()
|
|
||||||
switch data {
|
|
||||||
case .none:
|
|
||||||
break
|
|
||||||
case let .numericalPassword(value, timeout, _):
|
|
||||||
data = .numericalPassword(value: value, timeout: timeout, attempts: attempts)
|
|
||||||
case let .plaintextPassword(value, timeout, _):
|
|
||||||
data = .plaintextPassword(value: value, timeout: timeout, attempts: attempts)
|
|
||||||
}
|
|
||||||
transaction.setAccessChallengeData(data)
|
|
||||||
}).start()
|
|
||||||
}
|
|
||||||
legacyController.presentationCompleted = { [weak controller] in
|
|
||||||
if passcodeSettings?.enableBiometrics ?? false {
|
|
||||||
controller?.refreshTouchId()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
legacyController.bind(controller: controller)
|
|
||||||
legacyController.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .portrait, compactSize: .portrait)
|
|
||||||
legacyController.statusBar.statusBarStyle = .White
|
|
||||||
dismissImpl = { [weak legacyController] in
|
|
||||||
legacyController?.dismiss()
|
|
||||||
}
|
|
||||||
return legacyController
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import SwiftSignalKit
|
|||||||
import Postbox
|
import Postbox
|
||||||
|
|
||||||
enum PasscodeSetupControllerMode {
|
enum PasscodeSetupControllerMode {
|
||||||
case setup(PasscodeEntryFieldType)
|
case setup(change: Bool, PasscodeEntryFieldType)
|
||||||
case entry(PostboxAccessChallengeData)
|
case entry(PostboxAccessChallengeData)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ final class PasscodeSetupController: ViewController {
|
|||||||
|
|
||||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData))
|
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData))
|
||||||
|
|
||||||
|
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
|
||||||
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBar.style.style
|
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBar.style.style
|
||||||
|
|
||||||
self.nextAction = UIBarButtonItem(title: self.presentationData.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
|
self.nextAction = UIBarButtonItem(title: self.presentationData.strings.Common_Next, style: .done, target: self, action: #selector(self.nextPressed))
|
||||||
@ -50,7 +51,7 @@ final class PasscodeSetupController: ViewController {
|
|||||||
self.displayNodeDidLoad()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
self.controllerNode.selectPasscodeMode = { [weak self] in
|
self.controllerNode.selectPasscodeMode = { [weak self] in
|
||||||
guard let strongSelf = self, case let .setup(type) = strongSelf.mode else {
|
guard let strongSelf = self, case let .setup(change, type) = strongSelf.mode else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ final class PasscodeSetupController: ViewController {
|
|||||||
} else {
|
} else {
|
||||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.PasscodeSettings_6DigitCode, action: { [weak self] in
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.PasscodeSettings_6DigitCode, action: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.mode = .setup(.digits6)
|
strongSelf.mode = .setup(change: change, .digits6)
|
||||||
strongSelf.controllerNode.updateMode(strongSelf.mode)
|
strongSelf.controllerNode.updateMode(strongSelf.mode)
|
||||||
}
|
}
|
||||||
dismissAction()
|
dismissAction()
|
||||||
@ -75,7 +76,7 @@ final class PasscodeSetupController: ViewController {
|
|||||||
} else {
|
} else {
|
||||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.PasscodeSettings_4DigitCode, action: {
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.PasscodeSettings_4DigitCode, action: {
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.mode = .setup(.digits4)
|
strongSelf.mode = .setup(change: change, .digits4)
|
||||||
strongSelf.controllerNode.updateMode(strongSelf.mode)
|
strongSelf.controllerNode.updateMode(strongSelf.mode)
|
||||||
}
|
}
|
||||||
dismissAction()
|
dismissAction()
|
||||||
@ -85,7 +86,7 @@ final class PasscodeSetupController: ViewController {
|
|||||||
} else {
|
} else {
|
||||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.PasscodeSettings_AlphanumericCode, action: {
|
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.PasscodeSettings_AlphanumericCode, action: {
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.mode = .setup(.alphanumeric)
|
strongSelf.mode = .setup(change: change, .alphanumeric)
|
||||||
strongSelf.controllerNode.updateMode(strongSelf.mode)
|
strongSelf.controllerNode.updateMode(strongSelf.mode)
|
||||||
}
|
}
|
||||||
dismissAction()
|
dismissAction()
|
||||||
@ -130,6 +131,7 @@ final class PasscodeSetupController: ViewController {
|
|||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
super.viewDidAppear(animated)
|
super.viewDidAppear(animated)
|
||||||
|
self.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||||
|
|
||||||
self.controllerNode.activateInput()
|
self.controllerNode.activateInput()
|
||||||
}
|
}
|
||||||
@ -137,7 +139,7 @@ final class PasscodeSetupController: ViewController {
|
|||||||
override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||||
super.containerLayoutUpdated(layout, transition: transition)
|
super.containerLayoutUpdated(layout, transition: transition)
|
||||||
|
|
||||||
self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: 0.0, transition: transition)
|
self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationHeight, transition: transition)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func nextPressed() {
|
@objc func nextPressed() {
|
||||||
|
|||||||
@ -49,7 +49,8 @@ final class PasscodeSetupControllerNode: ASDisplayNode {
|
|||||||
|
|
||||||
private let hapticFeedback = HapticFeedback()
|
private let hapticFeedback = HapticFeedback()
|
||||||
|
|
||||||
private var validLayout: ContainerViewLayout?
|
private var validLayout: (ContainerViewLayout, CGFloat)?
|
||||||
|
private var maxBottomInset: CGFloat?
|
||||||
|
|
||||||
init(presentationData: PresentationData, mode: PasscodeSetupControllerMode) {
|
init(presentationData: PresentationData, mode: PasscodeSetupControllerMode) {
|
||||||
self.presentationData = presentationData
|
self.presentationData = presentationData
|
||||||
@ -103,9 +104,13 @@ final class PasscodeSetupControllerNode: ASDisplayNode {
|
|||||||
case .entry:
|
case .entry:
|
||||||
self.modeButtonNode.isHidden = true
|
self.modeButtonNode.isHidden = true
|
||||||
text = self.presentationData.strings.EnterPasscode_EnterPasscode
|
text = self.presentationData.strings.EnterPasscode_EnterPasscode
|
||||||
case .setup:
|
case let .setup(change, _):
|
||||||
|
if change {
|
||||||
|
text = self.presentationData.strings.EnterPasscode_EnterNewPasscodeChange
|
||||||
|
} else {
|
||||||
text = self.presentationData.strings.EnterPasscode_EnterNewPasscodeNew
|
text = self.presentationData.strings.EnterPasscode_EnterNewPasscodeNew
|
||||||
}
|
}
|
||||||
|
}
|
||||||
self.titleNode.attributedText = NSAttributedString(string: text, font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
self.titleNode.attributedText = NSAttributedString(string: text, font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||||
|
|
||||||
self.inputFieldNode.complete = { [weak self] passcode in
|
self.inputFieldNode.complete = { [weak self] passcode in
|
||||||
@ -116,13 +121,22 @@ final class PasscodeSetupControllerNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
self.validLayout = layout
|
self.validLayout = (layout, navigationBarHeight)
|
||||||
|
|
||||||
let insets = layout.insets(options: [.statusBar, .input])
|
var insets = layout.insets(options: [.statusBar, .input])
|
||||||
|
if let maxBottomInset = self.maxBottomInset {
|
||||||
|
if maxBottomInset > insets.bottom {
|
||||||
|
insets.bottom = maxBottomInset
|
||||||
|
} else {
|
||||||
|
self.maxBottomInset = insets.bottom
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.maxBottomInset = insets.bottom
|
||||||
|
}
|
||||||
|
|
||||||
self.wrapperNode.frame = CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: layout.size.height)
|
self.wrapperNode.frame = CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: layout.size.height)
|
||||||
|
|
||||||
let passcodeLayout = PasscodeLayout(layout: layout, titleOffset: 0.0, subtitleOffset: 0.0, inputFieldOffset: floor(insets.top + navigationBarHeight + (layout.size.height - navigationBarHeight - insets.top - insets.bottom - 38.0) / 2.0))
|
let passcodeLayout = PasscodeLayout(layout: layout, titleOffset: 0.0, subtitleOffset: 0.0, inputFieldOffset: floor(insets.top + navigationBarHeight + (layout.size.height - navigationBarHeight - insets.top - insets.bottom - 24.0) / 2.0))
|
||||||
let inputFieldFrame = self.inputFieldNode.updateLayout(layout: passcodeLayout, transition: transition)
|
let inputFieldFrame = self.inputFieldNode.updateLayout(layout: passcodeLayout, transition: transition)
|
||||||
transition.updateFrame(node: self.inputFieldNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
transition.updateFrame(node: self.inputFieldNode, frame: CGRect(origin: CGPoint(), size: layout.size))
|
||||||
|
|
||||||
@ -138,7 +152,7 @@ final class PasscodeSetupControllerNode: ASDisplayNode {
|
|||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.inputFieldNode.reset()
|
self.inputFieldNode.reset()
|
||||||
|
|
||||||
if case let .setup(type) = mode {
|
if case let .setup(_, type) = mode {
|
||||||
self.inputFieldNode.updateFieldType(type, animated: true)
|
self.inputFieldNode.updateFieldType(type, animated: true)
|
||||||
|
|
||||||
let fieldBackgroundAlpha: CGFloat
|
let fieldBackgroundAlpha: CGFloat
|
||||||
@ -170,7 +184,7 @@ final class PasscodeSetupControllerNode: ASDisplayNode {
|
|||||||
if let previousPasscode = self.previousPasscode {
|
if let previousPasscode = self.previousPasscode {
|
||||||
if self.currentPasscode == previousPasscode {
|
if self.currentPasscode == previousPasscode {
|
||||||
var numerical = false
|
var numerical = false
|
||||||
if case let .setup(type) = mode {
|
if case let .setup(_, type) = mode {
|
||||||
if case .alphanumeric = type {
|
if case .alphanumeric = type {
|
||||||
} else {
|
} else {
|
||||||
numerical = true
|
numerical = true
|
||||||
@ -196,7 +210,7 @@ final class PasscodeSetupControllerNode: ASDisplayNode {
|
|||||||
self.modeButtonNode.isHidden = true
|
self.modeButtonNode.isHidden = true
|
||||||
|
|
||||||
if let validLayout = self.validLayout {
|
if let validLayout = self.validLayout {
|
||||||
self.containerLayoutUpdated(validLayout, navigationBarHeight: 0.0, transition: .immediate)
|
self.containerLayoutUpdated(validLayout.0, navigationBarHeight: validLayout.1, transition: .immediate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user