From 7d94e97ef405f05d666bdceed7452f2c2969ceb1 Mon Sep 17 00:00:00 2001 From: TorIsHere Date: Tue, 23 Jun 2015 13:47:00 +0900 Subject: [PATCH 01/20] Add menu detail controller --- adam.xcodeproj/project.pbxproj | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/adam.xcodeproj/project.pbxproj b/adam.xcodeproj/project.pbxproj index bf931e2..5b8aa7d 100644 --- a/adam.xcodeproj/project.pbxproj +++ b/adam.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 213997341B3907580027AB55 /* MenuDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 213997331B3907580027AB55 /* MenuDetailViewController.swift */; }; 2150F5011B0EFEE200AFDF5E /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2150F5001B0EFEE200AFDF5E /* ProfileViewController.swift */; }; 21577E061B2E875000D4218F /* CurrencyConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21577E051B2E875000D4218F /* CurrencyConverter.swift */; }; 21577E081B2E87DB00D4218F /* CurrencyList.plist in Resources */ = {isa = PBXBuildFile; fileRef = 21577E071B2E87DB00D4218F /* CurrencyList.plist */; }; @@ -55,6 +56,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 213997331B3907580027AB55 /* MenuDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuDetailViewController.swift; sourceTree = ""; }; 2150F4FB1B0ED81C00AFDF5E /* Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = ""; }; 2150F5001B0EFEE200AFDF5E /* ProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = ""; }; 21577E051B2E875000D4218F /* CurrencyConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CurrencyConverter.swift; sourceTree = ""; }; @@ -137,6 +139,14 @@ name = Frameworks; sourceTree = ""; }; + 213997321B3907160027AB55 /* Menu Detail */ = { + isa = PBXGroup; + children = ( + 213997331B3907580027AB55 /* MenuDetailViewController.swift */, + ); + name = "Menu Detail"; + sourceTree = ""; + }; 4730F9DECD23A478A1E3060B /* Pods */ = { isa = PBXGroup; children = ( @@ -235,6 +245,7 @@ 96DA5A131AF284A80003E506 /* Menu */ = { isa = PBXGroup; children = ( + 213997321B3907160027AB55 /* Menu Detail */, 96DA5A141AF284BB0003E506 /* Menu.swift */, 96DA5A161AF2850E0003E506 /* MenuCell.swift */, 21577E051B2E875000D4218F /* CurrencyConverter.swift */, @@ -418,6 +429,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 213997341B3907580027AB55 /* MenuDetailViewController.swift in Sources */, 964690861B3308D800DB187D /* TutorialViewController.swift in Sources */, 21AF14891B0601C800108190 /* Restaurant.swift in Sources */, 967867701B2C9A7F0047C7BB /* SearchCell.swift in Sources */, From 03838ea7928e313490da52a0c0ea985687307be2 Mon Sep 17 00:00:00 2001 From: TorIsHere Date: Tue, 23 Jun 2015 13:47:27 +0900 Subject: [PATCH 02/20] Add Menu Detail page --- benri/Base.lproj/Main.storyboard | 255 ++++++++++++++++++++++++--- benri/MenuDetailViewController.swift | 71 ++++++++ 2 files changed, 298 insertions(+), 28 deletions(-) create mode 100644 benri/MenuDetailViewController.swift diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index e0aa771..5b8372b 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -189,6 +189,7 @@ + @@ -258,6 +259,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -796,9 +1007,6 @@ - - - @@ -822,27 +1030,18 @@ - - - - - - @@ -299,173 +303,203 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + - - + + + + + + + - - - - + + + + + + + + + - - - - - + - - - - - - - - + + + + - - - - - + - - - - - - - - + + + + - + + - - - - - + - - - - - - - - + + + + + - + - - + - + - + - - - - + + + + - + - - - - + + + + - + + - + + + + @@ -832,7 +866,7 @@ + - + - - - + + + + + + + + + + + + - - + - - - - - - - - - + + + + + + + - - + + - - - - - - - - - + + + + + + + - - + - - + + - - - - - - - - - + + + + + + + - - - - + + + + + - - - - + + + + + - - + - - - - + + + + + - - - - - - - + + + + + + + + + @@ -463,13 +497,15 @@ - - - - - - - + + + + + + + + + @@ -478,19 +514,21 @@ - - - - - - - + + + + + + + + + - + diff --git a/benri/MenuDetailViewController.swift b/benri/MenuDetailViewController.swift index 8791b52..31c475a 100644 --- a/benri/MenuDetailViewController.swift +++ b/benri/MenuDetailViewController.swift @@ -6,6 +6,7 @@ // Copyright (c) 2015 gobbl. All rights reserved. // +import MapKit import UIKit import Alamofire @@ -18,14 +19,14 @@ class MenuDetailViewController: UIViewController { var request: Alamofire.Request? + @IBOutlet weak var mapView: UIView! @IBOutlet weak var navBar: UINavigationBar! @IBOutlet weak var navItem: UINavigationItem! @IBOutlet weak var imageView: UIImageView! @IBOutlet weak var placementView: UIView! - - @IBOutlet weak var mapView: UIView! @IBOutlet weak var restaurantLabel: UILabel! + @IBAction func backToFirstPage(sender: AnyObject) { self.performSegueWithIdentifier("backFromMenuDetail", sender: self) } @@ -39,7 +40,7 @@ class MenuDetailViewController: UIViewController { self.restaurantLabel.text = restaurant.name let screenWidth = UIScreen.mainScreen().bounds.width - self.placementView.frame = CGRectMake(0, 0, screenWidth, placementView.frame.size.height) + self.imageView.frame = CGRectMake(0, 0, screenWidth, imageView.frame.size.height * screenWidth/imageView.frame.size.width) self.request?.cancel() @@ -59,9 +60,9 @@ class MenuDetailViewController: UIViewController { var camera = GMSCameraPosition.cameraWithLatitude(-33.86, longitude: 151.20, zoom: 6) - var myMap = GMSMapView.mapWithFrame(CGRectZero, camera: camera) - let mapSnapshot = myMap.snapshotViewAfterScreenUpdates(true) - self.view = myMap + var myMap = GMSMapView.mapWithFrame(CGRect(x: 0, y: 0, width: self.mapView.bounds.width, height: self.mapView.bounds.height), camera: camera) + self.mapView.addSubview(myMap) + //let mapSnapshot = myMap.snapshotViewAfterScreenUpdates(true) /*UIGraphicsBeginImageContext(myMap.frame.size) myMap.layer.renderInContext(UIGraphicsGetCurrentContext()) From 586926362622726d43c558fb06f3158a565cedb8 Mon Sep 17 00:00:00 2001 From: Tor is Here Date: Wed, 24 Jun 2015 10:13:50 +0900 Subject: [PATCH 06/20] Address dialog over map --- benri/Base.lproj/Main.storyboard | 92 +++++++++++++++++++++++++--- benri/MenuDetailViewController.swift | 51 +++++++++++++-- 2 files changed, 129 insertions(+), 14 deletions(-) diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index 6f335e4..f389d9a 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -338,8 +338,7 @@ - - + @@ -359,7 +358,7 @@ - + @@ -368,30 +367,79 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -400,11 +448,20 @@ + + + + + - + + + + + @@ -420,9 +477,16 @@ + + + + + + + @@ -439,9 +503,16 @@ + + + + + + + @@ -497,6 +568,7 @@ + @@ -505,7 +577,6 @@ - @@ -514,6 +585,7 @@ + @@ -522,11 +594,11 @@ - + diff --git a/benri/MenuDetailViewController.swift b/benri/MenuDetailViewController.swift index 31c475a..3f134bf 100644 --- a/benri/MenuDetailViewController.swift +++ b/benri/MenuDetailViewController.swift @@ -26,12 +26,17 @@ class MenuDetailViewController: UIViewController { @IBOutlet weak var imageView: UIImageView! @IBOutlet weak var placementView: UIView! @IBOutlet weak var restaurantLabel: UILabel! + @IBOutlet weak var addressTextView: UITextView! + + @IBAction func backToFirstPage(sender: AnyObject) { self.performSegueWithIdentifier("backFromMenuDetail", sender: self) } - + func showMap() { + println("Show map") + } override func viewDidLoad() { super.viewDidLoad() @@ -57,11 +62,49 @@ class MenuDetailViewController: UIViewController { } self.navItem.title = menu.menuName + var camera = GMSCameraPosition.cameraWithLatitude(restaurant.location.coordinate.latitude, + longitude: restaurant.location.coordinate.longitude, zoom: 16) + + var myMap:GMSMapView = GMSMapView.mapWithFrame(CGRect(x: 0, y: 0, width: self.mapView.bounds.width, height: self.mapView.bounds.width * 3 / 4), camera: camera) + myMap.settings.setAllGesturesEnabled(false) + + + var marker = GMSMarker() + marker.position = camera.target + marker.snippet = restaurant.name + marker.appearAnimation = kGMSMarkerAnimationPop + marker.map = myMap + + + self.addressTextView.text = restaurant.address + self.addressTextView.contentInset = UIEdgeInsetsMake(15, 15, + 10, 10) - var camera = GMSCameraPosition.cameraWithLatitude(-33.86, - longitude: 151.20, zoom: 6) - var myMap = GMSMapView.mapWithFrame(CGRect(x: 0, y: 0, width: self.mapView.bounds.width, height: self.mapView.bounds.height), camera: camera) + var singleTap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "showMap") + self.mapView.addGestureRecognizer(singleTap) + + + + //CGRect(x: currentFrame.origin.x - 20, y: currentFrame.origin.y, width: currentFrame.size.width + 40, height: currentFrame.size.height) + //self.addressLabel.text = restaurant.address + /*var addressLabel = UILabel(frame: CGRect(x: 0, y: -600, width: 200, height: 50)) + addressLabel.center = self.mapView.center + + addressLabel.font = UIFont(name: "Helvetica", size: 12) + addressLabel.adjustsFontSizeToFitWidth = true + addressLabel.numberOfLines = 0 + addressLabel.textAlignment = NSTextAlignment.Center + addressLabel.backgroundColor = UIColor.whiteColor() + addressLabel.text = restaurant.address + */ + + //self.view.insertSubview(myMap, aboveSubview: imageView) + //self.mapView.insertSubview(addressLabel, atIndex: 0) self.mapView.addSubview(myMap) + //self.mapView.addSubview(addressLabel) + + //self.mapView.insertSubview(myMap, belowSubview: addressLabel) + //let mapSnapshot = myMap.snapshotViewAfterScreenUpdates(true) /*UIGraphicsBeginImageContext(myMap.frame.size) From 7e34e88e5ea9696b49871ce03df5dfd3a2825d0a Mon Sep 17 00:00:00 2001 From: TorIsHere Date: Wed, 24 Jun 2015 12:43:58 +0900 Subject: [PATCH 07/20] Add placement for order now --- benri/Base.lproj/Main.storyboard | 53 ++++++++++++++++++++++------ benri/MenuDetailViewController.swift | 5 +++ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index f389d9a..1f942ff 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -344,13 +344,14 @@ - + @@ -556,19 +576,22 @@ + + + + - @@ -577,15 +600,19 @@ + + + + + - @@ -594,16 +621,22 @@ + + + + + + diff --git a/benri/MenuDetailViewController.swift b/benri/MenuDetailViewController.swift index 3f134bf..84bfb3f 100644 --- a/benri/MenuDetailViewController.swift +++ b/benri/MenuDetailViewController.swift @@ -27,9 +27,14 @@ class MenuDetailViewController: UIViewController { @IBOutlet weak var placementView: UIView! @IBOutlet weak var restaurantLabel: UILabel! @IBOutlet weak var addressTextView: UITextView! + @IBOutlet weak var priceLabel: UILabel! + @IBOutlet weak var distanceLabel: UILabel! + @IBAction func orderNow(sender: AnyObject) { + println(orderNow) + } @IBAction func backToFirstPage(sender: AnyObject) { self.performSegueWithIdentifier("backFromMenuDetail", sender: self) } From e12095b5e7a23a7b166af320dde8e47be0fae8be Mon Sep 17 00:00:00 2001 From: TorIsHere Date: Wed, 24 Jun 2015 18:55:12 +0900 Subject: [PATCH 08/20] Full map view --- MapViewController.swift | 94 +++++++++++++++++ benri/Base.lproj/Main.storyboard | 149 +++++++++++++++++++++++++++ benri/MenuDetailViewController.swift | 17 ++- 3 files changed, 256 insertions(+), 4 deletions(-) create mode 100644 MapViewController.swift diff --git a/MapViewController.swift b/MapViewController.swift new file mode 100644 index 0000000..1eb9cfa --- /dev/null +++ b/MapViewController.swift @@ -0,0 +1,94 @@ +// +// MapViewController.swift +// adam +// +// Created by ariyasuk-k on 6/24/15. +// Copyright (c) 2015 gobbl. All rights reserved. +// + +import UIKit + +class MapViewController: UIViewController { + + @IBOutlet weak var addressTextView: UITextView! + @IBAction func backToDetail(sender: AnyObject) { + + } + + @IBOutlet weak var mapView: UIView! + var restaurant: Restaurant! + + var gMap:GMSMapView! + var gCamera:GMSCameraPosition! + + var destinationMarker:GMSMarker! + + override func viewWillAppear(animated: Bool) { + super.viewWillAppear(animated) + self.gMap.myLocationEnabled = true + self.gMap.addObserver(self, forKeyPath: "myLocation", options: .New, context: nil) + } + + override func viewWillDisappear(animated: Bool) { + super.viewWillDisappear(animated) + self.gMap.removeObserver(self, forKeyPath: "myLocation") + } + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + if restaurant != nil { + + addressTextView.text = restaurant.address + + let screenWidth = UIScreen.mainScreen().bounds.width + let screenHeight = UIScreen.mainScreen().bounds.height + + self.gCamera = GMSCameraPosition.cameraWithLatitude(restaurant.location.coordinate.latitude, + longitude: restaurant.location.coordinate.longitude, zoom: 17) + + self.gMap = GMSMapView.mapWithFrame(CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight), camera: self.gCamera) + + self.gMap.settings.myLocationButton = true + self.gMap.settings.compassButton = true + + self.destinationMarker = GMSMarker() + self.destinationMarker.position = self.gCamera.target + self.destinationMarker.snippet = restaurant.name + self.destinationMarker.appearAnimation = kGMSMarkerAnimationPop + self.destinationMarker.map = self.gMap + + //self.mapView.insertSubview(myMap, aboveSubview: addressTextView) + self.mapView.addSubview(self.gMap) + + + } + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + + + // MARK: Observer + + override func observeValueForKeyPath(keyPath: String, ofObject object: AnyObject, change: [NSObject : AnyObject], context: UnsafeMutablePointer) { + + if keyPath == "myLocation" && object.isKindOfClass(GMSMapView) { + //self.gMap.animateToCameraPosition(GMSCameraPosition.cameraWithTarget(self.gMap.myLocation.coordinate, zoom: 14)) + + } + } +} diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index 1f942ff..3590ccb 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -639,6 +639,7 @@ + @@ -646,6 +647,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benri/MenuDetailViewController.swift b/benri/MenuDetailViewController.swift index 84bfb3f..dd33cf0 100644 --- a/benri/MenuDetailViewController.swift +++ b/benri/MenuDetailViewController.swift @@ -33,7 +33,7 @@ class MenuDetailViewController: UIViewController { @IBAction func orderNow(sender: AnyObject) { - println(orderNow) + println("orderNow") } @IBAction func backToFirstPage(sender: AnyObject) { self.performSegueWithIdentifier("backFromMenuDetail", sender: self) @@ -41,6 +41,7 @@ class MenuDetailViewController: UIViewController { func showMap() { println("Show map") + self.performSegueWithIdentifier("showMap", sender: self) } override func viewDidLoad() { @@ -82,8 +83,8 @@ class MenuDetailViewController: UIViewController { self.addressTextView.text = restaurant.address - self.addressTextView.contentInset = UIEdgeInsetsMake(15, 15, - 10, 10) + self.addressTextView.contentInset = UIEdgeInsetsMake(5, 5, + 5, 5) var singleTap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "showMap") self.mapView.addGestureRecognizer(singleTap) @@ -136,5 +137,13 @@ class MenuDetailViewController: UIViewController { // Pass the selected object to the new view controller. } */ - + + // MARK: - PrepareForSegue + + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + if segue.identifier == "showMap" { + var vc:MapViewController = segue.destinationViewController as! MapViewController + vc.restaurant = self.restaurant + } + } } From ee0a7ef3d8ce7542ae62d7a15772fb8bd862646b Mon Sep 17 00:00:00 2001 From: TorIsHere Date: Thu, 25 Jun 2015 19:53:56 +0900 Subject: [PATCH 09/20] Add back from map view --- MapViewController.swift | 2 +- adam.xcodeproj/project.pbxproj | 4 ++++ benri/Base.lproj/Main.storyboard | 2 ++ benri/MenuDetailViewController.swift | 6 ++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/MapViewController.swift b/MapViewController.swift index 1eb9cfa..b93d5a0 100644 --- a/MapViewController.swift +++ b/MapViewController.swift @@ -12,7 +12,7 @@ class MapViewController: UIViewController { @IBOutlet weak var addressTextView: UITextView! @IBAction func backToDetail(sender: AnyObject) { - + self.performSegueWithIdentifier("backFromMapView", sender: self) } @IBOutlet weak var mapView: UIView! diff --git a/adam.xcodeproj/project.pbxproj b/adam.xcodeproj/project.pbxproj index 5b8aa7d..f291d38 100644 --- a/adam.xcodeproj/project.pbxproj +++ b/adam.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 2150F5011B0EFEE200AFDF5E /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2150F5001B0EFEE200AFDF5E /* ProfileViewController.swift */; }; 21577E061B2E875000D4218F /* CurrencyConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21577E051B2E875000D4218F /* CurrencyConverter.swift */; }; 21577E081B2E87DB00D4218F /* CurrencyList.plist in Resources */ = {isa = PBXBuildFile; fileRef = 21577E071B2E87DB00D4218F /* CurrencyList.plist */; }; + 21A29D341B3A6166009E0D0C /* MapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21A29D331B3A6166009E0D0C /* MapViewController.swift */; }; 21AF14871B05FA0B00108190 /* RestaurantServerAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21AF14861B05FA0B00108190 /* RestaurantServerAPI.swift */; }; 21AF14891B0601C800108190 /* Restaurant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21AF14881B0601C800108190 /* Restaurant.swift */; }; 21BF4D171B099714001CDBC3 /* RestaurantCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21BF4D161B099714001CDBC3 /* RestaurantCache.swift */; }; @@ -61,6 +62,7 @@ 2150F5001B0EFEE200AFDF5E /* ProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = ""; }; 21577E051B2E875000D4218F /* CurrencyConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CurrencyConverter.swift; sourceTree = ""; }; 21577E071B2E87DB00D4218F /* CurrencyList.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = CurrencyList.plist; sourceTree = ""; }; + 21A29D331B3A6166009E0D0C /* MapViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MapViewController.swift; path = ../MapViewController.swift; sourceTree = ""; }; 21AF14861B05FA0B00108190 /* RestaurantServerAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RestaurantServerAPI.swift; sourceTree = ""; }; 21AF14881B0601C800108190 /* Restaurant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Restaurant.swift; sourceTree = ""; }; 21BF4D161B099714001CDBC3 /* RestaurantCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RestaurantCache.swift; sourceTree = ""; }; @@ -179,6 +181,7 @@ 9656AD9B1AECC62800933A8E /* benri */ = { isa = PBXGroup; children = ( + 21A29D331B3A6166009E0D0C /* MapViewController.swift */, 96E377191B35981100229684 /* Localizable.strings */, 21D741271B21A9A9008A8EB5 /* DiscoverView.xib */, 96DA5A191AF28AAA0003E506 /* SVAPI */, @@ -437,6 +440,7 @@ 96DA5A0F1AF274670003E506 /* Const.swift in Sources */, 21BF4D171B099714001CDBC3 /* RestaurantCache.swift in Sources */, 96DA5A171AF2850E0003E506 /* MenuCell.swift in Sources */, + 21A29D341B3A6166009E0D0C /* MapViewController.swift in Sources */, 96DA5A151AF284BB0003E506 /* Menu.swift in Sources */, 9656AD9F1AECC62800933A8E /* AppDelegate.swift in Sources */, 9646908A1B3392F600DB187D /* PageContentViewController.swift in Sources */, diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index 3590ccb..f9ae6ed 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -789,9 +789,11 @@ + + diff --git a/benri/MenuDetailViewController.swift b/benri/MenuDetailViewController.swift index dd33cf0..7db6932 100644 --- a/benri/MenuDetailViewController.swift +++ b/benri/MenuDetailViewController.swift @@ -39,6 +39,12 @@ class MenuDetailViewController: UIViewController { self.performSegueWithIdentifier("backFromMenuDetail", sender: self) } + @IBAction func returnFromMapView(sender: UIStoryboardSegue) { + if sender.identifier == "backFromMapView" { + println("backFromMapView") + } + } + func showMap() { println("Show map") self.performSegueWithIdentifier("showMap", sender: self) From 18916252e215d174499674c719bed406cbba9a04 Mon Sep 17 00:00:00 2001 From: Tor is Here Date: Fri, 26 Jun 2015 10:14:36 +0900 Subject: [PATCH 10/20] Show distance --- benri/MenuDetailViewController.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/benri/MenuDetailViewController.swift b/benri/MenuDetailViewController.swift index 7db6932..1a3a58c 100644 --- a/benri/MenuDetailViewController.swift +++ b/benri/MenuDetailViewController.swift @@ -16,6 +16,7 @@ class MenuDetailViewController: UIViewController { var restaurant:Restaurant! var imageCache:ImageCache = ImageCache.sharedInstance + var locationService:LocationService = LocationService.sharedInstance var request: Alamofire.Request? @@ -96,6 +97,8 @@ class MenuDetailViewController: UIViewController { self.mapView.addGestureRecognizer(singleTap) + let storeDistance = self.locationService.getDistanceFrom(restaurant.location) + _setDistanceLabel(storeDistance) //CGRect(x: currentFrame.origin.x - 20, y: currentFrame.origin.y, width: currentFrame.size.width + 40, height: currentFrame.size.height) //self.addressLabel.text = restaurant.address @@ -152,4 +155,18 @@ class MenuDetailViewController: UIViewController { vc.restaurant = self.restaurant } } + + func updateDistantLabelVisible() { + if let isLocationEnable:AnyObject = NSUserDefaults.standardUserDefaults().valueForKey("isLocationEnable") { + self.distanceLabel.hidden = !(isLocationEnable as! Bool) + } else { + self.distanceLabel.hidden = false + } + } + + func _setDistanceLabel(distance: Double) { + var formatter : String = String(format: "%.02f km", distance) + self.distanceLabel.text = formatter + self.updateDistantLabelVisible() + } } From 4fa7f8bfc5a41b4959dbb7c7c02cc1040919ed60 Mon Sep 17 00:00:00 2001 From: Tor is Here Date: Fri, 26 Jun 2015 10:14:59 +0900 Subject: [PATCH 11/20] Merge back button and address text view --- benri/Base.lproj/Main.storyboard | 62 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index f9ae6ed..44cca11 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -350,9 +350,6 @@ - - - @@ -507,21 +501,21 @@ - - - + + + + + + - - - @@ -592,6 +586,10 @@ + + + + @@ -600,10 +598,6 @@ - - - - @@ -613,6 +607,10 @@ + + + + @@ -621,10 +619,6 @@ - - - - @@ -656,6 +650,7 @@ + @@ -688,11 +683,14 @@ - - + - - - - - + @@ -425,12 +411,9 @@ - - - - + @@ -445,11 +428,14 @@ + + + @@ -486,6 +472,9 @@ + + + @@ -514,6 +503,9 @@ + + + diff --git a/benri/MenuDetailViewController.swift b/benri/MenuDetailViewController.swift index 1a3a58c..cab4429 100644 --- a/benri/MenuDetailViewController.swift +++ b/benri/MenuDetailViewController.swift @@ -78,7 +78,7 @@ class MenuDetailViewController: UIViewController { var camera = GMSCameraPosition.cameraWithLatitude(restaurant.location.coordinate.latitude, longitude: restaurant.location.coordinate.longitude, zoom: 16) - var myMap:GMSMapView = GMSMapView.mapWithFrame(CGRect(x: 0, y: 0, width: self.mapView.bounds.width, height: self.mapView.bounds.width * 3 / 4), camera: camera) + var myMap:GMSMapView = GMSMapView.mapWithFrame(CGRect(x: 0, y: 0, width: screenWidth, height: screenWidth * 3 / 4), camera: camera) myMap.settings.setAllGesturesEnabled(false) From 189c53c16ecc72ae085340661ff4ca65c9364842 Mon Sep 17 00:00:00 2001 From: TorIsHere Date: Fri, 26 Jun 2015 16:43:49 +0900 Subject: [PATCH 14/20] Add direction in map view (automatically) --- MapViewController.swift | 59 +++++++++++++++++++++++++++----- benri/Base.lproj/Main.storyboard | 2 +- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/MapViewController.swift b/MapViewController.swift index 97c7a20..b2a275a 100644 --- a/MapViewController.swift +++ b/MapViewController.swift @@ -10,7 +10,7 @@ import UIKit import Alamofire import SwiftyJSON -class MapViewController: UIViewController { +class MapViewController: UIViewController, GMSMapViewDelegate { @IBOutlet weak var addressTextView: UITextView! @IBAction func backToDetail(sender: AnyObject) { @@ -23,9 +23,11 @@ class MapViewController: UIViewController { var gMap:GMSMapView! var gCamera:GMSCameraPosition! var destinationMarker:GMSMarker! + var steps:Array! + var polyline:GMSPolyline! var apiKey:String! - + override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) self.gMap.myLocationEnabled = true @@ -63,6 +65,7 @@ class MapViewController: UIViewController { self.gMap.myLocationEnabled = true self.gMap.settings.myLocationButton = true self.gMap.settings.compassButton = true + self.gMap.delegate = self self.destinationMarker = GMSMarker() self.destinationMarker.position = self.gCamera.target @@ -81,7 +84,17 @@ class MapViewController: UIViewController { // Dispose of any resources that can be recreated. } - + // MARK: - Google Maps Delegate + func mapView(mapView: GMSMapView!, didTapMarker marker: GMSMarker!) -> Bool { + print(marker.position.latitude) + print(",") + print(marker.position.longitude) + + return true + } + + + /* // MARK: - Navigation @@ -109,6 +122,7 @@ class MapViewController: UIViewController { } } + func fetchDirectionsFrom(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D, completion: ((String?) -> Void)) -> () { let urlString = "https://maps.googleapis.com/maps/api/directions/json"//?key=\(self.apiKey)&origin=\(from.latitude),\(from.longitude)&destination=\(to.latitude),\(to.longitude)&mode=walking" @@ -127,15 +141,44 @@ class MapViewController: UIViewController { (req, res, json, error) in UIApplication.sharedApplication().networkActivityIndicatorVisible = false if error != nil { - + println("Error") } else { print(req) let myJSON = JSON(json!) - println(myJSON) - let routes = myJSON["routes"] - if routes != nil { + self.steps = myJSON["routes"][0]["legs"][0]["steps"].arrayValue - } + NSOperationQueue.mainQueue().addOperationWithBlock({ () -> Void in + if let encodePath = myJSON["routes"][0]["overview_polyline"]["points"].string { + var path:GMSPath = GMSPath(fromEncodedPath: encodePath) + self.polyline = GMSPolyline(path: path) + self.polyline.strokeWidth = 5 + self.polyline.strokeColor = UIColor.blueColor() + self.polyline.map = self.gMap + } + }) + println(myJSON["routes"][0]["legs"][0]["steps"]) + + //self.steps = myJSON["routes"][0]["legs"][0]["steps"] + + /* [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + + self.directionsButton.alpha = 1.0; + + GMSPath *path = + + [GMSPath pathFromEncodedPath: + + json[@"routes"][0][@"overview_polyline"][@"points"]]; + + self.polyline = [GMSPolyline polylineWithPath:path]; + + self.polyline.strokeWidth = 7; + + self.polyline.strokeColor = [UIColor greenColor]; + + self.polyline.map = self.mapView; + + }];*/ } /*if let routes = myJSON["routes"] as? [AnyObject] { diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index a565f55..68a6c44 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -648,7 +648,7 @@ - + From 80201ea4cd7b8ad0872e1468148ed4c5ee12d3f3 Mon Sep 17 00:00:00 2001 From: TorIsHere Date: Fri, 26 Jun 2015 18:18:30 +0900 Subject: [PATCH 15/20] Show direction when tap on marker --- MapViewController.swift | 78 ++++++----------------------------------- 1 file changed, 11 insertions(+), 67 deletions(-) diff --git a/MapViewController.swift b/MapViewController.swift index b2a275a..19625ef 100644 --- a/MapViewController.swift +++ b/MapViewController.swift @@ -86,9 +86,11 @@ class MapViewController: UIViewController, GMSMapViewDelegate { // MARK: - Google Maps Delegate func mapView(mapView: GMSMapView!, didTapMarker marker: GMSMarker!) -> Bool { - print(marker.position.latitude) - print(",") - print(marker.position.longitude) + if let startLocation = self.gMap.myLocation { + fetchDirectionsFrom(startLocation.coordinate, to: self.destinationMarker.position, completion: { (optionalRoute) -> Void in + + }) + } return true } @@ -111,13 +113,11 @@ class MapViewController: UIViewController, GMSMapViewDelegate { override func observeValueForKeyPath(keyPath: String, ofObject object: AnyObject, change: [NSObject : AnyObject], context: UnsafeMutablePointer) { if keyPath == "myLocation" && object.isKindOfClass(GMSMapView) { - //self.gMap.animateToCameraPosition(GMSCameraPosition.cameraWithTarget(self.gMap.myLocation.coordinate, zoom: 14)) - println(self.gMap.myLocation.coordinate) - println(destinationMarker.position) - fetchDirectionsFrom(self.gMap.myLocation.coordinate, to: destinationMarker.position, completion: { (optionalRoute) -> Void in + /*fetchDirectionsFrom(self.gMap.myLocation.coordinate, to: self.destinationMarker.position, completion: { (optionalRoute) -> Void in - }) + })*/ + } } @@ -125,8 +125,7 @@ class MapViewController: UIViewController, GMSMapViewDelegate { func fetchDirectionsFrom(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D, completion: ((String?) -> Void)) -> () { - let urlString = "https://maps.googleapis.com/maps/api/directions/json"//?key=\(self.apiKey)&origin=\(from.latitude),\(from.longitude)&destination=\(to.latitude),\(to.longitude)&mode=walking" - + let urlString = "https://maps.googleapis.com/maps/api/directions/json" let parameters:[String:AnyObject] = [ "key" : self.apiKey, "origin" : [String(stringInterpolationSegment: from.latitude),String(stringInterpolationSegment: from.longitude)], @@ -135,15 +134,13 @@ class MapViewController: UIViewController, GMSMapViewDelegate { ] UIApplication.sharedApplication().networkActivityIndicatorVisible = true - //AIzaSyDK-l1MAppwX8uz2iTlhOjvfnAtiJ6wV5U - //AIzaSyDK-l1MAppwX8uz2iTlhOjvfnAtiJ6wV5U Alamofire.request(.GET, urlString, parameters: parameters, encoding: .URL).responseJSON{ (req, res, json, error) in UIApplication.sharedApplication().networkActivityIndicatorVisible = false if error != nil { - println("Error") + println(error) } else { - print(req) + let myJSON = JSON(json!) self.steps = myJSON["routes"][0]["legs"][0]["steps"].arrayValue @@ -156,60 +153,7 @@ class MapViewController: UIViewController, GMSMapViewDelegate { self.polyline.map = self.gMap } }) - println(myJSON["routes"][0]["legs"][0]["steps"]) - - //self.steps = myJSON["routes"][0]["legs"][0]["steps"] - - /* [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - - self.directionsButton.alpha = 1.0; - - GMSPath *path = - - [GMSPath pathFromEncodedPath: - - json[@"routes"][0][@"overview_polyline"][@"points"]]; - - self.polyline = [GMSPolyline polylineWithPath:path]; - - self.polyline.strokeWidth = 7; - - self.polyline.strokeColor = [UIColor greenColor]; - - self.polyline.map = self.mapView; - - }];*/ - } - /*if let routes = myJSON["routes"] as? [AnyObject] { - if let route = routes.first as? [String : AnyObject] { - if let polyline = route["overview_polyline"] as AnyObject? as? [String : String] { - if let points = polyline["points"] as AnyObject? as? String { - encodedRoute = points - } - } - } - }*/ } - - /* - session.dataTaskWithURL(NSURL(string: urlString)!) {data, response, error in - UIApplication.sharedApplication().networkActivityIndicatorVisible = false - var encodedRoute: String? - if let json = NSJSONSerialization.JSONObjectWithData(data, options:nil, error:nil) as? [String:AnyObject] { - if let routes = json["routes"] as AnyObject? as? [AnyObject] { - if let route = routes.first as? [String : AnyObject] { - if let polyline = route["overview_polyline"] as AnyObject? as? [String : String] { - if let points = polyline["points"] as AnyObject? as? String { - encodedRoute = points - } - } - } - } - } - dispatch_async(dispatch_get_main_queue()) { - completion(encodedRoute) - } - }.resume()*/ } } From 310e1d252f341dc70d2316c20710424824680fb3 Mon Sep 17 00:00:00 2001 From: TorIsHere Date: Fri, 26 Jun 2015 18:38:04 +0900 Subject: [PATCH 16/20] Clean up code --- MapViewController.swift | 1 - benri/MenuDetailViewController.swift | 30 +--------------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/MapViewController.swift b/MapViewController.swift index 19625ef..d892002 100644 --- a/MapViewController.swift +++ b/MapViewController.swift @@ -73,7 +73,6 @@ class MapViewController: UIViewController, GMSMapViewDelegate { self.destinationMarker.appearAnimation = kGMSMarkerAnimationPop self.destinationMarker.map = self.gMap - //self.mapView.insertSubview(myMap, aboveSubview: addressTextView) self.mapView.addSubview(self.gMap) } diff --git a/benri/MenuDetailViewController.swift b/benri/MenuDetailViewController.swift index cab4429..bbdb5f3 100644 --- a/benri/MenuDetailViewController.swift +++ b/benri/MenuDetailViewController.swift @@ -100,35 +100,7 @@ class MenuDetailViewController: UIViewController { let storeDistance = self.locationService.getDistanceFrom(restaurant.location) _setDistanceLabel(storeDistance) - //CGRect(x: currentFrame.origin.x - 20, y: currentFrame.origin.y, width: currentFrame.size.width + 40, height: currentFrame.size.height) - //self.addressLabel.text = restaurant.address - /*var addressLabel = UILabel(frame: CGRect(x: 0, y: -600, width: 200, height: 50)) - addressLabel.center = self.mapView.center - - addressLabel.font = UIFont(name: "Helvetica", size: 12) - addressLabel.adjustsFontSizeToFitWidth = true - addressLabel.numberOfLines = 0 - addressLabel.textAlignment = NSTextAlignment.Center - addressLabel.backgroundColor = UIColor.whiteColor() - addressLabel.text = restaurant.address - */ - - //self.view.insertSubview(myMap, aboveSubview: imageView) - //self.mapView.insertSubview(addressLabel, atIndex: 0) - self.mapView.addSubview(myMap) - //self.mapView.addSubview(addressLabel) - - //self.mapView.insertSubview(myMap, belowSubview: addressLabel) - - //let mapSnapshot = myMap.snapshotViewAfterScreenUpdates(true) - - /*UIGraphicsBeginImageContext(myMap.frame.size) - myMap.layer.renderInContext(UIGraphicsGetCurrentContext()) - var screenShotImage = UIGraphicsGetImageFromCurrentImageContext() - UIGraphicsEndImageContext() - - self.imageView.image = screenShotImage*/ - + self.mapView.addSubview(myMap) } override func didReceiveMemoryWarning() { From 8c21cf8202a5f089553549ff0879afa2addccdca Mon Sep 17 00:00:00 2001 From: TorIsHere Date: Fri, 26 Jun 2015 19:32:01 +0900 Subject: [PATCH 17/20] [WIP] placement for star rating --- benri/Base.lproj/Main.storyboard | 182 +++++++++++++++--- .../emptyStar.imageset/Contents.json | 23 +++ .../emptyStar.imageset/EmptyStar@1.png | Bin 0 -> 436 bytes .../emptyStar.imageset/EmptyStar@2.png | Bin 0 -> 1167 bytes .../emptyStar.imageset/EmptyStar@3.png | Bin 0 -> 1796 bytes .../fullStar.imageset/Contents.json | 23 +++ .../fullStar.imageset/FullStar@1.png | Bin 0 -> 551 bytes .../fullStar.imageset/FullStar@2.png | Bin 0 -> 1267 bytes .../fullStar.imageset/FullStar@3.png | Bin 0 -> 2006 bytes 9 files changed, 197 insertions(+), 31 deletions(-) create mode 100644 benri/Images.xcassets/emptyStar.imageset/Contents.json create mode 100644 benri/Images.xcassets/emptyStar.imageset/EmptyStar@1.png create mode 100644 benri/Images.xcassets/emptyStar.imageset/EmptyStar@2.png create mode 100644 benri/Images.xcassets/emptyStar.imageset/EmptyStar@3.png create mode 100644 benri/Images.xcassets/fullStar.imageset/Contents.json create mode 100644 benri/Images.xcassets/fullStar.imageset/FullStar@1.png create mode 100644 benri/Images.xcassets/fullStar.imageset/FullStar@2.png create mode 100644 benri/Images.xcassets/fullStar.imageset/FullStar@3.png diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index 68a6c44..d215471 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -279,10 +279,10 @@ - @@ -421,6 +415,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -431,21 +520,28 @@ + - + + - + + + + + - + + @@ -454,29 +550,40 @@ - + + + + + + + + - - - - - - - - + + + + + + + + + + - + + + @@ -485,29 +592,40 @@ - + + + + + + + + - - - - - - - - + + + + + + + + + + - + + + @@ -1644,6 +1762,8 @@ + + diff --git a/benri/Images.xcassets/emptyStar.imageset/Contents.json b/benri/Images.xcassets/emptyStar.imageset/Contents.json new file mode 100644 index 0000000..14a4e15 --- /dev/null +++ b/benri/Images.xcassets/emptyStar.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "EmptyStar@1.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "EmptyStar@2.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "EmptyStar@3.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/benri/Images.xcassets/emptyStar.imageset/EmptyStar@1.png b/benri/Images.xcassets/emptyStar.imageset/EmptyStar@1.png new file mode 100644 index 0000000000000000000000000000000000000000..d54864f5b067a7ec2354349200aac612bd6bfd99 GIT binary patch literal 436 zcmV;l0ZaagP)Px$Zb?KzR5%fxQoBmTP!!C~Lrbe95JXXAVbwxJ5Q}YGMASya|FE;O)!yFHPW%UZ zQL$4|8_BC$NMVzQGm@+~yGb?}81BiOnaRmX6lKEYdEP!TL8hopf-K9lG)>P4)=k>R zAm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R6ljedKO|tB zS_cBOBt$GgQ5pG)8TmPxOs-&8Rdm)t{_&!RSf)@Y`~j(1YV`xP=(P^dJ^=A+hS09} hpk`NL8JLz6@h=L@FYV1=qK*In002ovPDHLkV1m&%Ef)X) literal 0 HcmV?d00001 diff --git a/benri/Images.xcassets/emptyStar.imageset/EmptyStar@3.png b/benri/Images.xcassets/emptyStar.imageset/EmptyStar@3.png new file mode 100644 index 0000000000000000000000000000000000000000..8a43083b60f97d5eb71b40b39beffbcdf6468f6e GIT binary patch literal 1796 zcmV+f2mAPmP)Px*zDYzuRA>d&noCTaRTzeu8&qb>B#?pOVq3ILP181{k*0}844Qb0qAMfOP2)mc zsVf%7#I9Vq)rG{3>B1)78f|M>c)^4=rZH$5kSY-?cMDUw-^S;~f5;5X4ChSe|Dh*2 zeCP6=?|a{Kn{&>Ouf(H}NF*v37Z*#*%F33a(dbPt+y=dHA|JD}vnPE%UmQ6~_M#Vl z{a!dpCX;*c^CZK?Be0qh}xk8S$ z)XtP^HvuI*>6_@<>J*(ETYn4?t;7cn!AP&wX=m8POs(kTaNELkJBX|_gHWR1Kk2s^ z>Km&Sl^h`V5TC)jM$ab1)K2Yf8f~XrG;#p*GqnyNAHk{VsHN~}^jdZ1l$})J?aHDV zf|z=}gWWG$2q@Y`mX?;Zv6L3lK3f~(v*p;>SdHKBkFvWp(7T8Ejj909anjoMD=>bT zSWZ5a&5>c*BDNOL?Z?h7(&NZp{3_ia2n256H&IhlGiG9McDGLBG`?N|Vt2#ym){x7g;wC9Nb zP&dX1pGWovdDAH6>aUI9ISLLT*ViEu-Q5|$rjD+4&}mk!2k@^^H^4ys5)Oy^{Cccm zD8HcM3>8ySNGab*(jg}NXT(RmGB%Xq;o)`&z6~jD4tHAU7qPm!y0abrzb379xE?YtimKp!@%x#X8NCM#LGaa-;%=4Td>@>bB9X`s z>BNLLgPaO9SJ^=?vnUf}^{De0jkoAYcP9fx^z(2D`AIMs?92Ahn-z3*b@eEO5=_xf zWIYCSH_NKK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@3.png new file mode 100644 index 0000000000000000000000000000000000000000..14b40150db56c8eb1acf1abb61f78919bc8df637 GIT binary patch literal 2006 zcmV;{2Pyc8P)Px+kV!;ARA>d&T3cuxRTN!k?lU)Snzl)r+GzUH;sdlIqJmbb`XR08hqWO3Bcg(W zf(T;KDE(0JQ&2w?@qtfNY^flvZB|I>cL{Qah+-d z*#4Uv>)^VN*-P`&kg9Gm*|#NwroGW!x@b{PtZ*!~3ulg37Xtk zc&Lo+rD_(#;OYAjV95khimybqPGzc;VkagdM*6odKw$2m&P^5cZc-VQ)ixF6rc@O> zG3PuqG3)m2D}w4y9B<>W9K9wm-BfJ?-x@vzG6@`g0wY(S>)p@T2IlMwe4n))Sj;hHlw6wdO>u!*k0nMR5#QKuo@^jM*; zsxx(04$6g`9J6knkL~^m__jCf9%jmW$2;#lXgQu>rUn{1@^JO2oL_f4941Fgr=nITDaQJqvb>R2wST#}el zn4!Dngx#;)aF<+TqlM+nZYlCKEq5i4a5}luezy6O<8Z0;u2`<^7XycIEqaivaXF43mlKP%+~8519{d_xqj^MS zH;+=v*$w4*cORU@{!;Z-DN`(BTI>h_k%-xTTbr}+{FVq9=O(IHiWxCQC+6~{Gie$l z;!Is!u@p06icZWpIlcugi-~MbYgjj2egK; zrz;W5Vn)M@PAuswF^!E(QzDkdj0P8pn8^1vJpCDyH`Dl@Ml51l>Vi>cTVQZxl!X9*kzMl~1|E)7SIq?f*4`*4$HhP3DKS%XC3 zTsmJC!}AVNz9SrL)R7Oo%Q*DBCP|Ej(F>>BB|XeA*qM48bCd7cR^8q`jPBmYy2X^K z=bb^>N%$FODZ^@q+5V?VkVmScSsI0aD+m=gW7C@W@<*G}SR~V*=;?l8cGlSx* zIK9R$WFxyM&1g~T3l#ic(YgDGxwLJ_LKC|gQzCz~rO|Lz3(|?p`ElcRRx&zft{x+# zq{ZwsjceD8EieBRdMetlEggOxr_32rx-oR{I?UMlw_Gc~qrUb#V{Qn&z*Vi`0XQJ? zO&?D7=#)Iky(z&duP?LelXCEhDX3E&!hUTDO$yN&M2jngL@vk|(4DP@~By|VT8b~Z_u~i4)Ag@VNcwzxaj9)qg$2h7x87hAT^ZIrf zbGv>Rh%F5d&|d!5>Tz_OVu$HYwfx0tSQ{9#F4V?Q5^)NJ oL%)sn*aa+07*qoM6N<$f>~?eegFUf literal 0 HcmV?d00001 From 8316ccbe63f3d00f24b50eae4b632b7318a38876 Mon Sep 17 00:00:00 2001 From: Tor is Here Date: Sat, 27 Jun 2015 16:23:35 +0900 Subject: [PATCH 18/20] Add rating variable for menu --- benri/Menu.swift | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/benri/Menu.swift b/benri/Menu.swift index 98f2baf..5187043 100644 --- a/benri/Menu.swift +++ b/benri/Menu.swift @@ -89,6 +89,26 @@ class Menu { } } + var _ratingCount:Int = 0 + var ratingCount:Int { + get { + return _ratingCount + } + set(newRatingCount) { + _ratingCount = newRatingCount + } + } + + var _ratingTotal:Int = 1 + var ratingTotal:Int { + get { + return _ratingTotal + } + set(newRatingTotal) { + _ratingTotal = newRatingTotal + } + } + var currency:String = "JPY" var currencySign:String = "¥" var tags:NSMutableArray = [] @@ -151,5 +171,15 @@ class Menu { if let restaurantID:String = itemJSON["restaurant"]["$id"]["$oid"].string { self.restaurantID = restaurantID } + + /**** Rating count ****/ + if let ratingCount:Int = itemJSON["ratingCount"].int { + self.ratingCount = ratingCount + } + + /**** Rating total ****/ + if let ratingTotal:Int = itemJSON["ratingTotal"].int { + self.ratingTotal = ratingTotal + } } } \ No newline at end of file From 4b88178e57a0591c5a568e5c0a53b652c49ea6f4 Mon Sep 17 00:00:00 2001 From: Tor is Here Date: Sat, 27 Jun 2015 16:33:36 +0900 Subject: [PATCH 19/20] Rating star for detail page --- benri/Base.lproj/Main.storyboard | 252 ++++++++++-------- .../halfStar.imageset/Contents.json | 23 ++ .../halfStar.imageset/HalfStar@1.png | Bin 0 -> 477 bytes .../halfStar.imageset/HalfStar@2.png | Bin 0 -> 1113 bytes .../halfStar.imageset/HalfStar@3.png | Bin 0 -> 1643 bytes benri/MenuDetailViewController.swift | 107 +++++++- 6 files changed, 260 insertions(+), 122 deletions(-) create mode 100644 benri/Images.xcassets/halfStar.imageset/Contents.json create mode 100644 benri/Images.xcassets/halfStar.imageset/HalfStar@1.png create mode 100644 benri/Images.xcassets/halfStar.imageset/HalfStar@2.png create mode 100644 benri/Images.xcassets/halfStar.imageset/HalfStar@3.png diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index d215471..d6591b7 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -31,7 +31,7 @@ - +