Skip to content

Commit 50be838

Browse files
committed
iOS: Clean up whitespace and improve code readability
1 parent 4bbc57a commit 50be838

12 files changed

+41
-60
lines changed

src/ios/GoogleMaps/CordovaGoogleMaps.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,20 @@ - (void)_destroyMap:(NSString *)mapId {
163163
if (![self.viewPlugins objectForKey:mapId]) return;
164164

165165
CDVPlugin<IPluginView> *pluginView = [self.viewPlugins objectForKey:mapId];
166+
166167
if ([mapId hasPrefix:@"streetview_"]) {
167168
PluginStreetViewPanorama *pluginSV = (PluginStreetViewPanorama *)pluginView;
168169
pluginSV.isRemoved = YES;
169-
//[pluginSV clear:nil];
170170
[pluginSV pluginUnload];
171171
[self.pluginLayer removePluginOverlay:pluginSV.panoramaCtrl];
172172
pluginSV.panoramaCtrl.view = nil;
173173
pluginSV = nil;
174+
174175
} else {
175176
PluginMap *pluginMap = (PluginMap *)pluginView;
176177
pluginMap.isRemoved = YES;
177-
//[pluginMap clear:nil];
178178
[pluginMap pluginUnload];
179179
[self.pluginLayer removePluginOverlay:pluginMap.mapCtrl];
180-
181180
pluginMap.mapCtrl.view = nil;
182181
[pluginMap.mapCtrl.plugins removeAllObjects];
183182
pluginMap.mapCtrl.plugins = nil;
@@ -186,7 +185,6 @@ - (void)_destroyMap:(NSString *)mapId {
186185
pluginMap = nil;
187186
}
188187

189-
190188
[self.viewPlugins removeObjectForKey:mapId];
191189
}
192190
/**
@@ -552,3 +550,4 @@ - (void)putHtmlElements:(CDVInvokedUrlCommand *)command {
552550
}
553551

554552
@end
553+

src/ios/GoogleMaps/MyPluginLayer.m

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ - (id)initWithWebView:(UIView *)webView {
3434
self.isSuspended = false;
3535
self.opaque = NO;
3636
[self.webView removeFromSuperview];
37+
3738
// prevent webView from bouncing
3839
if ([self.webView respondsToSelector:@selector(scrollView)]) {
3940
((UIScrollView*)[self.webView performSelector:@selector(scrollView)]).bounces = NO;
@@ -46,7 +47,6 @@ - (id)initWithWebView:(UIView *)webView {
4647
}
4748

4849
self.pluginScrollView = [[MyPluginScrollView alloc] initWithFrame:[self.webView frame]];
49-
5050
self.pluginScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
5151

5252
// Set webview delegate to MyPluginLayer and set contentSize of pluginScrollView to match the one of webView
@@ -57,16 +57,7 @@ - (id)initWithWebView:(UIView *)webView {
5757
}
5858

5959
[self addSubview:self.pluginScrollView];
60-
6160
[self addSubview:self.webView];
62-
63-
64-
// dispatch_queue_t q_background = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
65-
//
66-
// dispatch_async(q_background, ^{
67-
// [self startRedrawTimer];
68-
// });
69-
7061
return self;
7162
}
7263

@@ -90,6 +81,7 @@ - (void)stopRedrawTimer {
9081
}
9182
}
9283
}
84+
9385
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
9486
{
9587
[self syncPluginScrollViewContentOffsetWithWebViewScrollView];
@@ -98,6 +90,7 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
9890
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
9991
[self syncPluginScrollViewContentOffsetWithWebViewScrollView];
10092
}
93+
10194
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
10295
[self syncPluginScrollViewContentOffsetWithWebViewScrollView];
10396
}
@@ -214,11 +207,7 @@ - (void)removePluginOverlay:(PluginViewController *)pluginViewCtrl {
214207
[pluginViewCtrl.view removeFromSuperview];
215208
[pluginViewCtrl removeFromParentViewController];
216209
[self.pluginScrollView detachView:pluginViewCtrl.view];
217-
218-
//[pluginViewCtrl.view setFrame:CGRectMake(0, -pluginViewCtrl.view.frame.size.height, pluginViewCtrl.view.frame.size.width, pluginViewCtrl.view.frame.size.height)];
219-
//[pluginViewCtrl.view setNeedsDisplay];
220210
}];
221-
222211
}
223212

224213
- (void)resizeTask:(NSTimer *)timer {
@@ -248,9 +237,7 @@ - (void)updateViewPosition:(PluginViewController *)pluginViewCtrl {
248237
offset.y *= zoomScale;
249238
[self.pluginScrollView setContentOffset:offset];
250239

251-
if (!pluginViewCtrl.divId) {
252-
return;
253-
}
240+
if (!pluginViewCtrl.divId) return;
254241

255242
NSDictionary *domInfo = nil;
256243
@synchronized(self.pluginScrollView.HTMLNodes) {
@@ -339,13 +326,15 @@ - (void)updateViewPosition:(PluginViewController *)pluginViewCtrl {
339326
}
340327

341328
}
329+
342330
- (void)execJS: (NSString *)jsString {
343331
if ([self.webView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) {
344332
[self.webView performSelector:@selector(stringByEvaluatingJavaScriptFromString:) withObject:jsString];
345333
} else if ([self.webView respondsToSelector:@selector(evaluateJavaScript:completionHandler:)]) {
346334
[self.webView performSelector:@selector(evaluateJavaScript:completionHandler:) withObject:jsString withObject:nil];
347335
}
348336
}
337+
349338
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
350339
CGPoint browserClickPoint = CGPointMake(point.x - self.webView.frame.origin.x, point.y - self.webView.frame.origin.y);
351340
//NSLog(@"-->zoomScale = %f", self.webView.scrollView.zoomScale);
@@ -381,6 +370,7 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
381370
return hit;
382371
}
383372
}
373+
384374
if (self.pluginScrollView.mapCtrls == nil || self.pluginScrollView.mapCtrls.count == 0) {
385375
// Assumes all touches for the browser
386376
//NSLog(@"--->browser!");
@@ -464,8 +454,8 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
464454
}
465455
}
466456

467-
//NSLog(@"--->in browser!");
468-
return [self.webView hitTest:browserClickPoint withEvent:event];
457+
//NSLog(@"--->in browser!");
458+
return [self.webView hitTest:browserClickPoint withEvent:event];
469459
}
470460

471461
- (NSString *)findClickedDom:(NSString *)domId withPoint:(CGPoint)clickPoint isMapChild:(BOOL)isMapChild overflow:(OverflowCSS *)overflow {
@@ -711,3 +701,4 @@ - (NSString *)findClickedDom:(NSString *)domId withPoint:(CGPoint)clickPoint isM
711701

712702

713703
@end
704+

src/ios/GoogleMaps/PluginCircle.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ - (void)pluginInitialize
2121

2222
- (void)pluginUnload
2323
{
24-
2524
// Plugin destroy
2625
NSArray *keys = [self.mapCtrl.objects allKeys];
2726
NSString *key;
27+
2828
for (int i = 0; i < [keys count]; i++) {
2929
key = [keys objectAtIndex:i];
30+
3031
if ([key hasPrefix:@"circle_property"]) {
3132
key = [key stringByReplacingOccurrencesOfString:@"_property" withString:@""];
3233
GMSCircle *circle = (GMSCircle *)[self.mapCtrl.objects objectForKey:key];
@@ -129,6 +130,7 @@ -(void)create:(CDVInvokedUrlCommand *)command
129130

130131
});
131132
}
133+
132134
/**
133135
* Set center
134136
* @params command First Argument is circle ID, Second is latitude, Third is longitude
@@ -173,7 +175,6 @@ -(void)setFillColor:(CDVInvokedUrlCommand *)command
173175
}];
174176
}
175177

176-
177178
/**
178179
* Set stroke color
179180
* @params command First Argument is circle ID, Second is RGB color array
@@ -232,6 +233,7 @@ -(void)setRadius:(CDVInvokedUrlCommand *)command
232233
}];
233234
}];
234235
}
236+
235237
/**
236238
* Set z-index
237239
* @params command First Argument is circle ID, Second is z-index
@@ -284,8 +286,6 @@ -(void)setVisible:(CDVInvokedUrlCommand *)command
284286

285287
}];
286288
}
287-
288-
289289
/**
290290
* Set clickable
291291
* @params command First Argument is circle ID, Second is clickable

src/ios/GoogleMaps/PluginGroundOverlay.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ - (void)pluginUnload
3535
groundoverlay.map = nil;
3636
groundoverlay = nil;
3737
}
38+
3839
[self.mapCtrl.objects removeObjectForKey:key];
3940
}
4041
}
@@ -456,7 +457,6 @@ -(void)setBearing:(CDVInvokedUrlCommand *)command
456457

457458
}
458459

459-
460460
/**
461461
* Set clickable
462462
* @params command First Argument is ground overlay ID, Second is clickable

src/ios/GoogleMaps/PluginMap.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ - (void)loadPlugin:(CDVInvokedUrlCommand*)command {
8787
// https://github.com/apache/cordova-ios/blob/582e35776f01ee03f32f0986de181bcf5eb4d232/CordovaLib/Classes/Public/CDVViewController.m#L577
8888
//
8989
CDVViewController *cdvViewController = (CDVViewController*)self.viewController;
90+
9091
if ([plugin respondsToSelector:@selector(setViewController:)]) {
9192
[plugin setViewController:cdvViewController];
9293
}
94+
9395
if ([plugin respondsToSelector:@selector(setCommandDelegate:)]) {
9496
[plugin setCommandDelegate:cdvViewController.commandDelegate];
9597
}
@@ -160,6 +162,7 @@ - (void)setDiv:(CDVInvokedUrlCommand *)command {
160162
[googlemaps.pluginLayer removePluginOverlay:self.mapCtrl];
161163
self.mapCtrl.attached = NO;
162164
self.mapCtrl.view = nil;
165+
163166
} else {
164167
self.mapCtrl.view = self.mapCtrl.map;
165168
[googlemaps.pluginLayer addPluginOverlay:self.mapCtrl];
@@ -169,6 +172,7 @@ - (void)setDiv:(CDVInvokedUrlCommand *)command {
169172
self.mapCtrl.isRenderedAtOnce = NO; //prevent unexpected animation
170173
[googlemaps.pluginLayer updateViewPosition:self.mapCtrl];
171174
}
175+
172176
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
173177
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
174178
}];
@@ -268,7 +272,6 @@ - (void)clear:(CDVInvokedUrlCommand *)command {
268272
if (command != (id)[NSNull null]) {
269273
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
270274
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
271-
272275
}
273276
}
274277

src/ios/GoogleMaps/PluginMapViewController.m

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ - (void)mapView:(GMSMapView *)mapView didTapMyLocation:(CLLocationCoordinate2D)l
6565
}
6666

6767
- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
68-
69-
7068
if (self.activeMarker) {
7169
/*
7270
NSString *clusterId_markerId =[NSString stringWithFormat:@"%@", self.activeMarker.userData];
@@ -185,9 +183,6 @@ - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D
185183
CLLocationCoordinate2D hitArea = [self.map.projection coordinateForPoint:CGPointMake(1, 1)];
186184
CLLocationDistance threshold = GMSGeometryDistance(origin, hitArea);
187185

188-
189-
190-
//
191186
maxZIndex = -1;
192187
CLLocationCoordinate2D touchPoint = kCLLocationCoordinate2DInvalid;
193188

@@ -268,6 +263,7 @@ - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D
268263

269264

270265
}
266+
271267
/**
272268
* map_long_click
273269
*/
@@ -288,7 +284,6 @@ - (void) mapView:(GMSMapView *)mapView willMove:(BOOL)gesture
288284
[self triggerCameraEvent:@"camera_move_start" position:self.map.camera];
289285
}
290286

