Skip to content

Commit a5c5761

Browse files
committed
UI changes
1 parent 8410648 commit a5c5761

10 files changed

Lines changed: 74 additions & 50 deletions

File tree

AnimalsApp/AnimalsApp.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
A463D071285A373800929A3C /* Animals.swift in Sources */ = {isa = PBXBuildFile; fileRef = A463D070285A373700929A3C /* Animals.swift */; };
3535
A463D074285A398900929A3C /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A463D073285A398900929A3C /* HomeViewModel.swift */; };
3636
A463D078285A5A8000929A3C /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A463D077285A5A8000929A3C /* OpenSans-Regular.ttf */; };
37+
A463D07A285B8D8E00929A3C /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = A463D079285B8D8D00929A3C /* Colors.swift */; };
3738
/* End PBXBuildFile section */
3839

3940
/* Begin PBXContainerItemProxy section */
@@ -91,6 +92,7 @@
9192
A463D070285A373700929A3C /* Animals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Animals.swift; sourceTree = "<group>"; };
9293
A463D073285A398900929A3C /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
9394
A463D077285A5A8000929A3C /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "OpenSans-Regular.ttf"; sourceTree = "<group>"; };
95+
A463D079285B8D8D00929A3C /* Colors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Colors.swift; sourceTree = "<group>"; };
9496
/* End PBXFileReference section */
9597

9698
/* Begin PBXFrameworksBuildPhase section */
@@ -203,7 +205,6 @@
203205
A463D04E2858F47C00929A3C /* HomeViewController */ = {
204206
isa = PBXGroup;
205207
children = (
206-
A463D075285A580400929A3C /* Components */,
207208
A463D0512858F60C00929A3C /* HomeViewController.swift */,
208209
A463D0522858F60C00929A3C /* HomeViewController.xib */,
209210
);
@@ -231,6 +232,7 @@
231232
A463D05F2858F66B00929A3C /* Views */ = {
232233
isa = PBXGroup;
233234
children = (
235+
A463D075285A580400929A3C /* Components */,
234236
A463D06A285A22AF00929A3C /* DetailViewController */,
235237
A463D0502858F4DE00929A3C /* FavoritesViewController */,
236238
A463D04F2858F49600929A3C /* RegisterViewController */,
@@ -244,6 +246,7 @@
244246
isa = PBXGroup;
245247
children = (
246248
A463D06128590D0300929A3C /* Images.swift */,
249+
A463D079285B8D8D00929A3C /* Colors.swift */,
247250
);
248251
path = DesignSystem;
249252
sourceTree = "<group>";
@@ -561,6 +564,7 @@
561564
A463D071285A373800929A3C /* Animals.swift in Sources */,
562565
A463D04B2858F39000929A3C /* MainTabBarController.swift in Sources */,
563566
A463D074285A398900929A3C /* HomeViewModel.swift in Sources */,
567+
A463D07A285B8D8E00929A3C /* Colors.swift in Sources */,
564568
A463D05D2858F64B00929A3C /* FavoritesViewController.swift in Sources */,
565569
A463D06D285A22D200929A3C /* DetailViewController.swift in Sources */,
566570
A463D069285A1A5A00929A3C /* WebServices.swift in Sources */,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0xA3",
9+
"green" : "0xA3",
10+
"red" : "0xA3"
11+
}
12+
},
13+
"idiom" : "universal"
14+
}
15+
],
16+
"info" : {
17+
"author" : "xcode",
18+
"version" : 1
19+
}
20+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Colors.swift
3+
// AnimalsApp
4+
//
5+
// Created by Laura Pinheiro Marson on 16/06/22.
6+
//
7+
8+
import UIKit
9+
10+
extension UIColor {
11+
static let blueTabBarColor: UIColor? = UIColor(named: "blueTabBarColor")
12+
static let blueTextColor: UIColor? = UIColor(named: "blueTextColor")
13+
14+
}

