Commit 6524daa8 by Julio Hermosa

primera entrega

parent 57491b63
...@@ -42,79 +42,112 @@ ...@@ -42,79 +42,112 @@
<objects> <objects>
<viewController storyboardIdentifier="pendientesVC" id="Ncc-gI-9dq" customClass="PendingsViewController" customModule="ayudapy" customModuleProvider="target" sceneMemberID="viewController"> <viewController storyboardIdentifier="pendientesVC" id="Ncc-gI-9dq" customClass="PendingsViewController" customModule="ayudapy" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="s2s-eb-0xG"> <view key="view" contentMode="scaleToFill" id="s2s-eb-0xG">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> <rect key="frame" x="0.0" y="0.0" width="500" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <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"> <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="414" height="818"/> <rect key="frame" x="0.0" y="44" width="500" height="818"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<prototypes> <prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="124" id="D8e-6i-a9c" customClass="MyPendingsTableViewCell" customModule="ayudapy" customModuleProvider="target"> <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="414" height="124"/> <rect key="frame" x="0.0" y="28" width="500" height="110"/>
<autoresizingMask key="autoresizingMask"/> <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"> <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="414" height="124"/> <rect key="frame" x="0.0" y="0.0" width="500" height="110"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bU8-yM-Yme"> <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bU8-yM-Yme">
<rect key="frame" x="0.0" y="0.0" width="414" height="124"/> <rect key="frame" x="0.0" y="8" width="499" height="116"/>
<subviews> <subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="Arg-Pc-Vth"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="C7N-NJ-YuH">
<rect key="frame" x="90" y="40.5" width="50" height="43.5"/> <rect key="frame" x="0.0" y="0.0" width="499" height="116"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dIv-9y-AeI">
<rect key="frame" x="0.0" y="0.0" width="38" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" 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="24" width="50" height="19.5"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="5uy-us-Ehr">
<rect key="frame" x="20" y="28.5" width="49.5" height="67.5"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="25" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rt6-8B-njG"> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="5uy-us-Ehr">
<rect key="frame" x="0.0" y="0.0" width="49.5" height="42"/> <rect key="frame" x="32" y="17" width="49.5" height="62.5"/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="35"/> <subviews>
<nil key="textColor"/> <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">
<nil key="highlightedColor"/> <rect key="frame" x="0.0" y="0.0" width="49.5" height="42"/>
</label> <fontDescription key="fontDescription" type="system" weight="heavy" pointSize="35"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Month" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A6k-4E-FiW"> <nil key="textColor"/>
<rect key="frame" x="0.0" y="47" width="49.5" height="20.5"/> <nil key="highlightedColor"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/> </label>
<nil key="textColor"/> <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">
<nil key="highlightedColor"/> <rect key="frame" x="0.0" y="42" width="49.5" height="20.5"/>
</label> <fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" alignment="top" translatesAutoresizingMaskIntoConstraints="NO" id="Arg-Pc-Vth">
<rect key="frame" x="91.5" y="0.0" width="407.5" height="116"/>
<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="59.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" 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="59.5" width="50" height="56.5"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VLe-bj-MvJ">
<rect key="frame" x="360" y="-6" width="103" height="108"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="0.24040085119999999" blue="0.2524891279" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" title="Delete">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="deleteRow:" destination="D8e-6i-a9c" eventType="touchUpInside" id="eGP-bs-lFf"/>
</connections>
</button>
</subviews> </subviews>
</stackView> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="Arg-Pc-Vth" firstAttribute="leading" secondItem="5uy-us-Ehr" secondAttribute="trailing" constant="10" id="Dt9-oj-7qE"/>
<constraint firstAttribute="trailing" secondItem="Arg-Pc-Vth" secondAttribute="trailing" id="Mck-4x-NwY"/>
<constraint firstItem="Arg-Pc-Vth" firstAttribute="top" secondItem="C7N-NJ-YuH" secondAttribute="top" id="SMK-db-fln"/>
<constraint firstItem="5uy-us-Ehr" firstAttribute="leading" secondItem="C7N-NJ-YuH" secondAttribute="leading" constant="32" id="TQI-Bh-ycO"/>
<constraint firstAttribute="bottom" secondItem="5uy-us-Ehr" secondAttribute="bottom" constant="36.5" id="Zsu-RA-gIe"/>
<constraint firstItem="5uy-us-Ehr" firstAttribute="top" secondItem="C7N-NJ-YuH" secondAttribute="top" constant="17" id="pHg-od-S6v"/>
<constraint firstAttribute="bottom" secondItem="Arg-Pc-Vth" secondAttribute="bottom" id="wNj-fg-TIG"/>
</constraints>
</view>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="Arg-Pc-Vth" firstAttribute="centerY" secondItem="bU8-yM-Yme" secondAttribute="centerY" id="FLK-Iq-COf"/> <constraint firstAttribute="bottom" secondItem="C7N-NJ-YuH" secondAttribute="bottom" id="90R-LQ-SCc"/>
<constraint firstAttribute="trailing" secondItem="Arg-Pc-Vth" secondAttribute="trailing" constant="241" id="LFe-8V-jB0"/> <constraint firstItem="C7N-NJ-YuH" firstAttribute="leading" secondItem="bU8-yM-Yme" secondAttribute="leading" id="Eab-SY-pQV"/>
<constraint firstItem="Arg-Pc-Vth" firstAttribute="leading" secondItem="5uy-us-Ehr" secondAttribute="trailing" constant="20.5" id="Vq2-gE-s0B"/> <constraint firstItem="C7N-NJ-YuH" firstAttribute="top" secondItem="bU8-yM-Yme" secondAttribute="top" id="Mr3-vO-LvB"/>
<constraint firstItem="5uy-us-Ehr" firstAttribute="leading" secondItem="bU8-yM-Yme" secondAttribute="leading" constant="20" id="Z0Q-cc-I8E"/> <constraint firstAttribute="trailing" secondItem="C7N-NJ-YuH" secondAttribute="trailing" id="Oxv-sN-EjK"/>
<constraint firstItem="5uy-us-Ehr" firstAttribute="centerY" secondItem="bU8-yM-Yme" secondAttribute="centerY" id="hJS-Xf-8tM"/> <constraint firstItem="C7N-NJ-YuH" firstAttribute="trailing" secondItem="50T-ZC-KZu" secondAttribute="trailing" id="VUP-Oz-xXO"/>
<constraint firstAttribute="bottom" secondItem="5uy-us-Ehr" secondAttribute="bottom" constant="20" id="yNm-7i-4g1"/> <constraint firstItem="C7N-NJ-YuH" firstAttribute="bottom" secondItem="50T-ZC-KZu" secondAttribute="bottom" id="uIa-C8-d0Y"/>
</constraints> </constraints>
<viewLayoutGuide key="contentLayoutGuide" id="26x-S3-ikO"/> <viewLayoutGuide key="contentLayoutGuide" id="26x-S3-ikO"/>
<viewLayoutGuide key="frameLayoutGuide" id="50T-ZC-KZu"/> <viewLayoutGuide key="frameLayoutGuide" id="50T-ZC-KZu"/>
</scrollView> </scrollView>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="bU8-yM-Yme" firstAttribute="top" secondItem="aAc-DI-Gps" secondAttribute="top" id="IdU-cZ-AcF"/> <constraint firstAttribute="leading" secondItem="bU8-yM-Yme" secondAttribute="trailing" id="ElR-zd-A6I"/>
<constraint firstAttribute="bottom" secondItem="bU8-yM-Yme" secondAttribute="bottom" id="S9W-33-DmU"/> <constraint firstItem="bU8-yM-Yme" firstAttribute="leading" secondItem="aAc-DI-Gps" secondAttribute="leading" id="QQw-tp-GAm"/>
<constraint firstAttribute="trailing" secondItem="bU8-yM-Yme" secondAttribute="trailing" id="TFa-vg-O66"/> <constraint firstItem="bU8-yM-Yme" firstAttribute="top" secondItem="aAc-DI-Gps" secondAttribute="top" id="TyR-QX-96O"/>
<constraint firstItem="bU8-yM-Yme" firstAttribute="leading" secondItem="aAc-DI-Gps" secondAttribute="leading" id="dMW-Y5-1L0"/> <constraint firstAttribute="bottom" secondItem="bU8-yM-Yme" secondAttribute="bottom" id="xGU-Zw-Qhz"/>
</constraints> </constraints>
</tableViewCellContentView> </tableViewCellContentView>
<constraints>
<constraint firstAttribute="trailing" secondItem="bU8-yM-Yme" secondAttribute="trailing" constant="1" id="2TT-oW-Udo"/>
<constraint firstAttribute="bottom" secondItem="bU8-yM-Yme" secondAttribute="bottom" constant="-14" id="FM1-nh-Pii"/>
<constraint firstItem="bU8-yM-Yme" firstAttribute="top" secondItem="D8e-6i-a9c" secondAttribute="top" constant="8" id="h7S-b7-B9X"/>
<constraint firstItem="bU8-yM-Yme" firstAttribute="leading" secondItem="D8e-6i-a9c" secondAttribute="leading" id="qhI-My-wfT"/>
</constraints>
<connections> <connections>
<outlet property="dayLabel" destination="rt6-8B-njG" id="R9g-fH-iWH"/> <outlet property="dayLabel" destination="rt6-8B-njG" id="R9g-fH-iWH"/>
<outlet property="deleteButton" destination="VLe-bj-MvJ" id="Oxh-mM-u2B"/>
<outlet property="detailLabel" destination="J2F-4P-f1j" id="sDw-bP-ghK"/> <outlet property="detailLabel" destination="J2F-4P-f1j" id="sDw-bP-ghK"/>
<outlet property="monthLabel" destination="A6k-4E-FiW" id="ffX-IQ-uuq"/> <outlet property="monthLabel" destination="A6k-4E-FiW" id="ffX-IQ-uuq"/>
<outlet property="titleLabel" destination="dIv-9y-AeI" id="jR9-VN-COa"/> <outlet property="titleLabel" destination="dIv-9y-AeI" id="jR9-VN-COa"/>
...@@ -125,13 +158,14 @@ ...@@ -125,13 +158,14 @@
</subviews> </subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints> <constraints>
<constraint firstItem="xjn-bv-SjL" firstAttribute="bottom" secondItem="FJC-EV-fMA" secondAttribute="bottom" id="ExC-6C-Zfl"/> <constraint firstItem="FJC-EV-fMA" firstAttribute="top" secondItem="xjn-bv-SjL" secondAttribute="top" id="Xok-P4-ZNr"/>
<constraint firstItem="xjn-bv-SjL" firstAttribute="trailing" secondItem="FJC-EV-fMA" secondAttribute="trailing" id="Jvz-bO-cUa"/> <constraint firstItem="FJC-EV-fMA" firstAttribute="leading" secondItem="xjn-bv-SjL" secondAttribute="leading" id="ai1-l6-nNN"/>
<constraint firstItem="FJC-EV-fMA" firstAttribute="leading" secondItem="xjn-bv-SjL" secondAttribute="leading" id="gEp-mf-iCe"/> <constraint firstItem="FJC-EV-fMA" firstAttribute="trailing" secondItem="xjn-bv-SjL" secondAttribute="trailing" id="gov-Ey-HOG"/>
<constraint firstItem="FJC-EV-fMA" firstAttribute="top" secondItem="xjn-bv-SjL" secondAttribute="top" id="imn-U6-gJo"/> <constraint firstItem="FJC-EV-fMA" firstAttribute="bottom" secondItem="xjn-bv-SjL" secondAttribute="bottom" id="ipl-yq-36T"/>
</constraints> </constraints>
<viewLayoutGuide key="safeArea" id="xjn-bv-SjL"/> <viewLayoutGuide key="safeArea" id="xjn-bv-SjL"/>
</view> </view>
<size key="freeformSize" width="500" height="896"/>
<connections> <connections>
<outlet property="tableView" destination="FJC-EV-fMA" id="z3n-NG-YzE"/> <outlet property="tableView" destination="FJC-EV-fMA" id="z3n-NG-YzE"/>
</connections> </connections>
......
...@@ -42,6 +42,15 @@ class CoreDataManager { ...@@ -42,6 +42,15 @@ class CoreDataManager {
print("error al guardar \(error)") print("error al guardar \(error)")
} }
} }
func deleteFavorites(id: Int, array: [Entity]){
let context = container.viewContext
for i in 0..<array.count {
if array[i].id == Int64(id){
context.delete(array[i])
}
}
}
func fetchFavorites()->[Entity]{ func fetchFavorites()->[Entity]{
let fetchRequest: NSFetchRequest<Entity> = Entity.fetchRequest() let fetchRequest: NSFetchRequest<Entity> = Entity.fetchRequest()
do { do {
......
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
<attribute name="id" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/> <attribute name="id" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="message" optional="YES" attributeType="String"/> <attribute name="message" optional="YES" attributeType="String"/>
<attribute name="name" optional="YES" attributeType="String"/> <attribute name="name" optional="YES" attributeType="String"/>
<attribute name="phoneNumber" optional="YES" attributeType="String"/>
<attribute name="title" optional="YES" attributeType="String"/> <attribute name="title" optional="YES" attributeType="String"/>
</entity> </entity>
<elements> <elements>
<element name="Entity" positionX="-54" positionY="-9" width="128" height="133"/> <element name="Entity" positionX="-54" positionY="-9" width="128" height="148"/>
</elements> </elements>
</model> </model>
\ No newline at end of file
...@@ -22,5 +22,6 @@ extension Entity { ...@@ -22,5 +22,6 @@ extension Entity {
@NSManaged public var date: Date? @NSManaged public var date: Date?
@NSManaged public var address: String? @NSManaged public var address: String?
@NSManaged public var title: String? @NSManaged public var title: String?
@NSManaged public var phoneNumber: String?
} }
...@@ -56,7 +56,7 @@ extension String{ ...@@ -56,7 +56,7 @@ extension String{
returnValue = String(subStr) returnValue = String(subStr)
case .hour: case .hour:
let start = date.index(date.startIndex, offsetBy: 10) let start = date.index(date.startIndex, offsetBy: 11)
let end = date.index(date.startIndex, offsetBy: 16) let end = date.index(date.startIndex, offsetBy: 16)
let range = start..<end let range = start..<end
let subStr = date[range] let subStr = date[range]
......
...@@ -149,7 +149,6 @@ class MapViewController: UIViewController { ...@@ -149,7 +149,6 @@ class MapViewController: UIViewController {
marker.map = self.mapView marker.map = self.mapView
marker.iconView = markerView marker.iconView = markerView
//marker.icon = markerImage
marker.title = "\(features[i].properties.pk)" marker.title = "\(features[i].properties.pk)"
} }
}) })
......
...@@ -10,17 +10,29 @@ import UIKit ...@@ -10,17 +10,29 @@ import UIKit
class MyPendingsTableViewCell: UITableViewCell { class MyPendingsTableViewCell: UITableViewCell {
var id = Int()
let format = Format.init()
let manager = CoreDataManager()
@IBOutlet weak var dayLabel: UILabel! @IBOutlet weak var dayLabel: UILabel!
@IBOutlet weak var monthLabel: UILabel! @IBOutlet weak var monthLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var detailLabel: UILabel! @IBOutlet weak var detailLabel: UILabel!
let format = Format.init() @IBOutlet weak var deleteButton: UIButton!
@IBAction func deleteRow(_ sender: Any) {
let array = manager.fetchFavorites()
print(id)
manager.deleteFavorites(id: id, array: array)
}
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
dayLabel.textColor = format.subTitleTextColor dayLabel.textColor = format.subTitleTextColor
monthLabel.textColor = format.titleTextColor monthLabel.textColor = format.titleTextColor
} }
override func setSelected(_ selected: Bool, animated: Bool) { override func setSelected(_ selected: Bool, animated: Bool) {
......
...@@ -9,10 +9,20 @@ ...@@ -9,10 +9,20 @@
import UIKit import UIKit
import CoreData 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 { class PendingsViewController: UIViewController {
let manager = CoreDataManager() let manager = CoreDataManager()
var favorites = [(Int64, String, String)]() var myPendings = [MyPendings]()
let format = Format.init() let format = Format.init()
@IBOutlet weak var tableView: UITableView! @IBOutlet weak var tableView: UITableView!
...@@ -20,11 +30,10 @@ class PendingsViewController: UIViewController { ...@@ -20,11 +30,10 @@ class PendingsViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
let array = manager.fetchFavorites() let array = manager.fetchFavorites()
for i in 0..<manager.fetchFavorites().count { for i in 0..<manager.fetchFavorites().count {
favorites.append((Int64(array[i].id),array[i].message!,"\(array[i].date!)")) 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(array[i].id, array[i].name!, array[i].date!)
} }
//print(favorites)
} }
override func viewDidLoad() { override func viewDidLoad() {
...@@ -42,17 +51,35 @@ extension PendingsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -42,17 +51,35 @@ extension PendingsViewController: UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MyPendingsTableViewCell let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MyPendingsTableViewCell
let date = favorites[indexPath.row].2 let date = myPendings[indexPath.row].date
let month = date.getDatePart(dateUnit: .month) let month = date.getDatePart(dateUnit: .month)
let monthString = month.getMonthShortString() let monthString = month.getMonthShortString()
let day = date.getDatePart(dateUnit: .day) let day = date.getDatePart(dateUnit: .day)
cell.titleLabel.text = "\(favorites[indexPath.row].1)" var detailLabel:String = ""
cell.detailLabel.text = "\(favorites[indexPath.row].2)" cell.titleLabel.text = myPendings[indexPath.row].title
cell.titleLabel.textColor = format.subTitleTextColor
cell.titleLabel.font = format.subTitleFontStyle
if let address = myPendings[indexPath.row].address {
detailLabel = address
}
if let contactName = myPendings[indexPath.row].contactName {
detailLabel = detailLabel + "\n\(contactName)"
}
if let contactNumber = myPendings[indexPath.row].contactNumber {
detailLabel = detailLabel + "\n\(contactNumber)"
}
cell.detailLabel.text = detailLabel
cell.detailLabel.font = format.bodyFontStyle
cell.dayLabel.text = day cell.dayLabel.text = day
cell.monthLabel.text = monthString cell.monthLabel.text = monthString
let id = myPendings[indexPath.row].id
cell.id = id
return cell return cell
} }
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 50)) let headerLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
headerLabel.text = "Mis Pendientes" headerLabel.text = "Mis Pendientes"
......
...@@ -24,8 +24,6 @@ class RequestViewController: UIViewController { ...@@ -24,8 +24,6 @@ class RequestViewController: UIViewController {
var isFavorite = Bool() var isFavorite = Bool()
var checked = Bool() var checked = Bool()
var favorites = [Int]() var favorites = [Int]()
// private let appDelegate = UIApplication.shared.delegate as! AppDelegate
// private let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
private let manager = CoreDataManager() private let manager = CoreDataManager()
...@@ -52,8 +50,12 @@ class RequestViewController: UIViewController { ...@@ -52,8 +50,12 @@ class RequestViewController: UIViewController {
} }
func showRequestInformation(){ func showRequestInformation(){
let day = date.getDatePart(dateUnit: .day)
let month = (date.getDatePart(dateUnit: .month)).getMonthInSpanish()
let year = date.getDatePart(dateUnit: .year)
let hour = date.getDatePart(dateUnit: .hour)
let dateLabel = UILabel() let dateLabel = UILabel()
dateLabel.text = "Publicado el:\(date)" dateLabel.text = "Publicado el \(day) de \(month) de \(year) a las \(hour)"
dateLabel.font = format.dateFontStyle dateLabel.font = format.dateFontStyle
dateLabel.textColor = format.dateTextColor dateLabel.textColor = format.dateTextColor
let titleLbl = UILabel() let titleLbl = UILabel()
...@@ -81,17 +83,11 @@ class RequestViewController: UIViewController { ...@@ -81,17 +83,11 @@ class RequestViewController: UIViewController {
addressLabel.text = "\(address)" addressLabel.text = "\(address)"
addressLabel.lineBreakMode = .byWordWrapping addressLabel.lineBreakMode = .byWordWrapping
addressLabel.numberOfLines = .max addressLabel.numberOfLines = .max
// let cityLabel = UILabel()
// cityLabel.text = city let howToGetButton = UIButton()
let howToGetButton = UIButton()//(frame: CGRect(x: 0, y: 0, width: view.frame.width * 0.9, height: 20))
howToGetButton.backgroundColor = format.subTitleTextColor howToGetButton.backgroundColor = format.subTitleTextColor
howToGetButton.layer.cornerRadius = 10 howToGetButton.layer.cornerRadius = 10
// let howToGetLabel = UILabel()
// howToGetLabel.text = "Como LLegar"
// howToGetLabel.font = format.subTitleFontStyle
// howToGetLabel.textColor = .white
// howToGetLabel.textAlignment = .center
// howToGetButton.addSubview(howToGetLabel)
howToGetButton.setTitle("Como llegar", for: .normal) howToGetButton.setTitle("Como llegar", for: .normal)
howToGetButton.titleLabel?.font = format.subTitleFontStyle howToGetButton.titleLabel?.font = format.subTitleFontStyle
let contactLabel = UILabel() let contactLabel = UILabel()
......
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