Skip to content

Commit b6de842

Browse files
committed
remove favorites screen
1 parent fbb9eee commit b6de842

2 files changed

Lines changed: 0 additions & 99 deletions

File tree

AnimalsApp/AnimalsApp/Views/FavoritesViewController/FavoritesViewController.swift

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -9,93 +9,13 @@ import UIKit
99

1010
class FavoritesViewController: UIViewController {
1111

12-
var favoritesVM: FavoritesViewModel?
13-
14-
@IBOutlet weak var tableView: UITableView!
15-
1612
override func viewDidLoad() {
1713
super.viewDidLoad()
18-
favoritesVM = FavoritesViewModel()
1914

20-
tableView.dataSource = self
21-
tableView.delegate = self
22-
23-
tableView.register(UINib(nibName: "AnimalTableViewCell", bundle: nil), forCellReuseIdentifier: "Animal")
24-
25-
setNavigationItems()
26-
favoritesVM?.getFavoriteAnimals { [weak self] in self?.tableView.reloadData()
2715
}
28-
}
29-
30-
override func viewWillAppear(_ animated: Bool) {
31-
super.viewWillAppear(animated)
32-
favoritesVM?.getFavoriteAnimals { [weak self] in self?.tableView.reloadData()
33-
}
34-
}
35-
36-
private func setNavigationItems() {
37-
title = "Favoritos"
38-
39-
let appearance = UINavigationBarAppearance()
40-
appearance.configureWithOpaqueBackground()
41-
appearance.titleTextAttributes = [
42-
NSAttributedString.Key.foregroundColor: UIColor.blueTextColor ?? UIColor.blue,
43-
NSAttributedString.Key.font: UIFont(name: "OpenSans", size: 20) ?? UIFont.systemFont(ofSize: 20)]
44-
navigationController?.navigationBar.standardAppearance = appearance
45-
navigationController?.navigationBar.scrollEdgeAppearance = navigationController?.navigationBar.standardAppearance
46-
47-
navigationItem.backButtonTitle = ""
48-
}
4916

5017
}
5118

52-
// MARK: TableView Data Source
53-
extension FavoritesViewController: UITableViewDataSource {
54-
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
55-
return favoritesVM?.numberOfRows() ?? 0
56-
}
57-
58-
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
59-
60-
guard let cell = tableView.dequeueReusableCell(withIdentifier: "Animal", for: indexPath) as? AnimalTableViewCell else {
61-
return UITableViewCell()
62-
}
63-
64-
cell.animal = favoritesVM?.modelAt(indexPath.row)
65-
cell.index = indexPath.row
66-
cell.delegate = self
67-
cell.configure()
68-
69-
return cell
70-
}
71-
72-
}
73-
74-
// MARK: TableView Delegate
75-
extension FavoritesViewController: UITableViewDelegate {
76-
77-
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
78-
let detailVC = DetailViewController(nibName: "DetailViewController", bundle: nil)
79-
80-
let animal = favoritesVM?.modelAt(indexPath.row)
81-
detailVC.animal = animal
8219

83-
navigationController?.pushViewController(detailVC, animated: true)
84-
85-
tableView.deselectRow(at: indexPath, animated: true)
86-
}
87-
88-
}
8920

90-
// MARK: Action Delegate Protocol
91-
extension FavoritesViewController: ActionDelegateProtocol {
92-
func addFavoriteTapped(at index: Int, with image: Data) {
93-
}
94-
95-
func removeFavoriteTapped(at index: Int) {
96-
favoritesVM?.removeFavorite(at: index) { [weak self] in
97-
self?.tableView.reloadData()
98-
}
99-
}
100-
}
10121

AnimalsApp/AnimalsApp/Views/FavoritesViewController/FavoritesViewController.xib

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,26 @@
44
<dependencies>
55
<deployment identifier="iOS"/>
66
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
7-
<capability name="Named colors" minToolsVersion="9.0"/>
87
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
98
<capability name="System colors in document resources" minToolsVersion="11.0"/>
109
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1110
</dependencies>
1211
<objects>
1312
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="FavoritesViewController" customModule="AnimalsApp" customModuleProvider="target">
1413
<connections>
15-
<outlet property="tableView" destination="Z7H-5c-G5G" id="KBe-qr-ZCy"/>
1614
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
1715
</connections>
1816
</placeholder>
1917
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
2018
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
2119
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
2220
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23-
<subviews>
24-
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="Z7H-5c-G5G">
25-
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
26-
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
27-
<color key="separatorColor" name="grayCellFrame"/>
28-
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
29-
</tableView>
30-
</subviews>
3121
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
3222
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
33-
<constraints>
34-
<constraint firstItem="Z7H-5c-G5G" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="Gij-fh-f3w"/>
35-
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="Z7H-5c-G5G" secondAttribute="trailing" id="Mbr-5U-mqf"/>
36-
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="Z7H-5c-G5G" secondAttribute="bottom" id="OEE-7F-ts3"/>
37-
<constraint firstItem="Z7H-5c-G5G" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="e7r-Gn-PgY"/>
38-
</constraints>
3923
<point key="canvasLocation" x="132" y="33"/>
4024
</view>
4125
</objects>
4226
<resources>
43-
<namedColor name="grayCellFrame">
44-
<color red="0.63921568627450975" green="0.63921568627450975" blue="0.63921568627450975" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
45-
</namedColor>
4627
<systemColor name="systemBackgroundColor">
4728
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
4829
</systemColor>

0 commit comments

Comments
 (0)