Skip to content

Commit 1c7cc94

Browse files
committed
Feat(AddressCell): create
1 parent 224cf8e commit 1c7cc94

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
98AF573227ADB16E00339A66 /* Restaurant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C4368627ADAEA500D9048A /* Restaurant.swift */; };
3535
98AF573327ADB16E00339A66 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C4368827ADAEBE00D9048A /* String+Extensions.swift */; };
3636
98AF573627ADB34C00339A66 /* DebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98AF573527ADB34C00339A66 /* DebugViewController.swift */; };
37+
F449E4A628886B9000855201 /* AdressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F449E4A528886B9000855201 /* AdressCell.swift */; };
3738
/* End PBXBuildFile section */
3839

3940
/* Begin PBXContainerItemProxy section */
@@ -77,6 +78,7 @@
7778
98F1297C272F51DE00B88A87 /* MenuItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItemViewController.swift; sourceTree = "<group>"; };
7879
98FC5AAA2732B938002412EA /* RestaurantDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestaurantDetailsView.swift; sourceTree = "<group>"; };
7980
98FC5AB72732C1EF002412EA /* MenuItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItemView.swift; sourceTree = "<group>"; };
81+
F449E4A528886B9000855201 /* AdressCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdressCell.swift; sourceTree = "<group>"; };
8082
/* End PBXFileReference section */
8183

8284
/* Begin PBXFrameworksBuildPhase section */
@@ -254,7 +256,8 @@
254256
children = (
255257
98C4368027ADADC000D9048A /* SampleComponentView.swift */,
256258
1E2324E4288720CA00414138 /* LoadingView.swift */,
257-
8B113972288865DE00A42625 /* EmptyView.swift */,
259+
F449E4A528886B9000855201 /* AdressCell.swift */,
260+
8B113972288865DE00A42625 /* EmptyView.swift */,
258261
);
259262
path = Components;
260263
sourceTree = "<group>";
@@ -383,6 +386,7 @@
383386
98AF572427ADB16E00339A66 /* SampleComponentView.swift in Sources */,
384387
8B113973288865DE00A42625 /* EmptyView.swift in Sources */,
385388
98AF572527ADB16E00339A66 /* HomeViewController.swift in Sources */,
389+
F449E4A628886B9000855201 /* AdressCell.swift in Sources */,
386390
98AF572627ADB16E00339A66 /* HomeView.swift in Sources */,
387391
98AF572727ADB16E00339A66 /* AddressSearchViewController.swift in Sources */,
388392
98AF572827ADB16E00339A66 /* AddressListView.swift in Sources */,
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//
2+
// AdressCell.swift
3+
// DeliveryApp
4+
//
5+
// Created by Daniel Alves Barreto on 20/07/22.
6+
//
7+
8+
import Foundation
9+
import UIKit
10+
11+
final class AddressCell: UITableViewCell {
12+
private lazy var container: UIStackView = {
13+
let view = UIStackView()
14+
view.translatesAutoresizingMaskIntoConstraints = false
15+
view.axis = .vertical
16+
view.spacing = 4
17+
view.addArrangedSubview(addressLabel)
18+
view.addArrangedSubview(neighborhoodLabel)
19+
return view
20+
}()
21+
22+
private lazy var addressLabel: UILabel = {
23+
let label = UILabel()
24+
label.translatesAutoresizingMaskIntoConstraints = false
25+
label.font = .systemFont(ofSize: 17, weight: .bold)
26+
label.textColor = .black
27+
return label
28+
}()
29+
30+
private lazy var neighborhoodLabel: UILabel = {
31+
let label = UILabel()
32+
label.translatesAutoresizingMaskIntoConstraints = false
33+
label.font = .systemFont(ofSize: 14)
34+
label.textColor = .lightGray
35+
return label
36+
}()
37+
38+
func updateView(address: String, neighborhood: String){
39+
addressLabel.text = address
40+
neighborhoodLabel.text = neighborhood
41+
}
42+
43+
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
44+
super.init(style: style, reuseIdentifier: reuseIdentifier)
45+
setup()
46+
}
47+
48+
required init?(coder: NSCoder) {
49+
fatalError("init(coder:) has not been implemented")
50+
}
51+
}
52+
53+
extension AddressCell: ViewCode {
54+
func setupSubviews() {
55+
addSubview(container)
56+
}
57+
58+
func setupConstraints() {
59+
setupContainerConstraints()
60+
}
61+
62+
func setupContainerConstraints(){
63+
NSLayoutConstraint.activate([
64+
container.topAnchor.constraint(equalTo: topAnchor, constant: 12),
65+
container.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 20),
66+
container.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -12)
67+
])
68+
}
69+
}

0 commit comments

Comments
 (0)