Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
90DEEE9734C2F687A494F707 /* Address.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D4299706444DDB25AAFE0EF /* Address.swift */; };
93D3FE52D4B4DAC55777C807 /* DividerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DBD4DFD1BA1A60A9F16143D /* DividerView.swift */; };
BAA07DA6700443EF669169E7 /* LoadingViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B83ED7FFA5AFCAD82D6B8B86 /* LoadingViewTests.swift */; };
BC21EA1E27CBE6CA009B5C42 /* AddressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC21EA1D27CBE6CA009B5C42 /* AddressView.swift */; };
BC21EA2027CBEDB2009B5C42 /* AddressViewSnapshotTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC21EA1F27CBEDB2009B5C42 /* AddressViewSnapshotTest.swift */; };
C116839CB42191825FD0EE20 /* DebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D984A5DB5D0A939DCA47A3C2 /* DebugViewController.swift */; };
C274F76137BE1C402CDD5365 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E139B851E36D86DF159299EC /* LaunchScreen.storyboard */; };
C83E21C6B44C37ECD30AC923 /* RestaurantCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E68565F02DD38DA7F889400 /* RestaurantCellView.swift */; };
Expand Down Expand Up @@ -87,6 +89,8 @@
AC221A1BAD589AB59E321F5D /* Pods-DeliveryApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DeliveryApp.debug.xcconfig"; path = "Target Support Files/Pods-DeliveryApp/Pods-DeliveryApp.debug.xcconfig"; sourceTree = "<group>"; };
B83ED7FFA5AFCAD82D6B8B86 /* LoadingViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingViewTests.swift; sourceTree = "<group>"; };
BB57AE2920562B7BFC4D49E6 /* MenuItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItemViewController.swift; sourceTree = "<group>"; };
BC21EA1D27CBE6CA009B5C42 /* AddressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressView.swift; sourceTree = "<group>"; };
BC21EA1F27CBEDB2009B5C42 /* AddressViewSnapshotTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressViewSnapshotTest.swift; sourceTree = "<group>"; };
C09A4CC3F67F3C6F5DCD55CF /* HomeViewSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewSnapshotTests.swift; sourceTree = "<group>"; };
CA69B52776E4F635CAECCC7E /* Pods_DeliveryApp_DeliveryAppTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DeliveryApp_DeliveryAppTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CED50894E508253133ADF8BE /* RestaurantListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestaurantListView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -135,6 +139,7 @@
F85F1AF9779855CFA0C113C3 /* CategoryCellViewSnapshotTests.swift */,
D59DF5B978A3EA3A1A744721 /* DividerViewSnapshotTests.swift */,
C09A4CC3F67F3C6F5DCD55CF /* HomeViewSnapshotTests.swift */,
BC21EA1F27CBEDB2009B5C42 /* AddressViewSnapshotTest.swift */,
D6BA3897D551848000FCC171 /* RatingViewSnapshotTests.swift */,
);
path = SnapshotTests;
Expand Down Expand Up @@ -247,6 +252,8 @@
941A49E3E7F53E5B35CF07AB /* LoadingView.swift */,
4E68565F02DD38DA7F889400 /* RestaurantCellView.swift */,
974F53BB3C568B6A6DF0AE32 /* Category */,
98B0521756F2250C2953BCD5 /* Divider */,
BC21EA1D27CBE6CA009B5C42 /* AddressView.swift */,
F05F1884F7AA12EE689147DE /* Rating */,
);
path = Components;
Expand Down Expand Up @@ -411,8 +418,6 @@
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1200;
TargetAttributes = {
};
};
buildConfigurationList = 914F574E117DF9B00F203F9B /* Build configuration list for PBXProject "DeliveryApp" */;
compatibilityVersion = "Xcode 10.0";
Expand Down Expand Up @@ -539,6 +544,7 @@
3C60A8D2209C638C9F496A15 /* RestaurantListViewController.swift in Sources */,
8EDCF8A202AABC0D39C45DE1 /* SceneDelegate.swift in Sources */,
4AF0E5E8838752D0E5CA015F /* SettingsView.swift in Sources */,
BC21EA1E27CBE6CA009B5C42 /* AddressView.swift in Sources */,
D6E433843A90B28D0FAA57F5 /* SettingsViewController.swift in Sources */,
7141E7C89DBE44E0A62CC1D0 /* String+Extensions.swift in Sources */,
23A230758E657B5D9ED47F02 /* UIViewPreview.swift in Sources */,
Expand All @@ -550,6 +556,7 @@
buildActionMask = 2147483647;
files = (
8C3DD1447C559C0BEB2C5E77 /* CategoryCellViewSnapshotTests.swift in Sources */,
BC21EA2027CBEDB2009B5C42 /* AddressViewSnapshotTest.swift in Sources */,
F37395B3165B215EA15560D4 /* DeliveryAppTests.swift in Sources */,
58F089B26DEDB509E94F4CBF /* DividerViewSnapshotTests.swift in Sources */,
1F4C885F4F3C9D9487D5F02F /* EmptyViewSnapshot.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
runPostActionsOnFailure = "NO">
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -27,8 +26,16 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
onlyGenerateCoverageForSpecifiedTargets = "NO"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "25D3EF7051FF9C9EA9A15959"
BuildableName = "DeliveryApp.app"
BlueprintName = "DeliveryApp"
ReferencedContainer = "container:DeliveryApp.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -41,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "25D3EF7051FF9C9EA9A15959"
BuildableName = "DeliveryApp.app"
BlueprintName = "DeliveryApp"
ReferencedContainer = "container:DeliveryApp.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -73,8 +69,6 @@
ReferencedContainer = "container:DeliveryApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand All @@ -92,8 +86,6 @@
ReferencedContainer = "container:DeliveryApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
</CommandLineArguments>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//
// AddressView.swift
// DeliveryApp
//
// Created by Alexandre Cardoso on 21/02/22.
//

import UIKit

protocol AddressViewDelegate: AnyObject {
func didTapEditAddress()
}

final class AddressView: UIView {

private lazy var addressLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.text = "Selecione um endereço"
label.font = .systemFont(ofSize: 16, weight: .bold)
label.adjustsFontSizeToFitWidth = true
label.textColor = .black
label.textAlignment = .left
return label
}()

private lazy var editButton: UIButton = {
let button = UIButton(type: .system)
button.translatesAutoresizingMaskIntoConstraints = false
button.setAttributedTitle(
NSAttributedString(
string: "Editar",
attributes: [.font: UIFont.systemFont(ofSize: 15, weight: .bold)]
),
for: .normal
)
button.layer.cornerRadius = 10
button.layer.borderColor = UIColor.link.cgColor
button.layer.borderWidth = 1.0
button.addTarget(self, action: #selector(editAddress(_:)), for: .touchUpInside)
return button
}()

weak var delegate: AddressViewDelegate?

override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

func updateView(address: String) {
addressLabel.text = address
}

private func setupView() {
buildHierarchy()
buildConstraints()
}

@objc
private func editAddress(_ sender: UIButton) {
delegate?.didTapEditAddress()
}

}

extension AddressView {

private func buildHierarchy() {
addSubview(addressLabel)
addSubview(editButton)
}

private func buildConstraints() {
NSLayoutConstraint.activate([
addressLabel.leadingAnchor.constraint(equalTo: leadingAnchor),
addressLabel.centerYAnchor.constraint(equalTo: centerYAnchor),

editButton.heightAnchor.constraint(equalToConstant: 40),
editButton.widthAnchor.constraint(equalToConstant: 70),
editButton.leadingAnchor.constraint(equalTo: addressLabel.trailingAnchor, constant: 16),
editButton.centerYAnchor.constraint(equalTo: centerYAnchor)
])
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ final class HomeView: UIView {
return loadingView
}()

private lazy var addressView: AddressView = {
let view = AddressView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .white
return view
}()

private lazy var dividerView: DividerView = {
let view = DividerView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

init() {

super.init(frame: .zero)
Expand Down Expand Up @@ -65,12 +78,16 @@ private extension HomeView {

self.configureSubviews()
self.configureLoadingViewConstraints()
self.configureAddressViewConstraints()
self.configureDividerViewConstraints()
self.configureTableViewConstraints()

}

func configureSubviews() {

self.addSubview(self.addressView)
self.addSubview(self.dividerView)
self.addSubview(self.tableView)
self.addSubview(self.loadingView)
}
Expand All @@ -84,11 +101,28 @@ private extension HomeView {
])
}

func configureAddressViewConstraints() {
NSLayoutConstraint.activate([
self.addressView.topAnchor.constraint(equalTo: self.safeAreaLayoutGuide.topAnchor),
self.addressView.leadingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.leadingAnchor, constant: 16),
self.addressView.trailingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.trailingAnchor),
self.addressView.heightAnchor.constraint(equalToConstant: 66)
])
}

func configureDividerViewConstraints() {
NSLayoutConstraint.activate([
self.dividerView.topAnchor.constraint(equalTo: self.addressView.bottomAnchor, constant: 8),
self.dividerView.leadingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.leadingAnchor),
self.dividerView.trailingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.trailingAnchor),
])
}

func configureTableViewConstraints() {
NSLayoutConstraint.activate([
self.tableView.leadingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.leadingAnchor),
self.tableView.trailingAnchor.constraint(equalTo: self.safeAreaLayoutGuide.trailingAnchor),
self.tableView.topAnchor.constraint(equalTo: self.safeAreaLayoutGuide.topAnchor),
self.tableView.topAnchor.constraint(equalTo: self.dividerView.bottomAnchor, constant: 10),
self.tableView.bottomAnchor.constraint(equalTo: self.safeAreaLayoutGuide.bottomAnchor)
])
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// AddressViewSnapshotTest.swift
// DeliveryAppTests
//
// Created by Alexandre Cardoso on 27/02/22.
//

import XCTest
import SnapshotTesting

@testable import DeliveryApp

final class AddressViewSnapshotTest: XCTestCase {

func test_AddressView_DefaultAddress() {
let frame = CGRect(x: 0, y: 0, width: 375, height: 66)
let view = AddressView(frame: frame)

assertSnapshot(matching: view, as: .image, record: false)
}

func test_AddressView_InformedAddress() {
let frame = CGRect(x: 0, y: 0, width: 375, height: 66)
let view = AddressView(frame: frame)

view.updateView(address: "Avenida Paulista, 1000")

assertSnapshot(matching: view, as: .image, record: false)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion solutions/devsprint-michael-douglas-2/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: eed1b6882996396c07abdbbdb955edb2ea0353a2

COCOAPODS: 1.11.2
COCOAPODS: 1.10.1