Map screen

This commit is contained in:
Selim Mustafaev 2020-08-27 22:30:46 +03:00
parent 9bd3426f14
commit ac552c3749
6 changed files with 123 additions and 7 deletions

View File

@ -86,6 +86,7 @@
7AB67E8C2435C38700258F61 /* CustomTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AB67E8B2435C38700258F61 /* CustomTextField.swift */; }; 7AB67E8C2435C38700258F61 /* CustomTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AB67E8B2435C38700258F61 /* CustomTextField.swift */; };
7AB67E8E2435D1A000258F61 /* CustomButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AB67E8D2435D1A000258F61 /* CustomButton.swift */; }; 7AB67E8E2435D1A000258F61 /* CustomButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AB67E8D2435D1A000258F61 /* CustomButton.swift */; };
7AE26A3324EEF9EC00625033 /* UIViewControllerExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE26A3224EEF9EC00625033 /* UIViewControllerExt.swift */; }; 7AE26A3324EEF9EC00625033 /* UIViewControllerExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE26A3224EEF9EC00625033 /* UIViewControllerExt.swift */; };
7AE26A3524F31B0700625033 /* EventsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE26A3424F31B0700625033 /* EventsController.swift */; };
7AEFE728240455E200910EB7 /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AEFE727240455E200910EB7 /* SettingsController.swift */; }; 7AEFE728240455E200910EB7 /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AEFE727240455E200910EB7 /* SettingsController.swift */; };
7AF58D2F24029C5200CE01A0 /* MagazineLayout in Frameworks */ = {isa = PBXBuildFile; productRef = 7AF58D2E24029C5200CE01A0 /* MagazineLayout */; }; 7AF58D2F24029C5200CE01A0 /* MagazineLayout in Frameworks */ = {isa = PBXBuildFile; productRef = 7AF58D2E24029C5200CE01A0 /* MagazineLayout */; };
7AF58D3124029E1000CE01A0 /* VehicleHeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF58D3024029E1000CE01A0 /* VehicleHeaderCell.swift */; }; 7AF58D3124029E1000CE01A0 /* VehicleHeaderCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF58D3024029E1000CE01A0 /* VehicleHeaderCell.swift */; };
@ -166,6 +167,7 @@
7AB67E8B2435C38700258F61 /* CustomTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTextField.swift; sourceTree = "<group>"; }; 7AB67E8B2435C38700258F61 /* CustomTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTextField.swift; sourceTree = "<group>"; };
7AB67E8D2435D1A000258F61 /* CustomButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomButton.swift; sourceTree = "<group>"; }; 7AB67E8D2435D1A000258F61 /* CustomButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomButton.swift; sourceTree = "<group>"; };
7AE26A3224EEF9EC00625033 /* UIViewControllerExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewControllerExt.swift; sourceTree = "<group>"; }; 7AE26A3224EEF9EC00625033 /* UIViewControllerExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewControllerExt.swift; sourceTree = "<group>"; };
7AE26A3424F31B0700625033 /* EventsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsController.swift; sourceTree = "<group>"; };
7AEFE727240455E200910EB7 /* SettingsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; }; 7AEFE727240455E200910EB7 /* SettingsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; };
7AF58D3024029E1000CE01A0 /* VehicleHeaderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehicleHeaderCell.swift; sourceTree = "<group>"; }; 7AF58D3024029E1000CE01A0 /* VehicleHeaderCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehicleHeaderCell.swift; sourceTree = "<group>"; };
7AF58D57240309CA00CE01A0 /* VehicleTextParamCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehicleTextParamCell.swift; sourceTree = "<group>"; }; 7AF58D57240309CA00CE01A0 /* VehicleTextParamCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehicleTextParamCell.swift; sourceTree = "<group>"; };
@ -250,6 +252,7 @@
7A33381024990DAE00D878F1 /* FiltersController.swift */, 7A33381024990DAE00D878F1 /* FiltersController.swift */,
7A27ADC6249D43210035F39E /* RegionsController.swift */, 7A27ADC6249D43210035F39E /* RegionsController.swift */,
7A27ADF2249F8B650035F39E /* RecordsController.swift */, 7A27ADF2249F8B650035F39E /* RecordsController.swift */,
7AE26A3424F31B0700625033 /* EventsController.swift */,
); );
path = Controllers; path = Controllers;
sourceTree = "<group>"; sourceTree = "<group>";
@ -504,6 +507,7 @@
7A659B5924A2B1BA0043A0F2 /* AudioRecord.swift in Sources */, 7A659B5924A2B1BA0043A0F2 /* AudioRecord.swift in Sources */,
7A488C3C24A74B990054D0B2 /* RxTableViewRealmDataSource.swift in Sources */, 7A488C3C24A74B990054D0B2 /* RxTableViewRealmDataSource.swift in Sources */,
7A6DD90C24335A6D009DE740 /* FlagLayer.swift in Sources */, 7A6DD90C24335A6D009DE740 /* FlagLayer.swift in Sources */,
7AE26A3524F31B0700625033 /* EventsController.swift in Sources */,
7AB67E8C2435C38700258F61 /* CustomTextField.swift in Sources */, 7AB67E8C2435C38700258F61 /* CustomTextField.swift in Sources */,
7A27ADF5249FD2F90035F39E /* FileManagerExt.swift in Sources */, 7A27ADF5249FD2F90035F39E /* FileManagerExt.swift in Sources */,
7AE26A3324EEF9EC00625033 /* UIViewControllerExt.swift in Sources */, 7AE26A3324EEF9EC00625033 /* UIViewControllerExt.swift in Sources */,

