Commit 64307c70 by Julio Hermosa

Se corrige error al obtener la información de algunos pedidos (por campos…

Se corrige error al obtener la información de algunos pedidos (por campos nulos, se cambia a opcional la variable picture en el struct )
parent 574b8ff0
......@@ -42,7 +42,7 @@ struct Request: Codable {
let title, message, name, phone: String
let address, city: String
let location: Location
let picture: String
let picture: String?
let active: Bool
let added: String
}
......
......@@ -32,47 +32,51 @@
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<navigationItem key="navigationItem" id="Dzc-XL-JCT"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="133" y="153"/>
<point key="canvasLocation" x="71" y="152"/>
</scene>
<!--Pendings View Controller-->
<scene sceneID="1wO-Og-nyO">
<objects>
<viewController storyboardIdentifier="pendientesVC" id="Ncc-gI-9dq" customClass="PendingsViewController" customModule="ayudapy" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="s2s-eb-0xG">
<rect key="frame" x="0.0" y="0.0" width="500" height="896"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="124" estimatedRowHeight="-1" sectionHeaderHeight="50" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="FJC-EV-fMA">
<rect key="frame" x="0.0" y="44" width="500" height="818"/>
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="110" id="D8e-6i-a9c" customClass="MyPendingsTableViewCell" customModule="ayudapy" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="500" height="110"/>
<rect key="frame" x="0.0" y="28" width="414" height="110"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="D8e-6i-a9c" id="aAc-DI-Gps">
<rect key="frame" x="0.0" y="0.0" width="500" height="110"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="110"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6Nx-7P-kFB">
<rect key="frame" x="20" y="11" width="460" height="88"/>
<stackView opaque="NO" contentMode="scaleToFill" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="6Nx-7P-kFB">
<rect key="frame" x="20" y="11" width="374" height="88"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="5uy-us-Ehr">
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="5uy-us-Ehr">
<rect key="frame" x="0.0" y="0.0" width="70" height="88"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="25" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rt6-8B-njG">
<rect key="frame" x="0.0" y="0.0" width="70" height="42"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="30" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rt6-8B-njG">
<rect key="frame" x="0.0" y="0.0" width="70" height="58"/>
<constraints>
<constraint firstAttribute="height" constant="42" id="Wfx-VK-I1j"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="35"/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="40"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Month" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A6k-4E-FiW">
<rect key="frame" x="0.0" y="42" width="70" height="46"/>
<rect key="frame" x="0.0" y="58" width="70" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="Tjm-E6-mBu"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
......@@ -80,31 +84,42 @@
</subviews>
<constraints>
<constraint firstAttribute="width" constant="70" id="WeG-F5-Sa1"/>
<constraint firstAttribute="height" constant="88" id="ZkU-Gs-4vz"/>
</constraints>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="Arg-Pc-Vth">
<rect key="frame" x="70" y="0.0" width="390" height="88"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oVa-l8-Iq5">
<rect key="frame" x="80" y="0.0" width="2" height="88"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="2" id="k6q-fo-91W"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="TopLeft" axis="vertical" distribution="fillProportionally" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="Arg-Pc-Vth">
<rect key="frame" x="92" y="0.0" width="282" height="88"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dIv-9y-AeI">
<rect key="frame" x="0.0" y="0.0" width="33.5" height="45"/>
<rect key="frame" x="0.0" y="0.0" width="33.5" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="sFK-1c-khk"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="TopLeft" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Details" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="6" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J2F-4P-f1j">
<rect key="frame" x="0.0" y="45" width="50" height="43"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="TopLeft" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Details" lineBreakMode="tailTruncation" numberOfLines="6" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J2F-4P-f1j">
<rect key="frame" x="0.0" y="20" width="50" height="68"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<color key="textColor" cocoaTouchSystemColor="viewFlipsideBackgroundColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<constraints>
<constraint firstItem="Arg-Pc-Vth" firstAttribute="top" secondItem="6Nx-7P-kFB" secondAttribute="top" id="B8U-Kh-5qj"/>
<constraint firstAttribute="bottom" secondItem="Arg-Pc-Vth" secondAttribute="bottom" id="B8c-71-2BS"/>
<constraint firstItem="5uy-us-Ehr" firstAttribute="top" secondItem="6Nx-7P-kFB" secondAttribute="top" id="TfY-P8-ksI"/>
<constraint firstItem="5uy-us-Ehr" firstAttribute="leading" secondItem="6Nx-7P-kFB" secondAttribute="leading" id="VVJ-Q5-bRh"/>
<constraint firstItem="Arg-Pc-Vth" firstAttribute="leading" secondItem="5uy-us-Ehr" secondAttribute="trailing" id="nX0-uu-DC8"/>
<constraint firstAttribute="trailing" secondItem="Arg-Pc-Vth" secondAttribute="trailing" id="ZxU-5c-o8H"/>
<constraint firstAttribute="bottom" secondItem="5uy-us-Ehr" secondAttribute="bottom" id="yJZ-zv-3j7"/>
</constraints>
</stackView>
......@@ -135,14 +150,13 @@
</constraints>
<viewLayoutGuide key="safeArea" id="xjn-bv-SjL"/>
</view>
<size key="freeformSize" width="500" height="896"/>
<connections>
<outlet property="tableView" destination="FJC-EV-fMA" id="z3n-NG-YzE"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="jba-kr-XcD" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="131.8840579710145" y="810.9375"/>
<point key="canvasLocation" x="70" y="808"/>
</scene>
<!--Info View Controller-->
<scene sceneID="7G2-hN-2Te">
......@@ -201,7 +215,24 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="7cy-pi-7CO" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="828.98550724637687" y="152.67857142857142"/>
<point key="canvasLocation" x="748" y="153"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="iaO-rv-Znt">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" navigationBarHidden="YES" id="Q6w-uW-cQ2" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="jQr-bH-FP1">
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="U2f-dO-whx"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="2Ff-bq-Mdq" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="70" y="-532"/>
</scene>
</scenes>
<resources>
......
......@@ -22,6 +22,7 @@ class MapViewController: UIViewController {
let format:Format = Format.init()
var bbox = String()
var id = Int()
var favorites = [Entity]()
let defaultLocation = CLLocation(latitude: -57.5879897, longitude: -43.2723609)
//-57.5879897,-43.2723609 -> Posición de Roshka
......@@ -138,14 +139,14 @@ class MapViewController: UIViewController {
let long = features[i].geometry.coordinates[0]
self.id = features[i].properties.pk
let position = CLLocationCoordinate2D(latitude: lat, longitude: long)
let markerView = UIView(frame: CGRect(x: 0, y: 0, width: 24, height: 30))
let markerButton = UIButton(frame: CGRect(x: 0, y: 0, width: 24, height: 30))
markerView.addSubview(markerButton)
let markerView = UIView(frame: CGRect(x: 0, y: 0, width: 30, height: 35))
let markerButton = UIButton(frame: CGRect(x: 0, y: 0, width: 30, height: 35))
markerButton.addTarget(self, action: #selector(self.goToInfo), for: .touchUpInside)
let pin = self.addPins(id: self.id)
markerButton.setImage(pin, for: .normal)
print("Nombre\(pin)")
markerButton.setImage(UIImage(named: pin), for: .normal)
markerView.addSubview(markerButton)
let marker = GMSMarker(position: position)
marker.map = self.mapView
marker.iconView = markerView
marker.title = "\(features[i].properties.pk)"
......@@ -173,15 +174,30 @@ class MapViewController: UIViewController {
}
//Verificamos si el marcador corresponde a un favorito y agregamos la imagen correspondiente
func addPins(id: Int)->UIImage{
let array = manager.fetchFavorites()
var pinImage = UIImage(named: "pinGMAPS")
for i in 0 ..< array.count{
if array[i].id == Int64(id) {
pinImage = UIImage(named: "pinFavGMAPS")
func addPins(id: Int)->String{
//let array = manager.fetchFavorites()
var named = String()
if favorites.count > 0{
for i in 0 ..< favorites.count{
if favorites[i].id == Int64(id) {
print("es favorito")
named = "pinFavGMAPS"
}
else {
print("no es favorito")
named = "pinGMAPS"
}
}
return pinImage!
}
else{
named = "pinGMAPS"
}
return named
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
favorites = manager.fetchFavorites()
}
......
......@@ -19,22 +19,11 @@ class MyPendingsTableViewCell: UITableViewCell {
@IBOutlet weak var monthLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var detailLabel: UILabel!
@IBOutlet weak var deleteButton: UIButton!
// @IBAction func deleteRow(_ sender: Any) {
// array = manager.fetchFavorites()
// print(id)
// manager.deleteFavorites(id: id, array: array)
// }
override func awakeFromNib() {
super.awakeFromNib()
dayLabel.textColor = format.subTitleTextColor
monthLabel.textColor = format.titleTextColor
}
override func setSelected(_ selected: Bool, animated: Bool) {
......
......@@ -9,44 +9,35 @@
import UIKit
import CoreData
struct MyPendings{
var id: Int
var title: String?
var message: String?
var date: String?
var address: String?
var contactNumber: String?
var contactName: String?
}
class PendingsViewController: UIViewController {
let manager = CoreDataManager()
var array = [Entity]()
var myPendings = [MyPendings]()
let format = Format.init()
@IBOutlet weak var tableView: UITableView!
func goToRequestViewController(pk: Int){
let pedidosVC = self.storyboard?.instantiateViewController(withIdentifier: "pedidosVC")as! RequestViewController
pedidosVC.id = pk
print("ID del pedido: \(pk)")
pedidosVC.helpRequest()
//show(pedidosVC, sender: nil)
present(pedidosVC, animated: true, completion: nil)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
array = manager.fetchFavorites()
// for i in 0..<manager.fetchFavorites().count {
// myPendings.append(MyPendings(id: Int(array[i].id), title: array[i].title, message: array[i].message, date: array[i].date, address: array[i].address, contactNumber: array[i].name, contactName: array[i].phoneNumber))
// }
// print("Mis pendintes\(myPendings)")
}
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
}
}
extension PendingsViewController: UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
......@@ -97,6 +88,10 @@ extension PendingsViewController: UITableViewDelegate, UITableViewDataSource{
headerLabel.addSubview(heartImage)
return headerLabel
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
goToRequestViewController(pk: Int(array[indexPath.row].id))
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
switch editingStyle {
case .delete:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment