diff --git a/Sources/Earthquake Network.xcodeproj/project.pbxproj b/Sources/Earthquake Network.xcodeproj/project.pbxproj index 1249850..cb34fb0 100644 --- a/Sources/Earthquake Network.xcodeproj/project.pbxproj +++ b/Sources/Earthquake Network.xcodeproj/project.pbxproj @@ -7,13 +7,13 @@ objects = { /* Begin PBXBuildFile section */ + 65DBFB4B25E29DD60041CBA6 /* SeismicNetworksMapDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65DBFB4A25E29DD60041CBA6 /* SeismicNetworksMapDetailViewController.swift */; }; 8C10B0B92281FE7F00125C9F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8C10B0BD2281FE7F00125C9F /* Localizable.strings */; }; 8C10B0BA2281FE7F00125C9F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8C10B0BD2281FE7F00125C9F /* Localizable.strings */; }; 8C10B0BB2281FE7F00125C9F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8C10B0BD2281FE7F00125C9F /* Localizable.strings */; }; 8C14113121ED3E5B00A59729 /* SettingsRealTimeAlertsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C14113021ED3E5B00A59729 /* SettingsRealTimeAlertsViewController.m */; }; 8C14113721EE502800A59729 /* EQNAllertaSismica.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C14113621EE502800A59729 /* EQNAllertaSismica.m */; }; 8C2B251121938BFD00E0E25E /* SegnalazioniUtenteDettagliMappa.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2B251021938BFD00E0E25E /* SegnalazioniUtenteDettagliMappa.m */; }; - 8C2B25142193927E00E0E25E /* ReteSismiDettagliMappa.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2B25132193927E00E0E25E /* ReteSismiDettagliMappa.m */; }; 8C465D9A21F653AB00F04673 /* Assets.xcassets in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CBD3DD12149B9AD0070C963 /* Assets.xcassets */; }; 8C465D9B21F653CA00F04673 /* Assets.xcassets in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CBD3DD12149B9AD0070C963 /* Assets.xcassets */; }; 8C465D9C21F7BBE700F04673 /* PastquakesAnnotation.m in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C602249218EDBE200C799C2 /* PastquakesAnnotation.m */; }; @@ -41,7 +41,7 @@ 8C7CD64921F7D11700835812 /* ReteSismicaAnnotation.m in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CD08637218B3BEE0000CB5E /* ReteSismicaAnnotation.m */; }; 8C7CD64A21F7D11700835812 /* ReteSismicaAnnotation.h in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CD08636218B3BEE0000CB5E /* ReteSismicaAnnotation.h */; }; 8C8EBBA721540039002784BA /* EQNUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C8EBBA621540039002784BA /* EQNUser.m */; }; - 8CA46BA12194532E00C63C16 /* SismaAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CA46BA02194532E00C63C16 /* SismaAnnotation.m */; }; + 8CA46BA12194532E00C63C16 /* EQNMapAnnotationSeismic.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CA46BA02194532E00C63C16 /* EQNMapAnnotationSeismic.m */; }; 8CADAA9421B2627D0044E256 /* LogViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CADAA9321B2627D0044E256 /* LogViewController.m */; }; 8CAFD7C521825E4A00F8BD29 /* EQNSisma.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CAFD7C421825E4A00F8BD29 /* EQNSisma.m */; }; 8CBD3DC72149B9AD0070C963 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CBD3DC62149B9AD0070C963 /* AppDelegate.m */; }; @@ -272,6 +272,7 @@ /* Begin PBXFileReference section */ 25A8BFFE29D46740E8A8A7A3 /* Pods_Earthquake_Network.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Earthquake_Network.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 40CD2E5581CF2FA3D52F392D /* Pods-Earthquake Network.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Earthquake Network.release.xcconfig"; path = "Pods/Target Support Files/Pods-Earthquake Network/Pods-Earthquake Network.release.xcconfig"; sourceTree = ""; }; + 65DBFB4A25E29DD60041CBA6 /* SeismicNetworksMapDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeismicNetworksMapDetailViewController.swift; sourceTree = ""; }; 8C10B0AF2281FBE800125C9F /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Main.strings; sourceTree = ""; }; 8C10B0B02281FBE800125C9F /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/LaunchScreen.strings; sourceTree = ""; }; 8C10B0B12281FBE800125C9F /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/MainInterface.strings; sourceTree = ""; }; @@ -288,8 +289,6 @@ 8C14113621EE502800A59729 /* EQNAllertaSismica.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNAllertaSismica.m; sourceTree = ""; }; 8C2B250F21938BFD00E0E25E /* SegnalazioniUtenteDettagliMappa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SegnalazioniUtenteDettagliMappa.h; sourceTree = ""; }; 8C2B251021938BFD00E0E25E /* SegnalazioniUtenteDettagliMappa.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SegnalazioniUtenteDettagliMappa.m; sourceTree = ""; }; - 8C2B25122193927E00E0E25E /* ReteSismiDettagliMappa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReteSismiDettagliMappa.h; sourceTree = ""; }; - 8C2B25132193927E00E0E25E /* ReteSismiDettagliMappa.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReteSismiDettagliMappa.m; sourceTree = ""; }; 8C465D9721F6539700F04673 /* Earthquake Network.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = "Earthquake Network.xcodeproj"; sourceTree = ""; }; 8C483CAD21FDA53B00259FD2 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; }; 8C483CB021FDA8C700259FD2 /* Earthquake Network-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Earthquake Network-Bridging-Header.h"; sourceTree = ""; }; @@ -326,8 +325,8 @@ 8C7A3B65225A5EA40045B266 /* NSDictionary+EQNExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+EQNExtensions.h"; sourceTree = ""; }; 8C8EBBA521540039002784BA /* EQNUser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNUser.h; sourceTree = ""; }; 8C8EBBA621540039002784BA /* EQNUser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNUser.m; sourceTree = ""; }; - 8CA46B9F2194532E00C63C16 /* SismaAnnotation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SismaAnnotation.h; sourceTree = ""; }; - 8CA46BA02194532E00C63C16 /* SismaAnnotation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SismaAnnotation.m; sourceTree = ""; }; + 8CA46B9F2194532E00C63C16 /* EQNMapAnnotationSeismic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNMapAnnotationSeismic.h; sourceTree = ""; }; + 8CA46BA02194532E00C63C16 /* EQNMapAnnotationSeismic.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNMapAnnotationSeismic.m; sourceTree = ""; }; 8CADAA9221B2627D0044E256 /* LogViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LogViewController.h; sourceTree = ""; }; 8CADAA9321B2627D0044E256 /* LogViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LogViewController.m; sourceTree = ""; }; 8CAFD7C321825E4A00F8BD29 /* EQNSisma.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNSisma.h; sourceTree = ""; }; @@ -584,6 +583,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 65DBFB5225E2A2580041CBA6 /* Map annotation */ = { + isa = PBXGroup; + children = ( + 8CA46B9F2194532E00C63C16 /* EQNMapAnnotationSeismic.h */, + 8CA46BA02194532E00C63C16 /* EQNMapAnnotationSeismic.m */, + ); + path = "Map annotation"; + sourceTree = ""; + }; 8C465D9821F6539700F04673 /* Products */ = { isa = PBXGroup; children = ( @@ -634,8 +642,6 @@ 8CD08637218B3BEE0000CB5E /* ReteSismicaAnnotation.m */, 8C602248218EDBE200C799C2 /* PastquakesAnnotation.h */, 8C602249218EDBE200C799C2 /* PastquakesAnnotation.m */, - 8CA46B9F2194532E00C63C16 /* SismaAnnotation.h */, - 8CA46BA02194532E00C63C16 /* SismaAnnotation.m */, ); path = annotation; sourceTree = ""; @@ -761,8 +767,7 @@ DC65B390250F243E00251693 /* SeismicSettingsNetworksViewController.swift */, DC2814372519C56100C1AFF7 /* SeismicNetworksViewController.swift */, DCC76BD7251F56050005C4DC /* SeismicCardSettingsViewController.swift */, - 8C2B25122193927E00E0E25E /* ReteSismiDettagliMappa.h */, - 8C2B25132193927E00E0E25E /* ReteSismiDettagliMappa.m */, + 65DBFB4A25E29DD60041CBA6 /* SeismicNetworksMapDetailViewController.swift */, ); path = "Seismic Networks"; sourceTree = ""; @@ -1030,6 +1035,7 @@ DCF9E15024F6EA0B002B6B1D /* Networks */, DC99A50124E66DFB0071BC9F /* Commands */, DCEFF21824F587CC009D3FE1 /* Settings */, + 65DBFB5225E2A2580041CBA6 /* Map annotation */, 8C483CBB21FDACE500259FD2 /* VersioneProProducts.swift */, 8C483CB721FDACD300259FD2 /* IAPHelper.swift */, DCF10DC524D2B8C7009F34C3 /* EQNPurchaseUtility.swift */, @@ -1556,7 +1562,6 @@ 8CF6604F214C0E58009F4314 /* EQNCalibrazione.m in Sources */, DCBB84F0252CFC4600F12633 /* AlertsNoLocationTableViewCell.swift in Sources */, DCD3E3C024D15576007C78D4 /* PurchaseProVersionViewController.swift in Sources */, - 8C2B25142193927E00E0E25E /* ReteSismiDettagliMappa.m in Sources */, 8CF05B51218C41FB0055012B /* PickerViewController.m in Sources */, DC99A50324E66E270071BC9F /* EQNCommandProtocol.swift in Sources */, DCB45BC8250E86E100DB2D0C /* SeismicSettingsViewController.swift in Sources */, @@ -1568,6 +1573,7 @@ 8C14113121ED3E5B00A59729 /* SettingsRealTimeAlertsViewController.m in Sources */, DCBB267A24D1E7F500F04559 /* SubscriptionsHeaderTableViewCell.swift in Sources */, DC65B391250F243E00251693 /* SeismicSettingsNetworksViewController.swift in Sources */, + 65DBFB4B25E29DD60041CBA6 /* SeismicNetworksMapDetailViewController.swift in Sources */, DC08804124F5B41400186D97 /* SettingSliderTableViewCell.swift in Sources */, 8CBD3DD82149B9AD0070C963 /* main.m in Sources */, 8CF05B57218C93BA0055012B /* EQNUtility.m in Sources */, @@ -1586,7 +1592,7 @@ 8CBD3DC72149B9AD0070C963 /* AppDelegate.m in Sources */, DC974AFF251748B300A139EC /* SeismicFiltersViewController.swift in Sources */, DC105641251E7ECE002579BB /* UIFont+Extensions.swift in Sources */, - 8CA46BA12194532E00C63C16 /* SismaAnnotation.m in Sources */, + 8CA46BA12194532E00C63C16 /* EQNMapAnnotationSeismic.m in Sources */, DCB28CEE24FB8400001F557E /* SettingsViewController.swift in Sources */, DCB528212560161C005288E5 /* AlertSimulatorViewController.swift in Sources */, DCC76BD8251F56050005C4DC /* SeismicCardSettingsViewController.swift in Sources */, diff --git a/Sources/Earthquake Network/Controllers/Seismic Networks/ReteSismiDettagliMappa.h b/Sources/Earthquake Network/Controllers/Seismic Networks/ReteSismiDettagliMappa.h deleted file mode 100644 index 7e5bef6..0000000 --- a/Sources/Earthquake Network/Controllers/Seismic Networks/ReteSismiDettagliMappa.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// ReteSismiDettagliMappa.h -// Earthquake Network -// -// Refactored by Andrea Busi on 26/09/2020. -// Copyright © 2020 Earthquake Network. All rights reserved. -// - -#import "DettagliMappaViewController.h" -#import "EQNSisma.h" - - -@interface ReteSismiDettagliMappa : DettagliMappaViewController -@property (nonatomic, strong, nullable) EQNSisma *sisma; -@end diff --git a/Sources/Earthquake Network/Controllers/Seismic Networks/ReteSismiDettagliMappa.m b/Sources/Earthquake Network/Controllers/Seismic Networks/ReteSismiDettagliMappa.m deleted file mode 100644 index aa9f188..0000000 --- a/Sources/Earthquake Network/Controllers/Seismic Networks/ReteSismiDettagliMappa.m +++ /dev/null @@ -1,77 +0,0 @@ -// -// ReteSismiDettagliMappa.m -// Earthquake Network -// -// Refactored by Andrea Busi on 26/09/2020. -// Copyright © 2020 Earthquake Network. All rights reserved. -// - -#import "ReteSismiDettagliMappa.h" -#import "SismaAnnotation.h" -#import "EQNAdsUtility.h" - -@interface ReteSismiDettagliMappa () -@property (nonatomic, strong) GADBannerView *bannerView; -@end - -@implementation ReteSismiDettagliMappa - -#pragma mark - View Lifecycle - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - [self setupUI]; - - for (EQNSisma *sismi in [EQNManager defaultManager].retiSismiche ) { - [self creaMarcherWithSegnalazione:sismi]; - } -} - -#pragma mark - Private - -- (void)setupUI -{ - self.mapView.delegate = self; - self.bannerView = [EQNAdsUtility ottieniBannerWithController:self position:YES]; - - UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] - style:UIBarButtonItemStyleDone - target:self - action:@selector(chiudi:)]; - self.navigationController.navigationItem.leftBarButtonItem = backButton; -} - -- (void)creaMarcherWithSegnalazione:(id)segnalazione -{ - [super creaMarcherWithSegnalazione:segnalazione]; - - SismaAnnotation *anAnnotation = [[SismaAnnotation alloc] initWithTitle:self.sisma.place location:self.sisma.coordinate.coordinate intensita:[self.sisma.magnitude doubleValue]]; - - [self.mapView addAnnotation:anAnnotation]; - - MKCoordinateSpan span = MKCoordinateSpanMake(10.5, 10.5); - MKCoordinateRegion region = MKCoordinateRegionMake(self.sisma.coordinate.coordinate, span); - [self.mapView setCenterCoordinate:self.sisma.coordinate.coordinate animated:NO]; - [self.mapView setRegion:region animated:YES]; -} - -#pragma mark - MKMapViewDelegate - -- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation -{ - if ([annotation isKindOfClass:[SismaAnnotation class]]) { - SismaAnnotation *anLocation = (SismaAnnotation *)annotation; - MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:IDENTIFIER_ANNOTATION_SISMI]; - if (annotationView == nil) { - annotationView = anLocation.annotationView; - } else { - annotationView.annotation = anLocation; - } - return annotationView; - } - return nil; -} - -@end diff --git a/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksMapDetailViewController.swift b/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksMapDetailViewController.swift new file mode 100644 index 0000000..62f8d1b --- /dev/null +++ b/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksMapDetailViewController.swift @@ -0,0 +1,72 @@ +// +// SeismicNetworksMapDetailViewController.swift +// Earthquake Network +// +// Created by Andrea Busi on 21/02/21. +// Copyright © 2021 Earthquake Network. All rights reserved. +// + +import UIKit +import MapKit + +class SeismicNetworksMapDetailViewController: EQNBaseViewController, MKMapViewDelegate { + + // MARK: - UI + + @IBOutlet private weak var mapView: MKMapView! + + // MARK: - State + + var seismic: EQNSisma? + + + // MARK: - View Lifecycle + + override func viewDidLoad() { + super.viewDidLoad() + + setupUI() + + if let seismic = seismic { + addMarker(for: seismic) + } + } + + // MARK: - Private + + private func setupUI() { + let closeButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(closeTapped(_:))) + navigationItem.rightBarButtonItem = closeButton + } + + private func addMarker(for seismic: EQNSisma) { + let annotation = EQNMapAnnotationSeismic(title: seismic.place, location: seismic.coordinate.coordinate, intensita: seismic.magnitude.doubleValue) + mapView.addAnnotation(annotation) + + let span = MKCoordinateSpan(latitudeDelta: 10.5, longitudeDelta: 10.5) + let region = MKCoordinateRegion(center: seismic.coordinate.coordinate, span: span) + mapView.setCenter(seismic.coordinate.coordinate, animated: false) + mapView.setRegion(region, animated: true) + } + + // MARK: - Actions + + @objc private func closeTapped(_ sender: Any) { + dismiss(animated: true) + } + + // MARK: - MKMapViewDelegate + + func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { + if let sismaAnnotation = annotation as? EQNMapAnnotationSeismic { + var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: EQNMapAnnotationSeismicIdentifier) + if annotationView == nil { + annotationView = sismaAnnotation.annotationView() + } else { + annotationView?.annotation = sismaAnnotation + } + return annotationView + } + return nil + } +} diff --git a/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksViewController.swift b/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksViewController.swift index c4b8cf3..d76ed7b 100644 --- a/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksViewController.swift +++ b/Sources/Earthquake Network/Controllers/Seismic Networks/SeismicNetworksViewController.swift @@ -66,8 +66,8 @@ class SeismicNetworksViewController: EQNBaseViewController, UITableViewDelegate, override func prepare(for segue: UIStoryboardSegue, sender: Any?) { switch segue.identifier { case Self.SegueIdentifierMap: - if let seismic = sender as? EQNSisma, let navController = segue.destination as? UINavigationController, let controller = navController.viewControllers.first as? ReteSismiDettagliMappa { - controller.sisma = seismic + if let seismic = sender as? EQNSisma, let navController = segue.destination as? UINavigationController, let controller = navController.viewControllers.first as? SeismicNetworksMapDetailViewController { + controller.seismic = seismic } case Self.SegueIdentifierFilters: if let controller = segue.destination as? SeismicFiltersViewController { diff --git a/Sources/Earthquake Network/Costanti.h b/Sources/Earthquake Network/Costanti.h index 9b672a7..8ad2392 100644 --- a/Sources/Earthquake Network/Costanti.h +++ b/Sources/Earthquake Network/Costanti.h @@ -103,9 +103,6 @@ static NSString * const EQNAdMobAppIdAdaptiveBanner = @"ca-app-pub-0053870219990 #define IDENTIFIER_ANNOTATION_RETESMARTPHONE @"IDENTIFIER_ANNOTATION_RETESMARTPHONE" // pastequakes #define IDENTIFIER_ANNOTATION_PASTQUAKES @"IDENTIFIER_ANNOTATION_PASTQUAKES" - -// sismi -#define IDENTIFIER_ANNOTATION_SISMI @"IDENTIFIER_ANNOTATION_SISMI" // rete smartphone notifiche #define IDENTIFIER_ANNOTATION_RS_NOTIFICA @"IDENTIFIER_ANNOTATION_RS_NOTIFICA" diff --git a/Sources/Earthquake Network/Earthquake Network-Bridging-Header.h b/Sources/Earthquake Network/Earthquake Network-Bridging-Header.h index e896805..1248e42 100644 --- a/Sources/Earthquake Network/Earthquake Network-Bridging-Header.h +++ b/Sources/Earthquake Network/Earthquake Network-Bridging-Header.h @@ -9,8 +9,8 @@ #import "EQNNotificheReteSismiche.h" #import "EQNSisma.h" #import "EQNBaseViewController.h" -#import "ReteSismiDettagliMappa.h" #import "SettingsBaseViewController.h" #import "PastquakesAnnotation.h" #import "EQNGeneratoreURLServer.h" #import "ServerRequest.h" +#import "EQNMapAnnotationSeismic.h" diff --git a/Sources/Earthquake Network/Models/Map annotation/EQNMapAnnotationSeismic.h b/Sources/Earthquake Network/Models/Map annotation/EQNMapAnnotationSeismic.h new file mode 100644 index 0000000..3a05c2d --- /dev/null +++ b/Sources/Earthquake Network/Models/Map annotation/EQNMapAnnotationSeismic.h @@ -0,0 +1,29 @@ +// +// EQNMapAnnotationSeismic.h +// Earthquake Network +// +// Refactored by Andrea Busi +// Copyright © 2021 Earthquake Network. All rights reserved. +// + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +static NSString * const EQNMapAnnotationSeismicIdentifier = @"EQNMapAnnotationSeismicIdentifier"; + + +@interface EQNMapAnnotationSeismic : NSObject + +@property (nonatomic, readonly) CLLocationCoordinate2D coordinate; +@property (nonatomic, copy) NSString *title; +@property (nonatomic, readonly) double magnitude; + +- (instancetype)initWithTitle:(NSString *)title location:(CLLocationCoordinate2D)coordinate intensita:(double)magnitude; + +- (MKAnnotationView *)annotationView; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Sources/Earthquake Network/model/annotation/SismaAnnotation.m b/Sources/Earthquake Network/Models/Map annotation/EQNMapAnnotationSeismic.m similarity index 56% rename from Sources/Earthquake Network/model/annotation/SismaAnnotation.m rename to Sources/Earthquake Network/Models/Map annotation/EQNMapAnnotationSeismic.m index f527a72..bdab586 100644 --- a/Sources/Earthquake Network/model/annotation/SismaAnnotation.m +++ b/Sources/Earthquake Network/Models/Map annotation/EQNMapAnnotationSeismic.m @@ -1,20 +1,21 @@ // -// SismaAnnotation.m +// EQNMapAnnotationSeismic.m // Earthquake Network // -// Created by Luca Beretta on 08/11/18. -// Copyright © 2018 Luca Beretta. All rights reserved. +// Refactored by Andrea Busi +// Copyright © 2021 Earthquake Network. All rights reserved. // -#import "SismaAnnotation.h" +#import "EQNMapAnnotationSeismic.h" -@implementation SismaAnnotation +@implementation EQNMapAnnotationSeismic --(id)initWithTitle:(NSString *)title location:(CLLocationCoordinate2D )coordinate intensita:(double)magnitude{ +#pragma mark - Init + +- (instancetype)initWithTitle:(NSString *)title location:(CLLocationCoordinate2D )coordinate intensita:(double)magnitude{ self = [super init]; if (self) { - _title = title; _coordinate = coordinate; _magnitude = magnitude; @@ -22,24 +23,23 @@ return self; } --(MKAnnotationView *)annotationView{ - - MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:self reuseIdentifier:IDENTIFIER_ANNOTATION_SISMI]; +#pragma mark - Annotation + +- (MKAnnotationView *)annotationView +{ + MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:self reuseIdentifier:EQNMapAnnotationSeismicIdentifier]; annotationView.enabled = YES; annotationView.canShowCallout = YES; NSString *imageString; NSLog(@"magnitudo %f", self.magnitude); - if(self.magnitude > 4.0){ + if (self.magnitude > 4.0){ imageString = @"dyamond_red"; - - }else if (self.magnitude < 3.0){ + } else if (self.magnitude < 3.0) { imageString = @"dyamond_green"; - - }else{ + } else { imageString = @"dyamond_yellow"; - } annotationView.image = [UIImage imageNamed:imageString]; diff --git a/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard b/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard index e046075..db0f507 100644 --- a/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard +++ b/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard @@ -368,11 +368,11 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern - + @@ -1457,53 +1457,50 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern - - - - - - - - - - - - - - - - - - - + - + - + + + + + + + + + + + - + + + + + + - + @@ -2560,6 +2557,25 @@ Sisma rilevato da 10 smartphone + + + + + + + + + + + + + + + + + + + diff --git a/Sources/Earthquake Network/model/annotation/SismaAnnotation.h b/Sources/Earthquake Network/model/annotation/SismaAnnotation.h deleted file mode 100644 index 1107215..0000000 --- a/Sources/Earthquake Network/model/annotation/SismaAnnotation.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// SismaAnnotation.h -// Earthquake Network -// -// Created by Luca Beretta on 08/11/18. -// Copyright © 2018 Luca Beretta. All rights reserved. -// - -#import -#import -#import "Costanti.h" - -@interface SismaAnnotation : NSObject - -@property (nonatomic, readonly) CLLocationCoordinate2D coordinate; -@property (nonatomic, copy) NSString *title; -@property (nonatomic, readonly) double magnitude; - --(id)initWithTitle:(NSString *)title location:(CLLocationCoordinate2D )coordinate intensita:(double)magnitude; --(MKAnnotationView *)annotationView ; - -@end