|
|
|
@ -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 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|