AnimalsApp/AnimalsApp/Services/WebServices.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ import Foundation
99
import Alamofire
1010

1111
protocol WebServicesContract: AnyObject {
12+
var endpoint: String { get }
1213
func fetchAnimals(completion: @escaping (Result<[Animal], Error>) -> ())
1314
func registerAnimal()
1415
}
1516

1617
class WebServices: WebServicesContract {
17-
let urlString = "https://bootcamp-ios-api.herokuapp.com/api/v1/animals"
18+
let endpoint: String = "https://bootcamp-ios-api.herokuapp.com/api/v1/animals"
1819

1920
func fetchAnimals(completion: @escaping (Result<[Animal], Error>) -> ()) {
2021

21-
AF.request(urlString)
22+
AF.request(endpoint)
2223
.validate()
2324
.responseDecodable(of: Animals.self) { (response) in
2425
switch response.result {

AnimalsApp/AnimalsApp/View Models/HomeViewModel.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77

88
import Foundation
9-
import Combine
109

1110
class HomeViewModel {
1211
private var webServices: WebServicesContract

AnimalsApp/AnimalsApp/Views/HomeViewController/Components/AnimalTableViewCell.swift renamed to AnimalsApp/AnimalsApp/Views/Components/AnimalTableViewCell.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class AnimalTableViewCell: UITableViewCell {
4646

4747
self.descriptionLabel.text = animal.description
4848

49+
self.animalImage.layer.cornerRadius = 10
50+
4951
let imageURL = animal.imageURL
5052
let placeholderImage = UIImage.imagePlaceHolder
5153

AnimalsApp/AnimalsApp/Views/HomeViewController/Components/AnimalTableViewCell.xib renamed to AnimalsApp/AnimalsApp/Views/Components/AnimalTableViewCell.xib

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616
<objects>
1717
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
1818
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
19-
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Animal" rowHeight="91" id="KGk-i7-Jjw" customClass="AnimalTableViewCell" customModule="AnimalsApp" customModuleProvider="target">
20-
<rect key="frame" x="0.0" y="0.0" width="302" height="91"/>
19+
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Animal" rowHeight="98" id="KGk-i7-Jjw" customClass="AnimalTableViewCell" customModule="AnimalsApp" customModuleProvider="target">
20+
<rect key="frame" x="0.0" y="0.0" width="302" height="98"/>
2121
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2222
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
23-
<rect key="frame" x="0.0" y="0.0" width="302" height="91"/>
23+
<rect key="frame" x="0.0" y="0.0" width="302" height="98"/>
2424
<autoresizingMask key="autoresizingMask"/>
2525
<subviews>
26-
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="imagePlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="lNA-6P-Vee">
27-
<rect key="frame" x="20" y="5" width="80" height="80"/>
26+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="imagePlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="lNA-6P-Vee">
27+
<rect key="frame" x="20" y="8" width="80" height="80"/>
2828
<constraints>
2929
<constraint firstAttribute="height" constant="80" id="WD3-HZ-qNY"/>
3030
<constraint firstAttribute="width" constant="80" id="kcM-BZ-81T"/>
3131
</constraints>
3232
</imageView>
3333
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="687-rn-Ydp">
34-
<rect key="frame" x="247" y="30" width="40" height="30"/>
34+
<rect key="frame" x="247" y="33" width="40" height="30"/>
3535
<constraints>
3636
<constraint firstAttribute="height" constant="30" id="7rZ-bg-lFP"/>
3737
<constraint firstAttribute="width" constant="40" id="i65-df-ED5"/>
@@ -42,29 +42,30 @@
4242
<action selector="favoritePressed:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="X9N-Mv-iRU"/>
4343
</connections>
4444
</button>
45-
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="fsl-xq-9yj">
46-
<rect key="frame" x="115" y="16" width="73" height="58"/>
45+
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="fsl-xq-9yj">
46+
<rect key="frame" x="115" y="21" width="71.5" height="54.5"/>
4747
<subviews>
4848
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Animal" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cyH-cm-d20">
49-
<rect key="frame" x="0.0" y="0.0" width="73" height="30"/>
49+
<rect key="frame" x="0.0" y="0.0" width="71.5" height="30"/>
5050
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="22"/>
5151
<color key="textColor" name="blueTextColor"/>
5252
<nil key="highlightedColor"/>
5353
</label>
5454
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Descrição" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mH9-v7-gy1">
55-
<rect key="frame" x="0.0" y="36" width="73" height="22"/>
56-
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="16"/>
55+
<rect key="frame" x="0.0" y="35" width="71.5" height="19.5"/>
56+
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="14"/>
5757
<color key="textColor" name="grayTextColor"/>
5858
<nil key="highlightedColor"/>
5959
</label>
6060
</subviews>
6161
</stackView>
6262
</subviews>
6363
<constraints>
64+
<constraint firstItem="687-rn-Ydp" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="fsl-xq-9yj" secondAttribute="trailing" constant="5" id="Fot-hl-ITO"/>
6465
<constraint firstItem="lNA-6P-Vee" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="20" id="IB3-A5-MoG"/>
6566
<constraint firstItem="fsl-xq-9yj" firstAttribute="centerY" secondItem="lNA-6P-Vee" secondAttribute="centerY" id="W6t-ob-L4I"/>
66-
<constraint firstItem="lNA-6P-Vee" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="5" id="jhP-MT-FBj"/>
67-
<constraint firstAttribute="bottom" secondItem="lNA-6P-Vee" secondAttribute="bottom" constant="5" id="mNv-vS-OgZ"/>
67+
<constraint firstItem="lNA-6P-Vee" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="8" id="jhP-MT-FBj"/>
68+
<constraint firstAttribute="bottom" secondItem="lNA-6P-Vee" secondAttribute="bottom" constant="8" id="mNv-vS-OgZ"/>
6869
<constraint firstAttribute="trailing" secondItem="687-rn-Ydp" secondAttribute="trailing" constant="15" id="oaJ-Ve-0pr"/>
6970
<constraint firstItem="fsl-xq-9yj" firstAttribute="leading" secondItem="lNA-6P-Vee" secondAttribute="trailing" constant="15" id="sdK-OL-XPW"/>
7071
<constraint firstItem="687-rn-Ydp" firstAttribute="centerY" secondItem="lNA-6P-Vee" secondAttribute="centerY" id="tSW-tO-h77"/>
@@ -77,7 +78,7 @@
7778
<outlet property="favoriteButton" destination="687-rn-Ydp" id="wgR-Fp-8k1"/>
7879
<outlet property="nameLabel" destination="cyH-cm-d20" id="Gts-qf-dcs"/>
7980
</connections>
80-
<point key="canvasLocation" x="118.84057971014494" y="66.629464285714278"/>
81+
<point key="canvasLocation" x="118.84057971014494" y="68.303571428571431"/>
8182
</tableViewCell>
8283
</objects>
8384
<resources>

AnimalsApp/AnimalsApp/Views/HomeViewController/HomeViewController.swift

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@
66
//
77

88
import UIKit
9-
import Combine
109

1110
class HomeViewController: UIViewController {
1211

1312
let homeVM = HomeViewModel()
1413

15-
let homeVM2 = HomeViewModel2()
16-
var bag = Set<AnyCancellable>()
17-
1814
@IBOutlet var tableView: UITableView!
1915
@IBOutlet weak var loadingView: UIActivityIndicatorView!
2016

@@ -27,39 +23,20 @@ class HomeViewController: UIViewController {
2723

2824
tableView.register(UINib(nibName: "AnimalTableViewCell", bundle: nil), forCellReuseIdentifier: "Animal")
2925

30-
3126
setNavigationItems()
3227
populateTableView()
33-
34-
homeVM2.$viewState
35-
.receive(on: DispatchQueue.main)
36-
.sink { value in
37-
switch value {
38-
39-
case .idle:
40-
break
41-
case .loading:
42-
// show indicator
43-
break
44-
case .error(_):
45-
// show error view
46-
break
47-
case .loaded(_):
48-
self.tableView.reloadData()
49-
}
50-
}.store(in: &bag)
51-
52-
5328
}
5429

5530
private func setNavigationItems() {
31+
title = "Home"
32+
5633
let appearance = UINavigationBarAppearance()
5734
appearance.configureWithOpaqueBackground()
35+
appearance.titleTextAttributes = [
36+
NSAttributedString.Key.foregroundColor: UIColor.blueTextColor ?? UIColor.blue,
37+
NSAttributedString.Key.font: UIFont(name: "OpenSans", size: 20) ?? UIFont.systemFont(ofSize: 20)]
5838
navigationController?.navigationBar.standardAppearance = appearance
5939
navigationController?.navigationBar.scrollEdgeAppearance = navigationController?.navigationBar.standardAppearance
60-
61-
title = "Home"
62-
navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor(named: "blueTextColor") as Any]
6340
}
6441

6542
private func populateTableView() {

AnimalsApp/AnimalsApp/Views/HomeViewController/HomeViewController.xib

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<dependencies>
55
<deployment identifier="iOS"/>
66
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
7+
<capability name="Named colors" minToolsVersion="9.0"/>
78
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
89
<capability name="System colors in document resources" minToolsVersion="11.0"/>
910
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -21,8 +22,10 @@
2122
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
2223
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2324
<subviews>
24-
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" estimatedSectionHeaderHeight="-1" sectionFooterHeight="28" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="Siv-wY-ZEk">
25+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" estimatedSectionHeaderHeight="-1" sectionFooterHeight="28" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="Siv-wY-ZEk">
2526
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
27+
<color key="separatorColor" name="grayCellFrame"/>
28+
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
2629
</tableView>
2730
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="large" translatesAutoresizingMaskIntoConstraints="NO" id="3je-EF-sGM">
2831
<rect key="frame" x="188.5" y="429.5" width="37" height="37"/>
@@ -31,17 +34,20 @@
3134
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
3235
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
3336
<constraints>
34-
<constraint firstItem="Siv-wY-ZEk" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="AmS-A8-kRI"/>
3537
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="Siv-wY-ZEk" secondAttribute="trailing" id="CK9-kj-fPh"/>
3638
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="Siv-wY-ZEk" secondAttribute="bottom" id="Fs7-zJ-zOE"/>
3739
<constraint firstItem="3je-EF-sGM" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="IXw-Qp-7bN"/>
40+
<constraint firstItem="Siv-wY-ZEk" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="Mug-YL-ycT"/>
3841
<constraint firstItem="Siv-wY-ZEk" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="RJW-a7-pVc"/>
3942
<constraint firstItem="3je-EF-sGM" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="sUh-hY-zSM"/>
4043
</constraints>
41-
<point key="canvasLocation" x="132" y="84"/>
44+
<point key="canvasLocation" x="131.8840579710145" y="83.705357142857139"/>
4245
</view>
4346
</objects>
4447
<resources>
48+
<namedColor name="grayCellFrame">
49+
<color red="0.63921568627450975" green="0.63921568627450975" blue="0.63921568627450975" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
50+
</namedColor>
4551
<systemColor name="systemBackgroundColor">
4652
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
4753
</systemColor>

AnimalsApp/AnimalsApp/Views/TabBarController/MainTabBarController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MainTabBarController: UITabBarController {
3838
tabBarItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
3939

4040
tabBarAppearance.stackedLayoutAppearance = tabBarItemAppearance
41-
tabBarAppearance.backgroundColor = UIColor(named: "blueTabBarColor")
41+
tabBarAppearance.backgroundColor = UIColor.blueTabBarColor
4242

4343
tabBar.standardAppearance = tabBarAppearance
4444
if #available(iOS 15.0, *) {

0 commit comments

Comments
 (0)