Skip to content

Commit

Permalink
[Feature] Add Hours This Week (#260)
Browse files Browse the repository at this point in the history
* Implement Hours This Week View

* Finish hours this week

* Fix collegetown menu view not loading content

* Fix PR issues
  • Loading branch information
whoiswillma authored Feb 8, 2020
1 parent 0baeda2 commit ce484ab
Show file tree
Hide file tree
Showing 12 changed files with 1,417 additions and 266 deletions.
28 changes: 16 additions & 12 deletions Eatery.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
5D0BA425221755E1008E320D /* LookAheadMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D0BA424221755E1008E320D /* LookAheadMenuView.swift */; };
5D0CC8E0223A949300526480 /* CampusEateriesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D0CC8DF223A949300526480 /* CampusEateriesViewController.swift */; };
5D0D8E0F223B286D001ADB85 /* EateriesFailedToLoadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D0D8E0E223B286D001ADB85 /* EateriesFailedToLoadView.swift */; };
5D10358323E9E69B002EBE90 /* HoursThisWeekView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D10358223E9E69B002EBE90 /* HoursThisWeekView.swift */; };
5D1E720C2234B0680028D7C7 /* Eatery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D1E720B2234B0680028D7C7 /* Eatery.swift */; };
5D1FAFF723C2D355005A7A47 /* CampusEateriesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D1FAFF623C2D355005A7A47 /* CampusEateriesView.swift */; };
5D1FAFF923C2D385005A7A47 /* CampusEateryRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D1FAFF823C2D385005A7A47 /* CampusEateryRow.swift */; };
Expand Down Expand Up @@ -216,6 +217,7 @@
5D0BA424221755E1008E320D /* LookAheadMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LookAheadMenuView.swift; sourceTree = "<group>"; };
5D0CC8DF223A949300526480 /* CampusEateriesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampusEateriesViewController.swift; sourceTree = "<group>"; };
5D0D8E0E223B286D001ADB85 /* EateriesFailedToLoadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EateriesFailedToLoadView.swift; sourceTree = "<group>"; };
5D10358223E9E69B002EBE90 /* HoursThisWeekView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HoursThisWeekView.swift; sourceTree = "<group>"; };
5D1E720B2234B0680028D7C7 /* Eatery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Eatery.swift; sourceTree = "<group>"; };
5D1FAFF623C2D355005A7A47 /* CampusEateriesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampusEateriesView.swift; sourceTree = "<group>"; };
5D1FAFF823C2D385005A7A47 /* CampusEateryRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampusEateryRow.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -480,6 +482,7 @@
5DB4677F23502E4B005CE574 /* PopularTimesView.swift */,
5D94B90A238B27DB0043BE1A /* PopularTimesAccuracyPrompt.swift */,
5DB4677D234FFC37005CE574 /* HistogramView.swift */,
5D10358223E9E69B002EBE90 /* HoursThisWeekView.swift */,
);
path = Eateries;
sourceTree = "<group>";
Expand Down Expand Up @@ -1272,6 +1275,7 @@
5DDB141722137C7500FCE59C /* LookAheadTableViewCell.swift in Sources */,
5DC7CB38236A3D78005C57DB /* CollegetownMenuViewController.swift in Sources */,
5DE1D433225ECF1B008054F4 /* EateriesSharedViewController.swift in Sources */,
5D10358323E9E69B002EBE90 /* HoursThisWeekView.swift in Sources */,
CE9C1FE1226431630062C398 /* EateriesViewController.swift in Sources */,
872E528B232DBA09006D12D4 /* Analytics.swift in Sources */,
5D34C4DF2356A60600A1132F /* SeparatorView.swift in Sources */,
Expand Down Expand Up @@ -1343,7 +1347,7 @@
);
INFOPLIST_FILE = "Eatery Watch App Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery.watchkitapp.watchkitextension;
Expand Down Expand Up @@ -1410,7 +1414,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Eatery Watch App Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery.watchkitapp.watchkitextension;
Expand Down Expand Up @@ -1478,7 +1482,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Eatery Watch App Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery.watchkitapp.watchkitextension;
Expand Down Expand Up @@ -1546,7 +1550,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "Eatery Watch App Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery.watchkitapp.watchkitextension;
Expand Down Expand Up @@ -1586,7 +1590,7 @@
);
IBSC_MODULE = Eatery_Watch_App_Extension;
INFOPLIST_FILE = "Eatery Watch App/Info.plist";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery.watchkitapp;
Expand Down Expand Up @@ -1654,7 +1658,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IBSC_MODULE = Eatery_Watch_App_Extension;
INFOPLIST_FILE = "Eatery Watch App/Info.plist";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery.watchkitapp;
Expand Down Expand Up @@ -1723,7 +1727,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IBSC_MODULE = Eatery_Watch_App_Extension;
INFOPLIST_FILE = "Eatery Watch App/Info.plist";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery.watchkitapp;
Expand Down Expand Up @@ -1792,7 +1796,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IBSC_MODULE = Eatery_Watch_App_Extension;
INFOPLIST_FILE = "Eatery Watch App/Info.plist";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery.watchkitapp;
Expand Down Expand Up @@ -1877,7 +1881,7 @@
INFOPLIST_FILE = Eatery/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
OTHER_LDFLAGS = "$(inherited)";
OTHER_SWIFT_FLAGS = "$(inherited) -DDEBUG";
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery;
Expand Down Expand Up @@ -1955,7 +1959,7 @@
INFOPLIST_FILE = Eatery/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2032,7 +2036,7 @@
INFOPLIST_FILE = Eatery/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2109,7 +2113,7 @@
INFOPLIST_FILE = Eatery/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.6.1;
MARKETING_VERSION = 2.8;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = org.cuappdev.eatery;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
24 changes: 14 additions & 10 deletions Eatery/Controllers/Eateries/Campus/CampusMenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CampusMenuViewController: EateriesMenuViewController {
override func viewDidLoad() {
super.viewDidLoad()

addMenuInfoView(CampusMenuInfoView())
addMenuInfoView()
addSeparatorView()

if !eatery.swipeDataByHour.isEmpty {
Expand All @@ -43,9 +43,21 @@ class CampusMenuViewController: EateriesMenuViewController {
addMenuPageViewController()
}

private func addMenuInfoView() {
let infoView = CampusMenuInfoView()
infoView.configure(eatery: eatery, userLocation: userLocation, meal: "Lunch")
addToStackView(infoView)

infoView.hero.id = EateriesViewController.AnimationKey.infoContainer.id(eatery: eatery)
let fadeModifiers = createHeroModifiers(.fade)
infoView.hoursHero.modifiers = fadeModifiers
infoView.statusHero.modifiers = fadeModifiers
infoView.locationHero.modifiers = fadeModifiers
infoView.distanceHero.modifiers = fadeModifiers
}

private func addPopularTimesView() {
let popularTimesView = PopularTimesView(eatery: eatery)
popularTimesView.layoutDelegate = self
addToStackView(popularTimesView)

popularTimesView.hero.modifiers = createHeroModifiers(.fade)
Expand Down Expand Up @@ -117,14 +129,6 @@ class CampusMenuViewController: EateriesMenuViewController {

}

extension CampusMenuViewController: PopularTimesViewLayoutDelegate {

func popularTimesContentSizeDidChange(_ popularTimesView: PopularTimesView) {
view.layoutIfNeeded()
}

}

extension CampusMenuViewController: TabbedPageViewControllerDelegate {

func tabbedPageViewController(_ tabbedPageViewController: TabbedPageViewController, titleForViewController viewController: UIViewController) -> String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CollegetownMenuViewController: EateriesMenuViewController {
override func viewDidLoad() {
super.viewDidLoad()

addMenuInfoView(CollegetownMenuInfoView())
addMenuInfoView()
addBlockSeparator()

addActionButton("Get Directions", action: #selector(directionsButtonPressed(_:)))
Expand All @@ -40,6 +40,19 @@ class CollegetownMenuViewController: EateriesMenuViewController {
addMapView()
}

private func addMenuInfoView() {
let infoView = CollegetownMenuInfoView()
infoView.configure(eatery: eatery, userLocation: userLocation)
addToStackView(infoView)

infoView.hero.id = EateriesViewController.AnimationKey.infoContainer.id(eatery: eatery)
let fadeModifiers = createHeroModifiers(.fade)
infoView.hoursHero.modifiers = fadeModifiers
infoView.statusHero.modifiers = fadeModifiers
infoView.locationHero.modifiers = fadeModifiers
infoView.distanceHero.modifiers = fadeModifiers
}

private func addActionButton(_ title: String, action: Selector) {
let container = UIView()

Expand Down
40 changes: 10 additions & 30 deletions Eatery/Controllers/Eateries/EateriesMenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,9 @@ import Hero
import MapKit
import UIKit

protocol MenuInfoView {
protocol DynamicContentSizeView {

var statusHero: HeroExtension<UILabel> { get }

var hoursHero: HeroExtension<UILabel> { get }

var locationHero: HeroExtension<UILabel> { get }

var distanceHero: HeroExtension<UILabel> { get }

func configure(eatery: Eatery, userLocation: CLLocation?)
var contentSizeDidChange: (() -> Void)? { get nonmutating set }

}

Expand All @@ -35,6 +27,8 @@ protocol MenuInfoView {
/// payment views.
class EateriesMenuViewController: ImageParallaxScrollViewController {

typealias ExpandingView = UIView & DynamicContentSizeView

enum HeroModifierGroups {

case fade
Expand Down Expand Up @@ -111,7 +105,7 @@ class EateriesMenuViewController: ImageParallaxScrollViewController {

func addSeparatorView() {
let separatorView = SeparatorView(insets: UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16))
stackView.addArrangedSubview(separatorView)
addToStackView(separatorView)
}

func addBlockSeparator() {
Expand All @@ -120,30 +114,16 @@ class EateriesMenuViewController: ImageParallaxScrollViewController {
separator.snp.makeConstraints { make in
make.height.equalTo(20)
}
stackView.addArrangedSubview(separator)
}

/// Add a menu info view to the stack view
///
/// This method sets up hero animations for the hero objects of the menu
/// info view, and calls `configure` with the provided eatery and location.
func addMenuInfoView<T: UIView & MenuInfoView>(_ infoView: T) {
infoView.configure(eatery: eatery, userLocation: userLocation)

stackView.addArrangedSubview(infoView)

infoView.hero.id = EateriesViewController.AnimationKey.infoContainer.id(eatery: eatery)

let fadeModifiers = createHeroModifiers(.fade)
infoView.hoursHero.modifiers = fadeModifiers
infoView.statusHero.modifiers = fadeModifiers
infoView.locationHero.modifiers = fadeModifiers
infoView.distanceHero.modifiers = fadeModifiers
addToStackView(separator)
}

/// Add a custom view to the stack view
func addToStackView(_ view: UIView) {
stackView.addArrangedSubview(view)

(view as? DynamicContentSizeView)?.contentSizeDidChange = { [weak self] in
self?.view.layoutIfNeeded()
}
}

func createHeroModifiers(_ groups: HeroModifierGroups...) -> [HeroModifier] {
Expand Down
7 changes: 6 additions & 1 deletion Eatery/Controllers/EateryTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class EateryTabBarController: UITabBarController {

lazy var watchAppRedesignBulletinManager: BLTNItemManager = {
let page = BLTNPageItem(title: "Eatery Watch App Redesign")
let manager = BLTNItemManager(rootItem: page)

page.image = UIImage(named: "watchAppPreview")

page.descriptionText = "Eatery for watchOS has been completely redone. Browse menus and hours right from your wrist."
Expand All @@ -33,8 +35,11 @@ class EateryTabBarController: UITabBarController {
}

page.alternativeButtonTitle = "Not now"
page.alternativeHandler = { _ in
manager.dismissBulletin()
}

return BLTNItemManager(rootItem: page)
return manager
}()

override func viewDidLoad() {
Expand Down
5 changes: 4 additions & 1 deletion Eatery/Extensions/UIColor+ColorScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension UIColor {

/// 0x4A90E2
static let eateryBlue = colorFromCode(0x4A90E2)

/// 0xb7d3f3
static let histogramBarBlue = colorFromCode(0xb7d3f3)

Expand Down Expand Up @@ -58,6 +58,9 @@ extension UIColor {
/// 0xE1E1E1
static let veryLightPink = colorFromCode(0xE1E1E1)

/// 0x7d8288
static let steel = colorFromCode(0x7D8288)

}

extension UIImage {
Expand Down
Loading

0 comments on commit ce484ab

Please sign in to comment.