diff --git a/ayudapy.xcworkspace/xcuserdata/roshka.xcuserdatad/UserInterfaceState.xcuserstate b/ayudapy.xcworkspace/xcuserdata/roshka.xcuserdatad/UserInterfaceState.xcuserstate index cd6d5ca..460ebbf 100644 Binary files a/ayudapy.xcworkspace/xcuserdata/roshka.xcuserdatad/UserInterfaceState.xcuserstate and b/ayudapy.xcworkspace/xcuserdata/roshka.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ayudapy/Base.lproj/Main.storyboard b/ayudapy/Base.lproj/Main.storyboard index c842af3..e900d42 100644 --- a/ayudapy/Base.lproj/Main.storyboard +++ b/ayudapy/Base.lproj/Main.storyboard @@ -42,79 +42,112 @@ - + - + - - + + - + - - + + - - - - - - - - - + + - - + + + + + + + + + + + + + + + - + + + + + + + + + + + - - - - - - + + + + + + - - - - + + + + + + + + + + + @@ -125,13 +158,14 @@ - - - - + + + + + diff --git a/ayudapy/CoreData/CoreDataManager.swift b/ayudapy/CoreData/CoreDataManager.swift index 3daeb24..d3cb26c 100644 --- a/ayudapy/CoreData/CoreDataManager.swift +++ b/ayudapy/CoreData/CoreDataManager.swift @@ -42,6 +42,15 @@ class CoreDataManager { print("error al guardar \(error)") } } + func deleteFavorites(id: Int, array: [Entity]){ + let context = container.viewContext + for i in 0..[Entity]{ let fetchRequest: NSFetchRequest = Entity.fetchRequest() do { diff --git a/ayudapy/CoreData/Favorites.xcdatamodeld/favoriteRequests.xcdatamodel/contents b/ayudapy/CoreData/Favorites.xcdatamodeld/favoriteRequests.xcdatamodel/contents index 17f590e..e830a76 100644 --- a/ayudapy/CoreData/Favorites.xcdatamodeld/favoriteRequests.xcdatamodel/contents +++ b/ayudapy/CoreData/Favorites.xcdatamodeld/favoriteRequests.xcdatamodel/contents @@ -6,9 +6,10 @@ + - + \ No newline at end of file diff --git a/ayudapy/Entity+CoreDataProperties.swift b/ayudapy/Entity+CoreDataProperties.swift index 51f7d3a..b72267e 100644 --- a/ayudapy/Entity+CoreDataProperties.swift +++ b/ayudapy/Entity+CoreDataProperties.swift @@ -22,5 +22,6 @@ extension Entity { @NSManaged public var date: Date? @NSManaged public var address: String? @NSManaged public var title: String? + @NSManaged public var phoneNumber: String? } diff --git a/ayudapy/Static/Format.swift b/ayudapy/Static/Format.swift index ce94509..60ed7ed 100644 --- a/ayudapy/Static/Format.swift +++ b/ayudapy/Static/Format.swift @@ -56,7 +56,7 @@ extension String{ returnValue = String(subStr) 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 range = start.. UITableViewCell { 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 monthString = month.getMonthShortString() let day = date.getDatePart(dateUnit: .day) - cell.titleLabel.text = "\(favorites[indexPath.row].1)" - cell.detailLabel.text = "\(favorites[indexPath.row].2)" + var detailLabel:String = "" + 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.monthLabel.text = monthString + + let id = myPendings[indexPath.row].id + cell.id = id + return cell } + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let headerLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 50)) headerLabel.text = "Mis Pendientes" diff --git a/ayudapy/ViewControllers/RequestViewController.swift b/ayudapy/ViewControllers/RequestViewController.swift index 86f9bfe..115c476 100644 --- a/ayudapy/ViewControllers/RequestViewController.swift +++ b/ayudapy/ViewControllers/RequestViewController.swift @@ -24,8 +24,6 @@ class RequestViewController: UIViewController { var isFavorite = Bool() var checked = Bool() 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() @@ -52,8 +50,12 @@ class RequestViewController: UIViewController { } 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() - dateLabel.text = "Publicado el:\(date)" + dateLabel.text = "Publicado el \(day) de \(month) de \(year) a las \(hour)" dateLabel.font = format.dateFontStyle dateLabel.textColor = format.dateTextColor let titleLbl = UILabel() @@ -81,17 +83,11 @@ class RequestViewController: UIViewController { addressLabel.text = "\(address)" addressLabel.lineBreakMode = .byWordWrapping addressLabel.numberOfLines = .max -// let cityLabel = UILabel() -// cityLabel.text = city - let howToGetButton = UIButton()//(frame: CGRect(x: 0, y: 0, width: view.frame.width * 0.9, height: 20)) + + let howToGetButton = UIButton() howToGetButton.backgroundColor = format.subTitleTextColor 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.titleLabel?.font = format.subTitleFontStyle let contactLabel = UILabel()