diff --git a/adam.xcodeproj/project.pbxproj b/adam.xcodeproj/project.pbxproj index 52ffb2e..2534884 100644 --- a/adam.xcodeproj/project.pbxproj +++ b/adam.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 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 */; }; 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 */; }; @@ -51,6 +53,8 @@ /* Begin PBXFileReference section */ 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 = ""; }; + 21577E071B2E87DB00D4218F /* CurrencyList.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = CurrencyList.plist; 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 = ""; }; @@ -216,6 +220,8 @@ children = ( 96DA5A141AF284BB0003E506 /* Menu.swift */, 96DA5A161AF2850E0003E506 /* MenuCell.swift */, + 21577E051B2E875000D4218F /* CurrencyConverter.swift */, + 21577E071B2E87DB00D4218F /* CurrencyList.plist */, 21AF14881B0601C800108190 /* Restaurant.swift */, ); name = Menu; @@ -318,6 +324,7 @@ 9656ADA61AECC62800933A8E /* Main.storyboard in Resources */, 9656ADAB1AECC62800933A8E /* LaunchScreen.xib in Resources */, 9656ADA81AECC62800933A8E /* Images.xcassets in Resources */, + 21577E081B2E87DB00D4218F /* CurrencyList.plist in Resources */, 21D741281B21A9A9008A8EB5 /* DiscoverView.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -399,6 +406,7 @@ 21D7412C1B21AD36008A8EB5 /* DiscoverViewController.swift in Sources */, 96DA5A111AF274670003E506 /* LocationService.swift in Sources */, 9616799B1B2C72BA00A43AD3 /* LocationSearchViewController.swift in Sources */, + 21577E061B2E875000D4218F /* CurrencyConverter.swift in Sources */, 96DA5A121AF274670003E506 /* ImageCache.swift in Sources */, 96C24E901B244527006C5806 /* SearchViewController.swift in Sources */, 2150F5011B0EFEE200AFDF5E /* ProfileViewController.swift in Sources */, diff --git a/benri/Base.lproj/Main.storyboard b/benri/Base.lproj/Main.storyboard index bcb1ae5..4771981 100644 --- a/benri/Base.lproj/Main.storyboard +++ b/benri/Base.lproj/Main.storyboard @@ -46,12 +46,9 @@ - + - - - @@ -195,16 +192,6 @@ - - - - - - - - - - @@ -214,17 +201,16 @@ + - - - - + - + + @@ -237,9 +223,10 @@ - - - + + + + @@ -253,9 +240,10 @@ - - - + + + + @@ -339,7 +327,6 @@ @@ -369,7 +356,7 @@ - + @@ -463,9 +450,7 @@ - - - + @@ -638,6 +623,9 @@ + + + diff --git a/benri/CurrencyConverter.swift b/benri/CurrencyConverter.swift new file mode 100644 index 0000000..06518e4 --- /dev/null +++ b/benri/CurrencyConverter.swift @@ -0,0 +1,49 @@ +// +// CurrencyConverter.swift +// adam +// +// Created by ariyasuk-k on 6/15/15. +// Copyright (c) 2015 gobbl. All rights reserved. +// + +import Foundation + +struct CurrencyConverter { + + static var symbolDict: NSDictionary? { + get { + if let path = NSBundle.mainBundle().pathForResource("CurrencyList", ofType: "plist") { + return NSDictionary(contentsOfFile: path) + } else { + return nil + } + + } + } + + static func codeToSymbol(code:String) -> String { + if let dict = CurrencyConverter.symbolDict { + // Use your dict here + for (key, value) in dict { + let myKey = key as! String + if code == myKey { + return value as! String + } + } + } + return code + } + + static func symbolToCode(symbol:String) -> String { + if let dict = CurrencyConverter.symbolDict { + // Use your dict here + for (key, value) in dict { + let myValue = value as! String + if symbol == myValue { + return key as! String + } + } + } + return symbol + } +} \ No newline at end of file diff --git a/benri/CurrencyList.plist b/benri/CurrencyList.plist new file mode 100644 index 0000000..4a63d1a --- /dev/null +++ b/benri/CurrencyList.plist @@ -0,0 +1,18 @@ + + + + + GBP + £ + EUR + + SGD + S$ + THB + ฿ + USD + $ + JPY + ¥ + + diff --git a/benri/FirstViewController.swift b/benri/FirstViewController.swift index a27c759..0986ff3 100644 --- a/benri/FirstViewController.swift +++ b/benri/FirstViewController.swift @@ -22,6 +22,7 @@ enum ScreenSize { IPHONE_4_7_INCH, IPHONE_5_5_INCH } + func getDeviceSize()->ScreenSize { let screenSize: CGRect = UIScreen.mainScreen().bounds @@ -71,7 +72,7 @@ class FirstViewController: UIViewController, CLLocationManagerDelegate, UIScroll var isPopulating = false var isInitiated = false var lastContentOffset:CGFloat = 0.0 - + override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. @@ -316,17 +317,31 @@ class FirstViewController: UIViewController, CLLocationManagerDelegate, UIScroll } func setVisibleNavigationBar(isVisible:Bool) { - // TODO use variable for magic number 72 , 28 + // TODO use variable for magic number 64 , 20 if isVisible { self.navBar.hidden = false - UIView.animateWithDuration(0.3, animations: { - self.menuTableView.frame = CGRectMake(self.menuTableView.frame.origin.x, 72, self.menuTableView.frame.size.width, self.menuTableView.frame.size.height) - }) + if self.menuTableView.frame.origin.y == 20 { + UIView.animateWithDuration(0.3, animations: { + self.menuTableView.frame = CGRectMake(self.menuTableView.frame.origin.x, 64, self.menuTableView.frame.size.width, self.menuTableView.frame.size.height - 44) + }) + } else { + UIView.animateWithDuration(0.3, animations: { + self.menuTableView.frame = CGRectMake(self.menuTableView.frame.origin.x, 64, self.menuTableView.frame.size.width, self.menuTableView.frame.size.height) + }) + } + } else { self.navBar.hidden = true - UIView.animateWithDuration(0.3, animations: { - self.menuTableView.frame = CGRectMake(self.menuTableView.frame.origin.x, 28, self.menuTableView.frame.size.width, self.menuTableView.frame.size.height) - }) + if self.menuTableView.frame.origin.y == 64 { + UIView.animateWithDuration(0.3, animations: { + self.menuTableView.frame = CGRectMake(self.menuTableView.frame.origin.x, 20, self.menuTableView.frame.size.width, self.menuTableView.frame.size.height + 44) + }) + + } else { + UIView.animateWithDuration(0.3, animations: { + self.menuTableView.frame = CGRectMake(self.menuTableView.frame.origin.x, 20, self.menuTableView.frame.size.width, self.menuTableView.frame.size.height) + }) + } } } @@ -389,20 +404,11 @@ class FirstViewController: UIViewController, CLLocationManagerDelegate, UIScroll } let menu = menuArray.objectAtIndex(indexPath.row) as! Menu - let restuarant = restuarantList.objectForKey(menu.restaurantID) as! Restaurant + let restaurant = restuarantList.objectForKey(menu.restaurantID) as! Restaurant - /* - if let image = self.imgCache.loadImage(menu.imgURL){ - cell.setImageByURL(menu.imgURL) - } else { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)){ - cell.setImageByURL(menu.imgURL) - } - }*/ cell.setImageByURL(menu.imgURL) - let storeDistance = self.locationService.getDistanceFrom(restuarant.location) + cell.setMenu(menu, restaurant: restaurant) - cell.setMenuCell(menu.menuName, retaurantName: restuarant.name, distanceVal: storeDistance, pointVal: 1, price: menu.price, address: restuarant.address) return cell } @@ -417,6 +423,7 @@ class FirstViewController: UIViewController, CLLocationManagerDelegate, UIScroll } return 400.0; } + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { } diff --git a/benri/MenuCell.swift b/benri/MenuCell.swift index 89971c0..8f3000d 100644 --- a/benri/MenuCell.swift +++ b/benri/MenuCell.swift @@ -19,6 +19,9 @@ class MenuCell: UITableViewCell { @IBOutlet weak var imgProgressView: UIProgressView! + var locationService = LocationService.sharedInstance + var imgCache:ImageCache = ImageCache.sharedInstance + var menuName: String = "" var storeName: String = "" var menuImageURL: NSURL = NSURL(string: "http://upload.wikimedia.org/wikipedia/commons/a/ad/Kyaraben_panda.jpg")! @@ -26,7 +29,6 @@ class MenuCell: UITableViewCell { var distant: String = "" var address: String = "" var isImageSet:Bool = false - var imgCache:ImageCache = ImageCache.sharedInstance override func awakeFromNib() { super.awakeFromNib() @@ -76,7 +78,7 @@ class MenuCell: UITableViewCell { } - func _setPriceLabel(price: Float){ + func _setPriceLabel(price: Float, currencyCode:String){ var const:Const = Const.sharedInstance var priceText = "" if price % 1 == 0 { @@ -86,11 +88,8 @@ class MenuCell: UITableViewCell { priceText = String(format: "%.2f", price) } - if let currency = const.getConst("setting", key: "CURRENCY") { - if let currencySign = const.getConst("currencySign", key: currency) { - priceText = " " + currencySign + " " + priceText + " " - } - } + let currencySymbol = CurrencyConverter.codeToSymbol(currencyCode) + priceText = " " + currencySymbol + " " + priceText + " " resizePriceLabelFrame(priceText) } @@ -189,13 +188,14 @@ class MenuCell: UITableViewCell { func _getAddress() -> String?{ return self.address } - - func setMenuCell(menuName: String, retaurantName: String, distanceVal:Double, pointVal: Int, price:Float, address: String) { - self._setMenuNameLabel(menuName) - self._setStoreNameLabel(retaurantName) - self._setPriceLabel(price) - self._setDistantLabel(distanceVal) - self._setAddress(address) + func setMenu(menu:Menu, restaurant:Restaurant) { + let storeDistance = self.locationService.getDistanceFrom(restaurant.location) + + self._setDistantLabel(storeDistance) + self._setMenuNameLabel(menu.menuName) + self._setStoreNameLabel(restaurant.name) + self._setPriceLabel(menu.price, currencyCode: menu.currency) + self._setAddress(restaurant.address) } } \ No newline at end of file diff --git a/benri/SearchViewController.swift b/benri/SearchViewController.swift index fcb191b..089d22d 100644 --- a/benri/SearchViewController.swift +++ b/benri/SearchViewController.swift @@ -106,7 +106,7 @@ class SearchViewController: UIViewController, UIPickerViewDataSource, UIPickerVi private func addBlurPage() { self.view.backgroundColor = UIColor.clearColor() - let blurEffect:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark + let blurEffect:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light ) let bluredEffectView = UIVisualEffectView(effect: blurEffect) let screenFrame = UIScreen.mainScreen().bounds @@ -161,7 +161,7 @@ class SearchViewController: UIViewController, UIPickerViewDataSource, UIPickerVi label.adjustsFontSizeToFitWidth = true label.opaque = false label.textAlignment = NSTextAlignment.Center - label.textColor = UIColor.whiteColor() + label.textColor = UIColor.blackColor() label.clipsToBounds = false return label