WinterGram/submodules/PassportUI/Sources/SecureIdPlaintextFormController.swift
Isaac 7b2b74e79b Postbox -> TelegramEngine wave 6: unused import Postbox batch sweep
First build-verified unused-import sweep: speculatively dropped
import Postbox from 782 consumer files (plain ^import Postbox$ lines,
excluding TelegramCore/Postbox/TelegramApi paths), iterated 18 full
project builds with --continueOnError, restored the import on every
file that failed to compile. 183 drops survived; 189 consumer modules
newly Postbox-free.

Bundled: spec + plan + C1 atomic batch drop + C2 CLAUDE.md outcome and
permanent methodology guidance under Wave-selection. The methodology
subsection captures the reusable playbook (--continueOnError is
essential, dependency graphs are deep so expect many iterations,
pattern-based preemptive restores accelerate convergence, and
CLAUDE.md's engine typealias cheat sheet arrows are migration targets
rather than typealiases in TelegramCore).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 23:46:13 +02:00

115 lines
4.9 KiB
Swift

import Foundation
import UIKit
import Display
import AsyncDisplayKit
import SwiftSignalKit
import TelegramCore
import TelegramPresentationData
import ProgressNavigationButtonNode
import AccountContext
public enum SecureIdPlaintextFormType {
case phone
case email
}
public final class SecureIdPlaintextFormController: FormController<SecureIdPlaintextFormInnerState, SecureIdPlaintextFormControllerNodeInitParams, SecureIdPlaintextFormControllerNode> {
private let context: AccountContext
private var presentationData: PresentationData
private let updatedValue: (SecureIdValueWithContext?) -> Void
private let secureIdContext: SecureIdAccessContext
private let type: SecureIdPlaintextFormType
private var immediatelyAvailableValue: SecureIdValue?
private var nextItem: UIBarButtonItem?
private var doneItem: UIBarButtonItem?
public init(context: AccountContext, secureIdContext: SecureIdAccessContext, type: SecureIdPlaintextFormType, immediatelyAvailableValue: SecureIdValue?, updatedValue: @escaping (SecureIdValueWithContext?) -> Void) {
self.context = context
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
self.secureIdContext = secureIdContext
self.type = type
self.immediatelyAvailableValue = immediatelyAvailableValue
self.updatedValue = updatedValue
super.init(initParams: SecureIdPlaintextFormControllerNodeInitParams(context: context, secureIdContext: secureIdContext), presentationData: self.presentationData)
self.navigationPresentation = .modal
switch type {
case .phone:
self.title = self.presentationData.strings.Passport_Phone_Title
case .email:
self.title = self.presentationData.strings.Passport_Email_Title
}
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
self.nextItem = UIBarButtonItem(title: self.presentationData.strings.Common_Next, style: .done, target: self, action: #selector(self.donePressed))
self.doneItem = UIBarButtonItem(title: self.presentationData.strings.Common_Done, style: .done, target: self, action: #selector(self.donePressed))
self.navigationItem.rightBarButtonItem = doneItem
}
required public init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
deinit {
}
@objc private func cancelPressed() {
self.dismiss()
}
@objc private func donePressed() {
self.controllerNode.save()
}
override public func displayNodeDidLoad() {
super.displayNodeDidLoad()
self.controllerNode.actionInputStateUpdated = { [weak self] state in
if let strongSelf = self {
switch state {
case .inProgress:
strongSelf.navigationItem.rightBarButtonItem = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: strongSelf.presentationData.theme.rootController.navigationBar.controlColor))
case .nextAvailable, .nextNotAvailable:
if strongSelf.navigationItem.rightBarButtonItem !== strongSelf.nextItem {
strongSelf.navigationItem.rightBarButtonItem = strongSelf.nextItem
}
if case .nextAvailable = state {
strongSelf.nextItem?.isEnabled = true
} else {
strongSelf.nextItem?.isEnabled = false
}
case .saveAvailable, .saveNotAvailable:
if strongSelf.navigationItem.rightBarButtonItem !== strongSelf.doneItem {
strongSelf.navigationItem.rightBarButtonItem = strongSelf.doneItem
}
if case .saveAvailable = state {
strongSelf.doneItem?.isEnabled = true
} else {
strongSelf.doneItem?.isEnabled = false
}
}
}
}
self.controllerNode.completedWithValue = { [weak self] valueWithContext in
if let strongSelf = self {
strongSelf.updatedValue(valueWithContext)
strongSelf.dismiss()
}
}
self.controllerNode.dismiss = { [weak self] in
self?.dismiss()
}
self.controllerNode.updateInnerState(transition: .immediate, with: SecureIdPlaintextFormInnerState(type: self.type, immediatelyAvailableValue: self.immediatelyAvailableValue))
}
public func applyPhoneCode(_ code: Int) {
self.controllerNode.applyPhoneCode(code)
}
}