-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPickVenueViewController.swift
More file actions
70 lines (50 loc) · 2.3 KB
/
Copy pathPickVenueViewController.swift
File metadata and controls
70 lines (50 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// PickVenueViewController.swift
// Bourbon-iOS
//
// Created by Alyssa Torres on 5/1/17.
// Copyright © 2017 Ourglass. All rights reserved.
//
import UIKit
class PickVenueViewController: UIViewController {
let emptyTableText = "It looks like you don't have any venues! Click on the plus sign above to add one."
let nc = NotificationCenter.default
var tableViewDataSource: OGVenueTableViewDataSource?
var tableViewDelegate: OGVenueTableViewDelegate?
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Pick a venue"
self.view.backgroundColor = UIColor(white: 51/255, alpha: 1.0)
// Alyssa split this out because the code is identical in both views that use the delegate and data source
tableViewDataSource = OGVenueTableViewDataSource(tableView,
type: OGVenueType.MINE,
noDataText: emptyTableText,
accessory: UITableViewCellAccessoryType.disclosureIndicator)
tableViewDelegate = OGVenueTableViewDelegate(tableView,
type: OGVenueType.MINE,
didSelect: didSelectVenue)
tableView.tableFooterView = UIView(frame: .zero)
nc.addObserver(
forName: NSNotification.Name(rawValue: ASNotification.myVenuesUpdated.rawValue),
object: nil, queue: nil) { _ in
self.tableView.reloadData()
}
StateController.sharedInstance.findMyVenues()
.then { _ -> Void in
self.tableView.reloadData()
}
.catch { err -> Void in
log.debug(err)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let vc = segue.destination as? SetupDeviceViewController,
let venue = sender as? OGVenue {
vc.selectedVenue = venue
}
}
func didSelectVenue(venue: OGVenue) {
performSegue(withIdentifier: "fromPickVenueToSetup", sender: venue)
}
}