View File

@ -63,5 +63,21 @@
landmarkType = "7"> landmarkType = "7">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "CDE92976-A8B4-4D3D-95F5-C2E8876C0601"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "AutoCat/Utils/Api.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "167"
endingLineNumber = "167"
landmarkName = "add(event:to:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints> </Breakpoints>
</Bucket> </Bucket>

View File

@ -219,6 +219,35 @@
</objects> </objects>
<point key="canvasLocation" x="1881" y="965"/> <point key="canvasLocation" x="1881" y="965"/>
</scene> </scene>
<!--Events-->
<scene sceneID="pPZ-gs-kHF">
<objects>
<viewController storyboardIdentifier="EventsController" title="Events" extendedLayoutIncludesOpaqueBars="YES" id="DmF-8j-ae3" customClass="EventsController" customModule="AutoCat" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="mYm-sh-pSj">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" mapType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="3Ru-VE-szI">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
</mapView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="bottomMargin" secondItem="3Ru-VE-szI" secondAttribute="bottom" id="asd-Fg-84K"/>
<constraint firstItem="3Ru-VE-szI" firstAttribute="leading" secondItem="mYm-sh-pSj" secondAttribute="leading" id="bOP-2E-BEk"/>
<constraint firstItem="3Ru-VE-szI" firstAttribute="top" secondItem="mYm-sh-pSj" secondAttribute="top" id="cmd-fX-3Qa"/>
<constraint firstAttribute="trailing" secondItem="3Ru-VE-szI" secondAttribute="trailing" id="w0g-Ng-mkW"/>
</constraints>
<viewLayoutGuide key="safeArea" id="9R5-6n-B3H"/>
</view>
<connections>
<outlet property="map" destination="3Ru-VE-szI" id="rYQ-5P-Kxr"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="heB-JE-Wi6" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1881" y="1660"/>
</scene>
<!--Search Controller--> <!--Search Controller-->
<scene sceneID="3Md-yW-a0R"> <scene sceneID="3Md-yW-a0R">
<objects> <objects>
@ -232,14 +261,14 @@
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<prototypes> <prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="VehicleCell" id="VEP-QD-i6y" customClass="VehicleCell" customModule="AutoCat" customModuleProvider="target"> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="VehicleCell" id="VEP-QD-i6y" customClass="VehicleCell" customModule="AutoCat" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="375" height="85.5"/> <rect key="frame" x="0.0" y="28" width="375" height="85"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="VEP-QD-i6y" id="8hH-8I-XLB"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="VEP-QD-i6y" id="8hH-8I-XLB">
<rect key="frame" x="0.0" y="0.0" width="375" height="85.5"/> <rect key="frame" x="0.0" y="0.0" width="375" height="85"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Kia (JF) Optima" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AQY-7N-q8D"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Kia (JF) Optima" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AQY-7N-q8D">
<rect key="frame" x="8" y="8" width="124" height="21.5"/> <rect key="frame" x="8" y="8" width="124" height="21"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/> <fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
@ -251,7 +280,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cvf-vM-QnT" customClass="PlateView" customModule="AutoCat" customModuleProvider="target"> <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cvf-vM-QnT" customClass="PlateView" customModule="AutoCat" customModuleProvider="target">
<rect key="frame" x="8" y="37.5" width="317" height="40"/> <rect key="frame" x="8" y="37" width="317" height="40"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="40" id="Xoz-Iw-PCU"/> <constraint firstAttribute="height" constant="40" id="Xoz-Iw-PCU"/>

