Merge pull request #160 from James-Sangalli/remove-text-mail-in-choose-transfer-mode

Remove text and email buttons, and rename "Others" in choose ticket transfer mode screen
pull/167/head
James Sangalli 7 years ago committed by GitHub
commit 1ebde421dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Trust/Localization/en.lproj/Localizable.strings
  2. 51
      Trust/Transactions/Coordinators/TicketsCoordinator.swift
  3. 47
      Trust/Transfer/ViewControllers/ChooseTicketTransferModeViewController.swift

@ -196,7 +196,7 @@
"a.wallet.ticketToken.transfer.mode.choose.email.title" = "Send Email";
"a.wallet.ticketToken.transfer.mode.choose.inputWalletAddress.title" = "Input Wallet Address";
"a.wallet.ticketToken.transfer.mode.choose.walletAddressViaQRCodeScanner.title" = "Use QR Code Scanner";
"a.wallet.ticketToken.transfer.mode.choose.other.title" = "Others";
"a.wallet.ticketToken.transfer.mode.choose.other.title" = "Share Link";
"a.wallet.ticketToken.transfer.mode.walletAddress.title" = "Input Wallet Address";
"a.wallet.ticketToken.transfer.mode.walletAddress.target.title" = "WALLET ADDRESS TO TRANSFER TO";
"a.wallet.ticketToken.transfer.mode.walletAddress.confirmation" = "Transfer to wallet address %@?";

