Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Commit

Permalink
Add files
Browse files Browse the repository at this point in the history
  • Loading branch information
okhanokbay committed Mar 10, 2018
1 parent e145be4 commit 2b4fb9e
Show file tree
Hide file tree
Showing 145 changed files with 11,053 additions and 325 deletions.
285 changes: 84 additions & 201 deletions Example/MapViewPlus.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Example/MapViewPlus.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 0 additions & 46 deletions Example/MapViewPlus/Base.lproj/LaunchScreen.xib

This file was deleted.

30 changes: 0 additions & 30 deletions Example/MapViewPlus/Base.lproj/Main.storyboard

This file was deleted.

41 changes: 41 additions & 0 deletions Example/MapViewPlus/BasicCalloutView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// BasicCalloutView.swift
// MapViewPlus
//
// Created by Okhan on 07/03/2018.
// Copyright © 2018 okhanokbay. All rights reserved.
//

import UIKit
import MapViewPlus

public protocol BasicCalloutViewModelDelegate: class {
func detailButtonTapped(withTitle title: String)
}

class BasicCalloutView: UIView {

weak var delegate: BasicCalloutViewModelDelegate?

@IBOutlet weak var label: UILabel!
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var button: UIButton!

override func awakeFromNib() {
super.awakeFromNib()
isUserInteractionEnabled = true
}

@IBAction func buttonTouchDown(_ sender: Any) {
delegate?.detailButtonTapped(withTitle: label.text!)
}
}

extension BasicCalloutView: CalloutViewPlus{
func configureCallout(_ viewModel: CalloutViewModel) {
let viewModel = viewModel as! BasicCalloutViewModel

label.text = viewModel.title
imageView.image = viewModel.image
}
}
70 changes: 70 additions & 0 deletions Example/MapViewPlus/BasicCalloutView.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="BasicCalloutView" customModule="MapViewPlus_Example" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="147" height="210"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="Ne5-pO-Nm2">
<rect key="frame" x="20" y="8" width="107" height="27"/>
<constraints>
<constraint firstAttribute="height" constant="27" id="Wal-Di-08P"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="DPZ-Gw-bHf">
<rect key="frame" x="28.5" y="43" width="90" height="99"/>
<constraints>
<constraint firstAttribute="width" constant="90" id="dtA-He-cA9"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hDy-bk-NGK">
<rect key="frame" x="28.5" y="154" width="90" height="44"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="90" id="Xxt-h0-Ztm"/>
<constraint firstAttribute="height" constant="44" id="YpJ-AQ-1UT"/>
</constraints>
<state key="normal" title="Detail">
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="buttonTouchDown:" destination="iN0-l3-epB" eventType="touchDown" id="fe6-QP-rRm"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.50196081400000003" green="0.0" blue="0.25098040700000002" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="hDy-bk-NGK" firstAttribute="top" secondItem="DPZ-Gw-bHf" secondAttribute="bottom" constant="12" id="BFf-YQ-pSk"/>
<constraint firstItem="Ne5-pO-Nm2" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="8" id="Ows-tq-dOt"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="Ne5-pO-Nm2" secondAttribute="trailing" constant="20" id="P7v-vK-b1b"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="hDy-bk-NGK" secondAttribute="bottom" constant="12" id="XAL-Ob-t14"/>
<constraint firstItem="DPZ-Gw-bHf" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="fDk-Vi-vR4"/>
<constraint firstItem="Ne5-pO-Nm2" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="fcT-AB-7Xa"/>
<constraint firstItem="DPZ-Gw-bHf" firstAttribute="top" secondItem="Ne5-pO-Nm2" secondAttribute="bottom" constant="8" id="lRy-2l-geC"/>
<constraint firstItem="hDy-bk-NGK" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="tjP-pB-vUl"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<connections>
<outlet property="button" destination="hDy-bk-NGK" id="HI0-AU-qvf"/>
<outlet property="imageView" destination="DPZ-Gw-bHf" id="XVB-v5-92b"/>
<outlet property="label" destination="Ne5-pO-Nm2" id="Gtp-Nq-lsC"/>
</connections>
<point key="canvasLocation" x="-198" y="-198"/>
</view>
</objects>
</document>
20 changes: 20 additions & 0 deletions Example/MapViewPlus/BasicCalloutViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// BasicCalloutViewModel.swift
// MapViewPlus
//
// Created by Okhan on 07/03/2018.
// Copyright © 2018 okhanokbay. All rights reserved.
//

import UIKit
import MapViewPlus

class BasicCalloutViewModel: CalloutViewModel {
var title: String
var image: UIImage

init(title: String, image: UIImage) {
self.title = title
self.image = image
}
}
71 changes: 71 additions & 0 deletions Example/MapViewPlus/BasicExampleViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// BasicExampleViewController.swift
// MapViewPlus
//
// Created by Okhan on 07/03/2018.
// Copyright © 2018 okhanokbay. All rights reserved.
//

import UIKit
import CoreLocation
import MapViewPlus

