Skip to content

Commit

Permalink
[Feat] sopt-makers#134 - MainServiceCVC 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
lsj8706 committed Apr 1, 2023
1 parent cd5218b commit 40038e5
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,39 @@ import DSKit

final class MainServiceCVC: UICollectionViewCell {

// MARK: - UI Components

private let serviceIcon: UIImageView = {
let imageView = UIImageView()
imageView.image = DSKitAsset.Assets.icnAttendance.image
imageView.tintColor = DSKitAsset.Colors.white.color
return imageView
}()

private let serviceTitleLabel: UILabel = {
let label = UILabel()
label.font = UIFont.Main.headline2
label.textColor = DSKitAsset.Colors.white100.color
label.textAlignment = .left
return label
}()

private let serviceDescriptionLabel: UILabel = {
let label = UILabel()
label.font = UIFont.Main.body1
label.textColor = DSKitAsset.Colors.gray30.color
label.textAlignment = .left
return label
}()

private lazy var containerStackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [serviceIcon, serviceTitleLabel, serviceDescriptionLabel])
stackView.axis = .vertical
stackView.spacing = 4
stackView.alignment = .leading
return stackView
}()

// MARK: - initialization

override init(frame: CGRect) {
Expand All @@ -30,10 +63,42 @@ final class MainServiceCVC: UICollectionViewCell {

extension MainServiceCVC {
private func setUI() {
self.backgroundColor = [UIColor.red, .blue, UIColor.brown, UIColor.lightGray, UIColor.green, UIColor.purple].randomElement()
self.backgroundColor = DSKitAsset.Colors.black60.color
self.layer.cornerRadius = 15
}

private func setLayout() {
self.addSubviews(containerStackView)

serviceIcon.snp.makeConstraints { make in
make.width.height.equalTo(24)
}

containerStackView.snp.makeConstraints { make in
make.leading.equalToSuperview().inset(16)
make.bottom.equalToSuperview().inset(12)
}
}
}

// MARK: - Methods

extension MainServiceCVC {
func initCell(serviceType: ServiceType, isMainService: Bool) {
serviceIcon.image = serviceType.icon
serviceTitleLabel.text = serviceType.title

if let description = serviceType.description {
serviceDescriptionLabel.isHidden = false
serviceDescriptionLabel.text = description
} else {
serviceDescriptionLabel.isHidden = true
}

if isMainService {
self.backgroundColor = DSKitAsset.Colors.purple100.color
} else {
self.backgroundColor = DSKitAsset.Colors.black60.color
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,38 @@ extension ServiceType {
return DSKitAsset.Assets.icCrew.image
}
}

var title: String {
switch self {
case .officialHomepage:
return I18N.Main.officialHomePage
case .review:
return I18N.Main.review
case .project:
return I18N.Main.project
case .faq:
return I18N.Main.faq
case .youtube:
return I18N.Main.youtube
case .attendance:
return I18N.Main.attendance
case .member:
return I18N.Main.member
case .notice:
return I18N.Main.notice
case .crew:
return I18N.Main.crew
}
}

var description: String? {
switch self {
case .attendance:
return I18N.Main.attend
case .notice:
return I18N.Main.checkGeneralNotice
default:
return nil
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class MainVC: UIViewController, MainViewControllable {

// MARK: - Properties

// 테스트용 임시 변수
private let serviceList: [ServiceType] = [.attendance, .member, .project]
// 서버 연결 시 지울 것

public var viewModel: MainViewModel!
public var factory: StampFeatureViewBuildable!
private var cancelBag = CancelBag()
Expand Down Expand Up @@ -155,6 +159,7 @@ extension MainVC: UICollectionViewDataSource {
return cell
}
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MainServiceCVC.className, for: indexPath) as? MainServiceCVC else { return UICollectionViewCell() }
cell.initCell(serviceType: serviceList[indexPath.item-1], isMainService: indexPath.item==1)
return cell
default:
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MainServiceCVC.className, for: indexPath) as? MainServiceCVC else { return UICollectionViewCell() }
Expand Down

0 comments on commit 40038e5

Please sign in to comment.