Skip to content

Commit e13ff7c

Browse files
authored
Merge pull request #2 from lauramarson/newchanges
fix tab bar and change homevc
2 parents f0fc8eb + cc46abb commit e13ff7c

6 files changed

Lines changed: 176 additions & 26 deletions

File tree

AnimalsApp/AnimalsApp.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
A463D05D2858F64B00929A3C /* FavoritesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A463D05B2858F64B00929A3C /* FavoritesViewController.swift */; };
2727
A463D05E2858F64B00929A3C /* FavoritesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A463D05C2858F64B00929A3C /* FavoritesViewController.xib */; };
2828
A463D06228590D0300929A3C /* Images.swift in Sources */ = {isa = PBXBuildFile; fileRef = A463D06128590D0300929A3C /* Images.swift */; };
29+
A463D065285953F900929A3C /* AnimalTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A463D063285953F900929A3C /* AnimalTableViewCell.swift */; };
30+
A463D066285953F900929A3C /* AnimalTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A463D064285953F900929A3C /* AnimalTableViewCell.xib */; };
2931
/* End PBXBuildFile section */
3032

3133
/* Begin PBXContainerItemProxy section */
@@ -75,6 +77,8 @@
7577
A463D05B2858F64B00929A3C /* FavoritesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesViewController.swift; sourceTree = "<group>"; };
7678
A463D05C2858F64B00929A3C /* FavoritesViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FavoritesViewController.xib; sourceTree = "<group>"; };
7779
A463D06128590D0300929A3C /* Images.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Images.swift; sourceTree = "<group>"; };
80+
A463D063285953F900929A3C /* AnimalTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimalTableViewCell.swift; sourceTree = "<group>"; };
81+
A463D064285953F900929A3C /* AnimalTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AnimalTableViewCell.xib; sourceTree = "<group>"; };
7882
/* End PBXFileReference section */
7983

