@@ -4,13 +4,13 @@ import NitroModules
44import UIKit
55
66final class StreetViewPanoramaViewImpl : UIView , GMSPanoramaViewDelegate {
7-
7+
88 private let mapErrorHandler : MapErrorHandler
99 private let locationHandler : LocationHandler
1010 private var panoramaView : GMSPanoramaView ?
1111 private var panoramaViewInitialized = false
1212 private var deInitialized = false
13-
13+
1414 init (
1515 frame: CGRect = . zero,
1616 mapErrorHandler: MapErrorHandler ,
@@ -20,10 +20,10 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
2020 self . locationHandler = locationHandler
2121 super. init ( frame: frame)
2222 }
23-
23+
2424 private var lifecycleAttached = false
2525 private var lifecycleTasks = [ Task < Void , Never > ] ( )
26-
26+
2727 private func attachLifecycleObservers( ) {
2828 if lifecycleAttached { return }
2929 lifecycleAttached = true
@@ -46,23 +46,23 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
4646 }
4747 )
4848 }
49-
49+
5050 private func detachLifecycleObservers( ) {
5151 if !lifecycleAttached { return }
5252 lifecycleAttached = false
5353 lifecycleTasks. forEach { $0. cancel ( ) }
5454 lifecycleTasks. removeAll ( )
5555 }
56-
56+
5757 required init ? ( coder: NSCoder ) {
5858 fatalError ( " init(coder:) has not been implemented " )
5959 }
60-
60+
6161 func initPanoramaView( ) {
6262 onMain {
6363 if self . panoramaViewInitialized { return }
6464 self . panoramaViewInitialized = true
65-
65+
6666 let props = self . streetViewInitialProps
6767 if let position = props? . position {
6868 let coordinate = position. toCLLocationCoordinate2D ( )
@@ -75,42 +75,42 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
7575 } else {
7676 self . panoramaView = GMSPanoramaView ( frame: self . bounds)
7777 }
78-
78+
7979 props? . panoramaId. map { self . panoramaView? . move ( toPanoramaID: $0) }
8080 props? . camera. map { self . panoramaView? . camera = $0. toGMSPanoramaCamera ( ) }
81-
81+
8282 self . panoramaView? . delegate = self
8383 self . panoramaView? . autoresizingMask = [ . flexibleWidth, . flexibleHeight]
8484 self . panoramaView. map { self . addSubview ( $0) }
85-
85+
8686 self . applyProps ( )
8787 self . initLocationCallbacks ( )
8888 self . onPanoramaReady ? ( true )
8989 }
9090 }
91-
91+
9292 private func initLocationCallbacks( ) {
9393 locationHandler. onUpdate = { [ weak self] loc in
9494 onMain { [ weak self] in
9595 self ? . onLocationUpdate ? ( loc. toRnLocation ( ) )
9696 }
9797 }
98-
98+
9999 locationHandler. onError = { [ weak self] error in
100100 onMain { [ weak self] in
101101 self ? . onLocationError ? ( error)
102102 }
103103 }
104104 }
105-
105+
106106 private func applyProps( ) {
107107 ( { self . uiSettings = self . uiSettings } ) ( )
108108 }
109-
109+
110110 var currentCamera : GMSPanoramaCamera ? { panoramaView? . camera }
111-
111+
112112 var streetViewInitialProps : RNStreetViewInitialProps ?
113-
113+
114114 var uiSettings : RNStreetViewUiSettings ? {
115115 didSet {
116116 onMain {
@@ -121,14 +121,14 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
121121 }
122122 }
123123 }
124-
124+
125125 var onPanoramaReady : ( ( Bool ) -> Void ) ?
126126 var onLocationUpdate : ( ( RNLocation ) -> Void ) ?
127127 var onLocationError : ( ( RNLocationErrorCode ) -> Void ) ?
128128 var onPanoramaChange : ( ( RNStreetViewPanoramaLocation ) -> Void ) ?
129129 var onCameraChange : ( ( RNStreetViewCamera ) -> Void ) ?
130130 var onPanoramaPress : ( ( RNStreetViewOrientation ) -> Void ) ?
131-
131+
132132 func setCamera( _ camera: GMSPanoramaCamera , animated: Bool , durationMs: Double ) {
133133 onMain {
134134 if animated {
@@ -140,7 +140,7 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
140140 }
141141 }
142142 }
143-
143+
144144 func setPosition( _ coordinate: CLLocationCoordinate2D , radius: UInt ? , source: GMSPanoramaSource ) {
145145 onMain {
146146 if let radius {
@@ -150,13 +150,13 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
150150 }
151151 }
152152 }
153-
153+
154154 func setPositionById( _ panoramaId: String ) {
155155 onMain {
156156 self . panoramaView? . move ( toPanoramaID: panoramaId)
157157 }
158158 }
159-
159+
160160 func deinitInternal( ) {
161161 guard !deInitialized else { return }
162162 deInitialized = true
@@ -167,17 +167,17 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
167167 self . panoramaView = nil
168168 }
169169 }
170-
170+
171171 private func appDidBecomeActive( ) {
172172 if window != nil {
173173 locationHandler. start ( )
174174 }
175175 }
176-
176+
177177 private func appDidEnterBackground( ) {
178178 locationHandler. stop ( )
179179 }
180-
180+
181181 override func didMoveToWindow( ) {
182182 super. didMoveToWindow ( )
183183 if window != nil {
@@ -189,11 +189,11 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
189189 detachLifecycleObservers ( )
190190 }
191191 }
192-
192+
193193 deinit {
194194 deinitInternal ( )
195195 }
196-
196+
197197 func panoramaView( _ panoramaView: GMSPanoramaView , didMoveTo panorama: GMSPanorama ? ) {
198198 onMain {
199199 guard let panorama else { return }
@@ -209,15 +209,15 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
209209 )
210210 }
211211 }
212-
212+
213213 func panoramaView( _ panoramaView: GMSPanoramaView , error: Error , onMoveNearCoordinate coordinate: CLLocationCoordinate2D ) {
214214 mapErrorHandler. report ( . panoramaNotFound, error. localizedDescription, error)
215215 }
216-
216+
217217 func panoramaView( _ panoramaView: GMSPanoramaView , error: Error , onMoveToPanoramaID panoramaID: String ) {
218218 mapErrorHandler. report ( . panoramaNotFound, error. localizedDescription, error)
219219 }
220-
220+
221221 func panoramaView( _ panoramaView: GMSPanoramaView , didMove camera: GMSPanoramaCamera ) {
222222 onMain {
223223 self . onCameraChange ? (
@@ -229,7 +229,7 @@ final class StreetViewPanoramaViewImpl: UIView, GMSPanoramaViewDelegate {
229229 )
230230 }
231231 }
232-
232+
233233 func panoramaView( _ panoramaView: GMSPanoramaView , didTap point: CGPoint ) {
234234 onMain {
235235 let orientation = panoramaView. orientation ( for: point)
0 commit comments