Manos Chorianopoulos

MapsViewController ui fixes

......@@ -29,7 +29,8 @@ private extension CSMButton {
setImage(UIImage(named: "ic_directions", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
setTitleColor(.white, for: .normal)
backgroundColor = UIColor(rgb: 0x79BF14)
// backgroundColor = UIColor(rgb: 0x79BF14)
backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
layer.cornerRadius = 12.0
imageEdgeInsets = UIEdgeInsets(top:0.0, left:0.0, bottom:0.0, right:5.0);
......
......@@ -21,9 +21,11 @@ import MapKit
@IBOutlet private var hoursView: UILabel!
@IBOutlet private var phoneView: UILabel!
@IBOutlet private var addressView: UILabel!
@IBOutlet private var directionsButton: CSMButton!
@IBOutlet private var directionsButton: UIButton!
@IBOutlet private var infoTopConstraint: NSLayoutConstraint!
@IBOutlet weak var topBorderLine: UIImageView!
@IBOutlet weak var phoneImageView: UIImageView!
@IBOutlet weak var addressImageView: UIImageView!
// public
public var couponSet: swiftApi.CouponSetItemModel?
......@@ -48,6 +50,8 @@ import MapKit
setNavigationTitle("Καταστήματα")
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
phoneImageView.image = UIImage(named: "ic_phone", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
addressImageView.image = UIImage(named: "ic_address", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
mapView.delegate = self
mapView.centerToLocation(initialLocation, regionRadius: 1000000)
......@@ -56,25 +60,26 @@ import MapKit
// mapView.layer.cornerRadius = 30
// mapView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
var aspectR: CGFloat = 0.0
aspectR = image.size.width/image.size.height
topBorderLine.translatesAutoresizingMaskIntoConstraints = false
topBorderLine.image = image
topBorderLine.contentMode = .scaleAspectFill
// let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
NSLayoutConstraint.activate([
topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
])
// topBorderLine.translatesAutoresizingMaskIntoConstraints = false
// topBorderLine.image = image
// topBorderLine.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
// ])
closeButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
closeButton.setImage(UIImage(named: "ic_close_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
titleView.font = UIFont(name: "PFSquareSansPro-Bold", size: 19)
titleView.textColor = UIColor(rgb: 0x757575)
......@@ -94,13 +99,18 @@ import MapKit
//directionsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
directionsButton.setTitle("Οδηγίες", for: .normal)
directionsButton.setImage(UIImage(named: "ic_directions", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
// directionsButton.sizeToFit()
directionsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
directionsButton.setTitleColor(.white, for: .normal)
directionsButton.tintColor = .white
directionsButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
directionsButton.layer.cornerRadius = 16.0
// directionsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
// directionsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
// directionsButton.sizeToFit()
//directionsButton.setTitleColor(.white, for: .normal)
//directionsButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00)
//directionsButton.layer.cornerRadius = 12.0
directionsButton.frame = CGRect(x: 0.0, y: 0.0, width: directionsButton.intrinsicContentSize.width+10, height: 50)
// directionsButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15)
directionsButton.setInsets(forContentPadding: UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15), imageTitlePadding: 10)
load()
}
......@@ -149,16 +159,16 @@ import MapKit
let filteredMerchants = (merchantsData ?? []).filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
if (self.isMarket == true) {
// if (self.isMarket == true) {
self.merchantsArray = filteredMerchants
if let parent = (merchantsData ?? []).first(where: {(($0._latitude == 0.0) && ($0._longitude == 0.0))}) {
self.parentMerchant = parent
}
} else {
self.merchantsArray = merchantsData ?? []
}
// } else {
// self.merchantsArray = merchantsData ?? []
// }
self.loadMapPins()
......@@ -318,7 +328,8 @@ import MapKit
private func loadPinDetailsView(_ annotation: MerchantAnnotation) {
self.selectedMerchant = annotation.model
self.titleView.text = self.selectedMerchant?._admin_name
// self.titleView.text = self.selectedMerchant?._admin_name
self.titleView.text = self.parentMerchant?._admin_name
if (self.isMarket == true) {
self.nameImageView.load(link: self.parentMerchant?._img_preview ?? "", placeholder: UIImage(), cache: URLCache())
......
......@@ -607,3 +607,23 @@ extension UIView {
layer.mask = shape
}
}
extension UIButton {
func setInsets(
forContentPadding contentPadding: UIEdgeInsets,
imageTitlePadding: CGFloat
) {
self.contentEdgeInsets = UIEdgeInsets(
top: contentPadding.top,
left: contentPadding.left,
bottom: contentPadding.bottom,
right: contentPadding.right + imageTitlePadding
)
self.titleEdgeInsets = UIEdgeInsets(
top: 0,
left: imageTitlePadding,
bottom: 0,
right: -imageTitlePadding
)
}
}
......