From a7676486b89d73f356da41365027160237d848eb Mon Sep 17 00:00:00 2001 From: tikhop Date: Wed, 26 Jul 2023 16:26:07 +0400 Subject: [PATCH 1/2] fix: Sheet controller doesn't work properly on iOS 15 --- .../PaymentController.swift | 4 +-- .../Amount/Model/Send/SendAmountModel.swift | 5 +--- .../EnterAddressViewController.swift | 1 + .../ConfirmPaymentViewController.swift | 2 +- .../UI/Payments/Pay/DWBasePayViewController.m | 19 ++++++------ .../Sources/UI/Payments/Pay/Pay.storyboard | 4 +-- .../UI/Payments/Pay/PayViewController.swift | 7 ----- .../UI/Views/SheetViewController.swift | 30 +++++++------------ Podfile.lock | 4 +-- 9 files changed, 30 insertions(+), 46 deletions(-) diff --git a/DashWallet/Sources/UI/Payment Controller/PaymentController.swift b/DashWallet/Sources/UI/Payment Controller/PaymentController.swift index 0adbb5907..441dba899 100644 --- a/DashWallet/Sources/UI/Payment Controller/PaymentController.swift +++ b/DashWallet/Sources/UI/Payment Controller/PaymentController.swift @@ -212,14 +212,14 @@ extension PaymentController: DWPaymentProcessorDelegate { vc.dismiss(animated: true) { if let vc = self.presentationContextProvider as? UIViewController, vc.navigationController?.topViewController is ProvideAmountViewController { - vc.navigationController?.popViewController(animated: true) + vc.navigationController?.popToRootViewController(animated: true) } self.delegate?.paymentControllerDidFinishTransaction(self, transaction: transaction) } } else { if let vc = presentationContextProvider as? UIViewController, vc.navigationController?.topViewController is ProvideAmountViewController { - vc.navigationController?.popViewController(animated: true) + vc.navigationController?.popToRootViewController(animated: true) } delegate?.paymentControllerDidFinishTransaction(self, transaction: transaction) diff --git a/DashWallet/Sources/UI/Payments/Amount/Model/Send/SendAmountModel.swift b/DashWallet/Sources/UI/Payments/Amount/Model/Send/SendAmountModel.swift index f762a2f41..799242bce 100644 --- a/DashWallet/Sources/UI/Payments/Amount/Model/Send/SendAmountModel.swift +++ b/DashWallet/Sources/UI/Payments/Amount/Model/Send/SendAmountModel.swift @@ -55,10 +55,7 @@ class SendAmountModel: BaseAmountModel { let account = DWEnvironment.sharedInstance().currentAccount let allAvailableFunds = account.maxOutputAmount - let authenticationManager = DSAuthenticationManager.sharedInstance() - let canShowInsufficientFunds = authenticationManager.didAuthenticate - - return canShowInsufficientFunds && (plainAmount > allAvailableFunds) + return plainAmount > allAvailableFunds } private var syncingActivityMonitor: SyncingActivityMonitor { SyncingActivityMonitor.shared } diff --git a/DashWallet/Sources/UI/Payments/Enter Address/EnterAddressViewController.swift b/DashWallet/Sources/UI/Payments/Enter Address/EnterAddressViewController.swift index ffacb83b0..ac0baf362 100644 --- a/DashWallet/Sources/UI/Payments/Enter Address/EnterAddressViewController.swift +++ b/DashWallet/Sources/UI/Payments/Enter Address/EnterAddressViewController.swift @@ -32,6 +32,7 @@ final class EnterAddressViewController: BaseViewController, PayableViewControlle var payModel: DWPayModelProtocol! { model } internal var paymentController: PaymentController! + @objc weak var paymentControllerDelegate: PaymentControllerDelegate? // MARK: Actions diff --git a/DashWallet/Sources/UI/Payments/Pay/Confirm/ConfirmPaymentViewController.swift b/DashWallet/Sources/UI/Payments/Pay/Confirm/ConfirmPaymentViewController.swift index 7bc6cb1a4..7d761c930 100644 --- a/DashWallet/Sources/UI/Payments/Pay/Confirm/ConfirmPaymentViewController.swift +++ b/DashWallet/Sources/UI/Payments/Pay/Confirm/ConfirmPaymentViewController.swift @@ -67,7 +67,7 @@ class ConfirmPaymentViewController: SheetViewController { } override func contentViewHeight() -> CGFloat { - 190 + CGFloat(model.items.count)*46 + view.safeAreaInsets.bottom + 190 + CGFloat(model.items.count)*46 } override func viewDidLoad() { diff --git a/DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m b/DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m index 321fd10cd..85183a34a 100644 --- a/DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m +++ b/DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m @@ -71,7 +71,7 @@ - (void)performScanQRCodeAction { - (void)payToAddressAction { DWEnterAddressViewController *vc = [[DWEnterAddressViewController alloc] init]; - + vc.paymentControllerDelegate = self; DWNavigationController *nvc = [[DWNavigationController alloc] initWithRootViewController: vc]; [self presentViewController:nvc animated:YES completion:nil]; } @@ -157,15 +157,16 @@ - (void)paymentControllerDidFailTransaction:(PaymentController *)controller { } - (void)paymentControllerDidFinishTransaction:(PaymentController *_Nonnull)controller transaction:(DSTransaction *_Nonnull)transaction { + [self dismissViewControllerAnimated:true completion:^{ + TxDetailModel *model = [[TxDetailModel alloc] initWithTransaction:transaction]; + SuccessTxDetailViewController *vc = [[SuccessTxDetailViewController alloc] initWithModel:model]; + vc.contactItem = _paymentController.contactItem; + vc.delegate = self; + [self presentViewController:vc + animated:YES + completion:nil]; + }]; - TxDetailModel *model = [[TxDetailModel alloc] initWithTransaction:transaction]; - SuccessTxDetailViewController *vc = [[SuccessTxDetailViewController alloc] initWithModel:model]; - vc.modalPresentationStyle = UIModalPresentationFullScreen; - vc.contactItem = _paymentController.contactItem; - vc.delegate = self; - [self presentViewController:vc - animated:YES - completion:nil]; } - (UIViewController *_Nonnull)presentationAnchorForPaymentController:(PaymentController *_Nonnull)controller { diff --git a/DashWallet/Sources/UI/Payments/Pay/Pay.storyboard b/DashWallet/Sources/UI/Payments/Pay/Pay.storyboard index 55988bb8c..aa2515ba3 100644 --- a/DashWallet/Sources/UI/Payments/Pay/Pay.storyboard +++ b/DashWallet/Sources/UI/Payments/Pay/Pay.storyboard @@ -3,7 +3,7 @@ - + @@ -12,7 +12,7 @@ - + diff --git a/DashWallet/Sources/UI/Payments/Pay/PayViewController.swift b/DashWallet/Sources/UI/Payments/Pay/PayViewController.swift index 629a875d2..e88d69dc7 100644 --- a/DashWallet/Sources/UI/Payments/Pay/PayViewController.swift +++ b/DashWallet/Sources/UI/Payments/Pay/PayViewController.swift @@ -19,32 +19,25 @@ import UIKit // MARK: - PayViewControllerDelegate -@objc(DWPayViewControllerDelegate) protocol PayViewControllerDelegate: AnyObject { func payViewControllerDidFinishPayment(_ controller: PayViewController, contact: DWDPBasicUserItem?) } // MARK: - PayViewController -@objc(DWPayViewController) class PayViewController: BaseViewController, PayableViewController { @IBOutlet weak var tableView: UITableView! - @objc var paymentController: PaymentController! - @objc var payModel: DWPayModelProtocol! var maxActionButtonWidth: CGFloat = 0 - @objc var demoMode = false - @objc var delegate: PayViewControllerDelegate? - @objc static func controller(with payModel: DWPayModelProtocol) -> PayViewController { let storyboard = UIStoryboard(name: "Pay", bundle: nil) let controller = storyboard.instantiateInitialViewController() as! PayViewController diff --git a/DashWallet/Sources/UI/Views/SheetViewController.swift b/DashWallet/Sources/UI/Views/SheetViewController.swift index 5fa5f7818..ad7d0b903 100644 --- a/DashWallet/Sources/UI/Views/SheetViewController.swift +++ b/DashWallet/Sources/UI/Views/SheetViewController.swift @@ -24,32 +24,24 @@ class SheetViewController: BaseViewController, DWModalPresentationControllerDele super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) - let contentViewHeight = contentViewHeight() - if contentViewHeight != -1 { - if #available(iOS 16.0, *) { - modalPresentationStyle = .pageSheet - - guard let sheet = sheetPresentationController else { return } + if #available(iOS 16.0, *) { + modalPresentationStyle = .pageSheet - let detents: [UISheetPresentationController.Detent] + guard let sheet = sheetPresentationController else { return } - let fitId = UISheetPresentationController.Detent.Identifier("fit") - detents = [UISheetPresentationController.Detent.custom(identifier: fitId) { _ in - contentViewHeight - }] - sheet.prefersGrabberVisible = true - sheet.detents = detents - } else { - modalPresentationStyle = .custom + let detents: [UISheetPresentationController.Detent] - modalTransition = DWModalTransition() - modalTransition?.modalPresentationControllerDelegate = self - transitioningDelegate = modalTransition - } + let fitId = UISheetPresentationController.Detent.Identifier("fit") + detents = [UISheetPresentationController.Detent.custom(identifier: fitId) { [weak self] _ in + self?.contentViewHeight() ?? 100 + }] + sheet.prefersGrabberVisible = true + sheet.detents = detents } else { modalPresentationStyle = .custom modalTransition = DWModalTransition() + modalTransition?.modalPresentationControllerDelegate = self transitioningDelegate = modalTransition } } diff --git a/Podfile.lock b/Podfile.lock index 4827b61a1..8e6b7715c 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -698,7 +698,7 @@ PODS: - nanopb/encode (= 2.30908.0) - nanopb/decode (2.30908.0) - nanopb/encode (2.30908.0) - - PromisesObjC (2.3.0) + - PromisesObjC (2.3.1) - Protobuf (3.23.4) - SDWebImage (5.13.2): - SDWebImage/Core (= 5.13.2) @@ -821,7 +821,7 @@ SPEC CHECKSUMS: MMSegmentSlider: db7ee0d6eb2eefbd511179195bf288ff2cebac0a Moya: 138f0573e53411fb3dc17016add0b748dfbd78ee nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96 - PromisesObjC: 7f84fefd35e085854377a97e19424ae424cc7a9e + PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 Protobuf: c6bc59bbab3d38a71c67f62d7cb7ca8f8ea4eca1 SDWebImage: 72f86271a6f3139cc7e4a89220946489d4b9a866 SQLite.swift: 903bfa3bc9ab06345fdfbb578e34f47cfcf417da From 45318243bb2beccfdb5116d336a5be4104c5204f Mon Sep 17 00:00:00 2001 From: tikhop Date: Wed, 26 Jul 2023 22:33:53 +0400 Subject: [PATCH 2/2] fix: Make sure the size of the clipboard content view is wrapping the text --- .../Enter Address/Views/PasteboardContentView.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DashWallet/Sources/UI/Payments/Enter Address/Views/PasteboardContentView.swift b/DashWallet/Sources/UI/Payments/Enter Address/Views/PasteboardContentView.swift index bdc51b7fa..deac73ad7 100644 --- a/DashWallet/Sources/UI/Payments/Enter Address/Views/PasteboardContentView.swift +++ b/DashWallet/Sources/UI/Payments/Enter Address/Views/PasteboardContentView.swift @@ -23,8 +23,8 @@ final class PasteboardContentView: UIView { private var textView: TappableTextView! override var intrinsicContentSize: CGSize { - let h = textView.contentSize.height + 36 + 10 // textView.contentSize.height + top padding + bottom padding - return CGSize(width: UIView.noIntrinsicMetric, height: min(200, h)) + let h = textView.contentSize.height + 36 + 10 + 5 // textView.contentSize.height + top padding + bottom padding + return CGSize(width: UIView.noIntrinsicMetric, height: min(220, h)) } override init(frame: CGRect) { @@ -54,7 +54,9 @@ final class PasteboardContentView: UIView { } } - invalidateIntrinsicContentSize() + DispatchQueue.main.async { + self.invalidateIntrinsicContentSize() + } } private func configureHierarchy() {