Skip to content

Commit

Permalink
Minor changes to remove warnings, improve style
Browse files Browse the repository at this point in the history
  • Loading branch information
whoiswillma committed Jan 22, 2019
1 parent 248299c commit 11e1f60
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"assets" : [
{
"idiom" : "watch",
"filename" : "Circular.imageset",
"role" : "circular"
},
{
"idiom" : "watch",
"filename" : "Extra Large.imageset",
"role" : "extra-large"
},
{
"idiom" : "watch",
"filename" : "Graphic Bezel.imageset",
"role" : "graphic-bezel"
},
{
"idiom" : "watch",
"filename" : "Graphic Circular.imageset",
"role" : "graphic-circular"
},
{
"idiom" : "watch",
"filename" : "Graphic Corner.imageset",
"role" : "graphic-corner"
},
{
"idiom" : "watch",
"filename" : "Graphic Large Rectangular.imageset",
"role" : "graphic-large-rectangular"
},
{
"idiom" : "watch",
"filename" : "Modular.imageset",
"role" : "modular"
},
{
"idiom" : "watch",
"filename" : "Utilitarian.imageset",
"role" : "utilitarian"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"images" : [
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
6 changes: 6 additions & 0 deletions Eatery Watch App Extension/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
52 changes: 16 additions & 36 deletions Eatery.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Eatery/Controllers/MealTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class MealTableViewController: UITableViewController {
return 1
}

if menu.count == 1, eatery.eateryType != .Dining, let first = menu.first {
if menu.count == 1, eatery.eateryType != .Dining, let item = menu.first {
// display menu items (of the only "dining station") as a table
return menu.first?.value.count ?? 0
return item.value.count
} else {
// display the menu items
return menu.count
Expand All @@ -118,7 +118,7 @@ class MealTableViewController: UITableViewController {
return emptyMenuCell(in: tableView, forRowAt: indexPath)
}

if menu.count == 1 && eatery.eateryType != .Dining {
if menu.count == 1, eatery.eateryType != .Dining {
return menuItemCell(in: tableView, forRowAt: indexPath)
} else {
return diningStationsCell(in: tableView, forRowAt: indexPath)
Expand Down
39 changes: 21 additions & 18 deletions Eatery/Models/Eatery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,32 @@ public enum Area: String {
case Central = "Central"
}

private func makeFormatter () -> DateFormatter {
let formatter = DateFormatter()
formatter.dateFormat = "YYYY-MM-dd"
return formatter
}

/// Represents a Cornell Dining Facility and information about it
/// such as open times, menus, location, etc.
public struct Eatery: Hashable {

public typealias MenuCategory = String

public typealias Menu = [MenuCategory: [MenuItem]]

/// A string of the form YYYY-MM-dd
public typealias DateString = String

public typealias EventName = String

public static func == (lhs: Eatery, rhs: Eatery) -> Bool {
return lhs.id == rhs.id
}

private static let dateFormatter = makeFormatter()
private static let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "YYYY-MM-dd"
return formatter
}()

public var hashValue: Int {
return id
}


/// Unique Identifier
public let id: Int
Expand Down Expand Up @@ -141,11 +147,11 @@ public struct Eatery: Hashable {

/// A menu of constant dining items. Exists if this eatery's menu
/// never changes. This should be used if it exists.
public var diningItems: [String: [MenuItem]]?
public var diningItems: Menu?

/// A constant hardcoded menu if this Eatery has one.
/// This should be used if it exists yet diningItems does not.
public let hardcodedMenu: [String: [MenuItem]]?
public let hardcodedMenu: Menu?

/// GPS Location
public let location: CLLocation
Expand All @@ -157,12 +163,11 @@ public struct Eatery: Hashable {
/// Maps the date the event occurs to a list of the event name
/// to the event itself e.g.:
/// [ "2015-03-01": ["Lunch": Event]]
public let events: [String: [String: Event]]
public let events: [DateString: [EventName: Event]]

/// ="This is an external eatery, i.e. a completely hardcoded eatery"
public let external: Bool


// Gives a string full of all the menus for this eatery today
// this is used for searching.
private var _todaysEventsString: String? = nil
Expand All @@ -181,7 +186,6 @@ public struct Eatery: Hashable {
}
}


init(id: Int, name: String, nameShort: String, slug: String, eateryType: EateryType, about: String, phone: String, area: Area, address: String, paymentMethods: [PaymentType], diningItems: [String : [MenuItem]]?, events: [String: [String: Event]], hardcodedMenu: [String : [MenuItem]]?, location: CLLocation, external: Bool) {
self.id = id
self.name = name
Expand Down Expand Up @@ -224,7 +228,6 @@ public struct Eatery: Hashable {
return false
}

//
/**
Tells if eatery is open within the calendar date given. This is distinct from `isOpenOnDate` in that it does not check a specific time, just the day, month, and year.

Expand Down Expand Up @@ -310,18 +313,18 @@ public struct Eatery: Hashable {
and the food items available for the category as a string list. Used to easily iterate
over all items in the hardcoded menu. Ex: [("Entrees",["Chicken", "Steak", "Fish"]), ("Fruit", ["Apples"])]
*/
private func getMenuIterable(_ menuList: [String: [MenuItem]]?) -> [(String,[String])] {
guard let menu = menuList else { return [] }
private func getMenuIterable(_ menu: Menu?) -> [(String,[String])] {
guard let menu = menu else { return [] }
return menu.map({ (name, items) -> (String, [String]) in
(name, items.map({ ($0.name) }))
})
}

public func getHardcodeMenuIterable() -> [(String,[String])] {
public func getHardcodeMenuIterable() -> [(String, [String])] {
return getMenuIterable(hardcodedMenu)
}

public func getDiningItemMenuIterable() -> [(String,[String])] {
public func getDiningItemMenuIterable() -> [(String, [String])] {
return getMenuIterable(diningItems)
}

Expand Down
3 changes: 1 addition & 2 deletions Eatery/Network/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ struct NetworkManager {

let timeDateFormatter = DateFormatter()
timeDateFormatter.dateFormat = "YYYY-MM-dd:h:mma"
timeDateFormatter.locale = Locale(identifier: "en_US_POSIX")
timeDateFormatter.locale = Locale(identifier: "en_US_POSIX") // force the date formatter to use 12-hour time
eatery.operatingHours.compactMap { $0 }.forEach { operatingHour in
let dateString = operatingHour.date
let date = dateFormatter.date(from: dateString) ?? Date()

let events = operatingHour.events.compactMap { $0 }
var allMenuItems: [MenuItem] = []
Expand Down
11 changes: 11 additions & 0 deletions Pods-Eatery.debug.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/ARCL" "${PODS_CONFIGURATION_BUILD_DIR}/Apollo" "${PODS_CONFIGURATION_BUILD_DIR}/FLEX" "${PODS_CONFIGURATION_BUILD_DIR}/Hero" "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher" "${PODS_CONFIGURATION_BUILD_DIR}/NVActivityIndicatorView" "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON-iOS" "${PODS_ROOT}/Crashlytics/iOS" "${PODS_ROOT}/Fabric/iOS"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/ARCL/ARCL.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Apollo/Apollo.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/FLEX/FLEX.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Hero/Hero.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/NVActivityIndicatorView/NVActivityIndicatorView.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON-iOS/SwiftyJSON.framework/Headers"
OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"z" -framework "ARCL" -framework "Apollo" -framework "Crashlytics" -framework "FLEX" -framework "Fabric" -framework "Hero" -framework "Kingfisher" -framework "NVActivityIndicatorView" -framework "Security" -framework "SnapKit" -framework "SwiftyJSON" -framework "SystemConfiguration" -framework "UIKit"
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods

0 comments on commit 11e1f60

Please sign in to comment.