291-
292287
/**
293288
* plugin.google.maps.event.CAMERA_MOVE
294289
*/
@@ -312,7 +307,6 @@ - (void) mapView:(GMSMapView *)mapView idleAtCameraPosition:(GMSCameraPosition *
312307
self.isDragging = NO;
313308
}
314309

315-
316310
/**
317311
* marker info_click
318312
*/
@@ -339,6 +333,7 @@ - (void)mapView:(GMSMapView *)mapView didLongPressInfoWindowOfMarker:(GMSMarker
339333
[self triggerMarkerEvent:@"info_long_click" marker:marker];
340334
}
341335
}
336+
342337
/**
343338
* plugin.google.maps.event.MARKER_DRAG_START
344339
*/
@@ -352,6 +347,7 @@ - (void) mapView:(GMSMapView *) mapView didBeginDraggingMarker:(GMSMarker *)mark
352347
[self triggerMarkerEvent:@"marker_drag_start" marker:marker];
353348
}
354349
}
350+
355351
/**
356352
* plugin.google.maps.event.MARKER_DRAG_END
357353
*/
@@ -365,6 +361,7 @@ - (void) mapView:(GMSMapView *) mapView didEndDraggingMarker:(GMSMarker *)marker
365361
[self triggerMarkerEvent:@"marker_drag_end" marker:marker];
366362
}
367363
}
364+
368365
/**
369366
* plugin.google.maps.event.MARKER_DRAG
370367
*/

