Skip to content

Commit

Permalink
Bug fixes and UI touch ups:
Browse files Browse the repository at this point in the history
Disappearing search bar fixed
-Sorted instructors/class names in filter screen
-Made the selected day in the class list screen bold
-Resolved a spacing issue on the home screen
-Detail view back/favorite buttons adjust color based on background color
-Header images in the detail views expand when the scrollview is pulled down
-Added ‘view all’ button to today’s classes header in the home screen
  • Loading branch information
jmf373 committed Oct 26, 2018
1 parent 18a7b02 commit d9e36d3
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 23 deletions.
1 change: 1 addition & 0 deletions Constants.swift
Expand Up @@ -15,6 +15,7 @@ struct Identifiers {
static let gymHoursHeaderView = "gymHoursHeaderView"
static let favoritesHeaderView = "favoritesHeaderView"
static let homeSectionHeaderView = "homeSectionHeaderView"
static let todaysClassesHeaderView = "todaysClassesHeaderView"

// CELLS
static let allGymsCell = "allGymsCell"
Expand Down
4 changes: 4 additions & 0 deletions Fitness.xcodeproj/project.pbxproj
Expand Up @@ -39,6 +39,7 @@
8D95F450208719030095B8AB /* GymHoursHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D95F44F208719030095B8AB /* GymHoursHeaderView.swift */; };
8DBB784F2139849B002BE0E0 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DBB784E2139849B002BE0E0 /* Constants.swift */; };
8DC5F7B72081375D0043C9CB /* FavoritesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DC5F7B62081375D0043C9CB /* FavoritesViewController.swift */; };
8DC6F7A8218381980048C305 /* TodaysClassesHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DC6F7A7218381980048C305 /* TodaysClassesHeaderView.swift */; };
8DD7C7712083AF8E004EB196 /* FavoritesHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD7C7702083AF8E004EB196 /* FavoritesHeaderView.swift */; };
8DD7C7732083E09A004EB196 /* DropdownHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD7C7722083E09A004EB196 /* DropdownHeaderView.swift */; };
8DD7C7752083E0FB004EB196 /* DropdownViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DD7C7742083E0FB004EB196 /* DropdownViewCell.swift */; };
Expand Down Expand Up @@ -110,6 +111,7 @@
8D95F44F208719030095B8AB /* GymHoursHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GymHoursHeaderView.swift; sourceTree = "<group>"; };
8DBB784E2139849B002BE0E0 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
8DC5F7B62081375D0043C9CB /* FavoritesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesViewController.swift; sourceTree = "<group>"; };
8DC6F7A7218381980048C305 /* TodaysClassesHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodaysClassesHeaderView.swift; sourceTree = "<group>"; };
8DD7C7702083AF8E004EB196 /* FavoritesHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesHeaderView.swift; sourceTree = "<group>"; };
8DD7C7722083E09A004EB196 /* DropdownHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropdownHeaderView.swift; sourceTree = "<group>"; };
8DD7C7742083E0FB004EB196 /* DropdownViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropdownViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -316,6 +318,7 @@
8DD7C7702083AF8E004EB196 /* FavoritesHeaderView.swift */,
8D03EE04206C473200EF83C7 /* HomeScreenHeaderView.swift */,
8D03EE06206C475200EF83C7 /* HomeSectionHeaderView.swift */,
8DC6F7A7218381980048C305 /* TodaysClassesHeaderView.swift */,
);
path = Headers;
sourceTree = "<group>";
Expand Down Expand Up @@ -568,6 +571,7 @@
C7EBD5AB2062E66800D76A8B /* ClassListCell.swift in Sources */,
C7EBD5A72062E60A00D76A8B /* ClassListViewController.swift in Sources */,
8D03EE05206C473200EF83C7 /* HomeScreenHeaderView.swift in Sources */,
8DC6F7A8218381980048C305 /* TodaysClassesHeaderView.swift in Sources */,
C71E8A012091651100542FA3 /* GymFilterCell.swift in Sources */,
8D03EE09206C477600EF83C7 /* AllGymsCell.swift in Sources */,
8D95F450208719030095B8AB /* GymHoursHeaderView.swift in Sources */,
Expand Down
31 changes: 27 additions & 4 deletions Fitness/Controllers/ClassDetailViewController.swift
Expand Up @@ -23,6 +23,7 @@ class ClassDetailViewController: UIViewController {
var durationLabel = UILabel()
var location: String!

var classImageContainer: UIView!
var classImageView = UIImageView()
var imageFilterView: UIView!
var semicircleView: UIImageView!
Expand Down Expand Up @@ -228,6 +229,10 @@ class ClassDetailViewController: UIViewController {
}

func setupHeader() {
classImageContainer = UIView()
classImageContainer.backgroundColor = .darkGray
contentView.addSubview(classImageContainer)

classImageView.contentMode = .scaleAspectFill
classImageView.kf.setImage(with: gymClassInstance.imageURL)
contentView.addSubview(classImageView)
Expand Down Expand Up @@ -272,7 +277,7 @@ class ClassDetailViewController: UIViewController {
contentView.addSubview(durationLabel)

backButton = UIButton()
backButton.setImage(#imageLiteral(resourceName: "back-arrow"), for: .normal)
backButton.setImage(UIImage(named: "back-arrow"), for: .normal)
backButton.sizeToFit()
backButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
contentView.addSubview(backButton)
Expand All @@ -297,11 +302,18 @@ class ClassDetailViewController: UIViewController {
let window = UIApplication.shared.keyWindow
let topPadding = window?.safeAreaInsets.top ?? 0.0
let dividerSpacing = 24

classImageContainer.snp.makeConstraints { make in
make.leading.trailing.equalTo(view)
make.top.equalTo(scrollView)
make.height.equalTo(360)
}

classImageView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().inset(-topPadding)
make.height.equalTo(360)
make.leading.trailing.equalTo(classImageContainer)
make.top.equalTo(view).priority(.high)
make.height.greaterThanOrEqualTo(classImageContainer).priority(.high)
make.bottom.equalTo(classImageContainer)
}

imageFilterView.snp.makeConstraints { make in
Expand Down Expand Up @@ -546,6 +558,17 @@ extension ClassDetailViewController: UICollectionViewDataSource, UICollectionVie
extension ClassDetailViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
statusBarUpdater?.refreshStatusBarStyle()

switch UIApplication.shared.statusBarStyle {
case .lightContent:
backButton.setImage(UIImage(named: "back-arrow"), for: .normal)
favoriteButton.setImage(UIImage(named: "white-star"), for: .normal)
favoriteButton.setImage(UIImage(named: "yellow-white-star"), for: .selected)
case .default:
backButton.setImage(UIImage(named: "back-arrow"), for: .normal)
favoriteButton.setImage(UIImage(named: "white-star"), for: .normal)
favoriteButton.setImage(UIImage(named: "yellow-white-star"), for: .selected)
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions Fitness/Controllers/ClassListViewController.swift
Expand Up @@ -116,6 +116,10 @@ class ClassListViewController: UIViewController {
}
}

override func viewWillAppear(_ animated: Bool) {
navigationController!.isNavigationBarHidden = false
}

override func viewDidAppear(_ animated: Bool) {
// Update favorited
for cell in classCollectionView.visibleCells {
Expand Down Expand Up @@ -230,6 +234,8 @@ extension ClassListViewController: UICollectionViewDelegate, UICollectionViewDat
let dayOfMonth = cal.component(.day, from: dateForCell)
cell.dayOfWeekLabel.text = daysOfWeek[dayOfWeek]
cell.dateLabel.text = "\(dayOfMonth)"
cell.dateLabel.font = ._12MontserratRegular
cell.dayOfWeekLabel.font = ._12MontserratRegular

if dateForCell < currDate {
cell.dateLabel.textColor = .fitnessMediumGrey
Expand All @@ -239,6 +245,8 @@ extension ClassListViewController: UICollectionViewDelegate, UICollectionViewDat
if dateForCell == calendarDateSelected {
cell.dateLabelCircle.isHidden = false
cell.dateLabel.textColor = .white
cell.dateLabel.font = ._12MontserratSemiBold
cell.dayOfWeekLabel.font = ._12MontserratSemiBold
}
return cell
}
Expand Down
16 changes: 6 additions & 10 deletions Fitness/Controllers/FilterViewController.swift
Expand Up @@ -159,9 +159,9 @@ class FilterViewController: UIViewController, RangeSeekSliderDelegate {

classTypeDropdownData = DropdownData(dropStatus: .up, titles: [], completed: false)

AppDelegate.networkManager.getClassNames { (classNames) in

AppDelegate.networkManager.getClassNames { classNames in
self.classTypeDropdownData.titles.append(contentsOf: classNames)
self.classTypeDropdownData.titles.sort()

self.classTypeDropdownData.completed = true
self.classTypeDropdown.reloadData()
Expand All @@ -185,16 +185,12 @@ class FilterViewController: UIViewController, RangeSeekSliderDelegate {
instructorDivider = UIView()
instructorDivider.backgroundColor = .fitnessLightGrey
contentView.addSubview(instructorDivider)

instructorDropdownData = DropdownData(dropStatus: .up, titles: [], completed: false)

AppDelegate.networkManager.getInstructors { (instructors) in

for instructor in instructors {
// self.instructorDropdownData.titles.append(instructor.name)
// self.instructorDropdownData.ids.append(instructor.id)
self.instructorDropdownData.titles.append(instructor)
}
AppDelegate.networkManager.getInstructors { instructors in
self.instructorDropdownData.titles.append(contentsOf: instructors)
self.instructorDropdownData.titles.sort()

self.instructorDropdownData.completed = true
self.instructorDropdown.reloadData()
Expand Down
29 changes: 25 additions & 4 deletions Fitness/Controllers/GymDetailViewController.swift
Expand Up @@ -33,6 +33,7 @@ class GymDetailViewController: UIViewController, UICollectionViewDelegate {
var contentView: UIView!

var backButton: UIButton!
var gymImageContainer: UIView!
var gymImageView: UIImageView!
var titleLabel: UILabel!

Expand Down Expand Up @@ -155,6 +156,10 @@ class GymDetailViewController: UIViewController, UICollectionViewDelegate {
}

//HEADER
gymImageContainer = UIView()
gymImageContainer.backgroundColor = .darkGray
contentView.addSubview(gymImageContainer)

gymImageView = UIImageView()
gymImageView.contentMode = UIView.ContentMode.scaleAspectFill
gymImageView.translatesAutoresizingMaskIntoConstraints = false
Expand All @@ -175,7 +180,7 @@ class GymDetailViewController: UIViewController, UICollectionViewDelegate {
}

backButton = UIButton()
backButton.setImage(#imageLiteral(resourceName: "back-arrow"), for: .normal)
backButton.setImage(UIImage(named: "back-arrow"), for: .normal)
backButton.sizeToFit()
backButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
contentView.addSubview(backButton)
Expand Down Expand Up @@ -248,11 +253,19 @@ class GymDetailViewController: UIViewController, UICollectionViewDelegate {
//HEADER
let window = UIApplication.shared.keyWindow
let topPadding = window?.safeAreaInsets.top ?? 0.0
gymImageView.snp.updateConstraints {make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().inset(-topPadding)

gymImageContainer.snp.makeConstraints { make in
make.leading.trailing.equalTo(view)
make.top.equalTo(scrollView)
make.height.equalTo(360)
}

gymImageView.snp.updateConstraints { make in
make.leading.trailing.equalTo(gymImageContainer)
make.top.equalTo(view).priority(.high)
make.height.greaterThanOrEqualTo(gymImageContainer).priority(.high)
make.bottom.equalTo(gymImageContainer)
}

if !gym.isOpen {
closedLabel?.snp.updateConstraints {make in
Expand Down Expand Up @@ -538,8 +551,16 @@ extension GymDetailViewController: UITableViewDelegate {
}
}

// MARK: - ScrollViewDelegate
extension GymDetailViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
statusBarUpdater?.refreshStatusBarStyle()

switch UIApplication.shared.statusBarStyle {
case .lightContent:
backButton.setImage(UIImage(named: "back-arrow"), for: .normal)
case .default:
backButton.setImage(UIImage(named: "back-arrow"), for: .normal)
}
}
}
26 changes: 21 additions & 5 deletions Fitness/Controllers/HomeController.swift
Expand Up @@ -62,6 +62,7 @@ class HomeController: UIViewController {
mainCollectionView.showsVerticalScrollIndicator = false

mainCollectionView.register(HomeSectionHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: HomeSectionHeaderView.identifier)
mainCollectionView.register(TodaysClassesHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: TodaysClassesHeaderView.identifier)
mainCollectionView.register(GymsCell.self, forCellWithReuseIdentifier: GymsCell.identifier)
mainCollectionView.register(TodaysClassesCell.self, forCellWithReuseIdentifier: TodaysClassesCell.identifier)
mainCollectionView.register(CategoryCell.self, forCellWithReuseIdentifier: CategoryCell.identifier)
Expand Down Expand Up @@ -189,10 +190,18 @@ extension HomeController: UICollectionViewDataSource {

switch kind {
case UICollectionView.elementKindSectionHeader:
// swiftlint:disable:next force_cast
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: HomeSectionHeaderView.identifier, for: indexPath) as! HomeSectionHeaderView
headerView.setTitle(title: sections[indexPath.section].rawValue)
return headerView
switch sections[indexPath.section] {
case .todaysClasses:
// swiftlint:disable:next force_cast
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: TodaysClassesHeaderView.identifier, for: indexPath) as! TodaysClassesHeaderView
headerView.delegate = self
return headerView
case .lookingFor, .allGyms:
// swiftlint:disable:next force_cast
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: HomeSectionHeaderView.identifier, for: indexPath) as! HomeSectionHeaderView
headerView.setTitle(title: sections[indexPath.section].rawValue)
return headerView
}
default:
fatalError("Unexpected element kind")
}
Expand Down Expand Up @@ -232,7 +241,7 @@ extension HomeController: UICollectionViewDelegate, UICollectionViewDelegateFlow
case .lookingFor:
return UIEdgeInsets(top: 0.0, left: 16.0, bottom: 32.0, right: 16.0)
case .todaysClasses:
return UIEdgeInsets(top: 0.0, left: 0.0, bottom: 32.0, right: 0.0)
return UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
}
}

Expand Down Expand Up @@ -275,6 +284,13 @@ extension HomeController: UICollectionViewDelegate, UICollectionViewDelegateFlow
}
}

// MARK: - NavigationDelegate
extension HomeController: NavigationDelegate {
func changeTab(index: Int) {
tabBarController?.selectedIndex = index
}
}

extension HomeController {

func getHourString(gym: Gym) -> String {
Expand Down
1 change: 1 addition & 0 deletions Fitness/Extensions/UIFont+Shared.swift
Expand Up @@ -43,6 +43,7 @@ extension UIFont {
static let _20MontserratBold = UIFont(name: "Montserrat-Bold", size: 20)
static let _24MontserratBold = UIFont(name: "Montserrat-Bold", size: 24)

static let _12MontserratSemiBold = UIFont(name: "Montserrat-SemiBold", size: 12)
static let _14MontserratSemiBold = UIFont(name: "Montserrat-SemiBold", size: 14)
static let _16MontserratSemiBold = UIFont(name: "Montserrat-SemiBold", size: 16)

Expand Down
64 changes: 64 additions & 0 deletions Fitness/Views/Headers/TodaysClassesHeaderView.swift
@@ -0,0 +1,64 @@
//
// TodaysClassesHeaderView.swift
// Fitness
//
// Created by Joseph Fulgieri on 10/26/18.
// Copyright © 2018 Uplift. All rights reserved.
//

import UIKit

protocol NavigationDelegate {
func changeTab(index: Int)
}

class TodaysClassesHeaderView: UICollectionReusableView {

// MARK: - INITIALIZATION
static let identifier = Identifiers.todaysClassesHeaderView
var titleLabel: UILabel!
var viewAllButton: UIButton!
var delegate: NavigationDelegate?

override init(frame: CGRect) {
super.init(frame: frame)

backgroundColor = UIColor.clear

titleLabel = UILabel()
titleLabel.font = ._14MontserratBold
titleLabel.textColor = .fitnessDarkGrey
titleLabel.text = "TODAY'S CLASSES"
addSubview(titleLabel)

viewAllButton = UIButton()
viewAllButton.setTitle("view all", for: .normal)
viewAllButton.setTitleColor(.fitnessDarkGrey, for: .normal)
viewAllButton.titleLabel?.font = ._12LatoBlack
viewAllButton.addTarget(self, action: #selector(viewAll), for: .touchUpInside)
addSubview(viewAllButton)

// MARK: - CONSTRAINTS
titleLabel.snp.updateConstraints {make in
make.leading.equalTo(16)
make.top.equalToSuperview()
make.height.equalTo(titleLabel.intrinsicContentSize.height)
}

viewAllButton.snp.updateConstraints { make in
make.trailing.equalToSuperview().offset(-15)
make.bottom.equalTo(titleLabel)
make.height.equalTo(titleLabel)
}
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

@objc func viewAll() {
guard let navigationDelegate = delegate else { return }
navigationDelegate.changeTab(index: 1)
}
}

0 comments on commit d9e36d3

Please sign in to comment.