From d251c40704a1c3238ad2eddc59a20ca81f692873 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Wed, 29 Nov 2017 12:43:47 +0900 Subject: [PATCH 01/18] =?UTF-8?q?=E5=90=84=E3=83=9A=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=AE=E8=A6=8B=E5=87=BA=E3=81=97=E3=81=AE=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cartfile.resolved | 2 +- NavigationForiOS/Base.lproj/Main.storyboard | 70 ++++++++++----------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index c52741f..df222f7 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,5 @@ github "Alamofire/Alamofire" "4.5.1" -github "SwiftyJSON/SwiftyJSON" "3.1.4" +github "SwiftyJSON/SwiftyJSON" "4.0.0" github "Swinject/Swinject" "2.1.1" github "Swinject/SwinjectStoryboard" "1.1.2" github "xmartlabs/Eureka" "4.0.1" diff --git a/NavigationForiOS/Base.lproj/Main.storyboard b/NavigationForiOS/Base.lproj/Main.storyboard index 7b7dc07..4f5a701 100644 --- a/NavigationForiOS/Base.lproj/Main.storyboard +++ b/NavigationForiOS/Base.lproj/Main.storyboard @@ -1,11 +1,11 @@ - - + + - + @@ -14,7 +14,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -68,7 +68,7 @@ - + - + @@ -373,7 +373,7 @@ - + @@ -382,12 +382,12 @@ - + - - + + @@ -407,15 +407,15 @@ - + - + - - + + @@ -424,7 +424,7 @@ - - - - - - @@ -534,7 +491,6 @@ - - + diff --git a/NavigationForiOS/HomeViewController.swift b/NavigationForiOS/HomeViewController.swift index 021c804..2c772df 100644 --- a/NavigationForiOS/HomeViewController.swift +++ b/NavigationForiOS/HomeViewController.swift @@ -7,103 +7,87 @@ // import UIKit +import Eureka -class HomeViewController: UIViewController, UITextFieldDelegate/*, UITableViewDelegate, UITableViewDataSource*/ { - -// @IBOutlet weak var tableView: UITableView! - @IBOutlet weak var eventIdInputForm: UITextField! - - @IBOutlet weak var errorLabel: UILabel! - +class HomeViewController: FormViewController { var events: [String] = [] - var searchedEvent: EventEntity? = nil - - // DI + var event: String = "" var eventService: EventService? - + override func viewDidLoad() { super.viewDidLoad() - self.errorLabel.text = "" -// eventService?.getEvents{ response in -// self.events = response -// self.tableView.reloadData() -// } - self.eventIdInputForm.delegate = self - } + + // API的に対象のイベントを取得し,Formの選択データにセット + eventService?.getEvents{ responseEvents in + self.events = responseEvents + + if let EventRow = self.form.rowBy(tag: "SourceEvents") { + EventRow.updateCell() + } + } + + form + +++ Section() + <<< PushRow("SourceEvents"){ + $0.title = "イベントを選択" + $0.selectorTitle = "イベント" + $0.options = self.events + $0.onChange{[unowned self] row in + self.event = row.value ?? self.events[0] + } + }.cellUpdate { cell, row in + row.options = self.events + } - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() + // Button + +++ Section() + <<< ButtonRow(){ + $0.title = "イベントの表示" + $0.onCellSelection{ [unowned self] cell, row in + if self.isSuccessLocationInput(event: self.event) { + //次のビュー(EventInfoViewController)用に目的地の値を保持する + let appDelegate = UIApplication.shared.delegate as! AppDelegate + appDelegate.event = self.event + let next = self.storyboard!.instantiateViewController(withIdentifier: "EventInfoStoryboard") + self.present(next,animated: true, completion: nil) + } + } + } } - func textFieldShouldReturn(_ eventIdInputForm: UITextField) -> Bool { - // キーボードを閉じる - eventIdInputForm.resignFirstResponder() - return true + /// 入力された場所が正しい入力かどうかの判定を行う関数 + /// + /// - Parameters: + /// - event: 選択したイベント + /// - Returns: 入力が正しければtrue,正しくなければfalse + func isSuccessLocationInput(event: String) -> Bool { + var success: Bool = true + if event == "" { + self.makeAlert(title: "エラー", message: "イベントを選択してください") + success = false + } + return success } - @IBAction func searchEvent(_ sender: Any) { - if !self.eventIdInputForm.hasText { - self.errorLabel.text = "イベントIDを入力してください" - return - } + /// アラートを作る関数 + /// + /// - Parameters: + /// - title: アラートのタイトル + /// - message: アラートのメッセージ + func makeAlert(title: String, message: String) -> Void { + // アラートを作成 + let alert = UIAlertController( + title: title, + message: message, + preferredStyle: .alert) - // リクエストして,対象のイベントIDが存在するかのチェック - eventService?.searchEvents( eventIdInputFormText: self.eventIdInputForm.text!, responseEvents: { (searchedEvent, responseStatus) in - - if responseStatus == ResponseStatus.DontMatchEventId { - self.errorLabel.text = "内部的なエラー" - } else if responseStatus == ResponseStatus.NotFound { - self.errorLabel.text = "指定されたのイベントは存在しません" - } else if responseStatus == ResponseStatus.Success { - let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate - self.searchedEvent = searchedEvent - if self.searchedEvent != nil { - // おk - self.errorLabel.text = "" - - let alert = UIAlertController(title:"イベント確認", message: (self.searchedEvent?.name)! + " でよろしいですか?", preferredStyle: UIAlertControllerStyle.actionSheet) - - let ok = UIAlertAction(title: "YES", style: UIAlertActionStyle.default, handler: { (action: UIAlertAction!) in - - appDelegate.eventInfo = self.searchedEvent - - let next = self.storyboard!.instantiateViewController(withIdentifier: "EventViewStoryboard") - self.present(next,animated: true, completion: nil) - }) - - let cancel = UIAlertAction(title: "キャンセル", style: UIAlertActionStyle.cancel, handler: { (action: UIAlertAction!) in - self.errorLabel.text = "" - }) - - alert.addAction(ok) - alert.addAction(cancel) - self.present(alert, animated: true, completion: nil) - } - } - }) + // アラートにボタンをつける + alert.addAction(UIAlertAction(title: "OK", style: .default)) + + // アラート表示 + self.present(alert, animated: true, completion: nil) } - -// /// セルの個数を指定するデリゲートメソッド(必須) -// func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { -// return self.events.count -// } -// -// // セクションヘッダーの高さ -// public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { -// return 50 -// } -// -// /// セルに値を設定するデータソースメソッド(必須) -// func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { -// -// // セルを取得する -// let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "LocationCell", for: indexPath as IndexPath) -// -// // セルに表示する値を設定する -// cell.textLabel!.text = self.events[indexPath.row] -// -// return cell -// } + } diff --git a/NavigationForiOS/RouteViewController.swift b/NavigationForiOS/RouteViewController.swift index 26776ff..35151cf 100644 --- a/NavigationForiOS/RouteViewController.swift +++ b/NavigationForiOS/RouteViewController.swift @@ -32,9 +32,9 @@ class RouteViewController: FormViewController { } form - +++ Section("ルートの選択") + +++ Section() <<< PushRow("SourceLocations"){ - $0.title = "現在地の選択" + $0.title = "現在地を選択" $0.selectorTitle = "現在地" $0.options = self.point $0.onChange{[unowned self] row in @@ -44,7 +44,7 @@ class RouteViewController: FormViewController { row.options = self.point } <<< PushRow("DestinationLocations"){ - $0.title = "目的地の選択" + $0.title = "目的地を選択" $0.selectorTitle = "目的地" $0.options = self.point $0.onChange{[unowned self] row in diff --git a/NavigationForiOS/SwinjectStoryboard.swift b/NavigationForiOS/SwinjectStoryboard.swift index 1fa4450..bb31e12 100644 --- a/NavigationForiOS/SwinjectStoryboard.swift +++ b/NavigationForiOS/SwinjectStoryboard.swift @@ -42,9 +42,12 @@ extension SwinjectStoryboard { } // HomeViewControllerのDIの設定 - container.storyboardInitCompleted(HomeViewController.self) { (r, vc) in +// container.storyboardInitCompleted(HomeViewController.self) { (r, vc) in +// vc.eventService = r.resolve(EventService.self)! +// } +// + defaultContainer.storyboardInitCompleted(HomeViewController.self) { (r, vc) in vc.eventService = r.resolve(EventService.self)! } - } } From 7e1e23c333131ddf30fd5a3a00f37e9dbda3b1c4 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Wed, 29 Nov 2017 18:54:48 +0900 Subject: [PATCH 06/18] =?UTF-8?q?=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88?= =?UTF-8?q?=E3=81=9A=E3=82=B3=E3=83=9F=E3=83=83=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/Base.lproj/Main.storyboard | 104 ++---------------- .../EventInfoViewController.swift | 77 ++++++++----- NavigationForiOS/EventService.swift | 2 +- 3 files changed, 60 insertions(+), 123 deletions(-) diff --git a/NavigationForiOS/Base.lproj/Main.storyboard b/NavigationForiOS/Base.lproj/Main.storyboard index 4574457..787d815 100644 --- a/NavigationForiOS/Base.lproj/Main.storyboard +++ b/NavigationForiOS/Base.lproj/Main.storyboard @@ -23,7 +23,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -74,12 +74,12 @@ - + - + @@ -87,79 +87,6 @@ - - - - - - - - - - - - @@ -169,17 +96,10 @@ - - - - - - - - + @@ -270,7 +190,7 @@ - + @@ -333,7 +253,7 @@ - + @@ -353,7 +273,7 @@ - + @@ -469,7 +389,7 @@ - + @@ -487,10 +407,10 @@ - + - + diff --git a/NavigationForiOS/EventInfoViewController.swift b/NavigationForiOS/EventInfoViewController.swift index 1b92449..ad8b745 100644 --- a/NavigationForiOS/EventInfoViewController.swift +++ b/NavigationForiOS/EventInfoViewController.swift @@ -6,37 +6,54 @@ // Copyright © 2017年 UmeSystems. All rights reserved. // -import Foundation import UIKit +import Eureka -class EventInfoViewController: UIViewController { +class EventInfoViewController: FormViewController { - @IBOutlet weak var eventName: UILabel! - - @IBOutlet weak var eventInfo: UILabel! - - @IBOutlet weak var eventDate: UILabel! - - @IBOutlet weak var eventLocation: UILabel! - - @IBOutlet weak var eventEndDate: UILabel! - - var event: EventEntity? = nil - - override func viewDidLoad() { - super.viewDidLoad() - - let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate - self.event = appDelegate.eventInfo! - - self.eventName.text = self.event?.name - self.eventInfo.text = self.event?.info - self.eventDate.text = self.event?.startDate - self.eventEndDate.text = self.event?.endDate - self.eventLocation.text = self.event?.location - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - } +// override func viewDidLoad() { +// super.viewDidLoad() +// +// form +// // Button +// +++ Section() +// <<< ButtonRow(){ +// $0.title = "ナビゲーションルートの選択" +// $0.onCellSelection{ [unowned self] cell, row in +// if self.isSuccessLocationInput() { +// let next = self.storyboard!.instantiateViewController(withIdentifier: "RouteStoryboard") +// self.present(next,animated: true, completion: nil) +// } +// } +// } +// } +// +// @IBOutlet weak var eventName: UILabel! +// +// @IBOutlet weak var eventInfo: UILabel! +// +// @IBOutlet weak var eventDate: UILabel! +// +// @IBOutlet weak var eventLocation: UILabel! +// +// @IBOutlet weak var eventEndDate: UILabel! +// +// var event: EventEntity? = nil +// +// override func viewDidLoad() { +// super.viewDidLoad() +// +// let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate +// self.event = appDelegate.eventInfo! +// +// self.eventName.text = self.event?.name +// self.eventInfo.text = self.event?.info +// self.eventDate.text = self.event?.startDate +// self.eventEndDate.text = self.event?.endDate +// self.eventLocation.text = self.event?.location +// } +// +// override func didReceiveMemoryWarning() { +// super.didReceiveMemoryWarning() +// } } diff --git a/NavigationForiOS/EventService.swift b/NavigationForiOS/EventService.swift index f661f21..dcaf0e2 100644 --- a/NavigationForiOS/EventService.swift +++ b/NavigationForiOS/EventService.swift @@ -21,7 +21,7 @@ class EventService { /// /// - Returns: イベントを含む配列 func getEvents(responseEvents: @escaping ([String]) -> Void){ - Alamofire.request("https://gist.githubusercontent.com/ferretdayo/b5743089f2d5f5468cca58ed9cf96b81/raw/2a6b2ca3937a61ab5b3a01ee30ecddb28103e41b/eventList.json") + Alamofire.request("\(Const().URL_API)/events") .responseJSON { response in var events: [String] = [] switch response.result { From e1e4b1f376c9b301d794d1a432d30c1ea22c81ce Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Wed, 29 Nov 2017 19:24:01 +0900 Subject: [PATCH 07/18] =?UTF-8?q?json=E3=81=AE=E5=BD=A2=E5=BC=8F=E3=81=AB?= =?UTF-8?q?=E5=90=88=E3=82=8F=E3=81=9B=E3=81=A6=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/EventService.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NavigationForiOS/EventService.swift b/NavigationForiOS/EventService.swift index dcaf0e2..e7a20af 100644 --- a/NavigationForiOS/EventService.swift +++ b/NavigationForiOS/EventService.swift @@ -27,8 +27,8 @@ class EventService { switch response.result { case .success(let response): let eventJson = JSON(response) - eventJson["events"].forEach{(_, data) in - events.append(data.string!) + eventJson["data"].forEach{(_, data) in + events.append(data["name"].string!) } break case .failure(let error): From 1eb15e3a679b0de2e10343c191299715bd707168 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Wed, 29 Nov 2017 20:00:23 +0900 Subject: [PATCH 08/18] =?UTF-8?q?=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88?= =?UTF-8?q?=E5=90=8D=E3=81=8B=E3=82=89=E6=83=85=E5=A0=B1=E5=8F=96=E3=82=8B?= =?UTF-8?q?=E6=89=8B=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/AppDelegate.swift | 3 --- NavigationForiOS/EventInfoViewController.swift | 4 ++-- NavigationForiOS/HomeViewController.swift | 11 ++++++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/NavigationForiOS/AppDelegate.swift b/NavigationForiOS/AppDelegate.swift index 509cec0..31a0653 100644 --- a/NavigationForiOS/AppDelegate.swift +++ b/NavigationForiOS/AppDelegate.swift @@ -14,9 +14,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? var eventInfo: EventEntity? - - //EventInfoViewControllerでeventの値を保持するために利用する - var event: String? //RouteViewControllerでdestinationの値を保持するために利用する var destination: String? diff --git a/NavigationForiOS/EventInfoViewController.swift b/NavigationForiOS/EventInfoViewController.swift index ad8b745..49f41fd 100644 --- a/NavigationForiOS/EventInfoViewController.swift +++ b/NavigationForiOS/EventInfoViewController.swift @@ -9,7 +9,7 @@ import UIKit import Eureka -class EventInfoViewController: FormViewController { +class EventInfoViewController: UIViewController { // override func viewDidLoad() { // super.viewDidLoad() @@ -27,7 +27,7 @@ class EventInfoViewController: FormViewController { // } // } // } -// +// // @IBOutlet weak var eventName: UILabel! // // @IBOutlet weak var eventInfo: UILabel! diff --git a/NavigationForiOS/HomeViewController.swift b/NavigationForiOS/HomeViewController.swift index 2c772df..5743cda 100644 --- a/NavigationForiOS/HomeViewController.swift +++ b/NavigationForiOS/HomeViewController.swift @@ -13,6 +13,7 @@ class HomeViewController: FormViewController { var events: [String] = [] var event: String = "" + var searchedEvent: EventEntity? = nil var eventService: EventService? override func viewDidLoad() { @@ -46,9 +47,13 @@ class HomeViewController: FormViewController { $0.title = "イベントの表示" $0.onCellSelection{ [unowned self] cell, row in if self.isSuccessLocationInput(event: self.event) { - //次のビュー(EventInfoViewController)用に目的地の値を保持する - let appDelegate = UIApplication.shared.delegate as! AppDelegate - appDelegate.event = self.event + debugPrint(self.event) + self.eventService?.searchEvents(eventIdInputFormText: self.event, responseEvents: { (searchedEvent, responseStatus) in + let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate + self.searchedEvent = searchedEvent + appDelegate.eventInfo = self.searchedEvent + debugPrint(self.searchedEvent) + }) let next = self.storyboard!.instantiateViewController(withIdentifier: "EventInfoStoryboard") self.present(next,animated: true, completion: nil) } From 0f88a8e0ff99ff4ddca0a6ac404dd6420a821b49 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Wed, 29 Nov 2017 20:18:20 +0900 Subject: [PATCH 09/18] =?UTF-8?q?=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88?= =?UTF-8?q?=E6=83=85=E5=A0=B1=E3=82=92=E5=8F=96=E5=BE=97=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=9F(URL=E3=81=AF=E7=9B=B4=E6=89=93=E3=81=A1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/EventService.swift | 7 ++++--- NavigationForiOS/HomeViewController.swift | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/NavigationForiOS/EventService.swift b/NavigationForiOS/EventService.swift index e7a20af..9910d2e 100644 --- a/NavigationForiOS/EventService.swift +++ b/NavigationForiOS/EventService.swift @@ -44,8 +44,9 @@ class EventService { /// /// - Parameter responseEvents: イベント情報 func searchEvents(eventIdInputFormText: String, responseEvents: @escaping (EventEntity?, ResponseStatus) -> Void){ - Alamofire.request("\(Const().URL_API)/events/\(eventIdInputFormText)") - .responseJSON { response in +// Alamofire.request("\(Const().URL_API)/events/\(eventIdInputFormText)") + Alamofire.request("\(Const().URL_API)/events/0kzrV") + .responseJSON { response in var events: EventEntity? = nil var responseStatus: ResponseStatus = ResponseStatus.Success switch response.result { @@ -57,7 +58,7 @@ class EventService { break; } let data = eventJson["data"] - if data["id"].string != eventIdInputFormText { + if data["name"].string != eventIdInputFormText { responseStatus = ResponseStatus.DontMatchEventId } else { let formatter = DateFormatter() diff --git a/NavigationForiOS/HomeViewController.swift b/NavigationForiOS/HomeViewController.swift index 5743cda..aa281fb 100644 --- a/NavigationForiOS/HomeViewController.swift +++ b/NavigationForiOS/HomeViewController.swift @@ -47,12 +47,10 @@ class HomeViewController: FormViewController { $0.title = "イベントの表示" $0.onCellSelection{ [unowned self] cell, row in if self.isSuccessLocationInput(event: self.event) { - debugPrint(self.event) self.eventService?.searchEvents(eventIdInputFormText: self.event, responseEvents: { (searchedEvent, responseStatus) in let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate self.searchedEvent = searchedEvent appDelegate.eventInfo = self.searchedEvent - debugPrint(self.searchedEvent) }) let next = self.storyboard!.instantiateViewController(withIdentifier: "EventInfoStoryboard") self.present(next,animated: true, completion: nil) From 2f390ba1b0f6dfa55fac5e9fbd7432d07cc85d55 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Thu, 30 Nov 2017 18:03:48 +0900 Subject: [PATCH 10/18] =?UTF-8?q?=E4=B8=80=E6=97=A6=E3=82=B3=E3=83=9F?= =?UTF-8?q?=E3=83=83=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/AppDelegate.swift | 2 - NavigationForiOS/Base.lproj/Main.storyboard | 12 +-- NavigationForiOS/EventEntity.swift | 6 +- .../EventInfoViewController.swift | 100 ++++++++++-------- NavigationForiOS/EventService.swift | 4 +- NavigationForiOS/HomeViewController.swift | 9 +- 6 files changed, 74 insertions(+), 59 deletions(-) diff --git a/NavigationForiOS/AppDelegate.swift b/NavigationForiOS/AppDelegate.swift index 31a0653..5c03e6c 100644 --- a/NavigationForiOS/AppDelegate.swift +++ b/NavigationForiOS/AppDelegate.swift @@ -12,7 +12,6 @@ import UIKit class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - var eventInfo: EventEntity? //RouteViewControllerでdestinationの値を保持するために利用する @@ -46,6 +45,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } - } diff --git a/NavigationForiOS/Base.lproj/Main.storyboard b/NavigationForiOS/Base.lproj/Main.storyboard index 787d815..03bd70a 100644 --- a/NavigationForiOS/Base.lproj/Main.storyboard +++ b/NavigationForiOS/Base.lproj/Main.storyboard @@ -39,7 +39,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -74,11 +74,12 @@ - + + @@ -97,9 +98,8 @@ - - + @@ -273,7 +273,7 @@ - + diff --git a/NavigationForiOS/EventEntity.swift b/NavigationForiOS/EventEntity.swift index e76eeef..dac9203 100644 --- a/NavigationForiOS/EventEntity.swift +++ b/NavigationForiOS/EventEntity.swift @@ -11,15 +11,15 @@ import Foundation class EventEntity { var id: String? var name: String? - var info: String? + var description: String? var startDate: String? var endDate: String? var location: String? - init(id: String, name: String, info: String, startDate: String, endDate: String, location: String) { + init(id: String, name: String, description: String, startDate: String, endDate: String, location: String) { self.id = id self.name = name - self.info = info + self.description = description self.startDate = startDate self.endDate = endDate self.location = location diff --git a/NavigationForiOS/EventInfoViewController.swift b/NavigationForiOS/EventInfoViewController.swift index 49f41fd..a0843c0 100644 --- a/NavigationForiOS/EventInfoViewController.swift +++ b/NavigationForiOS/EventInfoViewController.swift @@ -9,51 +9,63 @@ import UIKit import Eureka -class EventInfoViewController: UIViewController { +class EventInfoViewController: FormViewController { -// override func viewDidLoad() { -// super.viewDidLoad() -// -// form -// // Button -// +++ Section() -// <<< ButtonRow(){ -// $0.title = "ナビゲーションルートの選択" -// $0.onCellSelection{ [unowned self] cell, row in -// if self.isSuccessLocationInput() { -// let next = self.storyboard!.instantiateViewController(withIdentifier: "RouteStoryboard") -// self.present(next,animated: true, completion: nil) -// } -// } -// } -// } -// -// @IBOutlet weak var eventName: UILabel! -// -// @IBOutlet weak var eventInfo: UILabel! -// -// @IBOutlet weak var eventDate: UILabel! -// -// @IBOutlet weak var eventLocation: UILabel! -// -// @IBOutlet weak var eventEndDate: UILabel! -// -// var event: EventEntity? = nil -// -// override func viewDidLoad() { -// super.viewDidLoad() -// + var event: EventEntity? = nil + var eventName: String! + var eventDescription: String! + var eventDate: String! + var eventEndDate: String! + var eventLocation: String! + + override func viewDidLoad() { + super.viewDidLoad() + // let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate // self.event = appDelegate.eventInfo! -// -// self.eventName.text = self.event?.name -// self.eventInfo.text = self.event?.info -// self.eventDate.text = self.event?.startDate -// self.eventEndDate.text = self.event?.endDate -// self.eventLocation.text = self.event?.location -// } -// -// override func didReceiveMemoryWarning() { -// super.didReceiveMemoryWarning() -// } + + self.eventName = self.event?.name + self.eventDescription = self.event?.description + self.eventDate = self.event?.startDate + self.eventEndDate = self.event?.endDate + self.eventLocation = self.event?.location + + form + +++ Section() + <<< LabelRow(){ + $0.title = "イベント名" + $0.value = self.eventName + } + +// +++ Section(self.eventDescription) + + +++ Section() + <<< LabelRow(){ + $0.title = "開始日時" + $0.value = self.eventDate + } + <<< LabelRow(){ + $0.title = "終了日時" + $0.value = self.eventEndDate + } + + +++ Section() + <<< LabelRow(){ + $0.title = "場所" + $0.value = self.eventLocation + } + + // Button + +++ Section() + <<< ButtonRow(){ + $0.title = "ナビゲーションルートの選択" + $0.onCellSelection{ [unowned self] cell, row in + let next = self.storyboard!.instantiateViewController(withIdentifier: "RouteStoryboard") + self.present(next,animated: true, completion: nil) + } + } + + } + } + diff --git a/NavigationForiOS/EventService.swift b/NavigationForiOS/EventService.swift index 9910d2e..198825a 100644 --- a/NavigationForiOS/EventService.swift +++ b/NavigationForiOS/EventService.swift @@ -17,7 +17,7 @@ enum ResponseStatus{ } class EventService { - /// イベントの名前を取得 + /// イベントの名前とidを取得 /// /// - Returns: イベントを含む配列 func getEvents(responseEvents: @escaping ([String]) -> Void){ @@ -64,7 +64,7 @@ class EventService { let formatter = DateFormatter() formatter.timeZone = NSTimeZone(name: "GMT")! as TimeZone! formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" - events = EventEntity(id: data["id"].string!, name: data["name"].string!, info: data["description"].string!, startDate: formatter.string(from: Date(timeIntervalSince1970: TimeInterval(data["startDate"].int!)/1000)), endDate: formatter.string(from: Date(timeIntervalSince1970: TimeInterval(data["endDate"].int!)/1000)), location: data["location"].string!) + events = EventEntity(id: data["id"].string!, name: data["name"].string!, description: data["description"].string!, startDate: formatter.string(from: Date(timeIntervalSince1970: TimeInterval(data["startDate"].int!)/1000)), endDate: formatter.string(from: Date(timeIntervalSince1970: TimeInterval(data["endDate"].int!)/1000)), location: data["location"].string!) responseStatus = ResponseStatus.Success } break diff --git a/NavigationForiOS/HomeViewController.swift b/NavigationForiOS/HomeViewController.swift index aa281fb..ec769e0 100644 --- a/NavigationForiOS/HomeViewController.swift +++ b/NavigationForiOS/HomeViewController.swift @@ -50,13 +50,18 @@ class HomeViewController: FormViewController { self.eventService?.searchEvents(eventIdInputFormText: self.event, responseEvents: { (searchedEvent, responseStatus) in let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate self.searchedEvent = searchedEvent - appDelegate.eventInfo = self.searchedEvent + if self.searchedEvent != nil { + appDelegate.eventInfo = self.searchedEvent! + debugPrint(appDelegate.eventInfo!.id!) + debugPrint(appDelegate.eventInfo!.name!) + debugPrint(appDelegate.eventInfo!.description!) + } }) let next = self.storyboard!.instantiateViewController(withIdentifier: "EventInfoStoryboard") self.present(next,animated: true, completion: nil) } } - } + } } /// 入力された場所が正しい入力かどうかの判定を行う関数 From 3e39382414607d282e292266948ead5fc785494d Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Thu, 30 Nov 2017 18:34:47 +0900 Subject: [PATCH 11/18] =?UTF-8?q?=E3=83=8A=E3=83=93=E3=82=B2=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=90=E3=83=BC=E3=81=8C=E5=87=BA?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/EventInfoViewController.swift | 5 +++-- NavigationForiOS/HomeViewController.swift | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NavigationForiOS/EventInfoViewController.swift b/NavigationForiOS/EventInfoViewController.swift index a0843c0..4391539 100644 --- a/NavigationForiOS/EventInfoViewController.swift +++ b/NavigationForiOS/EventInfoViewController.swift @@ -60,8 +60,9 @@ class EventInfoViewController: FormViewController { <<< ButtonRow(){ $0.title = "ナビゲーションルートの選択" $0.onCellSelection{ [unowned self] cell, row in - let next = self.storyboard!.instantiateViewController(withIdentifier: "RouteStoryboard") - self.present(next,animated: true, completion: nil) + let vc = self.storyboard!.instantiateViewController(withIdentifier: "RouteStoryboard") + let navigationController = UINavigationController(rootViewController: vc) + self.present(navigationController, animated: true, completion: nil) } } diff --git a/NavigationForiOS/HomeViewController.swift b/NavigationForiOS/HomeViewController.swift index ec769e0..3c99894 100644 --- a/NavigationForiOS/HomeViewController.swift +++ b/NavigationForiOS/HomeViewController.swift @@ -57,8 +57,9 @@ class HomeViewController: FormViewController { debugPrint(appDelegate.eventInfo!.description!) } }) - let next = self.storyboard!.instantiateViewController(withIdentifier: "EventInfoStoryboard") - self.present(next,animated: true, completion: nil) + let vc = self.storyboard!.instantiateViewController(withIdentifier: "EventInfoStoryboard") + let navigationController = UINavigationController(rootViewController: vc) + self.present(navigationController, animated: true, completion: nil) } } } From f98bd07f5da8d40097c1dacd89301819725e7704 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Thu, 30 Nov 2017 19:14:59 +0900 Subject: [PATCH 12/18] =?UTF-8?q?UI=E3=81=AE=E5=A4=89=E6=9B=B4=E3=81=8C?= =?UTF-8?q?=E4=B8=80=E9=80=9A=E3=82=8A=E7=B5=82=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/EventInfoViewController.swift | 4 ++-- NavigationForiOS/HomeViewController.swift | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/NavigationForiOS/EventInfoViewController.swift b/NavigationForiOS/EventInfoViewController.swift index 4391539..53de612 100644 --- a/NavigationForiOS/EventInfoViewController.swift +++ b/NavigationForiOS/EventInfoViewController.swift @@ -21,8 +21,8 @@ class EventInfoViewController: FormViewController { override func viewDidLoad() { super.viewDidLoad() -// let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate -// self.event = appDelegate.eventInfo! + let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate + self.event = appDelegate.eventInfo! self.eventName = self.event?.name self.eventDescription = self.event?.description diff --git a/NavigationForiOS/HomeViewController.swift b/NavigationForiOS/HomeViewController.swift index 3c99894..bcf8e68 100644 --- a/NavigationForiOS/HomeViewController.swift +++ b/NavigationForiOS/HomeViewController.swift @@ -13,7 +13,6 @@ class HomeViewController: FormViewController { var events: [String] = [] var event: String = "" - var searchedEvent: EventEntity? = nil var eventService: EventService? override func viewDidLoad() { @@ -49,17 +48,16 @@ class HomeViewController: FormViewController { if self.isSuccessLocationInput(event: self.event) { self.eventService?.searchEvents(eventIdInputFormText: self.event, responseEvents: { (searchedEvent, responseStatus) in let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate - self.searchedEvent = searchedEvent - if self.searchedEvent != nil { - appDelegate.eventInfo = self.searchedEvent! - debugPrint(appDelegate.eventInfo!.id!) - debugPrint(appDelegate.eventInfo!.name!) - debugPrint(appDelegate.eventInfo!.description!) + if searchedEvent != nil { + appDelegate.eventInfo = searchedEvent +// debugPrint(appDelegate.eventInfo!.id!) +// debugPrint(appDelegate.eventInfo!.name!) +// debugPrint(appDelegate.eventInfo!) + let vc = self.storyboard!.instantiateViewController(withIdentifier: "EventInfoStoryboard") + let navigationController = UINavigationController(rootViewController: vc) + self.present(navigationController, animated: true, completion: nil) } }) - let vc = self.storyboard!.instantiateViewController(withIdentifier: "EventInfoStoryboard") - let navigationController = UINavigationController(rootViewController: vc) - self.present(navigationController, animated: true, completion: nil) } } } From a8d9801a844d4c89873de883d94800012c5fcc08 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Thu, 30 Nov 2017 19:22:03 +0900 Subject: [PATCH 13/18] =?UTF-8?q?=E4=B8=80=E6=97=A6=E3=82=B3=E3=83=9F?= =?UTF-8?q?=E3=83=83=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/EventInfoViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NavigationForiOS/EventInfoViewController.swift b/NavigationForiOS/EventInfoViewController.swift index 53de612..0f9b097 100644 --- a/NavigationForiOS/EventInfoViewController.swift +++ b/NavigationForiOS/EventInfoViewController.swift @@ -37,7 +37,7 @@ class EventInfoViewController: FormViewController { $0.value = self.eventName } -// +++ Section(self.eventDescription) + +++ Section(self.eventDescription) +++ Section() <<< LabelRow(){ From 39301b6ee9792630c6dfa265de856a03b24d3ee7 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Sat, 2 Dec 2017 05:34:36 +0900 Subject: [PATCH 14/18] =?UTF-8?q?=E3=83=8A=E3=83=93=E3=82=B2=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E7=94=BB=E9=9D=A2=E3=81=AEUI?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/Base.lproj/Main.storyboard | 93 ++++++++++----------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/NavigationForiOS/Base.lproj/Main.storyboard b/NavigationForiOS/Base.lproj/Main.storyboard index 03bd70a..b4c2583 100644 --- a/NavigationForiOS/Base.lproj/Main.storyboard +++ b/NavigationForiOS/Base.lproj/Main.storyboard @@ -300,84 +300,83 @@ + - - - - - - - - - - - - - - From 2736bf75807b08cf81e3978be1c7227f63d968f1 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Tue, 5 Dec 2017 13:45:25 +0900 Subject: [PATCH 15/18] =?UTF-8?q?URL=E3=81=AE=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcshareddata/xcschemes/NavigationForiOS.xcscheme | 2 +- NavigationForiOS/Const.swift | 2 +- NavigationForiOS/EventService.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NavigationForiOS.xcodeproj/xcshareddata/xcschemes/NavigationForiOS.xcscheme b/NavigationForiOS.xcodeproj/xcshareddata/xcschemes/NavigationForiOS.xcscheme index fc0bb08..9f95f27 100644 --- a/NavigationForiOS.xcodeproj/xcshareddata/xcschemes/NavigationForiOS.xcscheme +++ b/NavigationForiOS.xcodeproj/xcshareddata/xcschemes/NavigationForiOS.xcscheme @@ -92,7 +92,7 @@ Void){ // Alamofire.request("\(Const().URL_API)/events/\(eventIdInputFormText)") - Alamofire.request("\(Const().URL_API)/events/0kzrV") + Alamofire.request("\(Const().URL_API)/events/a1002") .responseJSON { response in var events: EventEntity? = nil var responseStatus: ResponseStatus = ResponseStatus.Success From 53fd8f91d229c14bed6ffcb7e8bfc4efdd51ff28 Mon Sep 17 00:00:00 2001 From: shunsukeumemura Date: Tue, 5 Dec 2017 17:26:30 +0900 Subject: [PATCH 16/18] =?UTF-8?q?=E3=83=87=E3=82=B6=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NavigationForiOS/Base.lproj/Main.storyboard | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NavigationForiOS/Base.lproj/Main.storyboard b/NavigationForiOS/Base.lproj/Main.storyboard index b4c2583..e7da3b9 100644 --- a/NavigationForiOS/Base.lproj/Main.storyboard +++ b/NavigationForiOS/Base.lproj/Main.storyboard @@ -301,7 +301,7 @@ - + + + - - -