mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Add password tip to payment prompt
This commit is contained in:
@@ -470,6 +470,9 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
|||||||
private let paymentAuthDisposable = MetaDisposable()
|
private let paymentAuthDisposable = MetaDisposable()
|
||||||
private var applePayAuthrorizationCompletion: ((PKPaymentAuthorizationStatus) -> Void)?
|
private var applePayAuthrorizationCompletion: ((PKPaymentAuthorizationStatus) -> Void)?
|
||||||
private var applePayController: PKPaymentAuthorizationViewController?
|
private var applePayController: PKPaymentAuthorizationViewController?
|
||||||
|
|
||||||
|
private var passwordTip: String?
|
||||||
|
private var passwordTipDisposable: Disposable?
|
||||||
|
|
||||||
init(controller: BotCheckoutController?, navigationBar: NavigationBar, updateNavigationOffset: @escaping (CGFloat) -> Void, context: AccountContext, invoice: TelegramMediaInvoice, messageId: MessageId, present: @escaping (ViewController, Any?) -> Void, dismissAnimated: @escaping () -> Void) {
|
init(controller: BotCheckoutController?, navigationBar: NavigationBar, updateNavigationOffset: @escaping (CGFloat) -> Void, context: AccountContext, invoice: TelegramMediaInvoice, messageId: MessageId, present: @escaping (ViewController, Any?) -> Void, dismissAnimated: @escaping () -> Void) {
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
@@ -885,12 +888,28 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
|||||||
self.actionButton.isEnabled = false
|
self.actionButton.isEnabled = false
|
||||||
|
|
||||||
self.listNode.supernode?.insertSubnode(self.inProgressDimNode, aboveSubnode: self.listNode)
|
self.listNode.supernode?.insertSubnode(self.inProgressDimNode, aboveSubnode: self.listNode)
|
||||||
|
|
||||||
|
self.passwordTipDisposable = (twoStepVerificationConfiguration(account: self.context.account)
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] value in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch value {
|
||||||
|
case .notSet:
|
||||||
|
break
|
||||||
|
case let .set(hint, _, _, _):
|
||||||
|
if !hint.isEmpty {
|
||||||
|
strongSelf.passwordTip = hint
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
self.formRequestDisposable?.dispose()
|
self.formRequestDisposable?.dispose()
|
||||||
self.payDisposable.dispose()
|
self.payDisposable.dispose()
|
||||||
self.paymentAuthDisposable.dispose()
|
self.paymentAuthDisposable.dispose()
|
||||||
|
self.passwordTipDisposable?.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateActionButton() {
|
private func updateActionButton() {
|
||||||
@@ -1231,7 +1250,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
|||||||
period = 1 * 60 * 60
|
period = 1 * 60 * 60
|
||||||
requiresBiometrics = false
|
requiresBiometrics = false
|
||||||
}
|
}
|
||||||
self.present(botCheckoutPasswordEntryController(context: self.context, strings: self.presentationData.strings, cartTitle: cardTitle, period: period, requiresBiometrics: requiresBiometrics, completion: { [weak self] token in
|
self.present(botCheckoutPasswordEntryController(context: self.context, strings: self.presentationData.strings, passwordTip: self.passwordTip, cartTitle: cardTitle, period: period, requiresBiometrics: requiresBiometrics, completion: { [weak self] token in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let durationString = timeIntervalString(strings: strongSelf.presentationData.strings, value: period)
|
let durationString = timeIntervalString(strings: strongSelf.presentationData.strings, value: period)
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ private final class BotCheckoutPasswordAlertContentNode: AlertContentNode {
|
|||||||
|
|
||||||
private let hapticFeedback = HapticFeedback()
|
private let hapticFeedback = HapticFeedback()
|
||||||
|
|
||||||
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, cardTitle: String, period: Int32, requiresBiometrics: Bool, cancel: @escaping () -> Void, completion: @escaping (TemporaryTwoStepPasswordToken) -> Void) {
|
init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, passwordTip: String?, cardTitle: String, period: Int32, requiresBiometrics: Bool, cancel: @escaping () -> Void, completion: @escaping (TemporaryTwoStepPasswordToken) -> Void) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.period = period
|
self.period = period
|
||||||
self.requiresBiometrics = requiresBiometrics
|
self.requiresBiometrics = requiresBiometrics
|
||||||
@@ -156,6 +156,8 @@ private final class BotCheckoutPasswordAlertContentNode: AlertContentNode {
|
|||||||
self.textFieldNode.textField.keyboardAppearance = theme.rootController.keyboardColor.keyboardAppearance
|
self.textFieldNode.textField.keyboardAppearance = theme.rootController.keyboardColor.keyboardAppearance
|
||||||
self.textFieldNode.textField.isSecureTextEntry = true
|
self.textFieldNode.textField.isSecureTextEntry = true
|
||||||
self.textFieldNode.textField.tintColor = theme.list.itemAccentColor
|
self.textFieldNode.textField.tintColor = theme.list.itemAccentColor
|
||||||
|
self.textFieldNode.textField.placeholder = passwordTip
|
||||||
|
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@@ -218,7 +220,7 @@ private final class BotCheckoutPasswordAlertContentNode: AlertContentNode {
|
|||||||
|
|
||||||
let textFieldBackgroundFrame = CGRect(origin: CGPoint(x: insets.left, y: resultSize.height - inputHeight + 12.0 - actionsHeight - insets.bottom), size: CGSize(width: resultSize.width - insets.left - insets.right, height: 25.0))
|
let textFieldBackgroundFrame = CGRect(origin: CGPoint(x: insets.left, y: resultSize.height - inputHeight + 12.0 - actionsHeight - insets.bottom), size: CGSize(width: resultSize.width - insets.left - insets.right, height: 25.0))
|
||||||
self.textFieldNodeBackground.frame = textFieldBackgroundFrame
|
self.textFieldNodeBackground.frame = textFieldBackgroundFrame
|
||||||
self.textFieldNode.frame = textFieldBackgroundFrame.offsetBy(dx: 0.0, dy: 1.0).insetBy(dx: 4.0, dy: 0.0)
|
self.textFieldNode.frame = textFieldBackgroundFrame.offsetBy(dx: 0.0, dy: 0.0).insetBy(dx: 4.0, dy: 0.0)
|
||||||
|
|
||||||
self.actionNodesSeparator.frame = CGRect(origin: CGPoint(x: 0.0, y: resultSize.height - actionsHeight - UIScreenPixel), size: CGSize(width: resultSize.width, height: UIScreenPixel))
|
self.actionNodesSeparator.frame = CGRect(origin: CGPoint(x: 0.0, y: resultSize.height - actionsHeight - UIScreenPixel), size: CGSize(width: resultSize.width, height: UIScreenPixel))
|
||||||
|
|
||||||
@@ -300,10 +302,10 @@ private final class BotCheckoutPasswordAlertContentNode: AlertContentNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func botCheckoutPasswordEntryController(context: AccountContext, strings: PresentationStrings, cartTitle: String, period: Int32, requiresBiometrics: Bool, completion: @escaping (TemporaryTwoStepPasswordToken) -> Void) -> AlertController {
|
func botCheckoutPasswordEntryController(context: AccountContext, strings: PresentationStrings, passwordTip: String?, cartTitle: String, period: Int32, requiresBiometrics: Bool, completion: @escaping (TemporaryTwoStepPasswordToken) -> Void) -> AlertController {
|
||||||
var dismissImpl: (() -> Void)?
|
var dismissImpl: (() -> Void)?
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
let controller = AlertController(theme: AlertControllerTheme(presentationData: presentationData), contentNode: BotCheckoutPasswordAlertContentNode(context: context, theme: presentationData.theme, strings: strings, cardTitle: cartTitle, period: period, requiresBiometrics: requiresBiometrics, cancel: {
|
let controller = AlertController(theme: AlertControllerTheme(presentationData: presentationData), contentNode: BotCheckoutPasswordAlertContentNode(context: context, theme: presentationData.theme, strings: strings, passwordTip: passwordTip, cardTitle: cartTitle, period: period, requiresBiometrics: requiresBiometrics, cancel: {
|
||||||
dismissImpl?()
|
dismissImpl?()
|
||||||
}, completion: { token in
|
}, completion: { token in
|
||||||
completion(token)
|
completion(token)
|
||||||
|
|||||||
Reference in New Issue
Block a user