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 @@ -33,11 +33,12 @@
98AF573227ADB16E00339A66 /* Restaurant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C4368627ADAEA500D9048A /* Restaurant.swift */; };
98AF573327ADB16E00339A66 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C4368827ADAEBE00D9048A /* String+Extensions.swift */; };
98AF573627ADB34C00339A66 /* DebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98AF573527ADB34C00339A66 /* DebugViewController.swift */; };
F449E4A628886B9000855201 /* AdressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F449E4A528886B9000855201 /* AdressCell.swift */; };
BB728CE428933D33002E6D4C /* RestaurantInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB728CE328933D33002E6D4C /* RestaurantInfoView.swift */; };
EE29C39B288F7613000DDB2D /* AddressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE29C399288F7613000DDB2D /* AddressView.swift */; };
EE29C39C288F7613000DDB2D /* MenuItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE29C39A288F7613000DDB2D /* MenuItemCell.swift */; };
EE5EF4DC2888DBD200B5553C /* RestaurantCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE5EF4DB2888DBD200B5553C /* RestaurantCell.swift */; };
EED63CA3288B637C00CB4610 /* EmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EED63CA2288B637C00CB4610 /* EmptyView.swift */; };
F449E4A628886B9000855201 /* AdressCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F449E4A528886B9000855201 /* AdressCell.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -80,11 +81,12 @@
98F1297C272F51DE00B88A87 /* MenuItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItemViewController.swift; sourceTree = "<group>"; };
98FC5AAA2732B938002412EA /* RestaurantDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestaurantDetailsView.swift; sourceTree = "<group>"; };
98FC5AB72732C1EF002412EA /* MenuItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItemView.swift; sourceTree = "<group>"; };
F449E4A528886B9000855201 /* AdressCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdressCell.swift; sourceTree = "<group>"; };
BB728CE328933D33002E6D4C /* RestaurantInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestaurantInfoView.swift; sourceTree = "<group>"; };
EE29C399288F7613000DDB2D /* AddressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddressView.swift; sourceTree = "<group>"; };
EE29C39A288F7613000DDB2D /* MenuItemCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuItemCell.swift; sourceTree = "<group>"; };
EE5EF4DB2888DBD200B5553C /* RestaurantCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestaurantCell.swift; sourceTree = "<group>"; };
EED63CA2288B637C00CB4610 /* EmptyView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmptyView.swift; sourceTree = "<group>"; };
F449E4A528886B9000855201 /* AdressCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdressCell.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -265,8 +267,8 @@
EED63CA2288B637C00CB4610 /* EmptyView.swift */,
98C4368027ADADC000D9048A /* SampleComponentView.swift */,
1E2324E4288720CA00414138 /* LoadingView.swift */,
BB728CE328933D33002E6D4C /* RestaurantInfoView.swift */,
F449E4A528886B9000855201 /* AdressCell.swift */,
8B113972288865DE00A42625 /* EmptyView.swift */,
EE5EF4DB2888DBD200B5553C /* RestaurantCell.swift */,
);
path = Components;
Expand Down Expand Up @@ -390,6 +392,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BB728CE428933D33002E6D4C /* RestaurantInfoView.swift in Sources */,
EE5EF4DC2888DBD200B5553C /* RestaurantCell.swift in Sources */,
98AF572227ADB16E00339A66 /* AppDelegate.swift in Sources */,
98AF573627ADB34C00339A66 /* DebugViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// RestaurantInfoView.swift
// DeliveryApp
//
// Created by Manoel Filho on 26/07/22.
//

import UIKit

final class RestaurantInfoView: UIView {

var restaurant: Restaurant? {
didSet{
self.nameLabel.text = restaurant?.name
self.categoryLabel.text = "\(restaurant?.category ?? "") \u{2022} \(restaurant?.deliveryTime.min ?? 0) - \(restaurant?.deliveryTime.max ?? 0) min"
self.restaurantImage.image = UIImage(named: "restaurant-logo")
}
}

private lazy var nameLabel: UILabel = {
let nameLabel = UILabel()
nameLabel.text = "Title"
nameLabel.font = .systemFont(ofSize: 22, weight: .bold)
nameLabel.tintColor = .black
return nameLabel
}()

private lazy var categoryLabel: UILabel = {
let categoryLabel = UILabel()
categoryLabel.text = "Category"
categoryLabel.font = .systemFont(ofSize: 15, weight: .regular)
categoryLabel.tintColor = .black
return categoryLabel
}()

private lazy var nameAndCategoryStackView: UIStackView = {
let nameAndCategoryStackView = UIStackView(arrangedSubviews: [nameLabel, categoryLabel])
nameAndCategoryStackView.axis = .vertical
nameAndCategoryStackView.spacing = 12
return nameAndCategoryStackView
}()

private lazy var restaurantImage: UIImageView = {
let restaurantImage = UIImageView()
restaurantImage.clipsToBounds = true
return restaurantImage
}()

private lazy var wrapperStackView: UIStackView = {
let wrapperStackView = UIStackView(arrangedSubviews: [nameAndCategoryStackView, restaurantImage])
wrapperStackView.translatesAutoresizingMaskIntoConstraints = false
wrapperStackView.alignment = .firstBaseline
return wrapperStackView
}()

convenience init() {
self.init(frame: .zero)
setup()
}

}

extension RestaurantInfoView: ViewCode {

func setupSubviews() {
addSubview(wrapperStackView)
}

func setupConstraints() {
setupWrapperStackViewConstraints()
setupRestaurantImageConstraints()
}

private func setupWrapperStackViewConstraints() {
NSLayoutConstraint.activate([
wrapperStackView.topAnchor.constraint(equalTo: topAnchor),
wrapperStackView.bottomAnchor.constraint(equalTo: bottomAnchor),
wrapperStackView.leadingAnchor.constraint(equalTo: leadingAnchor),
wrapperStackView.trailingAnchor.constraint(equalTo: trailingAnchor)
])
}

private func setupRestaurantImageConstraints() {
let sizeImage = CGSize(width: 48, height: 48)
NSLayoutConstraint.activate([
restaurantImage.widthAnchor.constraint(equalToConstant: sizeImage.width),
restaurantImage.heightAnchor.constraint(equalToConstant: sizeImage.height)
])
restaurantImage.layer.cornerRadius = sizeImage.width / 2
}

}