Skip to content

Commit

Permalink
Merge pull request #33 from ak2j38/hotfix-20220525
Browse files Browse the repository at this point in the history
Hotfix 20220525
  • Loading branch information
Damagucci-Juice committed May 26, 2022
2 parents 6694c07 + 5f1b0e0 commit 23051bf
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 165 deletions.
88 changes: 0 additions & 88 deletions iOS/Airbnb/Airbnb/Search/View/MyInfoCollectionViewController.swift

This file was deleted.

18 changes: 11 additions & 7 deletions iOS/Airbnb/Airbnb/Search/View/SearchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ class SearchViewController: UIViewController {

private var searchCollectionViewDataSource: (UICollectionView) -> UICollectionViewDiffableDataSource<Section, [SearchViewModel]> = { collectionView in
UICollectionViewDiffableDataSource<Section, [SearchViewModel]>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in

guard indexPath.item <= 3 else { return nil }

var cell: UICollectionViewCell?

if indexPath.item == 0 || indexPath.item == 2 {
switch indexPath.item {
case 0, 2:
cell = collectionView.dequeueReusableCell(
withReuseIdentifier: SearchTitleCollectionViewCell.reuseIdentifier,
for: indexPath)
Expand All @@ -68,8 +71,7 @@ class SearchViewController: UIViewController {
(cell as? SearchTitleCollectionViewCell)?.setData(model: model)
}

} else if indexPath.item == 1 {

case 1:
cell = collectionView.dequeueReusableCell(
withReuseIdentifier: MultipleRowsCollectionViewContainerCell.reuseIdentifier,
for: indexPath)
Expand All @@ -80,10 +82,11 @@ class SearchViewController: UIViewController {
items: itemIdentifier,
cellWidth: collectionView.frame.width * 2/3,
rowCount: 2)
default:
cell = collectionView.dequeueReusableCell(
withReuseIdentifier: MultipleRowsCollectionViewContainerCell.reuseIdentifier,
for: indexPath)

} else if indexPath.item == 3 {

cell = collectionView.dequeueReusableCell(withReuseIdentifier: MultipleRowsCollectionViewContainerCell.reuseIdentifier, for: indexPath)
(cell as? MultipleRowsCollectionViewContainerCell)?
.applyAttributes(
cellType: SearchOneInARowCollectionViewCell.self,
Expand All @@ -104,6 +107,7 @@ class SearchViewController: UIViewController {
var oneRowItems = [SearchViewModel]()
var twoRowItems = [SearchViewModel]()

// 임시 코드입니다.
for i in 0 ..< 18 {

let model = SearchViewModel(imageData: Data(), titleLabel: "\(i)", subTitleLabel: "\(i)\(i)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import SnapKit

class MultipleRowsCollectionViewContainerCell: UICollectionViewCell {

static var reuseIdentifier: String {
String(describing: Self.self)
}

private var multipleRowCollectionViewController: MultipleRowsCollectionViewController?

override func awakeFromNib() {
Expand All @@ -36,9 +32,12 @@ class MultipleRowsCollectionViewContainerCell: UICollectionViewCell {
cellWidth: cellWidth,
rowCount: rowCount)

contentView.subviews.forEach({ $0.removeFromSuperview() })
contentView.addSubview(multipleRowCollectionViewController!.collectionView)
guard let collectionViewController = multipleRowCollectionViewController else {
return
}

contentView.subviews.forEach({ $0.removeFromSuperview() })
contentView.addSubview(collectionViewController.collectionView)
layout()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import UIKit

private let reuseIdentifier = "Cell"

class MultipleRowsCollectionViewController: UICollectionViewController {

enum Section {
Expand Down Expand Up @@ -69,6 +67,8 @@ class MultipleRowsCollectionViewController: UICollectionViewController {

self.init(collectionViewLayout: layout)
collectionView.register(cellType, forCellWithReuseIdentifier: cellType.reuseIdentifier)
collectionView.showsVerticalScrollIndicator = false
collectionView.showsHorizontalScrollIndicator = false

self.unitCellType = cellType
self.customLayout = layout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import Foundation
import UIKit

class SearchCellCommonType: UICollectionViewCell {
protocol SearchCellCommonType: UICollectionViewCell {
func setData(model: SearchViewModel)
}

extension UICollectionViewCell {
static var reuseIdentifier: String { String(describing: Self.self) }
func setData(model: SearchViewModel) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,28 @@

import UIKit

class SearchOneInARowCollectionViewCell: SearchCellCommonType {
class SearchOneInARowCollectionViewCell: UICollectionViewCell, SearchCellCommonType {

private var mainImageView: UIImageView = {
let imageView = UIImageView()
return imageView
}()
private var mainImageView = UIImageView()

private var titleLabel: UILabel = {
let label = UILabel()
return label
}()
private var titleLabel = UILabel()

override func setData(model: SearchViewModel) {
func setData(model: SearchViewModel) {
mainImageView.image = UIImage(data: model.imageData)
titleLabel.text = model.titleLabel
}

override func awakeFromNib() {
super.awakeFromNib()
}

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

layout()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
layout()
}

private func layout() {
contentView.addSubview(mainImageView)
contentView.addSubview(titleLabel)

Expand All @@ -51,8 +49,4 @@ class SearchOneInARowCollectionViewCell: SearchCellCommonType {

contentView.backgroundColor = UIColor.init(displayP3Red: CGFloat.random(in: 0.0...1.0), green: CGFloat.random(in: 0.0...1.0), blue: CGFloat.random(in: 0.0...1.0), alpha: 1)
}

required init?(coder: NSCoder) {
super.init(coder: coder)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@

import UIKit

class SearchTitleCollectionViewCell: SearchCellCommonType {
class SearchTitleCollectionViewCell: UICollectionViewCell, SearchCellCommonType {

private var titleLabel: UILabel = {
let label = UILabel()
return label
}()
private var titleLabel: UILabel = UILabel()

override func setData(model: SearchViewModel) {
func setData(model: SearchViewModel) {
self.titleLabel.text = model.titleLabel
}

override func awakeFromNib() {
super.awakeFromNib()
}

override init(frame: CGRect) {
super.init(frame: frame)
self.layout()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
self.layout()
}

private func layout() {
contentView.addSubview(titleLabel)

titleLabel.snp.makeConstraints { make in
Expand All @@ -32,8 +34,4 @@ class SearchTitleCollectionViewCell: SearchCellCommonType {

contentView.backgroundColor = UIColor.init(displayP3Red: CGFloat.random(in: 0.0...1.0), green: CGFloat.random(in: 0.0...1.0), blue: CGFloat.random(in: 0.0...1.0), alpha: 1)
}

required init?(coder: NSCoder) {
super.init(coder: coder)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,33 @@

import UIKit

class SearchTwoInARowCollectionViewCell: SearchCellCommonType {
class SearchTwoInARowCollectionViewCell: UICollectionViewCell, SearchCellCommonType {

private var mainView: UIView = {
let view = UIView()
return view
}()
private var mainView = UIView()

private var mainImageView: UIImageView = {
let imageView = UIImageView()
return imageView
}()
private var mainImageView = UIImageView()

private var titleLabel: UILabel = {
let label = UILabel()
return label
}()
private var titleLabel = UILabel()

private var subTitleLabel: UILabel = {
let label = UILabel()
return label
}()
private var subTitleLabel = UILabel()

override func setData(model: SearchViewModel) {
func setData(model: SearchViewModel) {
mainImageView.image = UIImage(data: model.imageData)
titleLabel.text = model.titleLabel
subTitleLabel.text = model.subTitleLabel
}

override func awakeFromNib() {
super.awakeFromNib()
}

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

layout()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
layout()
}

private func layout() {
contentView.addSubview(mainView)

mainView.snp.makeConstraints { make in
Expand Down Expand Up @@ -78,8 +70,4 @@ class SearchTwoInARowCollectionViewCell: SearchCellCommonType {

contentView.backgroundColor = UIColor.init(displayP3Red: CGFloat.random(in: 0.0...1.0), green: CGFloat.random(in: 0.0...1.0), blue: CGFloat.random(in: 0.0...1.0), alpha: 1)
}

required init?(coder: NSCoder) {
super.init(coder: coder)
}
}

0 comments on commit 23051bf

Please sign in to comment.