Implemented the outlets of the LocationsListViewController view controller.
This commit is contained in:
parent
c91cbbe7dc
commit
39ec206454
@ -13,7 +13,19 @@ class LocationsListViewController: BaseViewController {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
var viewModel: LocationsListViewModeling
|
||||
private let viewModel: LocationsListViewModeling
|
||||
|
||||
// MARK: Outlets
|
||||
|
||||
private lazy var error = ErrorMessageView()
|
||||
private lazy var loading = LoadingSpinnerView()
|
||||
private lazy var table = {
|
||||
let table = UITableView(frame: .zero, style: .plain)
|
||||
|
||||
table.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
return table
|
||||
}()
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
@ -31,14 +43,9 @@ class LocationsListViewController: BaseViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(
|
||||
title: "Add",
|
||||
style: .plain,
|
||||
target: self,
|
||||
action: #selector(addLocationPressed)
|
||||
)
|
||||
title = "Locations"
|
||||
|
||||
setupBar()
|
||||
setupView()
|
||||
}
|
||||
|
||||
}
|
||||
@ -49,6 +56,41 @@ private extension LocationsListViewController {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func setupBar() {
|
||||
navigationController?.navigationBar.prefersLargeTitles = true
|
||||
navigationController?.navigationBar.tintColor = .red
|
||||
navigationItem.rightBarButtonItem = .init(
|
||||
title: "Add",
|
||||
style: .plain,
|
||||
target: self,
|
||||
action: #selector(addLocationPressed)
|
||||
)
|
||||
title = "Locations"
|
||||
}
|
||||
|
||||
func setupView() {
|
||||
view.addSubview(table)
|
||||
view.addSubview(error)
|
||||
view.addSubview(loading)
|
||||
|
||||
error.isHidden = true
|
||||
error.onRetry = { print("RETRY BUTTON PRESSED!") }
|
||||
|
||||
loading.isHidden = true
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
error.widthAnchor.constraint(equalToConstant: 300),
|
||||
view.centerXAnchor.constraint(equalTo: error.centerXAnchor),
|
||||
view.centerYAnchor.constraint(equalTo: error.centerYAnchor),
|
||||
view.centerXAnchor.constraint(equalTo: loading.centerXAnchor),
|
||||
view.centerYAnchor.constraint(equalTo: loading.centerYAnchor),
|
||||
view.bottomAnchor.constraint(equalTo: table.bottomAnchor),
|
||||
view.leadingAnchor.constraint(equalTo: table.leadingAnchor),
|
||||
view.topAnchor.constraint(equalTo: table.topAnchor),
|
||||
view.trailingAnchor.constraint(equalTo: table.trailingAnchor),
|
||||
])
|
||||
}
|
||||
|
||||
@objc func addLocationPressed() {
|
||||
viewModel.openAddLocation()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user