diff --git a/ZWallet.xcodeproj/project.pbxproj b/ZWallet.xcodeproj/project.pbxproj index 4af9968..4d1b6b8 100644 --- a/ZWallet.xcodeproj/project.pbxproj +++ b/ZWallet.xcodeproj/project.pbxproj @@ -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 = ""; }; EE57702C21D38A8200433CAB /* Pin.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Pin.storyboard; sourceTree = ""; }; EE57702E21D38BAD00433CAB /* ZWPinDotView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZWPinDotView.swift; sourceTree = ""; }; + EE73BAD72260EC6C00A6C82C /* PaymentParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentParser.swift; sourceTree = ""; }; + EE73BAD92260ED6F00A6C82C /* InvalidPaymentUri.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvalidPaymentUri.swift; sourceTree = ""; }; EE76B84121D7EC3F0093571F /* Home.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Home.storyboard; sourceTree = ""; }; EE76B84621D8D1930093571F /* SourceSansPro-BlackItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SourceSansPro-BlackItalic.ttf"; sourceTree = ""; }; EE76B84721D8D1930093571F /* SourceSansPro-SemiBoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SourceSansPro-SemiBoldItalic.ttf"; sourceTree = ""; }; @@ -261,6 +265,7 @@ children = ( EE377EB221E5303D00138385 /* ViewFactory.swift */, EE377ED921F4BE5500138385 /* TrxHistoryProvider.swift */, + EE73BAD72260EC6C00A6C82C /* PaymentParser.swift */, ); path = Services; sourceTree = ""; @@ -324,6 +329,7 @@ EE377EF021FDEE3F00138385 /* ZEC.swift */, EE1876A8221EE0B2004853A7 /* Payment.swift */, EE927CC2222567960059DADD /* TrxHistory.swift */, + EE73BAD92260ED6F00A6C82C /* InvalidPaymentUri.swift */, ); path = Types; sourceTree = ""; @@ -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 */, diff --git a/ZWallet/Infrastructure/de.lproj/InfoPlist.strings b/ZWallet/Infrastructure/de.lproj/InfoPlist.strings index 775fb10..524bdad 100644 --- a/ZWallet/Infrastructure/de.lproj/InfoPlist.strings +++ b/ZWallet/Infrastructure/de.lproj/InfoPlist.strings @@ -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"; diff --git a/ZWallet/Infrastructure/en.lproj/InfoPlist.strings b/ZWallet/Infrastructure/en.lproj/InfoPlist.strings index 2ebd595..6157b67 100644 --- a/ZWallet/Infrastructure/en.lproj/InfoPlist.strings +++ b/ZWallet/Infrastructure/en.lproj/InfoPlist.strings @@ -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"; diff --git a/ZWallet/ViewCoordinators/SendCoordinator.swift b/ZWallet/ViewCoordinators/SendCoordinator.swift index d0d1ee2..b9419d4 100644 --- a/ZWallet/ViewCoordinators/SendCoordinator.swift +++ b/ZWallet/ViewCoordinators/SendCoordinator.swift @@ -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) { diff --git a/ZWallet/Views/Scan/ScanVC.swift b/ZWallet/Views/Scan/ScanVC.swift index ad378b0..6f38a9f 100644 --- a/ZWallet/Views/Scan/ScanVC.swift +++ b/ZWallet/Views/Scan/ScanVC.swift @@ -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