class BasicExampleViewController: UIViewController {

@IBOutlet weak var mapView: MapViewPlus!
weak var currentCalloutView: UIView?

override func viewDidLoad() {
super.viewDidLoad()

self.navigationItem.title = "Basic Example"

mapView.delegate = self //Required

var annotations: [AnnotationPlus] = []

annotations.append(AnnotationPlus.init(viewModel: BasicCalloutViewModel.init(title: "Cafe", image: UIImage(named: "cafe.png")!), coordinate: CLLocationCoordinate2DMake(50.11, 8.68)))

annotations.append(AnnotationPlus.init(viewModel: BasicCalloutViewModel.init(title: "Factory", image: UIImage(named: "factory.png")!), coordinate: CLLocationCoordinate2DMake(50.85, 4.35)))

annotations.append(AnnotationPlus.init(viewModel: BasicCalloutViewModel.init(title: "House", image: UIImage(named: "house.png")!), coordinate: CLLocationCoordinate2DMake(48.85, 2.35)))

annotations.append(AnnotationPlus.init(viewModel: BasicCalloutViewModel.init(title: "Skyscraper", image: UIImage(named: "skyscraper.png")!), coordinate:CLLocationCoordinate2DMake(46.2039, 6.1400)))

mapView.setup(withAnnotations: annotations)

mapView.anchorViewCustomizerDelegate = self
}
}

extension BasicExampleViewController: MapViewPlusDelegate {
func mapView(_ mapView: MapViewPlus, imageFor annotation: AnnotationPlus) -> UIImage {
return UIImage(named: "basic_annotation_image.png")!
}

func mapView(_ mapView: MapViewPlus, calloutViewFor annotationView: AnnotationViewPlus) -> CalloutViewPlus{
let calloutView = Bundle.main.loadNibNamed("BasicCalloutView", owner: nil, options: nil)!.first as! BasicCalloutView
calloutView.delegate = self
currentCalloutView = calloutView
return calloutView
}

// Optional
func mapView(_ mapView: MapViewPlus, didAddAnnotations annotations: [AnnotationPlus]) {
mapView.showAnnotations(annotations, animated: true)
}
}

extension BasicExampleViewController: AnchorViewCustomizerDelegate {
func mapView(_ mapView: MapViewPlus, fillColorForAnchorOf calloutView: CalloutViewPlus) -> UIColor {
return currentCalloutView?.backgroundColor ?? mapView.defaultFillColorForAnchors
}
}

extension BasicExampleViewController: BasicCalloutViewModelDelegate {
func detailButtonTapped(withTitle title: String) {
let alert = UIAlertController.init(title: "\(title) tapped", message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction.init(title: "OK", style: .cancel, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
74 changes: 74 additions & 0 deletions Example/MapViewPlus/DefaultCalloutViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// ViewController.swift
// MapViewPlus
//
// Created by Okhan on 18/08/17.
// Copyright © 2017 okhanokbay. All rights reserved.
//

import UIKit
import MapKit
import MapViewPlus
import CoreLocation

class DefaultCalloutViewController: UIViewController {

@IBOutlet weak var mapView: MapViewPlus!

override func viewDidLoad() {
super.viewDidLoad()

self.navigationItem.title = "Default Callout View"

let annotations = [
AnnotationPlus.init(viewModel: DefaultCalloutViewModel.init(title: "Paris"), coordinate: CLLocationCoordinate2DMake(48.85, 2.35)),

AnnotationPlus.init(viewModel: DefaultCalloutViewModel.init(title: "Geneva", subtitle: "Switzerland", imageType: .downloadable(imageURL: URL.init(string: "https://media.istockphoto.com/photos/urban-view-with-famous-fountain-geneva-switzerland-hdr-picture-id477159306?k=6&m=477159306&s=612x612&w=0&h=NwvReV5kYj0M939OkdVenOSQvU4d0eGmqJcbwx_Qsr4=")!, placeholder: #imageLiteral(resourceName: "PlaceholderDark")), theme: .light, detailButtonType: .detailDisclosure), coordinate: CLLocationCoordinate2DMake(46.2039, 6.1400)),

AnnotationPlus.init(viewModel: DefaultCalloutViewModel.init(title: "Brussels", imageType: .downloadable(imageURL: URL.init(string: "https://cdn.pixabay.com/photo/2016/07/22/14/58/brussels-1534989_960_720.jpg")!, placeholder: #imageLiteral(resourceName: "PlaceholderLight")), theme: .dark, detailButtonType: .info), coordinate: CLLocationCoordinate2DMake(50.85, 4.35))]

mapView.delegate = self // Must conform to this to make it work.
mapView.setup(withAnnotations: annotations)
}
}

extension DefaultCalloutViewController: MapViewPlusDelegate {
func mapView(_ mapView: MapViewPlus, imageFor annotation: AnnotationPlus) -> UIImage {
return #imageLiteral(resourceName: "AnnotationImage")
}

func mapView(_ mapView: MapViewPlus, calloutViewFor annotationView: AnnotationViewPlus) -> CalloutViewPlus{
let calloutView = MapViewPlusTemplateHelper.defaultCalloutView

// Below two are:
// Required if DefaultCalloutView is being used
// Optional if you are using your own callout view
mapView.calloutViewCustomizerDelegate = calloutView
mapView.anchorViewCustomizerDelegate = calloutView

//Optional. Conform to this if you want button click delegate method to be called.
calloutView.delegate = self

return calloutView
}

// Optional
func mapView(_ mapView: MapViewPlus, didAddAnnotations annotations: [AnnotationPlus]) {
mapView.showAnnotations(annotations, animated: true)
}

// Optional. Just to show that delegate forwarding is actually working.
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
print("This method is being forwarded to you by MapViewPlusDelegate")
}
}

extension DefaultCalloutViewController: DefaultCalloutViewDelegate {
func buttonDetailTapped(with viewModel: DefaultCalloutViewModelProtocol, buttonType: DefaultCalloutViewButtonType) {
let alert = UIAlertController(title: buttonType == .background ? "Background Tapped" : "Detail Button Tapped", message: viewModel.title + " " + (viewModel.subtitle ?? ""), preferredStyle: .alert)
let confirmAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(confirmAction)
self.present(alert, animated: true, completion: nil)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2b4fb9e

Please sign in to comment.