Show scanned values
- refactored for pasteboard - added delegate if user wants to retake the scan
This commit is contained in:
parent
8f61be3967
commit
a1a3657a7f
|
@ -60,6 +60,8 @@
|
|||
EE57702B21D0230C00433CAB /* ZWProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE57702A21D0230C00433CAB /* ZWProgressBar.swift */; };
|
||||
EE57702D21D38A8200433CAB /* Pin.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EE57702C21D38A8200433CAB /* Pin.storyboard */; };
|
||||
EE57702F21D38BAD00433CAB /* ZWPinDotView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE57702E21D38BAD00433CAB /* ZWPinDotView.swift */; };
|
||||
EE73BAD82260EC6C00A6C82C /* PaymentParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE73BAD72260EC6C00A6C82C /* PaymentParser.swift */; };
|
||||
EE73BADA2260ED6F00A6C82C /* InvalidPaymentUri.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE73BAD92260ED6F00A6C82C /* InvalidPaymentUri.swift */; };
|
||||
EE76B84221D7EC3F0093571F /* Home.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EE76B84121D7EC3F0093571F /* Home.storyboard */; };
|
||||
EE76B85321D8D1930093571F /* SourceSansPro-BlackItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = EE76B84621D8D1930093571F /* SourceSansPro-BlackItalic.ttf */; };
|
||||
EE76B85421D8D1930093571F /* SourceSansPro-SemiBoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = EE76B84721D8D1930093571F /* SourceSansPro-SemiBoldItalic.ttf */; };
|
||||
|
@ -178,6 +180,8 @@
|
|||
EE57702A21D0230C00433CAB /* ZWProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZWProgressBar.swift; sourceTree = "<group>"; };
|
||||
EE57702C21D38A8200433CAB /* Pin.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Pin.storyboard; sourceTree = "<group>"; };
|
||||
EE57702E21D38BAD00433CAB /* ZWPinDotView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZWPinDotView.swift; sourceTree = "<group>"; };
|
||||
EE73BAD72260EC6C00A6C82C /* PaymentParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentParser.swift; sourceTree = "<group>"; };
|
||||
EE73BAD92260ED6F00A6C82C /* InvalidPaymentUri.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvalidPaymentUri.swift; sourceTree = "<group>"; };
|
||||
EE76B84121D7EC3F0093571F /* Home.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Home.storyboard; sourceTree = "<group>"; };
|
||||
EE76B84621D8D1930093571F /* SourceSansPro-BlackItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SourceSansPro-BlackItalic.ttf"; sourceTree = "<group>"; };
|
||||
EE76B84721D8D1930093571F /* SourceSansPro-SemiBoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SourceSansPro-SemiBoldItalic.ttf"; sourceTree = "<group>"; };
|
||||
|
@ -261,6 +265,7 @@
|
|||
children = (
|
||||
EE377EB221E5303D00138385 /* ViewFactory.swift */,
|
||||
EE377ED921F4BE5500138385 /* TrxHistoryProvider.swift */,
|
||||
EE73BAD72260EC6C00A6C82C /* PaymentParser.swift */,
|
||||
);
|
||||
path = Services;
|
||||
sourceTree = "<group>";
|
||||
|
@ -324,6 +329,7 @@
|
|||
EE377EF021FDEE3F00138385 /* ZEC.swift */,
|
||||
EE1876A8221EE0B2004853A7 /* Payment.swift */,
|
||||
EE927CC2222567960059DADD /* TrxHistory.swift */,
|
||||
EE73BAD92260ED6F00A6C82C /* InvalidPaymentUri.swift */,
|
||||
);
|
||||
path = Types;
|
||||
sourceTree = "<group>";
|
||||
|
@ -733,6 +739,7 @@
|
|||
EE1876A72219FA15004853A7 /* Wallet.swift in Sources */,
|
||||
EE377EF321FE181000138385 /* Date-Extension.swift in Sources */,
|
||||
EE07A45521E24FDD006031C8 /* Localization.swift in Sources */,
|
||||
EE73BAD82260EC6C00A6C82C /* PaymentParser.swift in Sources */,
|
||||
EE377EE921F7A76500138385 /* TrxDetailsVC.swift in Sources */,
|
||||
EEBEBB7B2200DFC000A6BD18 /* ScanVC.swift in Sources */,
|
||||
EE1876A9221EE0B2004853A7 /* Payment.swift in Sources */,
|
||||
|
@ -752,6 +759,7 @@
|
|||
EE377EC921E8F67000138385 /* PassphraseVCDelegate.swift in Sources */,
|
||||
EEBEBB9E2208D64C00A6BD18 /* AmountVC.swift in Sources */,
|
||||
EE07A45721E26E88006031C8 /* IocContainer.swift in Sources */,
|
||||
EE73BADA2260ED6F00A6C82C /* InvalidPaymentUri.swift in Sources */,
|
||||
EE377EF121FDEE3F00138385 /* ZEC.swift in Sources */,
|
||||
EEBEBB972207477100A6BD18 /* SendCoordinatorDelegate.swift in Sources */,
|
||||
EE377ED221F47E1400138385 /* HomeVC.swift in Sources */,
|
||||
|
|
|
@ -114,9 +114,9 @@
|
|||
|
||||
"global.memo" = "Memo";
|
||||
|
||||
"recipientAddress.pasteboard.correct.title" = "Pasteboard";
|
||||
"payment.title" = "Payment";
|
||||
|
||||
"recipientAddress.pasteboard.correct.take" = "Übernehmen";
|
||||
"payment.button.take" = "Übernehmen";
|
||||
|
||||
"global.cancel" = "Abbrechen";
|
||||
|
||||
|
|
|
@ -114,9 +114,9 @@
|
|||
|
||||
"global.memo" = "Memo";
|
||||
|
||||
"recipientAddress.pasteboard.correct.title" = "Pasteboard";
|
||||
"payment.title" = "Payment";
|
||||
|
||||
"recipientAddress.pasteboard.correct.take" = "Take";
|
||||
"payment.button.take" = "Take";
|
||||
|
||||
"global.cancel" = "Cancel";
|
||||
|
||||
|
|
|
@ -64,12 +64,10 @@ extension SendCoordinator: RecipientAddressDelegate {
|
|||
let result = self.paymentParser.process(uri: pasteboardContent)
|
||||
switch result {
|
||||
case .success(let payment):
|
||||
self.showPasteboardResult(payment: payment, on: sender)
|
||||
self.showValid(payment: payment, on: sender, onRetake: {})
|
||||
case .failure:
|
||||
self.showPasteboardError(on: sender)
|
||||
self.showPaymentError(on: sender)
|
||||
}
|
||||
|
||||
#warning("implement check and store")
|
||||
}
|
||||
|
||||
func recipientAddressVCEnterManuallyButtonTouched(sender: RecipientAddressVC) {
|
||||
|
@ -96,7 +94,10 @@ extension SendCoordinator: RecipientAddressDelegate {
|
|||
self.navigationController.pushViewController(vc, animated: true)
|
||||
}
|
||||
|
||||
private func showPasteboardResult(payment: PaymentProtocol, on viewController: UIViewController) {
|
||||
private func showValid(payment: PaymentProtocol,
|
||||
on viewController: UIViewController,
|
||||
onRetake retakeHandler: @escaping () -> Void)
|
||||
{
|
||||
guard let walletAddress = payment.targetAddress else { return }
|
||||
var message = "\(self.localizer.localized("global.targetAddress")): \(walletAddress)"
|
||||
|
||||
|
@ -108,10 +109,10 @@ extension SendCoordinator: RecipientAddressDelegate {
|
|||
message.append("\n\n\(self.localizer.localized("global.memo")): \(memo)")
|
||||
}
|
||||
|
||||
let alert = UIAlertController(title: self.localizer.localized("recipientAddress.pasteboard.correct.title"),
|
||||
let alert = UIAlertController(title: self.localizer.localized("payment.title"),
|
||||
message: message,
|
||||
preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: self.localizer.localized("recipientAddress.pasteboard.correct.take"),
|
||||
alert.addAction(UIAlertAction(title: self.localizer.localized("payment.button.take"),
|
||||
style: .default, handler: { _ in
|
||||
self.payment = payment
|
||||
let viewModel = AmountVCViewModel(mode: .new(initialAmount: self.payment.amount ?? 0),
|
||||
|
@ -119,11 +120,13 @@ extension SendCoordinator: RecipientAddressDelegate {
|
|||
#warning("set correct available amount")
|
||||
self.showAmountView(with: viewModel)
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: self.localizer.localized("global.cancel"), style: .cancel, handler: nil))
|
||||
alert.addAction(UIAlertAction(title: self.localizer.localized("global.cancel"),
|
||||
style: .cancel,
|
||||
handler: { _ in retakeHandler() }))
|
||||
viewController.present(alert, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
private func showPasteboardError(on viewController: UIViewController) {
|
||||
private func showPaymentError(on viewController: UIViewController) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -132,12 +135,13 @@ extension SendCoordinator: RecipientAddressDelegate {
|
|||
extension SendCoordinator: ScanVCDelegate {
|
||||
|
||||
func scanVCDelegateUriDetected(uri: String, sender: ScanVC) {
|
||||
#warning("implement check and store")
|
||||
|
||||
let viewModel = AmountVCViewModel(mode: .new(initialAmount: self.payment.amount ?? 0),
|
||||
availableAmount: 2208_000_000_000)
|
||||
#warning("set correct available amount")
|
||||
self.showAmountView(with: viewModel)
|
||||
let result = self.paymentParser.process(uri: uri)
|
||||
switch result {
|
||||
case .success(let payment):
|
||||
self.showValid(payment: payment, on: sender, onRetake: { sender.resumeCapturing() })
|
||||
case .failure:
|
||||
self.showPaymentError(on: sender)
|
||||
}
|
||||
}
|
||||
|
||||
func scanVCDelegateCancelled(sender: ScanVC) {
|
||||
|
|
|
@ -47,6 +47,10 @@ class ScanVC: UIViewController {
|
|||
self.stopCapturing()
|
||||
}
|
||||
|
||||
public func resumeCapturing() {
|
||||
self .startCapturing()
|
||||
}
|
||||
|
||||
private func setup() {
|
||||
self.descriptionLabel.layer.cornerRadius = 4
|
||||
self.descriptionLabel.layer.masksToBounds = true
|
||||
|
|
Loading…
Reference in New Issue