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 @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
1E2324E328871F2F00414138 /* ViewCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E2324E228871F2F00414138 /* ViewCode.swift */; };
1E2324E5288720CA00414138 /* LoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E2324E4288720CA00414138 /* LoadingView.swift */; };
98228D7D27BC489F006A38BB /* Address.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98228D7C27BC489F006A38BB /* Address.swift */; };
98228D7F27BC490E006A38BB /* RestaurantDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98228D7E27BC490E006A38BB /* RestaurantDetails.swift */; };
983271C6272752B50010C63A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 983271C5272752B50010C63A /* Assets.xcassets */; };
Expand Down Expand Up @@ -44,6 +46,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1E2324E228871F2F00414138 /* ViewCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewCode.swift; sourceTree = "<group>"; };
1E2324E4288720CA00414138 /* LoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingView.swift; sourceTree = "<group>"; };
98228D7C27BC489F006A38BB /* Address.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Address.swift; sourceTree = "<group>"; };
98228D7E27BC490E006A38BB /* RestaurantDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestaurantDetails.swift; sourceTree = "<group>"; };
983271B9272752AF0010C63A /* DeliveryApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DeliveryApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -91,6 +95,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
1E2324E128871F0F00414138 /* Protocols */ = {
isa = PBXGroup;
children = (
1E2324E228871F2F00414138 /* ViewCode.swift */,
);
path = Protocols;
sourceTree = "<group>";
};
983271B0272752AF0010C63A = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -153,12 +165,13 @@
983271EE272752EE0010C63A /* Screens */ = {
isa = PBXGroup;
children = (
98EA0559272A08D7007B0228 /* AddressSearch */,
98F12963272F307100B88A87 /* Components */,
983271F2272753100010C63A /* Home */,
98F12978272F4D7600B88A87 /* MenuItem */,
1E2324E128871F0F00414138 /* Protocols */,
98EA055F272A0950007B0228 /* RestaurantDetails */,
98EA0559272A08D7007B0228 /* AddressSearch */,
98EA055C272A0933007B0228 /* RestaurantList */,
98F12978272F4D7600B88A87 /* MenuItem */,
98F12979272F512900B88A87 /* Settings */,
);
path = Screens;
Expand Down Expand Up @@ -238,6 +251,7 @@
isa = PBXGroup;
children = (
98C4368027ADADC000D9048A /* SampleComponentView.swift */,
1E2324E4288720CA00414138 /* LoadingView.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -379,8 +393,10 @@
98AF572F27ADB16E00339A66 /* SettingsViewController.swift in Sources */,
98AF573027ADB16E00339A66 /* SettingsView.swift in Sources */,
98AF573127ADB16E00339A66 /* DeliveryApi.swift in Sources */,
1E2324E328871F2F00414138 /* ViewCode.swift in Sources */,
98AF573227ADB16E00339A66 /* Restaurant.swift in Sources */,
98AF573327ADB16E00339A66 /* String+Extensions.swift in Sources */,
1E2324E5288720CA00414138 /* LoadingView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// LoadingView.swift
// DeliveryApp
//
// Created by Vitor Conceicao on 19/07/22.
//

import UIKit

final class LoadingView: UIView {
private lazy var titleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.translatesAutoresizingMaskIntoConstraints = false
titleLabel.text = "Buscando endereços..."
titleLabel.font = .systemFont(ofSize: 17, weight: .bold)
titleLabel.tintColor = .black
return titleLabel
}()

private lazy var loadingIndicator: UIActivityIndicatorView = {
let loadingIndicator = UIActivityIndicatorView(style: .large)
loadingIndicator.translatesAutoresizingMaskIntoConstraints = false
return loadingIndicator
}()

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

extension LoadingView: ViewCode {
func setupSubviews() {
addSubview(titleLabel)
addSubview(loadingIndicator)
}

func setupConstraints() {
setupTitleLabelConstraints()
setupLoadingIndicatorConstraints()
}

func setupExtraConfiguration() {
loadingIndicator.startAnimating()
}

private func setupTitleLabelConstraints() {
NSLayoutConstraint.activate([
titleLabel.bottomAnchor.constraint(equalTo: centerYAnchor),
titleLabel.centerXAnchor.constraint(equalTo: centerXAnchor)
])
}

private func setupLoadingIndicatorConstraints() {
NSLayoutConstraint.activate([
loadingIndicator.topAnchor.constraint(equalTo: centerYAnchor, constant: 10),
loadingIndicator.centerXAnchor.constraint(equalTo: centerXAnchor)
])
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// ViewCode.swift
// DeliveryApp
//
// Created by Vitor Conceicao on 19/07/22.
//

import Foundation

protocol ViewCode {
func setupSubviews()
func setupConstraints()
func setupExtraConfiguration()
func setup()
}

extension ViewCode {
func setup() {
setupSubviews()
setupConstraints()
setupExtraConfiguration()
}

func setupExtraConfiguration() {}
}