8084
/* Begin PBXFrameworksBuildPhase section */
@@ -185,6 +189,8 @@
185189
children = (
186190
A463D0512858F60C00929A3C /* HomeViewController.swift */,
187191
A463D0522858F60C00929A3C /* HomeViewController.xib */,
192+
A463D063285953F900929A3C /* AnimalTableViewCell.swift */,
193+
A463D064285953F900929A3C /* AnimalTableViewCell.xib */,
188194
);
189195
path = HomeViewController;
190196
sourceTree = "<group>";
@@ -347,6 +353,7 @@
347353
files = (
348354
A463D04C2858F39000929A3C /* MainTabBarController.xib in Resources */,
349355
A463D0582858F62600929A3C /* RegisterViewController.xib in Resources */,
356+
A463D066285953F900929A3C /* AnimalTableViewCell.xib in Resources */,
350357
A463D0262858EBBD00929A3C /* LaunchScreen.storyboard in Resources */,
351358
A463D0232858EBBD00929A3C /* Assets.xcassets in Resources */,
352359
A463D05E2858F64B00929A3C /* FavoritesViewController.xib in Resources */,
@@ -479,6 +486,7 @@
479486
buildActionMask = 2147483647;
480487
files = (
481488
A463D06228590D0300929A3C /* Images.swift in Sources */,
489+
A463D065285953F900929A3C /* AnimalTableViewCell.swift in Sources */,
482490
A463D0212858EBBB00929A3C /* AnimalsApp.xcdatamodeld in Sources */,
483491
A463D0572858F62600929A3C /* RegisterViewController.swift in Sources */,
484492
A463D0172858EBBB00929A3C /* AppDelegate.swift in Sources */,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// AnimalTableViewCell.swift
3+
// AnimalsApp
4+
//
5+
// Created by Laura Pinheiro Marson on 14/06/22.
6+
//
7+
8+
import UIKit
9+
10+
class AnimalTableViewCell: UITableViewCell {
11+
12+
override func awakeFromNib() {
13+
super.awakeFromNib()
14+
// Initialization code
15+
}
16+
17+
override func setSelected(_ selected: Bool, animated: Bool) {
18+
super.setSelected(selected, animated: animated)
19+
20+
// Configure the view for the selected state
21+
}
22+
23+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
7+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9+
</dependencies>
10+
<objects>
11+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
12+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
13+
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Animal" rowHeight="59" id="KGk-i7-Jjw" customClass="AnimalTableViewCell" customModule="AnimalsApp" customModuleProvider="target">
14+
<rect key="frame" x="0.0" y="0.0" width="302" height="59"/>
15+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
16+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
17+
<rect key="frame" x="0.0" y="0.0" width="302" height="59"/>
18+
<autoresizingMask key="autoresizingMask"/>
19+
<subviews>
20+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="favorited" translatesAutoresizingMaskIntoConstraints="NO" id="lNA-6P-Vee">
21+
<rect key="frame" x="10" y="5" width="50" height="50"/>
22+
<constraints>
23+
<constraint firstAttribute="height" constant="50" id="WD3-HZ-qNY"/>
24+
<constraint firstAttribute="width" constant="50" id="kcM-BZ-81T"/>
25+
</constraints>
26+
</imageView>
27+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="687-rn-Ydp">
28+
<rect key="frame" x="277" y="22.5" width="15" height="15"/>
29+
<constraints>
30+
<constraint firstAttribute="height" constant="15" id="7rZ-bg-lFP"/>
31+
<constraint firstAttribute="width" constant="15" id="i65-df-ED5"/>
32+
</constraints>
33+
<state key="normal" title="Button"/>
34+
<buttonConfiguration key="configuration" style="plain" image="addFavorite"/>
35+
</button>
36+
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="fsl-xq-9yj">
37+
<rect key="frame" x="70" y="11" width="57" height="38.5"/>
38+
<subviews>
39+
<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">
40+
<rect key="frame" x="0.0" y="0.0" width="57" height="18"/>
41+
<fontDescription key="fontDescription" type="system" pointSize="15"/>
42+
<nil key="textColor"/>
43+
<nil key="highlightedColor"/>
44+
</label>
45+
<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">
46+
<rect key="frame" x="0.0" y="24" width="57" height="14.5"/>
47+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
48+
<nil key="textColor"/>
49+
<nil key="highlightedColor"/>
50+
</label>
51+
</subviews>
52+
</stackView>
53+
</subviews>
54+
<constraints>
55+
<constraint firstItem="lNA-6P-Vee" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="10" id="IB3-A5-MoG"/>
56+
<constraint firstItem="fsl-xq-9yj" firstAttribute="centerY" secondItem="lNA-6P-Vee" secondAttribute="centerY" id="W6t-ob-L4I"/>
57+
<constraint firstItem="lNA-6P-Vee" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="5" id="jhP-MT-FBj"/>
58+
<constraint firstAttribute="bottom" secondItem="lNA-6P-Vee" secondAttribute="bottom" constant="5" id="mNv-vS-OgZ"/>
59+
<constraint firstAttribute="trailing" secondItem="687-rn-Ydp" secondAttribute="trailing" constant="10" id="oaJ-Ve-0pr"/>
60+
<constraint firstItem="fsl-xq-9yj" firstAttribute="leading" secondItem="lNA-6P-Vee" secondAttribute="trailing" constant="10" id="sdK-OL-XPW"/>
61+
<constraint firstItem="687-rn-Ydp" firstAttribute="centerY" secondItem="lNA-6P-Vee" secondAttribute="centerY" id="tSW-tO-h77"/>
62+
</constraints>
63+
</tableViewCellContentView>
64+
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
65+
<point key="canvasLocation" x="118.84057971014494" y="55.915178571428569"/>
66+
</tableViewCell>
67+
</objects>
68+
<resources>
69+
<image name="addFavorite" width="22.5" height="21.5"/>
70+
<image name="favorited" width="22.5" height="21.5"/>
71+
</resources>
72+
</document>

AnimalsApp/AnimalsApp/Views/HomeViewController/HomeViewController.swift

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,34 @@
88
import UIKit
99

1010
class HomeViewController: UIViewController {
11-
11+
12+
@IBOutlet var tableView: UITableView!
13+
1214
override func viewDidLoad() {
1315
super.viewDidLoad()
1416

15-
view.backgroundColor = .red
17+
tableView.dataSource = self
18+
tableView.delegate = self
19+
20+
tableView.register(UINib(nibName: "AnimalTableViewCell", bundle: nil), forCellReuseIdentifier: "Animal")
1621
}
22+
}
1723

18-
19-
/*
20-
// MARK: - Navigation
21-
22-
// In a storyboard-based application, you will often want to do a little preparation before navigation
23-
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
24-
// Get the new view controller using segue.destination.
25-
// Pass the selected object to the new view controller.
24+
extension HomeViewController: UITableViewDataSource {
25+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
26+
return 5
2627
}
27-
*/
28+
29+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
30+
guard let cell = tableView.dequeueReusableCell(withIdentifier: "Animal") as? AnimalTableViewCell else {
31+
return UITableViewCell()
32+
}
33+
34+
return cell
35+
}
36+
37+
}
2838

39+
extension HomeViewController: UITableViewDelegate {
40+
2941
}
Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
34
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
57
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
69
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
710
</dependencies>
811
<objects>
9-
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HomeViewController" customModuleProvider="target">
12+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HomeViewController" customModule="AnimalsApp" customModuleProvider="target">
1013
<connections>
14+
<outlet property="tableView" destination="Siv-wY-ZEk" id="zHW-EM-j8u"/>
1115
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
1216
</connections>
1317
</placeholder>
1418
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
1519
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
16-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
20+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
1721
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18-
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
22+
<subviews>
23+
<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">
24+
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
25+
</tableView>
26+
</subviews>
1927
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
28+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
29+
<constraints>
30+
<constraint firstItem="Siv-wY-ZEk" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="AmS-A8-kRI"/>
31+
<constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="Siv-wY-ZEk" secondAttribute="trailing" id="CK9-kj-fPh"/>
32+
<constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="Siv-wY-ZEk" secondAttribute="bottom" id="Fs7-zJ-zOE"/>
33+
<constraint firstItem="Siv-wY-ZEk" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="RJW-a7-pVc"/>
34+
</constraints>
35+
<point key="canvasLocation" x="132" y="84"/>
2036
</view>
2137
</objects>
38+
<resources>
39+
<systemColor name="systemBackgroundColor">
40+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
41+
</systemColor>
42+
</resources>
2243
</document>

AnimalsApp/AnimalsApp/Views/TabBarController/MainTabBarController.swift

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,39 @@ class MainTabBarController: UITabBarController {
1111

1212
override func viewDidLoad() {
1313
super.viewDidLoad()
14-
15-
tabBar.barTintColor = .gray
14+
15+
setupViewControllers()
1616
setupTabBar()
1717
}
1818

19-
func setupTabBar() {
19+
func setupViewControllers() {
20+
2021
let homeVC = UINavigationController(rootViewController: HomeViewController())
21-
homeVC.tabBarItem.image = .homeTabBar
22-
homeVC.tabBarItem.selectedImage = .homeSelectedTabBar
22+
homeVC.tabBarItem = UITabBarItem(title: "Home", image: .homeTabBar, selectedImage: .homeSelectedTabBar)
2323

2424
let registerVC = UINavigationController(rootViewController: RegisterViewController())
25-
registerVC.tabBarItem.image = .registerTabBar
26-
registerVC.tabBarItem.selectedImage = .registerSelectedTabBar
25+
registerVC.tabBarItem = UITabBarItem(title: "Cadastrar", image: .registerTabBar, selectedImage: .registerSelectedTabBar)
2726

2827
let favoritesVC = UINavigationController(rootViewController: FavoritesViewController())
29-
favoritesVC.tabBarItem.image = .favoritesTabBar
30-
favoritesVC.tabBarItem.selectedImage = .favoritesSelectedTabBar
28+
favoritesVC.tabBarItem = UITabBarItem(title: "Favoritos", image: .favoritesTabBar, selectedImage: .favoritesSelectedTabBar)
3129

3230
viewControllers = [homeVC, registerVC, favoritesVC]
3331
}
3432

33+
func setupTabBar() {
34+
let tabBarAppearance = UITabBarAppearance()
35+
let tabBarItemAppearance = UITabBarItemAppearance()
36+
37+
tabBarItemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
38+
tabBarItemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
39+
40+
tabBarAppearance.stackedLayoutAppearance = tabBarItemAppearance
41+
tabBarAppearance.backgroundColor = UIColor(named: "blueTabBarColor")
42+
43+
tabBar.standardAppearance = tabBarAppearance
44+
if #available(iOS 15.0, *) {
45+
tabBar.scrollEdgeAppearance = tabBarAppearance
46+
}
47+
}
48+
3549
}

0 commit comments

Comments
 (0)