Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2024-02-08 16:45:42 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9e18ea3676eaa5c58c7c081d7992ff90cbcd93de
9e18ea36
1 parent
1d57e9fa
Add MapViewController
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
151 additions
and
76 deletions
SwiftWarplyFramework/SwiftWarplyFramework/Main.storyboard
SwiftWarplyFramework/SwiftWarplyFramework/MapViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/Main.storyboard
View file @
9e18ea3
...
...
@@ -4367,66 +4367,6 @@
<outlet
property=
"titleLabel"
destination=
"qfZ-mQ-mRL"
id=
"1Bw-YT-TGA"
/>
</connections>
</tableViewCell>
<tableViewCell
clipsSubviews=
"YES"
contentMode=
"scaleToFill"
insetsLayoutMarginsFromSafeArea=
"NO"
selectionStyle=
"none"
hidesAccessoryWhenEditing=
"NO"
indentationLevel=
"1"
indentationWidth=
"0.0"
reuseIdentifier=
"InboxTableViewCellId"
id=
"tNJ-bm-aGv"
customClass=
"InboxTableViewCell"
customModule=
"SwiftWarplyFramework"
customModuleProvider=
"target"
>
<rect
key=
"frame"
x=
"0.0"
y=
"338"
width=
"414"
height=
"78.5"
/>
<autoresizingMask
key=
"autoresizingMask"
/>
<tableViewCellContentView
key=
"contentView"
opaque=
"NO"
clipsSubviews=
"YES"
multipleTouchEnabled=
"YES"
contentMode=
"center"
insetsLayoutMarginsFromSafeArea=
"NO"
tableViewCell=
"tNJ-bm-aGv"
id=
"A90-Li-IDd"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"78.5"
/>
<autoresizingMask
key=
"autoresizingMask"
/>
<subviews>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Iar-hb-ngF"
>
<rect
key=
"frame"
x=
"20"
y=
"0.0"
width=
"374"
height=
"78.5"
/>
<subviews>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFill"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"q3d-Y7-YoH"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"205.5"
height=
"78.5"
/>
</imageView>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Label"
textAlignment=
"center"
lineBreakMode=
"tailTruncation"
numberOfLines=
"0"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"dNf-ph-58z"
>
<rect
key=
"frame"
x=
"215.5"
y=
"30"
width=
"148.5"
height=
"18.5"
/>
<fontDescription
key=
"fontDescription"
name=
"PeridotPE-Regular"
family=
"Peridot PE"
pointSize=
"15"
/>
<color
key=
"textColor"
red=
"0.12941176469999999"
green=
"0.12941176469999999"
blue=
"0.12941176469999999"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
<nil
key=
"highlightedColor"
/>
</label>
</subviews>
<color
key=
"backgroundColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<constraints>
<constraint
firstAttribute=
"bottom"
secondItem=
"q3d-Y7-YoH"
secondAttribute=
"bottom"
id=
"3lu-rv-RHI"
/>
<constraint
firstItem=
"dNf-ph-58z"
firstAttribute=
"leading"
secondItem=
"q3d-Y7-YoH"
secondAttribute=
"trailing"
constant=
"10"
id=
"BE4-GU-dWc"
/>
<constraint
firstItem=
"q3d-Y7-YoH"
firstAttribute=
"width"
secondItem=
"Iar-hb-ngF"
secondAttribute=
"width"
multiplier=
"0.55"
id=
"GNH-sm-qA8"
/>
<constraint
firstItem=
"q3d-Y7-YoH"
firstAttribute=
"top"
secondItem=
"Iar-hb-ngF"
secondAttribute=
"top"
id=
"H2X-D0-SQ0"
/>
<constraint
firstAttribute=
"bottom"
relation=
"greaterThanOrEqual"
secondItem=
"dNf-ph-58z"
secondAttribute=
"bottom"
constant=
"10"
id=
"HMr-jg-Egf"
/>
<constraint
firstItem=
"dNf-ph-58z"
firstAttribute=
"centerY"
secondItem=
"Iar-hb-ngF"
secondAttribute=
"centerY"
id=
"XRe-mw-R0J"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"dNf-ph-58z"
secondAttribute=
"trailing"
constant=
"10"
id=
"ZAx-jV-hle"
/>
<constraint
firstItem=
"q3d-Y7-YoH"
firstAttribute=
"leading"
secondItem=
"Iar-hb-ngF"
secondAttribute=
"leading"
id=
"d71-vY-Cgu"
/>
<constraint
firstItem=
"dNf-ph-58z"
firstAttribute=
"top"
relation=
"greaterThanOrEqual"
secondItem=
"Iar-hb-ngF"
secondAttribute=
"top"
constant=
"30"
id=
"oM5-Tj-eb3"
/>
</constraints>
</view>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
image=
"new_icon"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"0IZ-qO-cKj"
>
<rect
key=
"frame"
x=
"344"
y=
"5"
width=
"60"
height=
"25"
/>
<color
key=
"backgroundColor"
white=
"0.0"
alpha=
"0.0"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<constraints>
<constraint
firstAttribute=
"width"
constant=
"60"
id=
"ltd-9h-en3"
/>
<constraint
firstAttribute=
"height"
constant=
"25"
id=
"sjV-4S-ggn"
/>
</constraints>
</imageView>
</subviews>
<color
key=
"backgroundColor"
white=
"0.0"
alpha=
"0.0"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<constraints>
<constraint
firstItem=
"0IZ-qO-cKj"
firstAttribute=
"top"
secondItem=
"A90-Li-IDd"
secondAttribute=
"top"
constant=
"5"
id=
"1GR-gl-rM7"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"0IZ-qO-cKj"
secondAttribute=
"trailing"
constant=
"10"
id=
"6QW-pj-851"
/>
<constraint
firstItem=
"Iar-hb-ngF"
firstAttribute=
"leading"
secondItem=
"A90-Li-IDd"
secondAttribute=
"leading"
constant=
"20"
id=
"DbD-oU-ViN"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"Iar-hb-ngF"
secondAttribute=
"trailing"
constant=
"20"
id=
"IQM-tY-Clq"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"Iar-hb-ngF"
secondAttribute=
"bottom"
id=
"SKJ-aq-DIL"
/>
<constraint
firstItem=
"Iar-hb-ngF"
firstAttribute=
"top"
secondItem=
"A90-Li-IDd"
secondAttribute=
"top"
id=
"s7S-Fw-x5P"
/>
</constraints>
</tableViewCellContentView>
<color
key=
"backgroundColor"
white=
"0.0"
alpha=
"0.0"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
<connections>
<outlet
property=
"campaignImage"
destination=
"q3d-Y7-YoH"
id=
"mSE-US-ead"
/>
<outlet
property=
"campaignTitleLabel"
destination=
"dNf-ph-58z"
id=
"OL1-vm-neo"
/>
<outlet
property=
"inboxView"
destination=
"Iar-hb-ngF"
id=
"sYI-hQ-yfh"
/>
<outlet
property=
"newBadgeImage"
destination=
"0IZ-qO-cKj"
id=
"2Vu-X1-ZX6"
/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet
property=
"dataSource"
destination=
"EDh-Zo-yDu"
id=
"Few-SN-h9B"
/>
...
...
@@ -4468,17 +4408,34 @@
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
fixedFrame=
"YES"
text=
"MapViewController"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"hxt-S7-xrl"
>
<rect
key=
"frame"
x=
"127"
y=
"437"
width=
"145"
height=
"21"
/>
<autoresizingMask
key=
"autoresizingMask"
flexibleMaxX=
"YES"
flexibleMaxY=
"YES"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"17"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Rec-xf-ksW"
userLabel=
"Main View"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<subviews>
<mapView
clipsSubviews=
"YES"
multipleTouchEnabled=
"YES"
contentMode=
"scaleToFill"
mapType=
"standard"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"qZN-bc-ZwR"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
</mapView>
</subviews>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
<constraints>
<constraint
firstItem=
"qZN-bc-ZwR"
firstAttribute=
"top"
secondItem=
"Rec-xf-ksW"
secondAttribute=
"top"
id=
"4kw-W4-pBb"
/>
<constraint
firstItem=
"qZN-bc-ZwR"
firstAttribute=
"leading"
secondItem=
"Rec-xf-ksW"
secondAttribute=
"leading"
id=
"6ig-4b-zI9"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"qZN-bc-ZwR"
secondAttribute=
"bottom"
id=
"9X2-xK-rUq"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"qZN-bc-ZwR"
secondAttribute=
"trailing"
id=
"L0O-xh-DcY"
/>
</constraints>
</view>
</subviews>
<viewLayoutGuide
key=
"safeArea"
id=
"bFi-bg-SVE"
/>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
<constraints>
<constraint
firstAttribute=
"trailing"
secondItem=
"Rec-xf-ksW"
secondAttribute=
"trailing"
id=
"BQY-2F-4YR"
/>
<constraint
firstItem=
"Rec-xf-ksW"
firstAttribute=
"top"
secondItem=
"YX1-Nw-62m"
secondAttribute=
"top"
id=
"HBe-12-Juu"
/>
<constraint
firstItem=
"Rec-xf-ksW"
firstAttribute=
"leading"
secondItem=
"YX1-Nw-62m"
secondAttribute=
"leading"
id=
"OjV-oz-5gW"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"Rec-xf-ksW"
secondAttribute=
"bottom"
id=
"uP7-ob-anK"
/>
</constraints>
</view>
<connections>
<outlet
property=
"mapView"
destination=
"qZN-bc-ZwR"
id=
"3WA-X6-PXu"
/>
</connections>
</viewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"7av-3d-VKz"
userLabel=
"First Responder"
customClass=
"UIResponder"
sceneMemberID=
"firstResponder"
/>
</objects>
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MapViewController.swift
View file @
9e18ea3
...
...
@@ -5,25 +5,143 @@
// Created by Manos Chorianopoulos on 7/2/24.
//
import
UIKit
import
MapKit
@objc
public
class
MapViewController
:
UIViewController
,
MKMapViewDelegate
{
@IBOutlet
private
var
mapView
:
MKMapView
!
var
merchantsArray
:
Array
<
swiftApi
.
MerchantModel
>
=
[]
@objc
public
class
MapViewController
:
UIViewController
{
var
loading
:
Bool
=
false
let
initialLocation
=
CLLocation
(
latitude
:
37.9641262
,
longitude
:
23.7468592
)
// greece
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
// self.hidesBottomBarWhenPushed = true
mapView
.
delegate
=
self
mapView
.
centerToLocation
(
initialLocation
,
regionRadius
:
1000000
)
load
()
}
public
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
// self.navigationController?.hideHairline()
}
@objc
func
load
()
{
if
(
loading
)
{
return
;
}
showLoading
()
self
.
merchantsArray
=
generateRandomMerchantsInGreece
()
self
.
loadMapPins
()
showContent
()
}
func
generateRandomMerchantsInGreece
()
->
Array
<
swiftApi
.
MerchantModel
>
{
// Define the approximate bounding box coordinates for Greece
let
greeceBoundingBox
=
MKCoordinateRegion
(
center
:
CLLocationCoordinate2D
(
latitude
:
38.5
,
longitude
:
23.0
),
span
:
MKCoordinateSpan
(
latitudeDelta
:
2.0
,
longitudeDelta
:
3.0
)
)
// Generate 10 random merchants within Greece's bounding box
var
randomMerchants
:
Array
<
swiftApi
.
MerchantModel
>
=
[]
for
_
in
1
...
10
{
let
randomLatitude
=
Double
.
random
(
in
:
greeceBoundingBox
.
center
.
latitude
-
greeceBoundingBox
.
span
.
latitudeDelta
/
2
...
greeceBoundingBox
.
center
.
latitude
+
greeceBoundingBox
.
span
.
latitudeDelta
/
2
)
let
randomLongitude
=
Double
.
random
(
in
:
greeceBoundingBox
.
center
.
longitude
-
greeceBoundingBox
.
span
.
longitudeDelta
/
2
...
greeceBoundingBox
.
center
.
longitude
+
greeceBoundingBox
.
span
.
longitudeDelta
/
2
)
let
randomMerchant
=
swiftApi
.
MerchantModel
()
randomMerchant
.
_latitude
=
randomLatitude
randomMerchant
.
_longitude
=
randomLongitude
randomMerchants
.
append
(
randomMerchant
)
}
return
randomMerchants
}
// Do any additional setup after loading the view.
private
func
showLoading
()
{
loading
=
true
}
private
func
showContent
()
{
loading
=
false
}
private
func
loadMapPins
()
{
for
item
in
merchantsArray
{
let
pin
=
MerchantAnnotation
(
item
)
if
let
annotationView
=
mapView
.
view
(
for
:
pin
)
{
annotationView
.
isEnabled
=
false
}
mapView
.
addAnnotation
(
pin
)
}
}
// map view delegate
public
func
mapView
(
_
mapView
:
MKMapView
,
viewFor
annotation
:
MKAnnotation
)
->
MKAnnotationView
?
{
/*
// MARK: - Navigation
// guard !(annotation is MKUserLocation) else {
// return nil
// }
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
var
annotationView
=
mapView
.
dequeueReusableAnnotationView
(
withIdentifier
:
"warply_custom"
)
if
(
annotationView
==
nil
)
{
annotationView
=
MKAnnotationView
(
annotation
:
annotation
,
reuseIdentifier
:
"warply_custom"
)
annotationView
?
.
canShowCallout
=
false
}
else
{
annotationView
?
.
annotation
=
annotation
}
// custom pin image
let
customImageSize
=
CGSize
(
width
:
60
,
height
:
50
)
annotationView
?
.
image
=
UIImage
(
named
:
"map_marker"
,
in
:
MyEmptyClass
.
resourceBundle
(),
compatibleWith
:
nil
)
annotationView
?
.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
customImageSize
.
width
,
height
:
customImageSize
.
height
)
// Add shadow
annotationView
?
.
layer
.
shadowColor
=
UIColor
(
red
:
0.00
,
green
:
0.00
,
blue
:
0.00
,
alpha
:
0.16
)
.
cgColor
annotationView
?
.
layer
.
shadowOffset
=
CGSize
(
width
:
0.0
,
height
:
3.0
)
annotationView
?
.
layer
.
shadowOpacity
=
1.0
annotationView
?
.
layer
.
shadowRadius
=
6.0
return
annotationView
}
*/
public
func
mapView
(
_
mapView
:
MKMapView
,
didSelect
view
:
MKAnnotationView
)
{
// Disable the default behavior of selecting and zooming in on the pin
mapView
.
deselectAnnotation
(
view
.
annotation
,
animated
:
false
)
}
public
func
mapView
(
_
mapView
:
MKMapView
,
didDeselect
view
:
MKAnnotationView
)
{
}
}
private
extension
MKMapView
{
func
centerToLocation
(
_
location
:
CLLocation
,
regionRadius
:
CLLocationDistance
=
1000
)
{
let
coordinateRegion
=
MKCoordinateRegion
(
center
:
location
.
coordinate
,
latitudinalMeters
:
regionRadius
,
longitudinalMeters
:
regionRadius
)
setRegion
(
coordinateRegion
,
animated
:
true
)
}
}
...
...
Please
register
or
login
to post a comment