Conversation
setup project
add functionality
| import UIKit | ||
| import SnapKit | ||
|
|
||
| class AlbumCellHeader: UICollectionReusableView { |
| return button | ||
| }() | ||
|
|
||
| override init(frame: CGRect) { |
| return image | ||
| }() | ||
|
|
||
| lazy var title: UILabel = { |
There was a problem hiding this comment.
titleLabel, если будет просто title как будто данные из модели, лучше всегда делать привзяку UI элементам
| return label | ||
| }() | ||
|
|
||
| lazy var quantity: UILabel = { |
| return stack | ||
| }() | ||
|
|
||
| override init(frame: CGRect) { |
|
|
||
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
| clipsToBounds = true |
There was a problem hiding this comment.
это точно нужно? лучше его в метод setupviews
|
|
||
| static let identifier = "AlbumCollectionViewCell" | ||
|
|
||
| lazy var image: UIImageView = { |
There was a problem hiding this comment.
лучше, сделай другой нейминг какой именно image
| } | ||
|
|
||
| override func prepareForReuse() { | ||
| self.image.image = nil |
There was a problem hiding this comment.
self.image.image плохое обращения, лучше подумай как можно сделать перемениновать ui свойство
|
|
||
| import UIKit | ||
|
|
||
| class AlbumsViewController: UIViewController { |
|
|
||
| private let settingsDelegate = MediaCollectionViewCell() | ||
|
|
||
| private lazy var collectionView: UICollectionView = { |
| return collectionView | ||
| }() | ||
|
|
||
| override func viewDidLoad() { |
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
| setupController() |
There was a problem hiding this comment.
setupController -> setupNavigationController
| } | ||
|
|
||
| private func setupController() { | ||
| view.backgroundColor = .white |
There was a problem hiding this comment.
view.backgroundColor = .white должен быть в методе setupViews
| } | ||
| } | ||
|
|
||
| @objc func libraryNCleftButtonTapped() { } |
|
|
||
| @objc func libraryNCleftButtonTapped() { } | ||
|
|
||
| private func createLayout() -> UICollectionViewCompositionalLayout { |
| heightDimension: .absolute(44) | ||
| ) | ||
| let layoutGroup = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [layoutItem]) | ||
| // layoutGroup.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) |
There was a problem hiding this comment.
dead code, нельзя замочиенный код отправять в гит, всегда перед отправкой проверяй свой код, нужно удалить
| } | ||
| } | ||
|
|
||
| extension AlbumsViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { |
|
|
||
| extension AlbumsViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout { | ||
| func numberOfSections(in collectionView: UICollectionView) -> Int { | ||
| AlbumModel.modelsArray.count |
There was a problem hiding this comment.
лучше return писать явно, return AlbumModel.modelsArray.count
| } | ||
|
|
||
| func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
| AlbumModel.modelsArray[section].count |
There was a problem hiding this comment.
лучше return писать явно, return AlbumModel.modelsArray[section].count
|
|
||
| import UIKit | ||
|
|
||
| class MediaCollectionViewCell: UICollectionViewCell { |
|
|
||
| static let identifier = "MediaCollectionViewCell" | ||
|
|
||
| lazy var image: UIImageView = { |
There was a problem hiding this comment.
public, лучше явно указовай acess модификаторы
|
|
||
| private func setupConstraints() { | ||
| image.snp.makeConstraints { | ||
| $0.centerY.equalTo(contentView) |
There was a problem hiding this comment.
$0.centerY.leading.equalTo(contentView)
| } | ||
|
|
||
| override func prepareForReuse() { | ||
| self.image.image = nil |
|
|
||
| import UIKit | ||
|
|
||
| class ForYouViewController: UIViewController { |
| navigationItem.leftBarButtonItem?.tintColor = .black | ||
| } | ||
|
|
||
| @objc func libraryNCleftButtonTapped() { } |
| super.viewDidLoad() | ||
| view.backgroundColor = .white | ||
| title = "For You" | ||
| navigationController?.navigationBar.prefersLargeTitles = true |
There was a problem hiding this comment.
нужно вынести в отдельные методы, во viewdidload не должно быть логики
| import UIKit | ||
| import SnapKit | ||
|
|
||
| class LibraryViewController: UIViewController { |
|
|
||
| class LibraryViewController: UIViewController { | ||
|
|
||
| private lazy var collectionView: UICollectionView = { |
| return collectionView | ||
| }() | ||
|
|
||
| override func viewDidLoad() { |
| setupConstraints() | ||
| } | ||
|
|
||
| private func setupController() { |
|
|
||
| private func setupConstraints() { | ||
| collectionView.snp.makeConstraints { | ||
| $0.left.top.right.bottom.equalToSuperview() |
| } | ||
| } | ||
|
|
||
| @objc func libraryNCleftButtonTapped() { } |
|
|
||
| import UIKit | ||
|
|
||
| class SearchViewController: UIViewController { |
|
|
||
| class SearchViewController: UIViewController { | ||
|
|
||
| override func viewDidLoad() { |
| super.viewDidLoad() | ||
| view.backgroundColor = .white | ||
| title = "Search" | ||
| navigationController?.navigationBar.prefersLargeTitles = true |
| navigationItem.leftBarButtonItem?.tintColor = .black | ||
| } | ||
|
|
||
| @objc func libraryNCleftButtonTapped() { } |
|
|
||
| import UIKit | ||
|
|
||
| class TabBarController: UITabBarController { |
|
|
||
| class TabBarController: UITabBarController { | ||
|
|
||
| override func viewDidLoad() { |
| } | ||
|
|
||
| func setupTabBarViewControllers() { | ||
| let libraryVC = LibraryViewController() |
There was a problem hiding this comment.
не сокращай, libraryVC VC плохой нейминг, пиши полностью viewcontroller
| let searchIcon = UITabBarItem(title: "Search", image: UIImage(systemName: "magnifyingglass"), selectedImage: UIImage(systemName: "magnifyingglass")) | ||
| searchVC.tabBarItem = searchIcon | ||
|
|
||
| let libraryNC = UINavigationController(rootViewController: libraryVC) |
| } | ||
|
|
||
| func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
| let item = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) |
There was a problem hiding this comment.
cell Identifier лучше вынести во. static
| let layoutGroup = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [layoutItem]) | ||
| // layoutGroup.contentInsets = NSDirectionalEdgeInsets(top: 5, leading: 5, bottom: 5, trailing: 5) | ||
| let layoutSection = NSCollectionLayoutSection(group: layoutGroup) | ||
| // layoutSection.orthogonalScrollingBehavior = .continuous |
|
|
||
| import UIKit | ||
|
|
||
| struct AlbumModel { |
There was a problem hiding this comment.
лучше пиши Album, models нагружает читабельность
finished adding features, ready merge to main