@ -154,32 +154,6 @@ class TicketsCoordinator: NSObject, Coordinator {
return controller
}
private func transferViaText(ticketHolder: TicketHolder, paymentFlow: PaymentFlow) {
guard MFMessageComposeViewController.canSendText() else {
UIAlertController.alert(title: "", message: R.string.localizable.aSetupReminderTextText(), alertButtonTitles: [R.string.localizable.oK()], alertButtonStyles: [.cancel], viewController: navigationController, completion: nil)
return
}
let url = generateTransferLink(ticketHolder: ticketHolder, paymentFlow: paymentFlow)
let vc = MFMessageComposeViewController()
vc.messageComposeDelegate = self
vc.body = url
navigationController.present(vc, animated: true)
}
private func transferViaEmail(ticketHolder: TicketHolder, paymentFlow: PaymentFlow) {
guard MFMailComposeViewController.canSendMail() else {
UIAlertController.alert(title: "", message: R.string.localizable.aSetupReminderEmailText(), alertButtonTitles: [R.string.localizable.oK()], alertButtonStyles: [.cancel], viewController: navigationController, completion: nil)
return
}
let url = generateTransferLink(ticketHolder: ticketHolder, paymentFlow: paymentFlow)
let vc = MFMailComposeViewController()
vc.setMessageBody(url, isHTML: false)
vc.mailComposeDelegate = self
navigationController.present(vc, animated: true)
}
private func generateTransferLink(ticketHolder: TicketHolder, paymentFlow: PaymentFlow) -> String {
let timestamp = Int(NSDate().timeIntervalSince1970) + 86400
let order = Order(
@ -303,10 +277,6 @@ extension TicketsCoordinator: ChooseTicketTransferModeViewControllerDelegate {
let ticketHolder = viewController.ticketHolder
switch transferMode {
case .text:
transferViaText(ticketHolder: ticketHolder, paymentFlow: viewController.paymentFlow)
case .email:
transferViaEmail(ticketHolder: ticketHolder, paymentFlow: viewController.paymentFlow)
case .walletAddressTextEntry:
transferViaWalletAddressTextEntry(ticketHolder: ticketHolder, paymentFlow: viewController.paymentFlow)
case .walletAddressFromQRCode:
@ -362,24 +332,3 @@ extension TicketsCoordinator: TransferTicketsCoordinatorDelegate {
}
}
extension TicketsCoordinator: MFMessageComposeViewControllerDelegate {
func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
if result == .cancelled || result == .failed {
controller.dismiss(animated: true)
} else {
controller.dismiss(animated: false)
navigationController.dismiss(animated: true)
}
}
}
extension TicketsCoordinator: MFMailComposeViewControllerDelegate {
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
if result == .cancelled || result == .failed {
controller.dismiss(animated: true)
} else {
controller.dismiss(animated: false)
navigationController.dismiss(animated: true)
}
}
}

@ -4,8 +4,6 @@ import UIKit
import MessageUI
enum TicketTransferMode {
case text
case email
case walletAddressTextEntry
case walletAddressFromQRCode
case other
@ -19,8 +17,6 @@ class ChooseTicketTransferModeViewController: UIViewController {
//roundedBackground is used to achieve the top 2 rounded corners-only effect since maskedCorners to not round bottom corners is not available in iOS 10
let roundedBackground = UIView()
let titleLabel = UILabel()
let textButton = TransferModeButton()
let emailButton = TransferModeButton()
let inputWalletAddressButton = TransferModeButton()
let qrCodeScannerButton = TransferModeButton()
let otherButton = TransferModeButton()
@ -39,16 +35,6 @@ class ChooseTicketTransferModeViewController: UIViewController {
roundedBackground.cornerRadius = 20
view.addSubview(roundedBackground)
textButton.callback = {
self.delegate?.didChoose(transferMode: .text, in: self)
}
textButton.translatesAutoresizingMaskIntoConstraints = false
emailButton.callback = {
self.delegate?.didChoose(transferMode: .email, in: self)
}
emailButton.translatesAutoresizingMaskIntoConstraints = false
inputWalletAddressButton.callback = {
self.delegate?.didChoose(transferMode: .walletAddressTextEntry, in: self)
}
@ -65,33 +51,24 @@ class ChooseTicketTransferModeViewController: UIViewController {
otherButton.translatesAutoresizingMaskIntoConstraints = false
let buttonRow1 = UIStackView(arrangedSubviews: [
textButton,
emailButton,
inputWalletAddressButton,
qrCodeScannerButton,
])
buttonRow1.translatesAutoresizingMaskIntoConstraints = false
buttonRow1.axis = .horizontal
buttonRow1.spacing = 12
buttonRow1.distribution = .fill
let buttonPlaceholder = UIView()
let buttonRow2 = UIStackView(arrangedSubviews: [
inputWalletAddressButton,
qrCodeScannerButton,
otherButton,
buttonPlaceholder,
])
buttonRow2.translatesAutoresizingMaskIntoConstraints = false
buttonRow2.axis = .horizontal
buttonRow2.spacing = 12
buttonRow2.distribution = .fill
let buttonPlaceholder = UIView()
let buttonRow3 = UIStackView(arrangedSubviews: [
otherButton,
buttonPlaceholder,
])
buttonRow3.translatesAutoresizingMaskIntoConstraints = false
buttonRow3.axis = .horizontal
buttonRow3.spacing = 12
buttonRow3.distribution = .fill
let stackView = UIStackView(arrangedSubviews: [
.spacer(height: 7),
titleLabel,
@ -99,8 +76,6 @@ class ChooseTicketTransferModeViewController: UIViewController {
buttonRow1,
.spacer(height: 12),
buttonRow2,
.spacer(height: 12),
buttonRow3,
])
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
@ -140,12 +115,6 @@ class ChooseTicketTransferModeViewController: UIViewController {
titleLabel.textAlignment = .center
titleLabel.text = viewModel.titleLabelText
textButton.title = viewModel.textButtonTitle
textButton.image = viewModel.textButtonImage
emailButton.title = viewModel.emailButtonTitle
emailButton.image = viewModel.emailButtonImage
inputWalletAddressButton.title = viewModel.inputWalletAddressButtonTitle
inputWalletAddressButton.image = viewModel.inputWalletAddressButtonImage
@ -155,14 +124,10 @@ class ChooseTicketTransferModeViewController: UIViewController {
otherButton.title = viewModel.otherButtonTitle
otherButton.image = viewModel.otherButtonImage
textButton.label.font = viewModel.buttonTitleFont
emailButton.label.font = viewModel.buttonTitleFont
inputWalletAddressButton.label.font = viewModel.buttonTitleFont
qrCodeScannerButton.label.font = viewModel.buttonTitleFont
otherButton.label.font = viewModel.buttonTitleFont
textButton.label.textColor = viewModel.buttonTitleColor
emailButton.label.textColor = viewModel.buttonTitleColor
inputWalletAddressButton.label.textColor = viewModel.buttonTitleColor
qrCodeScannerButton.label.textColor = viewModel.buttonTitleColor
otherButton.label.textColor = viewModel.buttonTitleColor
@ -170,8 +135,6 @@ class ChooseTicketTransferModeViewController: UIViewController {
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
textButton.layer.cornerRadius = textButton.frame.size.height / 2
emailButton.layer.cornerRadius = emailButton.frame.size.height / 2
inputWalletAddressButton.layer.cornerRadius = inputWalletAddressButton.frame.size.height / 2
qrCodeScannerButton.layer.cornerRadius = qrCodeScannerButton.frame.size.height / 2
}

Loading…
Cancel
Save