Skip to content

Commit 1108b10

Browse files
authored
Merge pull request #34 from manoelfilho/main
Adding RestaurantInfoView
2 parents 3245321 + 8f0b971 commit 1108b10

File tree

2 files changed

+98
-3
lines changed

2 files changed

+98
-3
lines changed

solutions/devsprint-vinicius-carvalho-3/DeliveryApp.xcodeproj/project.pbxproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@
3333
98AF573227ADB16E00339A66 /* Restaurant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C4368627ADAEA500D9048A /* Restaurant.swift */; };
3434
98AF573327ADB16E00339A66 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C4368827ADAEBE00D9048A /* String+Extensions.swift */; };
3535
98AF573627ADB34C00339A66 /* DebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98AF573527ADB34C00339A66 /* DebugViewController.swift */; };
36-
F449E4A628886B9000855201 /* AdressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F449E4A528886B9000855201 /* AdressCell.swift */; };
36+
BB728CE428933D33002E6D4C /* RestaurantInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB728CE328933D33002E6D4C /* RestaurantInfoView.swift */; };
3737
EE29C39B288F7613000DDB2D /* AddressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE29C399288F7613000DDB2D /* AddressView.swift */; };
3838
EE29C39C288F7613000DDB2D /* MenuItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE29C39A288F7613000DDB2D /* MenuItemCell.swift */; };
3939
EE5EF4DC2888DBD200B5553C /* RestaurantCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE5EF4DB2888DBD200B5553C /* RestaurantCell.swift */; };
4040
EED63CA3288B637C00CB4610 /* EmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EED63CA2288B637C00CB4610 /* EmptyView.swift */; };
41+
F449E4A628886B9000855201 /* AdressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F449E4A528886B9000855201 /* AdressCell.swift */; };
4142
/* End PBXBuildFile section */
4243

4344
/* Begin PBXContainerItemProxy section */
@@ -80,11 +81,12 @@
8081
98F1297C272F51DE00B88A87 /* MenuItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItemViewController.swift; sourceTree = "<group>"; };
8182
98FC5AAA2732B938002412EA /* RestaurantDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestaurantDetailsView.swift; sourceTree = "<group>"; };
8283
98FC5AB72732C1EF002412EA /* MenuItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItemView.swift; sourceTree = "<group>"; };
83-
F449E4A528886B9000855201 /* AdressCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdressCell.swift; sourceTree = "<group>"; };
84+
BB728CE328933D33002E6D4C /* RestaurantInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestaurantInfoView.swift; sourceTree = "<group>"; };
8485
EE29C399288F7613000DDB2D /* AddressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddressView.swift; sourceTree = "<group>"; };
8586
EE29C39A288F7613000DDB2D /* MenuItemCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuItemCell.swift; sourceTree = "<group>"; };
8687
EE5EF4DB2888DBD200B5553C /* RestaurantCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestaurantCell.swift; sourceTree = "<group>"; };
8788
EED63CA2288B637C00CB4610 /* EmptyView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmptyView.swift; sourceTree = "<group>"; };
89+
F449E4A528886B9000855201 /* AdressCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdressCell.swift; sourceTree = "<group>"; };
8890
/* End PBXFileReference section */
8991

