-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainViewController.swift
More file actions
82 lines (61 loc) · 2.1 KB
/
Copy pathMainViewController.swift
File metadata and controls
82 lines (61 loc) · 2.1 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
70
71
72
73
74
75
76
77
78
79
80
81
82
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
import UIKit
import MapKit
public final class MainViewController: UIViewController {
// MARK: - Properties
public let map: MapViewController
public let toolbar = ExtraLightVisualEffectView()
public let toolbarStackView = UIStackView()
public let userTrackingButton = MKUserTrackingBarButtonItem()
public let searchButton = UIButton(type: .custom)
public let bookmarksButton = UIButton(type: .custom)
public let notificationsButton = UIButton(type: .custom)
public let configurationButton = UIButton(type: .custom)
internal let viewModel: MainViewModel
// MARK: - Init
public init(viewModel: MainViewModel) {
self.viewModel = viewModel
self.map = MapViewController(viewModel: viewModel.mapViewModel)
super.init(nibName: nil, bundle: nil)
}
@available(*, unavailable)
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - ViewDidLoad
override public func viewDidLoad() {
super.viewDidLoad()
self.initLayout()
}
// MARK: - ViewDidLayoutSubviews
override public func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.updateMapViewSafeAreaInsetsSoLegalInfoIsVisible()
}
private func updateMapViewSafeAreaInsetsSoLegalInfoIsVisible() {
let toolbarHeight = self.toolbarStackView.bounds.height
let currentInset = self.map.additionalSafeAreaInsets.bottom
if currentInset < toolbarHeight {
self.map.additionalSafeAreaInsets.bottom = toolbarHeight
}
}
// MARK: - Actions
@objc
public func searchButtonPressed() {
self.viewModel.didPressSearchButton()
}
@objc
public func bookmarksButtonPressed() {
self.viewModel.didPressBookmarksButton()
}
@objc
public func notificationsButtonPressed() {
self.viewModel.didPressNotificationsButton()
}
@objc
public func settingsButtonPressed() {
self.viewModel.didPressSettingsButton()
}
}