-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from timroesner/135-Add-pass-UI
Add Clipper Pass UI
- Loading branch information
Showing
33 changed files
with
487 additions
and
60 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file renamed
BIN
+5.99 KB
.../Assets.xcassets/Bus.imageset/iconBus.pdf → BayPass/Assets.xcassets/Bus.imageset/bus.pdf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,8 @@ | |
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// CPCollectionView.swift | ||
// BayPass | ||
// | ||
// Created by Zhe Li on 4/15/19. | ||
// Copyright © 2019 Tim Roesner. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
extension ClipperPassViewController: UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { | ||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection _: Int) -> Int { | ||
if collectionView == clipperPassCollectionView { | ||
return agencies.count | ||
} else { | ||
return UserManager.shared.getValidPasses().count | ||
} | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
if collectionView == clipperPassCollectionView { | ||
let cell = clipperPassCollectionView.dequeueReusableCell(withReuseIdentifier: clipperPassCollectionViewCellID, for: indexPath) as! ClipperPassCollectionViewCell | ||
cell.setup(with: Pass(name: agencies[indexPath.row].stringValue, | ||
duration: DateInterval(start: Date(timeIntervalSinceNow: -470_482.0), end: Date(timeIntervalSinceNow: 470_482.0)), | ||
price: 0.0, | ||
validOnAgency: agencies[indexPath.row])) | ||
return cell | ||
} else { | ||
let cell = recentlyPurchasedClipperPassCollectionView.dequeueReusableCell(withReuseIdentifier: recentlyPurchasedClipperPassCollectionViewCellID, for: indexPath) as! ClipperPassCollectionViewCell | ||
cell.setup(with: UserManager.shared.getValidPasses()[indexPath.row]) | ||
return cell | ||
} | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, insetForSectionAt _: Int) -> UIEdgeInsets { | ||
if collectionView == clipperPassCollectionView { | ||
return UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10) | ||
} else { | ||
return UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 15) | ||
} | ||
} | ||
|
||
func collectionView(_: UICollectionView, layout _: UICollectionViewLayout, minimumInteritemSpacingForSectionAt _: Int) -> CGFloat { | ||
return 10 | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt _: IndexPath) -> CGSize { | ||
if collectionView == clipperPassCollectionView { | ||
return CGSize(width: 160, height: 85) | ||
} else { | ||
return CGSize(width: 250, height: 140) | ||
} | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | ||
if collectionView == clipperPassCollectionView { | ||
let clipperPassCheckoutViewController = ClipperPassCheckoutViewController() | ||
clipperPassCheckoutViewController.agency = agencies[indexPath.row] | ||
navigationController?.pushViewController(clipperPassCheckoutViewController, animated: true) | ||
} else if collectionView == recentlyPurchasedClipperPassCollectionView { | ||
let clipperPassCheckoutViewController = ClipperPassCheckoutViewController() | ||
clipperPassCheckoutViewController.agency = UserManager.shared.getValidPasses()[indexPath.row].validOnAgency | ||
navigationController?.pushViewController(clipperPassCheckoutViewController, animated: true) | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
BayPass/Controller/Clipper/ClipperPassCheckoutViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// ClipperPassCheckoutViewController.swift | ||
// BayPass | ||
// | ||
// Created by Zhe Li on 4/15/19. | ||
// Copyright © 2019 Tim Roesner. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class ClipperPassCheckoutViewController: UIViewController { | ||
var agency = Agency.zero | ||
var dropDownOptions: [(title: String, values: [String])] = [ | ||
(title: "Ticket Type", values: ["Day Pass", "3 Day Pass", "Monthly Pass"]), | ||
(title: "Payment Method", values: PaymentMethod.allCases.map { $0.rawValue }), | ||
] | ||
private var stackedViews = [UIView]() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view.backgroundColor = .white | ||
|
||
title = agency.stringValue | ||
navigationController?.navigationBar.prefersLargeTitles = false | ||
setUpTicketView(newTicketView: TicketView(agency: agency, icon: agency.getIcon(), cornerRadius: 12)) | ||
setupDropDowns() | ||
} | ||
|
||
func setUpTicketView(newTicketView: TicketView) { | ||
view.addSubview(newTicketView) | ||
newTicketView.snp.makeConstraints { (make) -> Void in | ||
make.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(25).priority(.low) | ||
make.left.right.equalToSuperview().inset(16) | ||
make.height.equalTo(newTicketView.snp.width).multipliedBy(0.6) | ||
} | ||
newTicketView.layoutIfNeeded() | ||
stackedViews.append(newTicketView) | ||
} | ||
|
||
func setupDropDowns() { | ||
for option in dropDownOptions { | ||
let dropDown = DropDownMenu(title: option.title, items: option.values) | ||
view.addSubview(dropDown) | ||
dropDown.snp.makeConstraints { (make) -> Void in | ||
make.top.equalTo(stackedViews.last!.snp.bottom).offset(25) | ||
make.left.right.equalToSuperview().inset(12) | ||
} | ||
stackedViews.append(dropDown) | ||
} | ||
setUpButton(color: agency.getColor()) | ||
} | ||
|
||
func setUpButton(color: UIColor) { | ||
let payButton = BayPassButton(title: "Pay $xx.xx", color: color) | ||
payButton.addTarget(self, action: #selector(pay), for: .touchUpInside) | ||
view.addSubview(payButton) | ||
payButton.snp.makeConstraints { (make) -> Void in | ||
make.top.greaterThanOrEqualTo(stackedViews.last!.snp.bottom).offset(25) | ||
make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom).inset(20) | ||
make.right.left.equalToSuperview().inset(16) | ||
make.height.equalTo(50) | ||
} | ||
} | ||
|
||
@objc func pay() { | ||
print("pay") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
BayPass/Controller/Clipper/ClipperPassViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// | ||
// ClipperPassViewController.swift | ||
// BayPass | ||
// | ||
// Created by Zhe Li on 4/15/19. | ||
// Copyright © 2019 Tim Roesner. All rights reserved. | ||
// | ||
|
||
import SnapKit | ||
import UIKit | ||
|
||
class ClipperPassViewController: UIViewController { | ||
let agenciesLbl = UILabel() | ||
let recentlyPurchasedLbl = UILabel() | ||
|
||
let clipperPassCollectionViewCellID = "clipperPassCollectionViewCellID" | ||
let clipperPassCollectionView: UICollectionView = { | ||
let layout = UICollectionViewFlowLayout() | ||
let collection = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout) | ||
collection.backgroundColor = UIColor.white | ||
collection.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 20, right: 0) | ||
collection.isScrollEnabled = true | ||
collection.showsVerticalScrollIndicator = false | ||
return collection | ||
}() | ||
|
||
let recentlyPurchasedClipperPassCollectionViewCellID = "recentlyPurchasedClipperPassCollectionViewCellID" | ||
let recentlyPurchasedClipperPassCollectionView: UICollectionView = { | ||
let layout = UICollectionViewFlowLayout() | ||
let collection = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout) | ||
layout.scrollDirection = .horizontal | ||
collection.backgroundColor = UIColor.white | ||
collection.isScrollEnabled = true | ||
collection.showsHorizontalScrollIndicator = false | ||
return collection | ||
}() | ||
|
||
let agencies = Agency.allCases.filter{$0.rawValue != "0"} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view.backgroundColor = .white | ||
title = "Add Pass" | ||
navigationController?.navigationBar.prefersLargeTitles = false | ||
|
||
clipperPassCollectionView.delegate = self | ||
clipperPassCollectionView.dataSource = self | ||
clipperPassCollectionView.register(ClipperPassCollectionViewCell.self, forCellWithReuseIdentifier: clipperPassCollectionViewCellID) | ||
|
||
recentlyPurchasedClipperPassCollectionView.delegate = self | ||
recentlyPurchasedClipperPassCollectionView.dataSource = self | ||
recentlyPurchasedClipperPassCollectionView.register(ClipperPassCollectionViewCell.self, forCellWithReuseIdentifier: recentlyPurchasedClipperPassCollectionViewCellID) | ||
|
||
setupView() | ||
} | ||
|
||
func setupView() { | ||
view.addSubview(agenciesLbl) | ||
agenciesLbl.text = "Agencies" | ||
agenciesLbl.textColor = UIColor.black | ||
agenciesLbl.font = UIFont.systemFont(ofSize: 24, weight: .bold) | ||
|
||
view.addSubview(clipperPassCollectionView) | ||
clipperPassCollectionView.snp.makeConstraints { (make) -> Void in | ||
make.leading.equalToSuperview().offset(10) | ||
make.trailing.equalToSuperview().inset(10) | ||
make.top.equalTo(agenciesLbl.snp.bottom).offset(10) | ||
make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom) | ||
} | ||
|
||
if UserManager.shared.getValidPasses().count > 0 { | ||
view.addSubview(recentlyPurchasedLbl) | ||
recentlyPurchasedLbl.text = "Recently Purchased" | ||
recentlyPurchasedLbl.textColor = UIColor.black | ||
recentlyPurchasedLbl.font = UIFont.systemFont(ofSize: 26, weight: .bold) | ||
recentlyPurchasedLbl.snp.makeConstraints { (make) -> Void in | ||
make.leading.equalToSuperview().offset(20) | ||
make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(20) | ||
} | ||
|
||
view.addSubview(recentlyPurchasedClipperPassCollectionView) | ||
recentlyPurchasedClipperPassCollectionView.snp.makeConstraints { (make) -> Void in | ||
make.leading.equalToSuperview().offset(0) | ||
make.trailing.equalToSuperview().offset(0) | ||
make.top.equalTo(recentlyPurchasedLbl.snp.bottom).offset(10) | ||
make.height.equalTo(140) | ||
} | ||
|
||
agenciesLbl.snp.makeConstraints { (make) -> Void in | ||
make.leading.equalToSuperview().offset(20) | ||
make.top.equalTo(recentlyPurchasedClipperPassCollectionView.snp.bottom).offset(15) | ||
} | ||
} else { | ||
agenciesLbl.snp.makeConstraints { (make) -> Void in | ||
make.leading.equalToSuperview().offset(20) | ||
make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(15) | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.