From 65add7cba51a473d914811c55c6f78852ce6f2ee Mon Sep 17 00:00:00 2001 From: Michael Scoff Date: Sun, 26 Nov 2017 21:04:22 -0800 Subject: [PATCH] Set sourceView sourceRect to transaction items --- .../ViewControllers/TransactionViewController.swift | 9 +++++---- Trust/UI/Form/TransactionAppearance.swift | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Trust/Transactions/ViewControllers/TransactionViewController.swift b/Trust/Transactions/ViewControllers/TransactionViewController.swift index fcce3f1b6..1c3a4c22b 100644 --- a/Trust/Transactions/ViewControllers/TransactionViewController.swift +++ b/Trust/Transactions/ViewControllers/TransactionViewController.swift @@ -63,11 +63,11 @@ class TransactionViewController: UIViewController { } private func item(title: String, value: String) -> UIView { - return TransactionAppearance.item( + return TransactionAppearance.item( title: title, subTitle: value ) { [weak self] in - self?.showAlertSheet(title: $0, value: $1) + self?.showAlertSheet(title: $0, value: $1, sourceView: $2) } } @@ -87,13 +87,14 @@ class TransactionViewController: UIViewController { return stackView } - func showAlertSheet(title: String, value: String) { + func showAlertSheet(title: String, value: String, sourceView: UIView) { let alertController = UIAlertController( title: nil, message: value, preferredStyle: .actionSheet ) - alertController.popoverPresentationController?.sourceView = self.view + alertController.popoverPresentationController?.sourceView = sourceView + alertController.popoverPresentationController?.sourceRect = sourceView.bounds let copyAction = UIAlertAction(title: NSLocalizedString("transactionDetails.copy", value: "Copy", comment: ""), style: .default) { _ in UIPasteboard.general.string = value } diff --git a/Trust/UI/Form/TransactionAppearance.swift b/Trust/UI/Form/TransactionAppearance.swift index 8d8cf074d..0b9795e0b 100644 --- a/Trust/UI/Form/TransactionAppearance.swift +++ b/Trust/UI/Form/TransactionAppearance.swift @@ -19,7 +19,7 @@ struct TransactionAppearance { return view } - static func item(title: String, subTitle: String, completion:((_ title: String, _ value: String) -> Void)? = .none) -> UIView { + static func item(title: String, subTitle: String, completion:((_ title: String, _ value: String, _ sender: UIView) -> Void)? = .none) -> UIView { let titleLabel = UILabel(frame: .zero) titleLabel.translatesAutoresizingMaskIntoConstraints = false titleLabel.text = title @@ -42,7 +42,7 @@ struct TransactionAppearance { stackView.isLayoutMarginsRelativeArrangement = true UITapGestureRecognizer(addToView: stackView) { - completion?(title, subTitle) + completion?(title, subTitle, stackView) } return stackView