9092
/* Begin PBXFrameworksBuildPhase section */
@@ -265,8 +267,8 @@
265267
EED63CA2288B637C00CB4610 /* EmptyView.swift */,
266268
98C4368027ADADC000D9048A /* SampleComponentView.swift */,
267269
1E2324E4288720CA00414138 /* LoadingView.swift */,
270+
BB728CE328933D33002E6D4C /* RestaurantInfoView.swift */,
268271
F449E4A528886B9000855201 /* AdressCell.swift */,
269-
8B113972288865DE00A42625 /* EmptyView.swift */,
270272
EE5EF4DB2888DBD200B5553C /* RestaurantCell.swift */,
271273
);
272274
path = Components;
@@ -390,6 +392,7 @@
390392
isa = PBXSourcesBuildPhase;
391393
buildActionMask = 2147483647;
392394
files = (
395+
BB728CE428933D33002E6D4C /* RestaurantInfoView.swift in Sources */,
393396
EE5EF4DC2888DBD200B5553C /* RestaurantCell.swift in Sources */,
394397
98AF572227ADB16E00339A66 /* AppDelegate.swift in Sources */,
395398
98AF573627ADB34C00339A66 /* DebugViewController.swift in Sources */,
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//
2+
// RestaurantInfoView.swift
3+
// DeliveryApp
4+
//
5+
// Created by Manoel Filho on 26/07/22.
6+
//
7+
8+
import UIKit
9+
10+
final class RestaurantInfoView: UIView {
11+
12+
var restaurant: Restaurant? {
13+
didSet{
14+
self.nameLabel.text = restaurant?.name
15+
self.categoryLabel.text = "\(restaurant?.category ?? "") \u{2022} \(restaurant?.deliveryTime.min ?? 0) - \(restaurant?.deliveryTime.max ?? 0) min"
16+
self.restaurantImage.image = UIImage(named: "restaurant-logo")
17+
}
18+
}
19+
20+
private lazy var nameLabel: UILabel = {
21+
let nameLabel = UILabel()
22+
nameLabel.text = "Title"
23+
nameLabel.font = .systemFont(ofSize: 22, weight: .bold)
24+
nameLabel.tintColor = .black
25+
return nameLabel
26+
}()
27+
28+
private lazy var categoryLabel: UILabel = {
29+
let categoryLabel = UILabel()
30+
categoryLabel.text = "Category"
31+
categoryLabel.font = .systemFont(ofSize: 15, weight: .regular)
32+
categoryLabel.tintColor = .black
33+
return categoryLabel
34+
}()
35+
36+
private lazy var nameAndCategoryStackView: UIStackView = {
37+
let nameAndCategoryStackView = UIStackView(arrangedSubviews: [nameLabel, categoryLabel])
38+
nameAndCategoryStackView.axis = .vertical
39+
nameAndCategoryStackView.spacing = 12
40+
return nameAndCategoryStackView
41+
}()
42+
43+
private lazy var restaurantImage: UIImageView = {
44+
let restaurantImage = UIImageView()
45+
restaurantImage.clipsToBounds = true
46+
return restaurantImage
47+
}()
48+
49+
private lazy var wrapperStackView: UIStackView = {
50+
let wrapperStackView = UIStackView(arrangedSubviews: [nameAndCategoryStackView, restaurantImage])
51+
wrapperStackView.translatesAutoresizingMaskIntoConstraints = false
52+
wrapperStackView.alignment = .firstBaseline
53+
return wrapperStackView
54+
}()
55+
56+
convenience init() {
57+
self.init(frame: .zero)
58+
setup()
59+
}
60+
61+
}
62+
63+
extension RestaurantInfoView: ViewCode {
64+
65+
func setupSubviews() {
66+
addSubview(wrapperStackView)
67+
}
68+
69+
func setupConstraints() {
70+
setupWrapperStackViewConstraints()
71+
setupRestaurantImageConstraints()
72+
}
73+
74+
private func setupWrapperStackViewConstraints() {
75+
NSLayoutConstraint.activate([
76+
wrapperStackView.topAnchor.constraint(equalTo: topAnchor),
77+
wrapperStackView.bottomAnchor.constraint(equalTo: bottomAnchor),
78+
wrapperStackView.leadingAnchor.constraint(equalTo: leadingAnchor),
79+
wrapperStackView.trailingAnchor.constraint(equalTo: trailingAnchor)
80+
])
81+
}
82+
83+
private func setupRestaurantImageConstraints() {
84+
let sizeImage = CGSize(width: 48, height: 48)
85+
NSLayoutConstraint.activate([
86+
restaurantImage.widthAnchor.constraint(equalToConstant: sizeImage.width),
87+
restaurantImage.heightAnchor.constraint(equalToConstant: sizeImage.height)
88+
])
89+
restaurantImage.layer.cornerRadius = sizeImage.width / 2
90+
}
91+
92+
}

0 commit comments

Comments
 (0)