Skip to content

Commit

Permalink
Add Eatery Exceptions View (#300)
Browse files Browse the repository at this point in the history
* Add EateryExceptionView

* Integrate with the backend

* Use convenience color initializer
  • Loading branch information
whoiswillma authored Oct 2, 2020
1 parent 503758c commit 62e25fc
Show file tree
Hide file tree
Showing 20 changed files with 248 additions and 43 deletions.
15 changes: 13 additions & 2 deletions Eatery Watch App Extension/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class CampusEateriesQuery: GraphQLQuery {
about
phone
location
exceptions
campusArea {
__typename
descriptionShort
Expand Down Expand Up @@ -116,6 +117,7 @@ public final class CampusEateriesQuery: GraphQLQuery {
GraphQLField("about", type: .nonNull(.scalar(String.self))),
GraphQLField("phone", type: .nonNull(.scalar(String.self))),
GraphQLField("location", type: .nonNull(.scalar(String.self))),
GraphQLField("exceptions", type: .nonNull(.list(.scalar(String.self)))),
GraphQLField("campusArea", type: .nonNull(.object(CampusArea.selections))),
GraphQLField("paymentMethods", type: .nonNull(.object(PaymentMethod.selections))),
GraphQLField("swipeData", type: .nonNull(.list(.object(SwipeDatum.selections)))),
Expand All @@ -130,8 +132,8 @@ public final class CampusEateriesQuery: GraphQLQuery {
self.resultMap = unsafeResultMap
}

public init(id: Int, name: String, nameShort: String, slug: String, eateryType: String, about: String, phone: String, location: String, campusArea: CampusArea, paymentMethods: PaymentMethod, swipeData: [SwipeDatum?], coordinates: Coordinate, operatingHours: [OperatingHour?]) {
self.init(unsafeResultMap: ["__typename": "CampusEateryType", "id": id, "name": name, "nameShort": nameShort, "slug": slug, "eateryType": eateryType, "about": about, "phone": phone, "location": location, "campusArea": campusArea.resultMap, "paymentMethods": paymentMethods.resultMap, "swipeData": swipeData.map { (value: SwipeDatum?) -> ResultMap? in value.flatMap { (value: SwipeDatum) -> ResultMap in value.resultMap } }, "coordinates": coordinates.resultMap, "operatingHours": operatingHours.map { (value: OperatingHour?) -> ResultMap? in value.flatMap { (value: OperatingHour) -> ResultMap in value.resultMap } }])
public init(id: Int, name: String, nameShort: String, slug: String, eateryType: String, about: String, phone: String, location: String, exceptions: [String?], campusArea: CampusArea, paymentMethods: PaymentMethod, swipeData: [SwipeDatum?], coordinates: Coordinate, operatingHours: [OperatingHour?]) {
self.init(unsafeResultMap: ["__typename": "CampusEateryType", "id": id, "name": name, "nameShort": nameShort, "slug": slug, "eateryType": eateryType, "about": about, "phone": phone, "location": location, "exceptions": exceptions, "campusArea": campusArea.resultMap, "paymentMethods": paymentMethods.resultMap, "swipeData": swipeData.map { (value: SwipeDatum?) -> ResultMap? in value.flatMap { (value: SwipeDatum) -> ResultMap in value.resultMap } }, "coordinates": coordinates.resultMap, "operatingHours": operatingHours.map { (value: OperatingHour?) -> ResultMap? in value.flatMap { (value: OperatingHour) -> ResultMap in value.resultMap } }])
}

public var __typename: String {
Expand Down Expand Up @@ -215,6 +217,15 @@ public final class CampusEateriesQuery: GraphQLQuery {
}
}

public var exceptions: [String?] {
get {
return resultMap["exceptions"]! as! [String?]
}
set {
resultMap.updateValue(newValue, forKey: "exceptions")
}
}

public var campusArea: CampusArea {
get {
return CampusArea(unsafeResultMap: resultMap["campusArea"]! as! ResultMap)
Expand Down
1 change: 1 addition & 0 deletions Eatery Watch App Extension/Queries/campusEateries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ query CampusEateries {
about
phone
location
exceptions
campusArea {
descriptionShort
}
Expand Down
24 changes: 23 additions & 1 deletion Eatery.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
5DBD658823C7A1930070EA1F /* Color+ColorScheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DBD658723C7A1930070EA1F /* Color+ColorScheme.swift */; };
5DC06B7A21FE36020043701A /* PaymentMethodsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DC06B7921FE36020043701A /* PaymentMethodsView.swift */; };
5DC2D01922349CE800D2B0F5 /* collegetownEateries.graphql in Resources */ = {isa = PBXBuildFile; fileRef = 5DC2D01822349CE800D2B0F5 /* collegetownEateries.graphql */; };
5DC37327251ECC020001DC1C /* EateryExceptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DC37326251ECC010001DC1C /* EateryExceptionsView.swift */; };
5DC7CB36236A386D005C57DB /* EateriesMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DC7CB35236A386D005C57DB /* EateriesMenuViewController.swift */; };
5DC7CB38236A3D78005C57DB /* CollegetownMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DC7CB37236A3D78005C57DB /* CollegetownMenuViewController.swift */; };
5DC7CB3A236A3F79005C57DB /* CollegetownMenuInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DC7CB39236A3F79005C57DB /* CollegetownMenuInfoView.swift */; };
Expand Down Expand Up @@ -313,6 +314,7 @@
5DBD658723C7A1930070EA1F /* Color+ColorScheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+ColorScheme.swift"; sourceTree = "<group>"; };
5DC06B7921FE36020043701A /* PaymentMethodsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentMethodsView.swift; sourceTree = "<group>"; };
5DC2D01822349CE800D2B0F5 /* collegetownEateries.graphql */ = {isa = PBXFileReference; lastKnownFileType = text; path = collegetownEateries.graphql; sourceTree = "<group>"; };
5DC37326251ECC010001DC1C /* EateryExceptionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EateryExceptionsView.swift; sourceTree = "<group>"; };
5DC7CB35236A386D005C57DB /* EateriesMenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EateriesMenuViewController.swift; sourceTree = "<group>"; };
5DC7CB37236A3D78005C57DB /* CollegetownMenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollegetownMenuViewController.swift; sourceTree = "<group>"; };
5DC7CB39236A3F79005C57DB /* CollegetownMenuInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollegetownMenuInfoView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -533,6 +535,7 @@
5DB4677D234FFC37005CE574 /* HistogramView.swift */,
5D10358223E9E69B002EBE90 /* HoursThisWeekView.swift */,
5D5B8CC02450F1B2004E05EF /* SearchResultsTableViewCell.swift */,
5DC37326251ECC010001DC1C /* EateryExceptionsView.swift */,
);
path = Eateries;
sourceTree = "<group>";
Expand Down Expand Up @@ -1017,7 +1020,7 @@
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 1130;
LastUpgradeCheck = 1160;
ORGANIZATIONNAME = CUAppDev;
ORGANIZATIONNAME = "Cornell AppDev";
TargetAttributes = {
5D05FF3123C2C14400EF8CC9 = {
CreatedOnToolsVersion = 11.3;
Expand Down Expand Up @@ -1391,6 +1394,7 @@
C82E5F062388E96400C881B2 /* OnboardingLoginViewController.swift in Sources */,
5D0D8E0F223B286D001ADB85 /* EateriesFailedToLoadView.swift in Sources */,
5DF17731231C471C00194D14 /* BRBAccountViewController.swift in Sources */,
5DC37327251ECC020001DC1C /* EateryExceptionsView.swift in Sources */,
C82E5F042388E96400C881B2 /* OnboardingInfoViewController.swift in Sources */,
5DD59DD2244B7DF400F6FC36 /* CampusEateriesSearchViewController.swift in Sources */,
87E712EC23416C1900085DB5 /* GivingDayView.swift in Sources */,
Expand Down Expand Up @@ -1518,6 +1522,8 @@
DEVELOPMENT_ASSET_PATHS = "\"Eatery Watch App Extension/Preview Content\"";
DEVELOPMENT_TEAM = ZGMCXU7X3U;
ENABLE_PREVIEWS = YES;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down Expand Up @@ -1584,6 +1590,8 @@
ENABLE_NS_ASSERTIONS = NO;
ENABLE_PREVIEWS = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -1628,6 +1636,8 @@
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = ZGMCXU7X3U;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down Expand Up @@ -1694,6 +1704,8 @@
DEVELOPMENT_TEAM = ZGMCXU7X3U;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -1788,6 +1800,8 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = ZGMCXU7X3U;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = Eatery/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand Down Expand Up @@ -1823,6 +1837,8 @@
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = ZGMCXU7X3U;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down Expand Up @@ -1863,6 +1879,8 @@
DEVELOPMENT_ASSET_PATHS = "\"Eatery Watch App Extension/Preview Content\"";
DEVELOPMENT_TEAM = ZGMCXU7X3U;
ENABLE_PREVIEWS = YES;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down Expand Up @@ -1953,6 +1971,8 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = ZGMCXU7X3U;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = Eatery/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand Down Expand Up @@ -2033,6 +2053,8 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = ZGMCXU7X3U;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = Eatery/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand Down
10 changes: 10 additions & 0 deletions Eatery/Controllers/Eateries/EateriesMenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ class EateriesMenuViewController: ImageParallaxScrollViewController {
setUpStackView()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

UIView.animate(withDuration: 0.25) { [weak self] in
self?.menuHeaderView.exceptionsView.alpha = 1
}
}

private func setUpImageView() {
imageView.hero.id = EateriesViewController.AnimationKey.backgroundImageView.id(eatery: eatery)

Expand All @@ -91,6 +99,8 @@ class EateriesMenuViewController: ImageParallaxScrollViewController {
menuHeaderView.paymentHero.id = EateriesViewController.AnimationKey.paymentView.id(eatery: eatery)

menuHeaderView.favoriteHero.modifiers = createHeroModifiers(.fade)

menuHeaderView.exceptionsView.alpha = 0
}

private func setUpStackView() {
Expand Down
2 changes: 1 addition & 1 deletion Eatery/Controllers/Eateries/MapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerD
// Create bottom left re-center button
recenterButton.layer.cornerRadius = 6
recenterButton.setImage(UIImage(named: "locationArrowIcon"), for: .normal)
recenterButton.tintColor = UIColor.colorFromCode(0x3d90e2)
recenterButton.tintColor = UIColor(hex: 0x3d90e2)
recenterButton.imageEdgeInsets.left = -6
recenterButton.titleEdgeInsets.left = 8
recenterButton.backgroundColor = .white
Expand Down
38 changes: 19 additions & 19 deletions Eatery/Extensions/UIColor+ColorScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,56 @@ import UIKit

extension UIColor {

class func colorFromCode(_ code: Int) -> UIColor {
let red = CGFloat((code & 0xFF0000) >> 16) / 255
let green = CGFloat((code & 0xFF00) >> 8) / 255
let blue = CGFloat(code & 0xFF) / 255
convenience init(hex: Int) {
let red = CGFloat((hex & 0xFF0000) >> 16) / 255
let green = CGFloat((hex & 0xFF00) >> 8) / 255
let blue = CGFloat(hex & 0xFF) / 255

return UIColor(red: red, green: green, blue: blue, alpha: 1)
self.init(red: red, green: green, blue: blue, alpha: 1)
}

/// 0xF2655D
static let eateryRed = colorFromCode(0xF2655D)
static let eateryRed = UIColor(hex: 0xF2655D)

/// 0x2C7EDF
static let navigationBarBlue = colorFromCode(0x2C7EDF)
static let navigationBarBlue = UIColor(hex: 0x2C7EDF)

/// 0x4A90E2
static let eateryBlue = colorFromCode(0x4A90E2)
static let eateryBlue = UIColor(hex: 0x4A90E2)

/// 0xb7d3f3
static let histogramBarBlue = colorFromCode(0xb7d3f3)
static let histogramBarBlue = UIColor(hex: 0xb7d3f3)

/// 0x63C774
static let eateryGreen = colorFromCode(0x63C774)
static let eateryGreen = UIColor(hex: 0x63C774)

static let eateryOrange = colorFromCode(0xFF990E)
static let eateryOrange = UIColor(hex: 0xFF990E)

static let transparentEateryBlue = UIColor.eateryBlue.withAlphaComponent(0.8)

/// 0x222222
static let primary = colorFromCode(0x222222)
static let primary = UIColor(hex: 0x222222)

/// 0x7d8288
static let secondary = colorFromCode(0x7D8288)
static let secondary = UIColor(hex: 0x7D8288)

/// 0xE1E1E1
static let inactive = colorFromCode(0xE1E1E1)
static let inactive = UIColor(hex: 0xE1E1E1)

/// 0xE1E1E1
static let separator = colorFromCode(0xE1E1E1)
static let separator = UIColor(hex: 0xE1E1E1)

/// 0xF5F5F5
static let wash = colorFromCode(0xF5F5F5)
static let wash = UIColor(hex: 0xF5F5F5)

/// 0xF8E71C
static let favoriteYellow = colorFromCode(0xF8E71C)
static let favoriteYellow = UIColor(hex: 0xF8E71C)

/// 0xE1E1E1
static let veryLightPink = colorFromCode(0xE1E1E1)
static let veryLightPink = UIColor(hex: 0xE1E1E1)

/// 0x7d8288
static let steel = colorFromCode(0x7D8288)
static let steel = UIColor(hex: 0x7D8288)

}

Expand Down
1 change: 1 addition & 0 deletions Eatery/Queries/campusEateries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ query CampusEateries {
about
phone
location
exceptions
campusArea {
descriptionShort
}
Expand Down
64 changes: 64 additions & 0 deletions Eatery/Views/Eateries/EateryExceptionsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// EateryExceptionsView.swift
// Eatery
//
// Created by William Ma on 9/25/20.
// Copyright © 2020 CUAppDev. All rights reserved.
//

import UIKit

class EateryExceptionsView: UIView {

private let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .light))

private let imageView = UIImageView()

private let label = UILabel()

init() {
super.init(frame: .zero)

blurView.alpha = 0.5
blurView.clipsToBounds = true
addSubview(blurView)
blurView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}

imageView.contentMode = .scaleAspectFit
imageView.tintColor = .white
insertSubview(imageView, aboveSubview: blurView)
imageView.snp.makeConstraints { make in
make.leading.equalToSuperview().inset(8)
make.top.bottom.equalToSuperview().inset(4)
make.width.height.equalTo(16)
}

label.font = .systemFont(ofSize: 12)
label.textColor = .white
insertSubview(label, aboveSubview: blurView)
label.snp.makeConstraints { make in
make.leading.equalTo(imageView.snp.trailing).offset(4)
make.top.bottom.equalToSuperview().inset(4)
make.trailing.equalToSuperview().inset(8)
}
}

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

override func layoutSubviews() {
super.layoutSubviews()

blurView.layer.cornerRadius = frame.height / 2
}

func configure(color: UIColor, exception: String, image: UIImage?) {
blurView.backgroundColor = color
imageView.image = image
label.text = exception
}

}
Loading

0 comments on commit 62e25fc

Please sign in to comment.