Style show QR code screen in redeem flow

pull/111/head
Hwee-Boon Yar 7 years ago
parent ea60ef927a
commit a23b8fd83a
  1. 1
      Trust/Localization/en.lproj/Localizable.strings
  2. 97
      Trust/Redeem/ViewControllers/TicketRedemptionViewController.swift
  3. 40
      Trust/Redeem/ViewModels/TicketRedemptionViewModel.swift
  4. 6
      Trust/Transactions/Coordinators/TicketsCoordinator.swift

@ -180,6 +180,7 @@
"a.wallet.ticketToken.redeem.selectTickets.atLeastOne.title" = "Please select a ticket to redeem";
"a.wallet.ticketToken.redeem.selectQuantity.title" = "Select Quantity of Tickets";
"a.wallet.ticketToken.redeem.quantity.title" = "QUANTITY OF TICKETS";
"a.wallet.ticketToken.redeem.showQRCode.title" = "Show QR Code to Redemption Booth";
"a.wallet.ticketToken.sell.button.title" = "Sell";
"a.wallet.ticketToken.transfer.button.title" = "Transfer";
"a.wallet.ticketTokenBundle.status.sold.title" = "Sold";

@ -10,18 +10,71 @@ import UIKit
class TicketRedemptionViewController: UIViewController {
@IBOutlet weak var ticketView: TicketView!
@IBOutlet weak var imageView: UIImageView!
var viewModel: TicketRedemptionViewModel!
var titleLabel = UILabel()
let imageView = UIImageView()
let ticketView = TicketRowView()
let redeem = CreateRedeem()
var timer: Timer!
var session: WalletSession!
var session: WalletSession
let redeemListener = RedeemEventListener()
init(session: WalletSession) {
self.session = session
super.init(nibName: nil, bundle: nil)
titleLabel.translatesAutoresizingMaskIntoConstraints = false
imageView.translatesAutoresizingMaskIntoConstraints = false
let imageHolder = UIView()
imageHolder.translatesAutoresizingMaskIntoConstraints = false
imageHolder.backgroundColor = Colors.appWhite
imageHolder.cornerRadius = 20
imageHolder.addSubview(imageView)
ticketView.translatesAutoresizingMaskIntoConstraints = false
let stackView = UIStackView(arrangedSubviews: [
titleLabel,
.spacer(height: 10),
imageHolder,
.spacer(height: 4),
ticketView,
])
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = 0
stackView.distribution = .fill
stackView.alignment = .center
view.addSubview(stackView)
let xMargin = CGFloat(16)
NSLayoutConstraint.activate([
titleLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
titleLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),
imageView.leadingAnchor.constraint(equalTo: imageHolder.leadingAnchor, constant: 70),
imageView.trailingAnchor.constraint(equalTo: imageHolder.trailingAnchor, constant: -70),
imageView.topAnchor.constraint(equalTo: imageHolder.topAnchor, constant: 70),
imageView.bottomAnchor.constraint(equalTo: imageHolder.bottomAnchor, constant: -70),
imageHolder.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: xMargin),
imageHolder.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -xMargin),
stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stackView.topAnchor.constraint(equalTo: view.topAnchor),
])
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override
func viewDidLoad() {
super.viewDidLoad()
configureUI()
timer = Timer.scheduledTimer(timeInterval: 30,
target: self,
selector: #selector(configureUI),
@ -35,12 +88,6 @@ class TicketRedemptionViewController: UIViewController {
})
}
override
func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
title = viewModel.title
}
override
func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
@ -58,7 +105,6 @@ class TicketRedemptionViewController: UIViewController {
imageView.image = qrCodeInfo.toQRCode()
case .watch: break // TODO: What to do here?
}
ticketView.configure(ticketHolder: viewModel.ticketHolder)
}
private func showSuccessMessage() {
@ -85,4 +131,33 @@ class TicketRedemptionViewController: UIViewController {
print("deinit called")
}
func configure(viewModel: TicketRedemptionViewModel) {
self.viewModel = viewModel
view.backgroundColor = viewModel.backgroundColor
titleLabel.textAlignment = .center
titleLabel.textColor = viewModel.headerColor
titleLabel.font = viewModel.headerFont
titleLabel.numberOfLines = 0
titleLabel.text = viewModel.headerTitle
configureUI()
ticketView.configure(viewModel: .init())
ticketView.stateLabel.isHidden = true
ticketView.ticketCountLabel.text = viewModel.ticketCount
ticketView.titleLabel.text = viewModel.title
ticketView.venueLabel.text = viewModel.venue
ticketView.dateLabel.text = viewModel.date
ticketView.seatRangeLabel.text = viewModel.seatRange
ticketView.zoneNameLabel.text = viewModel.zoneName
}
}

@ -11,7 +11,45 @@ import UIKit
struct TicketRedemptionViewModel {
var ticketHolder: TicketHolder
var headerTitle: String {
return R.string.localizable.aWalletTicketTokenRedeemShowQRCodeTitle()
}
var headerColor: UIColor {
return Colors.appWhite
}
var headerFont: UIFont {
return Fonts.light(size: 25)!
}
var backgroundColor: UIColor {
return Colors.appBackground
}
var ticketCount: String {
return "x\(ticketHolder.tickets.count)"
}
var title: String {
return "Redemption"
return ticketHolder.name
}
var seatRange: String {
return ticketHolder.seatRange
}
var zoneName: String {
return ticketHolder.zone
}
var venue: String {
return ticketHolder.venue
}
var date: String {
//TODO Should format be localized?
return ticketHolder.date.format("dd MMM yyyy")
}
}

@ -105,9 +105,9 @@ class TicketsCoordinator: Coordinator {
}
private func makeTicketRedemptionViewController(for ticketHolder: TicketHolder) -> TicketRedemptionViewController {
let controller = R.storyboard.redeemTickets.ticketRedemptionViewController()!
controller.viewModel = TicketRedemptionViewModel(ticketHolder: ticketHolder)
controller.session = session
let controller = TicketRedemptionViewController(session: session)
let viewModel = TicketRedemptionViewModel(ticketHolder: ticketHolder)
controller.configure(viewModel: viewModel)
return controller
}

Loading…
Cancel
Save