src/ios/GoogleMaps/PluginMarker.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ - (void)pluginInitialize
2525

2626
- (void)pluginUnload
2727
{
28-
2928
// Plugin destroy
3029
NSArray *keys = [self.mapCtrl.objects allKeys];
3130
NSString *key;
@@ -90,6 +89,7 @@ -(void)create:(CDVInvokedUrlCommand *)command
9089
}];
9190

9291
}
92+
9393
- (void)_create:(NSString *)markerId markerOptions:(NSDictionary *)json callbackBlock:(void (^)(BOOL successed, id resultObj)) callbackBlock {
9494

9595
if ([NSThread isMainThread] == NO) {
@@ -249,6 +249,7 @@ -(void)showInfoWindow:(CDVInvokedUrlCommand *)command
249249
}];
250250
}];
251251
}
252+
252253
/**
253254
* Hide current infowindow
254255
*/
@@ -263,6 +264,7 @@ -(void)hideInfoWindow:(CDVInvokedUrlCommand *)command
263264
}];
264265
}];
265266
}
267+
266268
/**
267269
* Get the position of the specified marker.
268270
* Send as plugin result the current marker position with array(latitude, longitude)
@@ -314,7 +316,6 @@ -(void)setTitle:(CDVInvokedUrlCommand *)command
314316
}];
315317
}
316318

317-
318319
/**
319320
* Set snippet to the specified marker
320321
* @params command Will contain the markerId as first argument
@@ -446,7 +447,6 @@ -(void)setInfoWindowAnchor:(CDVInvokedUrlCommand *)command
446447
}];
447448
}
448449

449-
450450
/**
451451
* Set opacity
452452
* @params command The first argument contains the marker ID, the second is the opacity value

0 commit comments

Comments
 (0)