diff --git a/OCRoutes/OCRoutes/Custom Elements/FavoriteStopTableViewCell.swift b/OCRoutes/OCRoutes/Custom Elements/FavoriteStopTableViewCell.swift index 6ac1066..fae4ad5 100644 --- a/OCRoutes/OCRoutes/Custom Elements/FavoriteStopTableViewCell.swift +++ b/OCRoutes/OCRoutes/Custom Elements/FavoriteStopTableViewCell.swift @@ -37,6 +37,8 @@ class FavoriteStopTableViewCell : UITableViewCell { label.text = "6783" label.font = UIFont(name: "AvenirNext-Bold", size: 20) label.textColor = .black + label.textAlignment = .center + label.sizeToFit() label.setContentHuggingPriority(.defaultHigh, for: .horizontal) return label }() @@ -59,8 +61,8 @@ class FavoriteStopTableViewCell : UITableViewCell { let busStopNameLabel : UILabel = { let label = UILabel() label.text = "King Edward / Tempelton" - label.font = UIFont(name: "AvenirNext", size: 15) - label.textColor = Style.mainColor + label.font = UIFont(name: "AvenirNext-DemiBold", size: 15) + label.textColor = .black return label }() diff --git a/OCRoutes/OCRoutes/Custom Elements/FavouriteRoutesTableViewCell.swift b/OCRoutes/OCRoutes/Custom Elements/FavouriteRoutesTableViewCell.swift index d9eb2b4..3457f39 100644 --- a/OCRoutes/OCRoutes/Custom Elements/FavouriteRoutesTableViewCell.swift +++ b/OCRoutes/OCRoutes/Custom Elements/FavouriteRoutesTableViewCell.swift @@ -27,7 +27,7 @@ class FavouriteRoutesTableViewCell : UITableViewCell { // 1st column stack : Route number let busRouteNumberLabel : UILabel = { let label = UILabel() - label.text = "1234" + label.text = "SNOW" label.font = UIFont(name: "AvenirNext-Bold", size: 20) label.textColor = .black label.textAlignment = .center diff --git a/OCRoutes/OCRoutes/Custom Elements/FavouriteStopRouteInfoView.swift b/OCRoutes/OCRoutes/Custom Elements/FavouriteStopRouteInfoView.swift index 55edc17..3c6d94e 100644 --- a/OCRoutes/OCRoutes/Custom Elements/FavouriteStopRouteInfoView.swift +++ b/OCRoutes/OCRoutes/Custom Elements/FavouriteStopRouteInfoView.swift @@ -46,8 +46,8 @@ class FavouriteStopRouteInfoView : UIView { let nextBusTimeLabel : UILabel = { let label = UILabel() label.attributedText = NSAttributedString(string: "24m", attributes: [ - NSAttributedStringKey.font: UIFont(name: "AvenirNext-DemiBold", size: 13)!, - NSAttributedStringKey.foregroundColor: Style.darkGrey + NSAttributedStringKey.font: UIFont(name: "AvenirNext-DemiBold", size: 4)!, + NSAttributedStringKey.foregroundColor: UIColor.black ]) label.textAlignment = .right label.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) @@ -68,11 +68,11 @@ class FavouriteStopRouteInfoView : UIView { private func SetupRouteInfo() { if let myRoute = route { routeNumberLabel.attributedText = NSAttributedString(string: String(myRoute.routeNumber), attributes: [ - NSAttributedStringKey.font: UIFont(name: "AvenirNext-Bold", size: 13)!, + NSAttributedStringKey.font: UIFont(name: "AvenirNext-Bold", size: 16)!, NSAttributedStringKey.foregroundColor: Style.mainColor ]) routeNameLabel.attributedText = NSAttributedString(string: myRoute.routeName!, attributes: [ - NSAttributedStringKey.font: UIFont(name: "Avenir Next", size: 13)!, + NSAttributedStringKey.font: UIFont(name: "Avenir Next", size: 16)!, NSAttributedStringKey.foregroundColor: Style.darkGrey ]) diff --git a/OCRoutes/OCRoutes/Views/HomeViewController.swift b/OCRoutes/OCRoutes/Views/HomeViewController.swift index aedab50..e3d3bb2 100644 --- a/OCRoutes/OCRoutes/Views/HomeViewController.swift +++ b/OCRoutes/OCRoutes/Views/HomeViewController.swift @@ -57,7 +57,7 @@ class HomeViewController : UIViewController, PagingViewControllerDataSource, Pag if index == 0 { return PagingIndexItem(index: index, title: "Routes") as! T } else { - return PagingIndexItem(index: index, title: "Stop") as! T + return PagingIndexItem(index: index, title: "Stops") as! T } } diff --git a/OCRoutes/OCRoutes/Views/RoutesViewController.swift b/OCRoutes/OCRoutes/Views/RoutesViewController.swift index b044d87..f3b74c0 100644 --- a/OCRoutes/OCRoutes/Views/RoutesViewController.swift +++ b/OCRoutes/OCRoutes/Views/RoutesViewController.swift @@ -11,6 +11,9 @@ import UIKit class RoutesViewController : UIViewController { + let titleString: String = "All Routes" + var titleLabel: UILabel! + private var allRoutes : [BusRoute]? { didSet { DispatchQueue.main.async { @@ -19,9 +22,6 @@ class RoutesViewController : UIViewController { } } - let titleString: String = "All Routes" - var titleLabel: UILabel! - fileprivate var routesTableView : UITableView! override func viewDidLoad() { @@ -36,20 +36,19 @@ class RoutesViewController : UIViewController { // Setting up tableview SetupFavsTableView() - // Setup placeholder label - titleLabel = UILabel(frame: CGRect.zero) - titleLabel.attributedText = NSAttributedString(string: titleString, attributes: [ - NSAttributedStringKey.font: UIFont(name: "Avenir Next", size: 40)!, - NSAttributedStringKey.foregroundColor: Style.mainColor - ]) - titleLabel.textAlignment = .center - view.addSubview(titleLabel) + allRoutes = NetworkManager.GetAllRoutes() ApplyConstraint() } private func SetupFavsTableView() { routesTableView = UITableView(frame: CGRect.zero) + + routesTableView.delegate = self + routesTableView.dataSource = self + + routesTableView.backgroundColor = UIColor(red:0.96, green:0.96, blue:0.96, alpha:1.00) + view.addSubview(routesTableView) } @@ -59,15 +58,7 @@ class RoutesViewController : UIViewController { private func ApplyConstraint() { let safeArea = view.safeAreaLayoutGuide - - // Title label constraints - titleLabel.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([ - titleLabel.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.8), - titleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor), - titleLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor) - ]) - + // Routes table view constraints routesTableView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ @@ -82,7 +73,7 @@ class RoutesViewController : UIViewController { } // UITableViewDataSource delegation -extension RoutesViewController : UITableViewDataSource { +extension RoutesViewController : UITableViewDataSource, UITableViewDelegate { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if let count = allRoutes?.count { return count @@ -90,7 +81,27 @@ extension RoutesViewController : UITableViewDataSource { return 0 } + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return 70.0 + } + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - return UITableViewCell() + + if let route = allRoutes?[indexPath.row] { + var trackStyle = TrackStyle.Normal + + if(indexPath.row == 0) { + trackStyle = .Leading + } + + if ((indexPath.row + 1) == allRoutes?.count) { + trackStyle = .Ending + } + + return FavouriteRoutesTableViewCell(route: route, style: trackStyle) + } + + return UITableViewCell(style: .default, reuseIdentifier: "brokenCell") + } }