capacitor-google-navigation 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,19 +2,9 @@ import UIKit
2
2
  import GoogleMaps
3
3
  import GoogleNavigation
4
4
 
5
- /// A transparent view that passes touches through to underlying windows,
6
- /// only intercepting touches that land on one of its subviews (e.g. the close button).
7
- private class PassthroughView: UIView {
8
- override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
9
- let hit = super.hitTest(point, with: event)
10
- return hit == self ? nil : hit
11
- }
12
- }
13
-
14
5
  class NavigationMapViewController: UIViewController {
15
6
  private let session: GMSNavigationSession
16
7
  private var mapView: GMSMapView?
17
- private var overlayWindow: UIWindow?
18
8
  var onDismiss: (() -> Void)?
19
9
 
20
10
  init(session: GMSNavigationSession) {
@@ -46,33 +36,12 @@ class NavigationMapViewController: UIViewController {
46
36
  if enabled {
47
37
  mapView.cameraMode = .following
48
38
  }
39
+ addCloseButton()
49
40
  }
50
41
 
51
- override func viewDidAppear(_ animated: Bool) {
52
- super.viewDidAppear(animated)
53
- addCloseButtonWindow()
54
- }
55
-
56
- override func viewDidDisappear(_ animated: Bool) {
57
- super.viewDidDisappear(animated)
58
- tearDownCloseButtonWindow()
59
- }
60
-
61
- // MARK: - Close button in a top-level UIWindow above all SDK UI
62
-
63
- private func addCloseButtonWindow() {
64
- guard let scene = view.window?.windowScene else { return }
65
-
66
- let window = UIWindow(windowScene: scene)
67
- window.windowLevel = .alert + 1
68
- window.backgroundColor = .clear
69
-
70
- let overlayVC = UIViewController()
71
- let passthroughView = PassthroughView()
72
- passthroughView.backgroundColor = .clear
73
- overlayVC.view = passthroughView
74
- window.rootViewController = overlayVC
42
+ // MARK: - Close button overlaid directly on the map view
75
43
 
44
+ private func addCloseButton() {
76
45
  let button = UIButton(type: .system)
77
46
  button.setImage(UIImage(systemName: "xmark"), for: .normal)
78
47
  button.tintColor = .white
@@ -80,26 +49,17 @@ class NavigationMapViewController: UIViewController {
80
49
  button.layer.cornerRadius = 20
81
50
  button.translatesAutoresizingMaskIntoConstraints = false
82
51
  button.addTarget(self, action: #selector(closeTapped), for: .touchUpInside)
83
- overlayVC.view.addSubview(button)
52
+ view.addSubview(button)
84
53
 
85
54
  NSLayoutConstraint.activate([
86
- button.topAnchor.constraint(equalTo: overlayVC.view.safeAreaLayoutGuide.topAnchor, constant: 16),
87
- button.leadingAnchor.constraint(equalTo: overlayVC.view.leadingAnchor, constant: 16),
55
+ button.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 16),
56
+ button.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
88
57
  button.widthAnchor.constraint(equalToConstant: 40),
89
58
  button.heightAnchor.constraint(equalToConstant: 40),
90
59
  ])
91
-
92
- self.overlayWindow = window
93
- window.isHidden = false
94
- }
95
-
96
- private func tearDownCloseButtonWindow() {
97
- overlayWindow?.isHidden = true
98
- overlayWindow = nil
99
60
  }
100
61
 
101
62
  @objc private func closeTapped() {
102
- tearDownCloseButtonWindow()
103
63
  dismiss(animated: true) { [weak self] in
104
64
  self?.onDismiss?()
105
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-google-navigation",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "Google maps turn by turn navigation for capcitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",