View File

@ -0,0 +1,61 @@
import UIKit
import MapKit
class EventPin: NSObject, MKAnnotation {
var coordinate: CLLocationCoordinate2D
var title: String?
var subtitle: String?
init(coordinate: CLLocationCoordinate2D, title: String?, subtitle: String) {
self.coordinate = coordinate
self.title = title
self.subtitle = subtitle
}
}
class EventsController: UIViewController {
@IBOutlet weak var map: MKMapView!
public var events: [VehicleEvent] = [] {
didSet {
self.pins = self.events.map { event in
let coordinate = CLLocationCoordinate2D(latitude: event.latitude, longitude: event.longitude)
let subtitle = event.address ?? "\(event.latitude), \(event.longitude)"
let date = Date(timeIntervalSince1970: event.date)
let formatter = DateFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .short
let title = formatter.string(from: date)
return EventPin(coordinate: coordinate, title: title, subtitle: subtitle)
}
}
}
private var pins: [EventPin] = []
override func viewDidLoad() {
super.viewDidLoad()
self.map.addAnnotations(self.pins)
self.centerMap()
}
func centerMap() {
var minLat = 0.0, maxLat = 0.0, minLon = 0.0, maxLon = 0.0
for event in self.events {
if event.latitude < minLat || minLat == 0 { minLat = event.latitude }
if event.latitude > maxLat || maxLat == 0 { maxLat = event.latitude }
if event.longitude < minLon || minLon == 0 { minLon = event.longitude }
if event.longitude > maxLon || maxLon == 0 { maxLon = event.longitude }
}
let center = CLLocationCoordinate2D(latitude: (minLat + maxLat)/2, longitude: (minLon + maxLon)/2)
let leftTop = CLLocation(latitude: minLat, longitude: minLon)
let rightBottom = CLLocation(latitude: maxLat, longitude: maxLon)
let diagonal = leftTop.distance(from: rightBottom)
let region = MKCoordinateRegion(center: center, latitudinalMeters: diagonal, longitudinalMeters: diagonal)
self.map.setRegion(region, animated: true)
}
}

View File

@ -248,12 +248,17 @@ class ReportController: UIViewController, UICollectionViewDataSource, UICollecti
} }
if indexPath.section == ReportSection.general.rawValue { if indexPath.section == ReportSection.general.rawValue {
if indexPath.row == ReportGeneralSection.owners.rawValue {
let sb = UIStoryboard(name: "Main", bundle: nil) let sb = UIStoryboard(name: "Main", bundle: nil)
if indexPath.row == ReportGeneralSection.owners.rawValue {
let controller = sb.instantiateViewController(identifier: "OwnersController") as OwnersController let controller = sb.instantiateViewController(identifier: "OwnersController") as OwnersController
controller.owners = self.vehicle?.ownershipPeriods.toArray() ?? [] controller.owners = self.vehicle?.ownershipPeriods.toArray() ?? []
self.navigationController?.pushViewController(controller, animated: true) self.navigationController?.pushViewController(controller, animated: true)
} }
else if let events = self.vehicle?.events, indexPath.row == ReportGeneralSection.events.rawValue && events.count > 0 {
let controller = sb.instantiateViewController(identifier: "EventsController") as EventsController
controller.events = Array(events)
self.navigationController?.pushViewController(controller, animated: true)
}
} }
} }

View File

@ -3,8 +3,9 @@ import Foundation
enum Constants { enum Constants {
static var baseUrl: String { static var baseUrl: String {
#if DEBUG #if DEBUG
return "http://192.168.1.67:3000/" //return "http://127.0.0.1:3000/"
//return "https://vps.aliencat.pro:8443/" //return "http://192.168.1.67:3000/"
return "https://vps.aliencat.pro:8443/"
#else #else
return "https://vps.aliencat.pro:8443/" return "https://vps.aliencat.pro:8443/"
#endif #endif