Skip to content

Commit

Permalink
chore: Merge pull request #580 from dashpay/fix/sheet-controller
Browse files Browse the repository at this point in the history
fix: UI fixes and improvements for iOS 15
  • Loading branch information
tikhop authored Jul 27, 2023
2 parents addd012 + 4531824 commit 6d727fa
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ final class EnterAddressViewController: BaseViewController, PayableViewControlle
var payModel: DWPayModelProtocol! { model }

internal var paymentController: PaymentController!
@objc
weak var paymentControllerDelegate: PaymentControllerDelegate?

// MARK: Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -54,7 +54,9 @@ final class PasteboardContentView: UIView {
}
}

invalidateIntrinsicContentSize()
DispatchQueue.main.async {
self.invalidateIntrinsicContentSize()
}
}

private func configureHierarchy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
19 changes: 10 additions & 9 deletions DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions DashWallet/Sources/UI/Payments/Pay/Pay.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -12,7 +12,7 @@
<!--Pay View Controller-->
<scene sceneID="oX0-8k-mSo">
<objects>
<viewController id="BNa-mF-PJH" customClass="DWPayViewController" sceneMemberID="viewController">
<viewController id="BNa-mF-PJH" customClass="PayViewController" customModule="dashwallet" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ow4-5C-AVU">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down
7 changes: 0 additions & 7 deletions DashWallet/Sources/UI/Payments/Pay/PayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 11 additions & 19 deletions DashWallet/Sources/UI/Views/SheetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -821,7 +821,7 @@ SPEC CHECKSUMS:
MMSegmentSlider: db7ee0d6eb2eefbd511179195bf288ff2cebac0a
Moya: 138f0573e53411fb3dc17016add0b748dfbd78ee
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
PromisesObjC: 7f84fefd35e085854377a97e19424ae424cc7a9e
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
Protobuf: c6bc59bbab3d38a71c67f62d7cb7ca8f8ea4eca1
SDWebImage: 72f86271a6f3139cc7e4a89220946489d4b9a866
SQLite.swift: 903bfa3bc9ab06345fdfbb578e34f47cfcf417da
Expand Down

0 comments on commit 6d727fa

Please sign in to comment.