From 954cc788bb732f4826343daf448049fb38ddb06f Mon Sep 17 00:00:00 2001 From: Andrei Ashikhmin Date: Wed, 26 Jul 2023 17:55:28 +0700 Subject: [PATCH 1/4] chore: wrap deposit navigation in logs --- .../Sources/Models/CrowdNode/CrowdNode.swift | 8 +++- .../Sources/UI/CrowdNode/CrowdNodeModel.swift | 3 +- .../CrowdNodePortalViewController.swift | 1 + .../CrowdNodeTransferViewController.swift | 37 ++++++++++++++++++- .../Portal/Model/CrowdNodeTransferModel.swift | 6 +++ .../Portal/WithdrawalLimitsController.swift | 18 +++++++++ .../Amount/BaseAmountViewController.swift | 6 +++ ...seViewController+NetworkReachability.swift | 1 + 8 files changed, 77 insertions(+), 3 deletions(-) diff --git a/DashWallet/Sources/Models/CrowdNode/CrowdNode.swift b/DashWallet/Sources/Models/CrowdNode/CrowdNode.swift index 9b4336b78..063171e02 100644 --- a/DashWallet/Sources/Models/CrowdNode/CrowdNode.swift +++ b/DashWallet/Sources/Models/CrowdNode/CrowdNode.swift @@ -471,14 +471,20 @@ extension CrowdNode { } func hasAnyDeposits() -> Bool { + DSLogger.log("CrowdNodeDeposit: hasAnyDeposits") guard !accountAddress.isEmpty else { return false } + DSLogger.log("CrowdNodeDeposit: get currentWallet") let wallet = DWEnvironment.sharedInstance().currentWallet + DSLogger.log("CrowdNodeDeposit: create CrowdNodeDepositTx") let filter = CrowdNodeDepositTx(accountAddress: accountAddress) - return wallet.allTransactions.contains { + DSLogger.log("CrowdNodeDeposit: enumerate allTransactions") + let result = wallet.allTransactions.contains { tx in filter.matches(tx: tx) } + DSLogger.log("CrowdNodeDeposit: hasAnyDeposits: return \(result)") + return result } private func checkWithdrawalLimits(_ amount: UInt64) throws { diff --git a/DashWallet/Sources/UI/CrowdNode/CrowdNodeModel.swift b/DashWallet/Sources/UI/CrowdNode/CrowdNodeModel.swift index ee02a2024..c32eea789 100644 --- a/DashWallet/Sources/UI/CrowdNode/CrowdNodeModel.swift +++ b/DashWallet/Sources/UI/CrowdNode/CrowdNodeModel.swift @@ -98,7 +98,8 @@ final class CrowdNodeModel { var needsBackup: Bool { DWGlobalOptions.sharedInstance().walletNeedsBackup } var canSignUp: Bool { !needsBackup && hasEnoughWalletBalance } var shouldShowFirstDepositBanner: Bool { - !crowdNode.hasAnyDeposits() && crowdNodeBalance < CrowdNode.minimumDeposit + DSLogger.log("CrowdNodeDeposit: get shouldShowFirstDepositBanner. Balance: \(crowdNodeBalance)") + return !crowdNode.hasAnyDeposits() && crowdNodeBalance < CrowdNode.minimumDeposit } var canWithdraw: Bool { diff --git a/DashWallet/Sources/UI/CrowdNode/Portal/CrowdNodePortalViewController.swift b/DashWallet/Sources/UI/CrowdNode/Portal/CrowdNodePortalViewController.swift index 6dde13403..8efc508f1 100644 --- a/DashWallet/Sources/UI/CrowdNode/Portal/CrowdNodePortalViewController.swift +++ b/DashWallet/Sources/UI/CrowdNode/Portal/CrowdNodePortalViewController.swift @@ -245,6 +245,7 @@ extension CrowdNodePortalController : UITableViewDelegate, UITableViewDataSource switch item { case .deposit: + DSLogger.log("CrowdNodeDeposit: navigate to transfer with deposit mode") navigationController?.pushViewController(CrowdNodeTransferController.controller(mode: TransferDirection.deposit), animated: true) case .withdraw: if viewModel.canWithdraw { diff --git a/DashWallet/Sources/UI/CrowdNode/Portal/CrowdNodeTransferViewController.swift b/DashWallet/Sources/UI/CrowdNode/Portal/CrowdNodeTransferViewController.swift index 1c1f0e525..b4144c9f5 100644 --- a/DashWallet/Sources/UI/CrowdNode/Portal/CrowdNodeTransferViewController.swift +++ b/DashWallet/Sources/UI/CrowdNode/Portal/CrowdNodeTransferViewController.swift @@ -43,45 +43,57 @@ final class CrowdNodeTransferController: SendAmountViewController, NetworkReacha override var amountInputStyle: AmountInputControl.Style { .oppositeAmount } static func controller(mode: TransferDirection) -> CrowdNodeTransferController { + DSLogger.log("CrowdNodeDeposit: create transfer model for \(mode)") let model = CrowdNodeTransferModel() model.direction = mode + DSLogger.log("CrowdNodeDeposit: create viewController") let vc = CrowdNodeTransferController(model: model) return vc } override func viewDidLoad() { + DSLogger.log("CrowdNodeDeposit: super.viewDidLoad") super.viewDidLoad() + DSLogger.log("CrowdNodeDeposit: viewDidLoad") view.backgroundColor = .dw_secondaryBackground() navigationItem.backButtonDisplayMode = .minimal navigationItem.largeTitleDisplayMode = .never networkStatusDidChange = { [weak self] _ in + DSLogger.log("CrowdNodeDeposit: networkStatusDidChange") self?.reloadView() } startNetworkMonitoring() configureObservers() + DSLogger.log("CrowdNodeDeposit: viewDidLoad end") } override func viewDidAppear(_ animated: Bool) { + DSLogger.log("CrowdNodeDeposit: super.viewDidAppear") super.viewDidAppear(animated) + DSLogger.log("CrowdNodeDeposit: viewDidAppear") viewModel.showNotificationOnResult = false if mode == .deposit && viewModel.shouldShowWithdrawalLimitsDialog { showWithdrawalLimitsInfo() viewModel.shouldShowWithdrawalLimitsDialog = false } + + DSLogger.log("CrowdNodeDeposit: viewDidAppear end") } override func viewDidDisappear(_ animated: Bool) { + DSLogger.log("CrowdNodeDeposit: super.viewDidDisappear") super.viewDidDisappear(animated) viewModel.showNotificationOnResult = true } override var actionButtonTitle: String? { - mode.title + DSLogger.log("CrowdNodeDeposit: get actionButtonTitle") + return mode.title } override func actionButtonAction(sender: UIView) { @@ -101,8 +113,10 @@ final class CrowdNodeTransferController: SendAmountViewController, NetworkReacha } override func configureModel() { + DSLogger.log("CrowdNodeDeposit: super.configureModel") super.configureModel() + DSLogger.log("CrowdNodeDeposit: configureModel") model.inputsSwappedHandler = { [weak self] _ in self?.updateBalanceLabel() } @@ -158,22 +172,28 @@ final class CrowdNodeTransferController: SendAmountViewController, NetworkReacha extension CrowdNodeTransferController { override func configureHierarchy() { + DSLogger.log("CrowdNodeDeposit: super.configureHierarchy") super.configureHierarchy() + DSLogger.log("CrowdNodeDeposit: configureTitleBar") configureTitleBar() + DSLogger.log("CrowdNodeDeposit: set fromLabel") fromLabel = FromLabel(icon: mode.imageName, text: mode.direction) contentView.addSubview(fromLabel) + DSLogger.log("CrowdNodeDeposit: set KeyboardHeader") let keyboardHeader = KeyboardHeader(icon: mode.keyboardHeaderIcon, text: mode.keyboardHeader) keyboardHeader.translatesAutoresizingMaskIntoConstraints = false topKeyboardView = keyboardHeader + DSLogger.log("CrowdNodeDeposit: set NetworkUnavailableView") networkUnavailableView = NetworkUnavailableView(frame: .zero) networkUnavailableView.translatesAutoresizingMaskIntoConstraints = false networkUnavailableView.isHidden = true contentView.addSubview(networkUnavailableView) + DSLogger.log("CrowdNodeDeposit: activate transfer screen constraints") NSLayoutConstraint.activate([ fromLabel.centerXAnchor.constraint(equalTo: contentView.centerXAnchor), NSLayoutConstraint(item: fromLabel!, attribute: .centerY, relatedBy: .equal, toItem: view, attribute: .centerY, multiplier: 0.38, constant: 0), @@ -187,9 +207,11 @@ extension CrowdNodeTransferController { ]) if mode == .deposit && viewModel.shouldShowFirstDepositBanner { + DSLogger.log("CrowdNodeDeposit: set MinimumDepositBanner") let minimumDepositBanner = MinimumDepositBanner(frame: .zero) contentView.addSubview(minimumDepositBanner) + DSLogger.log("CrowdNodeDeposit: activate MinimumDepositBanner constraints") NSLayoutConstraint.activate([ minimumDepositBanner.heightAnchor.constraint(equalToConstant: 32), minimumDepositBanner.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), @@ -197,6 +219,7 @@ extension CrowdNodeTransferController { minimumDepositBanner.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 0), ]) + DSLogger.log("CrowdNodeDeposit: set UITapGestureRecognizer") let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(minimumDepositBannerTapAction)) minimumDepositBanner.addGestureRecognizer(tapGestureRecognizer) self.minimumDepositBanner = minimumDepositBanner @@ -204,6 +227,7 @@ extension CrowdNodeTransferController { } private func configureTitleBar() { + DSLogger.log("CrowdNodeDeposit: configureTitleBar") let titleViewStackView = UIStackView() titleViewStackView.alignment = .center titleViewStackView.translatesAutoresizingMaskIntoConstraints = false @@ -211,12 +235,14 @@ extension CrowdNodeTransferController { titleViewStackView.spacing = 1 navigationItem.titleView = titleViewStackView + DSLogger.log("CrowdNodeDeposit: titleLabel") let titleLabel = UILabel() titleLabel.font = .dw_mediumFont(ofSize: 16) titleLabel.minimumScaleFactor = 0.5 titleLabel.text = mode.title titleViewStackView.addArrangedSubview(titleLabel) + DSLogger.log("CrowdNodeDeposit: set dashPriceLabel") dashPriceLabel = UILabel() dashPriceLabel.font = .dw_font(forTextStyle: .footnote) dashPriceLabel.textColor = .dw_secondaryText() @@ -235,6 +261,7 @@ extension CrowdNodeTransferController { extension CrowdNodeTransferController { private func reloadView() { let isOnline = networkStatus == .online + DSLogger.log("CrowdNodeDeposit: reloadView, isOnline: \(isOnline)") networkUnavailableView.isHidden = isOnline keyboardContainer.isHidden = !isOnline if let btn = actionButton as? UIButton { btn.superview?.isHidden = !isOnline } @@ -300,15 +327,20 @@ extension CrowdNodeTransferController { } private func showWithdrawalLimitsInfo() { + DSLogger.log("CrowdNodeDeposit: showWithdrawalLimitsInfo") let vc = WithdrawalLimitsController() + DSLogger.log("CrowdNodeDeposit: assign WithdrawalLimitDialogModel") vc.model = WithdrawalLimitDialogModel(icon: "image.crowdnode.info", buttonText: nil, limits: viewModel.withdrawalLimits, highlightedLimit: -1) + DSLogger.log("CrowdNodeDeposit: create BaseNavigationController") let nvc = BaseNavigationController(rootViewController: vc) + DSLogger.log("CrowdNodeDeposit: present BaseNavigationController") present(nvc, animated: true) } } extension CrowdNodeTransferController { func configureObservers() { + DSLogger.log("CrowdNodeDeposit: configureObservers") viewModel.$crowdNodeBalance .receive(on: DispatchQueue.main) .removeDuplicates() @@ -334,10 +366,13 @@ extension CrowdNodeTransferController { } private func updateBalanceLabel() { + DSLogger.log("CrowdNodeDeposit: updateBalanceLabel") let amount = mode == .deposit ? viewModel.walletBalance : viewModel.crowdNodeBalance + DSLogger.log("CrowdNodeDeposit: formatted balance: \(amount)") let formatted = model.activeAmountType == .main ? amount.formattedDashAmount : CurrencyExchanger.shared.fiatAmountString(in: model.localCurrencyCode, for: amount.dashAmount) + DSLogger.log("CrowdNodeDeposit: set balance label: \(formatted)") fromLabel.balanceText = NSLocalizedString("Balance: ", comment: "CrowdNode") + formatted } } diff --git a/DashWallet/Sources/UI/CrowdNode/Portal/Model/CrowdNodeTransferModel.swift b/DashWallet/Sources/UI/CrowdNode/Portal/Model/CrowdNodeTransferModel.swift index 1ff6e3890..ae02f6b73 100644 --- a/DashWallet/Sources/UI/CrowdNode/Portal/Model/CrowdNodeTransferModel.swift +++ b/DashWallet/Sources/UI/CrowdNode/Portal/Model/CrowdNodeTransferModel.swift @@ -33,6 +33,7 @@ enum TransferDirection { case withdraw var imageName: String { + DSLogger.log("CrowdNodeDeposit: get imageName") switch self { case .deposit: return "image.explore.dash.wts.dash" case .withdraw: return "image.crowdnode.logo" @@ -40,6 +41,7 @@ enum TransferDirection { } var title: String { + DSLogger.log("CrowdNodeDeposit: get title") switch self { case .deposit: return NSLocalizedString("Deposit", comment: "CrowdNode") case .withdraw: return NSLocalizedString("Withdraw", comment: "CrowdNode") @@ -47,6 +49,7 @@ enum TransferDirection { } var direction: String { + DSLogger.log("CrowdNodeDeposit: get direction") switch self { case .deposit: return NSLocalizedString("from Dash Wallet", comment: "from Dash Wallet") case .withdraw: return NSLocalizedString("from CrowdNode", comment: "from CrowdNode") @@ -54,6 +57,7 @@ enum TransferDirection { } var keyboardHeader: String { + DSLogger.log("CrowdNodeDeposit: get keyboardHeader") switch self { case .deposit: return NSLocalizedString("Sending to CrowdNode account", comment: "CrowdNode") case .withdraw: return NSLocalizedString("Sending to Dash Wallet on this device", comment: "CrowdNode") @@ -61,6 +65,7 @@ enum TransferDirection { } var keyboardHeaderIcon: String { + DSLogger.log("CrowdNodeDeposit: get keyboardHeaderIcon") switch self { case .deposit: return "image.crowdnode.logo" case .withdraw: return "image.explore.dash.wts.dash" @@ -97,6 +102,7 @@ final class CrowdNodeTransferModel: SendAmountModel { public var direction: TransferDirection = .deposit var dashPriceDisplayString: String { + DSLogger.log("CrowdNodeDeposit: get dashPriceDisplayString") let dashAmount = kOneDash let dashAmountFormatted = dashAmount.formattedDashAmount let fiatBalanceFormatted = CurrencyExchanger.shared.fiatAmountString(in: localCurrencyCode, for: dashAmount.dashAmount) diff --git a/DashWallet/Sources/UI/CrowdNode/Portal/WithdrawalLimitsController.swift b/DashWallet/Sources/UI/CrowdNode/Portal/WithdrawalLimitsController.swift index 8223f33cf..45cc8e0e1 100644 --- a/DashWallet/Sources/UI/CrowdNode/Portal/WithdrawalLimitsController.swift +++ b/DashWallet/Sources/UI/CrowdNode/Portal/WithdrawalLimitsController.swift @@ -52,6 +52,7 @@ final class WithdrawalLimitsController: BaseViewController { } override func viewDidLoad() { + DSLogger.log("CrowdNodeDeposit: limits super.viewDidLoad") super.viewDidLoad() configureHierarchy() @@ -61,28 +62,34 @@ final class WithdrawalLimitsController: BaseViewController { // MARK: Life cycle extension WithdrawalLimitsController { private func configureHierarchy() { + DSLogger.log("CrowdNodeDeposit: limits configureHierarchy") view.backgroundColor = .dw_secondaryBackground() let action = UIAction { [weak self] _ in self?.closeAction() } + DSLogger.log("CrowdNodeDeposit: limits set rightBarButtonItem") let closeItem = UIBarButtonItem(systemItem: .close, primaryAction: action) navigationItem.rightBarButtonItem = closeItem + DSLogger.log("CrowdNodeDeposit: limits set scrollView") let scrollView = UIScrollView(frame: .zero) scrollView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(scrollView) + DSLogger.log("CrowdNodeDeposit: limits set contentView") let contentView = UIView() contentView.translatesAutoresizingMaskIntoConstraints = false contentView.backgroundColor = .clear scrollView.addSubview(contentView) + DSLogger.log("CrowdNodeDeposit: limits set iconView") let iconView = UIImageView(image: UIImage(named: model?.icon ?? "image.crowdnode.info")) iconView.contentMode = .scaleAspectFit iconView.translatesAutoresizingMaskIntoConstraints = false scrollView.addSubview(iconView) + DSLogger.log("CrowdNodeDeposit: limits set titleLabel") let titleLabel = UILabel() titleLabel.translatesAutoresizingMaskIntoConstraints = false titleLabel.textAlignment = .center @@ -90,6 +97,7 @@ extension WithdrawalLimitsController { titleLabel.text = NSLocalizedString("CrowdNode withdrawal limits", comment: "CrowdNode") scrollView.addSubview(titleLabel) + DSLogger.log("CrowdNodeDeposit: limits set titleLabel") let descriptionLabel = UILabel() descriptionLabel.translatesAutoresizingMaskIntoConstraints = false descriptionLabel.numberOfLines = 0 @@ -100,26 +108,33 @@ extension WithdrawalLimitsController { descriptionLabel.text = NSLocalizedString("Due to CrowdNode’s terms of service users can withdraw no more than:", comment: "CrowdNode") scrollView.addSubview(descriptionLabel) + DSLogger.log("CrowdNodeDeposit: limits set limitsStackView") let limitsStackView = UIStackView() limitsStackView.translatesAutoresizingMaskIntoConstraints = false limitsStackView.axis = .horizontal limitsStackView.distribution = .fillEqually scrollView.addSubview(limitsStackView) + DSLogger.log("CrowdNodeDeposit: limits set limitLabelsStackView") let limitLabelsStackView = UIStackView() limitLabelsStackView.translatesAutoresizingMaskIntoConstraints = false limitLabelsStackView.axis = .horizontal limitLabelsStackView.distribution = .fillEqually scrollView.addSubview(limitLabelsStackView) + DSLogger.log("CrowdNodeDeposit: limits enumerate limits") model?.limits.enumerated().forEach { + DSLogger.log("CrowdNodeDeposit: limit \($0.element)") let isHighlighted = $0.offset == model?.highlightedLimit + DSLogger.log("CrowdNodeDeposit: create limit") let limit = createLimitText(limit: $0.element, isHighlighted: isHighlighted) limitsStackView.addArrangedSubview(limit) + DSLogger.log("CrowdNodeDeposit: create createLimitLabel") let limitLabel = createLimitLabel(label: limitLabels[$0.offset], isHighlighted: isHighlighted) limitLabelsStackView.addArrangedSubview(limitLabel) } + DSLogger.log("CrowdNodeDeposit: limits activate constraints") let frameGuide = scrollView.frameLayoutGuide let contentGuide = scrollView.contentLayoutGuide @@ -160,6 +175,7 @@ extension WithdrawalLimitsController { ]) if let text = model?.buttonText { + DSLogger.log("CrowdNodeDeposit: limits set onlineAccountHint") let onlineAccountHint = UILabel() onlineAccountHint.translatesAutoresizingMaskIntoConstraints = false onlineAccountHint.numberOfLines = 0 @@ -170,6 +186,7 @@ extension WithdrawalLimitsController { onlineAccountHint.text = NSLocalizedString("Withdraw without limits with an online account on CrowdNode website.", comment: "CrowdNode") scrollView.addSubview(onlineAccountHint) + DSLogger.log("CrowdNodeDeposit: limits set actionButton") let actionButton = UIButton(type: .custom) actionButton.translatesAutoresizingMaskIntoConstraints = false actionButton.addTarget(self, action: #selector(actionButtonAction), for: .touchUpInside) @@ -179,6 +196,7 @@ extension WithdrawalLimitsController { actionButton.setTitle(text, for: .normal) scrollView.addSubview(actionButton) + DSLogger.log("CrowdNodeDeposit: limits activate buttonText constraint") NSLayoutConstraint.activate([ onlineAccountHint.topAnchor.constraint(equalTo: limitLabelsStackView.bottomAnchor, constant: 30), onlineAccountHint.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 15), diff --git a/DashWallet/Sources/UI/Payments/Amount/BaseAmountViewController.swift b/DashWallet/Sources/UI/Payments/Amount/BaseAmountViewController.swift index 39d9fe1fc..4c88e2e33 100644 --- a/DashWallet/Sources/UI/Payments/Amount/BaseAmountViewController.swift +++ b/DashWallet/Sources/UI/Payments/Amount/BaseAmountViewController.swift @@ -56,6 +56,7 @@ class BaseAmountViewController: ActionButtonViewController, AmountProviding { func maxButtonAction() { } init(model: BaseAmountModel) { + DSLogger.log("CrowdNodeDeposit: BaseAmountViewController init") self.model = model super.init(nibName: nil, bundle: nil) @@ -66,6 +67,7 @@ class BaseAmountViewController: ActionButtonViewController, AmountProviding { } internal func configureModel() { + DSLogger.log("CrowdNodeDeposit: BaseAmountViewController configureModel") model.amountChangeHandler = { [weak self] _ in self?.amountDidChange() } @@ -84,6 +86,7 @@ class BaseAmountViewController: ActionButtonViewController, AmountProviding { } internal func amountDidChange() { + DSLogger.log("CrowdNodeDeposit: BaseAmountViewController amountDidChange") actionButton?.isEnabled = model.isAllowedToContinue amountView.amountInputControl.reloadData() showErrorIfNeeded() @@ -123,6 +126,7 @@ class BaseAmountViewController: ActionButtonViewController, AmountProviding { } override func viewDidAppear(_ animated: Bool) { + DSLogger.log("CrowdNodeDeposit: BaseAmountViewController viewDidAppear") super.viewDidAppear(animated) actionButton?.isEnabled = model.isAllowedToContinue @@ -131,6 +135,7 @@ class BaseAmountViewController: ActionButtonViewController, AmountProviding { } override func viewDidLoad() { + DSLogger.log("CrowdNodeDeposit: BaseAmountViewController viewDidLoad") super.viewDidLoad() configureHierarchy() @@ -141,6 +146,7 @@ class BaseAmountViewController: ActionButtonViewController, AmountProviding { extension BaseAmountViewController { @objc internal func configureHierarchy() { + DSLogger.log("CrowdNodeDeposit: BaseAmountViewController configureHierarchy") contentView = UIView() contentView.translatesAutoresizingMaskIntoConstraints = false contentView.backgroundColor = .dw_secondaryBackground() diff --git a/DashWallet/Sources/UI/Views/BaseController/BaseViewController+NetworkReachability.swift b/DashWallet/Sources/UI/Views/BaseController/BaseViewController+NetworkReachability.swift index 6b7f5d7c5..8e70c1e30 100644 --- a/DashWallet/Sources/UI/Views/BaseController/BaseViewController+NetworkReachability.swift +++ b/DashWallet/Sources/UI/Views/BaseController/BaseViewController+NetworkReachability.swift @@ -32,6 +32,7 @@ extension NetworkReachabilityHandling { internal var reachability: DSReachabilityManager { DSReachabilityManager.shared() } public func startNetworkMonitoring() { + DSLogger.log("CrowdNodeDeposit: startNetworkMonitoring") if !reachability.isMonitoring { reachability.startMonitoring() } From a7676486b89d73f356da41365027160237d848eb Mon Sep 17 00:00:00 2001 From: tikhop Date: Wed, 26 Jul 2023 16:26:07 +0400 Subject: [PATCH 2/4] 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 3/4] 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() { From 7b10b5ea222f855c6d15d49977a92f2ae4229803 Mon Sep 17 00:00:00 2001 From: tikhop Date: Thu, 3 Aug 2023 14:20:08 +0400 Subject: [PATCH 4/4] chore: Bump up version --- DashWallet.xcodeproj/project.pbxproj | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/DashWallet.xcodeproj/project.pbxproj b/DashWallet.xcodeproj/project.pbxproj index 4ff5a90d7..b5e256529 100644 --- a/DashWallet.xcodeproj/project.pbxproj +++ b/DashWallet.xcodeproj/project.pbxproj @@ -7444,7 +7444,7 @@ INFOPLIST_KEY_CFBundleDisplayName = Dash; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; @@ -7502,7 +7502,7 @@ INFOPLIST_KEY_CFBundleDisplayName = Dash; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "DashWallet/dashwallet-Bridging-Header.h"; @@ -7587,7 +7587,7 @@ EXCLUDED_ARCHS = ""; IBSC_MODULE = WatchApp_Extension; INFOPLIST_FILE = WatchApp/Info.plist; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; @@ -7609,7 +7609,7 @@ EXCLUDED_ARCHS = ""; IBSC_MODULE = WatchApp_Extension; INFOPLIST_FILE = WatchApp/Info.plist; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; @@ -7630,7 +7630,7 @@ EXCLUDED_ARCHS = ""; INFOPLIST_FILE = "WatchApp Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp.watchkitextension; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; @@ -7653,7 +7653,7 @@ EXCLUDED_ARCHS = ""; INFOPLIST_FILE = "WatchApp Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp.watchkitextension; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; @@ -7681,7 +7681,7 @@ INFOPLIST_FILE = TodayExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.TodayExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -7706,7 +7706,7 @@ INFOPLIST_FILE = TodayExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.TodayExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -7823,7 +7823,7 @@ INFOPLIST_KEY_CFBundleDisplayName = Dash; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "DashWallet/dashwallet-Bridging-Header.h"; @@ -7851,7 +7851,7 @@ INFOPLIST_FILE = TodayExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.TodayExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -7903,7 +7903,7 @@ EXCLUDED_ARCHS = ""; IBSC_MODULE = WatchApp_Extension; INFOPLIST_FILE = WatchApp/Info.plist; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; @@ -7924,7 +7924,7 @@ EXCLUDED_ARCHS = ""; INFOPLIST_FILE = "WatchApp Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp.watchkitextension; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos; @@ -8040,7 +8040,7 @@ INFOPLIST_KEY_CFBundleDisplayName = Dash; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "DashWallet/dashwallet-Bridging-Header.h"; @@ -8067,7 +8067,7 @@ INFOPLIST_FILE = TodayExtension/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.TodayExtension; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -8118,7 +8118,7 @@ EXCLUDED_ARCHS = ""; IBSC_MODULE = WatchApp_Extension; INFOPLIST_FILE = WatchApp/Info.plist; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = watchos; @@ -8139,7 +8139,7 @@ EXCLUDED_ARCHS = ""; INFOPLIST_FILE = "WatchApp Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.0.3; PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp.watchkitextension; PRODUCT_NAME = "${TARGET_NAME}"; SDKROOT = watchos;