Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit e58e50a

Browse files
committed
Добавил блоки-комментарии для структуры
1 parent 7b47a23 commit e58e50a

5 files changed

Lines changed: 75 additions & 2 deletions

File tree

AvitoTech-TraineeAssignment/AvitoTech-TraineeAssignment/Screens/Catalog/CatalogCell.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ import UIKit
99
import Kingfisher
1010

1111
final class CatalogCell: UICollectionViewCell, ReuseIdentifying {
12+
// MARK: - iternal properties
1213
var id: String?
13-
14+
15+
16+
// MARK: - private ui properties
17+
1418
private let imageView: UIImageView = {
1519
let imageView = UIImageView()
1620
imageView.contentMode = .scaleAspectFill
@@ -60,6 +64,9 @@ final class CatalogCell: UICollectionViewCell, ReuseIdentifying {
6064
return label
6165
}()
6266

67+
68+
// MARK: - class methods
69+
6370
override func prepareForReuse() {
6471
super.prepareForReuse()
6572
id = nil
@@ -79,6 +86,9 @@ final class CatalogCell: UICollectionViewCell, ReuseIdentifying {
7986
fatalError("init(coder:) has not been implemented")
8087
}
8188

89+
90+
// MARK: - iternal methods
91+
8292
func setImage(link: URL?) {
8393
imageView.kf.indicatorType = .activity
8494
imageView.kf.setImage(with: link)
@@ -100,6 +110,9 @@ final class CatalogCell: UICollectionViewCell, ReuseIdentifying {
100110
dateLabel.text = date.formattedDate
101111
}
102112

113+
114+
// MARK: - private methods
115+
103116
private func setView() {
104117
contentView.backgroundColor = .clear
105118
contentView.addSubview(imageView)

AvitoTech-TraineeAssignment/AvitoTech-TraineeAssignment/Screens/Catalog/CatalogViewController.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
import UIKit
99

1010
final class CatalogViewController: UIViewController, CatalogViewControllerProtocol {
11+
// MARK: - private properties
1112
private var presenter: CatalogViewPresenterProtocol
12-
1313
private let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
1414
private let refreshControl = UIRefreshControl()
1515

16+
17+
// MARK: - class methods
18+
1619
init(presenter: CatalogViewPresenterProtocol) {
1720
self.presenter = presenter
1821
super.init(nibName: nil, bundle: nil)
@@ -32,6 +35,9 @@ final class CatalogViewController: UIViewController, CatalogViewControllerProtoc
3235
presenter.viewDidLoad()
3336
}
3437

38+
39+
// MARK: - protocol's methods
40+
3541
func updateCollection() {
3642
collectionView.reloadData()
3743
}
@@ -61,6 +67,9 @@ final class CatalogViewController: UIViewController, CatalogViewControllerProtoc
6167
navigationController?.pushViewController(viewController, animated: true)
6268
}
6369

70+
71+
// MARK: - private methods
72+
6473
private func configureCollection() {
6574
collectionView.backgroundColor = .clear
6675
collectionView.refreshControl = refreshControl
@@ -85,12 +94,18 @@ final class CatalogViewController: UIViewController, CatalogViewControllerProtoc
8594
refreshControl.addTarget(self, action: #selector(pullToRefresh), for: .valueChanged)
8695
}
8796

97+
98+
// MARK: - @objc methods
99+
88100
@objc private func pullToRefresh() {
89101
refreshControl.endRefreshing()
90102
presenter.viewDidPullToRefresh()
91103
}
92104
}
93105

106+
107+
// MARK: - extension CatalogViewController + UICollectionViewDelegateFlowLayout
108+
94109
extension CatalogViewController: UICollectionViewDelegateFlowLayout {
95110
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
96111
let width = (collectionView.frame.width - 32) / 2 - 10 // MARK: из ширины экрана вычитаем констрейнты (16+16=32) и получаем ширину коллекции, делим её на 2, так как по 2 ячейки, а также вычитаем расстояние между ячейками (10)
@@ -107,6 +122,9 @@ extension CatalogViewController: UICollectionViewDelegateFlowLayout {
107122
}
108123
}
109124

125+
126+
// MARK: - extension CatalogViewController + UICollectionViewDataSource
127+
110128
extension CatalogViewController: UICollectionViewDataSource {
111129
func numberOfSections(in collectionView: UICollectionView) -> Int {
112130
1

AvitoTech-TraineeAssignment/AvitoTech-TraineeAssignment/Screens/Catalog/CatalogViewPresenter.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@
88
import UIKit
99

1010
final class CatalogViewPresenter: CatalogViewPresenterProtocol {
11+
// MARK: - protocol's properties
1112
var numberOfAdvertisement: Int {
1213
catalogNetworkService.catalogModel?.advertisements.count ?? 0
1314
}
1415

16+
17+
// MARK: - private properties
18+
1519
weak private var viewController: CatalogViewControllerProtocol?
1620
private let catalogNetworkService = CatalogNetworkService.shared
1721
private var catalogNetworkServiceObserverData: NSObjectProtocol?
1822
private var catalogNetworkServiceObserverError: NSObjectProtocol?
1923

24+
25+
// MARK: - protocol's methods
26+
2027
func injectViewController(viewController: CatalogViewControllerProtocol) {
2128
self.viewController = viewController
2229
}
@@ -57,6 +64,9 @@ final class CatalogViewPresenter: CatalogViewPresenterProtocol {
5764
viewController?.showCatalogsObjectView(viewController: catalogsObjectViewController)
5865
}
5966

67+
68+
// MARK: - private methods
69+
6070
private func updateViewCollection() {
6171
viewController?.removeHud()
6272
viewController?.updateCollection()

AvitoTech-TraineeAssignment/AvitoTech-TraineeAssignment/Screens/CatalogsObject/CatalogsObjectViewController.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import MessageUI
1212
final class CatalogsObjectViewController: UIViewController, CatalogsObjectViewControllerProtocol {
1313
private var presenter: CatalogsObjectViewPresenterProtocol
1414

15+
16+
// MARK: - ui properties
17+
1518
private let scrollView: UIScrollView = {
1619
let scrollView = UIScrollView()
1720
scrollView.translatesAutoresizingMaskIntoConstraints = false
@@ -117,6 +120,9 @@ final class CatalogsObjectViewController: UIViewController, CatalogsObjectViewCo
117120
return map
118121
}()
119122

123+
124+
// MARK: - class methods
125+
120126
init(presenter: CatalogsObjectViewPresenterProtocol) {
121127
self.presenter = presenter
122128
super.init(nibName: nil, bundle: nil)
@@ -135,6 +141,9 @@ final class CatalogsObjectViewController: UIViewController, CatalogsObjectViewCo
135141
presenter.viewDidLoad()
136142
}
137143

144+
145+
// MARK: - protocol's methods
146+
138147
func showHud() {
139148
UIBlockingProgressHUD.show()
140149
}
@@ -171,6 +180,9 @@ final class CatalogsObjectViewController: UIViewController, CatalogsObjectViewCo
171180
mapView.setRegion(region, animated: true)
172181
}
173182

183+
184+
// MARK: - private methods
185+
174186
private func configureNavigationBar() {
175187
navigationItem.leftBarButtonItem = UIBarButtonItem(image: .backArrow, style: .plain, target: self, action: #selector(backButtonTap))
176188
}
@@ -242,6 +254,9 @@ final class CatalogsObjectViewController: UIViewController, CatalogsObjectViewCo
242254
adressLabel.text = adress
243255
}
244256

257+
258+
// MARK: - @objc methods
259+
245260
@objc func backButtonTap() {
246261
navigationController?.popViewController(animated: true)
247262
}
@@ -255,6 +270,9 @@ final class CatalogsObjectViewController: UIViewController, CatalogsObjectViewCo
255270
}
256271
}
257272

273+
274+
// MARK: - extension CatalogsObjectViewController + MFMailComposeViewControllerDelegate
275+
258276
extension CatalogsObjectViewController: MFMailComposeViewControllerDelegate {
259277
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
260278
controller.dismiss(animated: true, completion: nil)

AvitoTech-TraineeAssignment/AvitoTech-TraineeAssignment/Screens/CatalogsObject/CatalogsObjectViewPresenter.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ import MessageUI
1111
import CoreLocation
1212

1313
final class CatalogsObjectViewPresenter: CatalogsObjectViewPresenterProtocol {
14+
// MARK: - protocol's properties
15+
1416
var adress: String {
1517
guard let model = catalogsObjectNetworkService.catalogsObjectModel else { return "" }
1618
return "г. " + model.location + ", " + model.address
1719
}
1820

21+
22+
// MARK: - private properties
23+
1924
weak private var viewController: CatalogsObjectViewControllerProtocol?
2025

2126
private var objectId: String?
@@ -26,10 +31,16 @@ final class CatalogsObjectViewPresenter: CatalogsObjectViewPresenterProtocol {
2631
private var catalogsObjectNetworkServiceObserverData: NSObjectProtocol?
2732
private var catalogsObjectNetworkServiceObserverError: NSObjectProtocol?
2833

34+
35+
// MARK: - class methods
36+
2937
init(objectId: String) {
3038
self.objectId = objectId
3139
}
3240

41+
42+
// MARK: - protocol's methods
43+
3344
func injectViewController(viewController: CatalogsObjectViewControllerProtocol) {
3445
self.viewController = viewController
3546
}
@@ -79,6 +90,9 @@ final class CatalogsObjectViewPresenter: CatalogsObjectViewPresenterProtocol {
7990
}
8091
}
8192

93+
94+
// MARK: - private methods
95+
8296
private func loadData() {
8397
guard let objectId = objectId else { return }
8498
viewController?.showHud()

0 commit comments

Comments
 (0)