diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/AppListCollectionViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/AppListCollectionViewCell.swift index 30e6194..02fbd09 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/AppListCollectionViewCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/AppListCollectionViewCell.swift @@ -10,21 +10,21 @@ import UIKit import SnapKit import Then -class AppListCollectionViewCell: UICollectionViewCell { +final class AppListCollectionViewCell: UICollectionViewCell { static let identifer = "AppListCollectionViewCell" - let appImageView = UIImageView().then { + private let appImageView = UIImageView().then { $0.backgroundColor = .blue $0.makeCornerRound(radius: 8.adjusted) } - let appNameLabel = UILabel().then { + private let appNameLabel = UILabel().then { $0.textColor = .gray2 $0.font = .iosText6Medium14 } - let timeLabel = UILabel().then { + private let timeLabel = UILabel().then { $0.textColor = .whiteText $0.font = .iosText4Semibold16 } @@ -43,19 +43,15 @@ class AppListCollectionViewCell: UICollectionViewCell { } private func setUI(){ - setViewHierarchy() + setHierarchy() setConstraints() } - private func setViewHierarchy() { - self.backgroundColor = .clear - contentView.backgroundColor = .gray7 - contentView.makeCornerRound(radius: 6.adjusted) + private func setHierarchy() { contentView.addSubviews(appImageView, appNameLabel, timeLabel) } private func setConstraints() { - appImageView.snp.makeConstraints { $0.size.equalTo(40.adjusted) $0.leading.equalToSuperview().offset(17.adjustedWidth) @@ -74,6 +70,12 @@ class AppListCollectionViewCell: UICollectionViewCell { } + func configureContentView() { + self.backgroundColor = .clear + contentView.backgroundColor = .gray7 + contentView.makeCornerRound(radius: 6.adjusted) + } + func configureCell(appName: String, appIconImage: UIImage = UIImage(), appTime: String){ self.appNameLabel.text = appName self.appImageView.image = appIconImage diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/DateCollectionViewCell.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/DateCollectionViewCell.swift index 5e29648..cee9d20 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/DateCollectionViewCell.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/DateCollectionViewCell.swift @@ -11,15 +11,15 @@ import SnapKit import Then class DateCollectionViewCell: UICollectionViewCell { + static let identifer = "DateCollectionViewCell" - let dateLabel = UILabel().then { - $0.text = "1" + private let dateLabel = UILabel().then { $0.textColor = .gray2 $0.font = .iosText6Medium14 } - let imageView = UIImageView().then { + private let imageView = UIImageView().then { $0.backgroundColor = .background $0.makeCornerRound(radius: 8.adjusted) } @@ -33,11 +33,11 @@ class DateCollectionViewCell: UICollectionViewCell { fatalError("init(coder:) has not been implemented") } private func setUI(){ - setViewHierarchy() + setHierarchy() setConstraints() } - private func setViewHierarchy() { + private func setHierarchy() { contentView.addSubviews(dateLabel, imageView) } diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift index 5f7d841..e3197a7 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/AppCollectionReusableView.swift @@ -10,18 +10,18 @@ import UIKit import SnapKit import Then -class AppCollectionReusableView: UICollectionReusableView { +final class AppCollectionReusableView: UICollectionReusableView { static let identifier = "AppCollectionReusableView" - let titleLabel = UILabel().then { + private let titleLabel = UILabel().then { $0.text = StringLiteral.Challenge.AppList.appListHeaderTitle $0.font = .iosText5Medium16 $0.textColor = .gray1 $0.setTextWithLineHeight(text: $0.text, lineHeight: 24) } - let deleteButton = UIButton().then { + private let deleteButton = UIButton().then { $0.setTitle(StringLiteral.Challenge.AppList.appListHeaderButtonText, for: .normal) $0.titleLabel?.font = .iosText4Semibold16 diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/GrayBackgroundView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/GrayBackgroundView.swift index 3d9e8f5..1354a29 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/GrayBackgroundView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/GrayBackgroundView.swift @@ -10,7 +10,8 @@ import UIKit import SnapKit import Then -class GrayBackgroundView: UICollectionReusableView { +final class GrayBackgroundView: UICollectionReusableView { + private let grayBackgroundView = UIView().then { $0.backgroundColor = .gray7 } diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/TitleCollectionReusableView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/TitleCollectionReusableView.swift index e2c55bb..395d423 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/TitleCollectionReusableView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Cells/HeaderFooterView/TitleCollectionReusableView.swift @@ -10,7 +10,7 @@ import UIKit import SnapKit import Then -class TitleCollectionReusableView: UICollectionReusableView { +final class TitleCollectionReusableView: UICollectionReusableView { static let identifier = "TitleCollectionReusableView" diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift index 3edc4a1..91bed98 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/ViewControllers/ChallengeViewController.swift @@ -12,7 +12,6 @@ import Then final class ChallengeViewController: UIViewController { - private let navigationBar = HMHNavigationBar(leftItem: .normal, isBackButton: false, isTitleLabel: true, @@ -27,7 +26,6 @@ final class ChallengeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() setUI() - setDelegate() } private func setUI(){ @@ -46,24 +44,4 @@ final class ChallengeViewController: UIViewController { } } - private func setDelegate(){ - challengeView.challengeCollectionView.delegate = self - } -} - -extension ChallengeViewController: UICollectionViewDelegate {} - -extension ChallengeViewController: UIScrollViewDelegate { - - func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) { - if scrollView.panGestureRecognizer.translation(in: scrollView).y < 0 { - UIView.animate(withDuration: 0.3, animations: { - self.navigationBar.alpha = 0 - }) - } else { - UIView.animate(withDuration: 0.3, animations: { - self.navigationBar.alpha = 1 - }) - } - } } diff --git a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift index 3967c8e..c13b555 100644 --- a/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift +++ b/HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift @@ -20,14 +20,6 @@ final class ChallengeView: UIView { lazy var challengeCollectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()).then { $0.backgroundColor = .background $0.collectionViewLayout = createLayout() - - $0.register(DateCollectionViewCell.self, forCellWithReuseIdentifier: DateCollectionViewCell.identifer) - $0.register(AppListCollectionViewCell.self, forCellWithReuseIdentifier: AppListCollectionViewCell.identifer) - - $0.register(TitleCollectionReusableView.self, forSupplementaryViewOfKind: StringLiteral.Challenge.Idetifier.titleHeaderViewId, - withReuseIdentifier: TitleCollectionReusableView.identifier) - $0.register(AppCollectionReusableView.self, forSupplementaryViewOfKind: StringLiteral.Challenge.Idetifier.appListHeaderViewId, - withReuseIdentifier: AppCollectionReusableView.identifier) } override init(frame: CGRect) { @@ -59,6 +51,20 @@ final class ChallengeView: UIView { } } + func setRegister() { + + challengeCollectionView.register(DateCollectionViewCell.self, forCellWithReuseIdentifier: DateCollectionViewCell.identifer) + challengeCollectionView.register(AppListCollectionViewCell.self, + forCellWithReuseIdentifier: AppListCollectionViewCell.identifer) + + challengeCollectionView.register(TitleCollectionReusableView.self, + forSupplementaryViewOfKind: StringLiteral.Challenge.Idetifier.titleHeaderViewId, + withReuseIdentifier: TitleCollectionReusableView.identifier) + challengeCollectionView.register(AppCollectionReusableView.self, + forSupplementaryViewOfKind: StringLiteral.Challenge.Idetifier.appListHeaderViewId, + withReuseIdentifier: AppCollectionReusableView.identifier) + } + func configureView() { self.backgroundColor = .background } @@ -67,9 +73,7 @@ final class ChallengeView: UIView { challengeCollectionView.dataSource = self } - func addTarget() { - - } + func addTarget() {} } extension ChallengeView: UICollectionViewDataSource { @@ -112,10 +116,12 @@ extension ChallengeView: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { if kind == StringLiteral.Challenge.Idetifier.titleHeaderViewId { - guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: StringLiteral.Challenge.Idetifier.titleHeaderViewId, withReuseIdentifier: TitleCollectionReusableView.identifier, for: indexPath) as? TitleCollectionReusableView else { return UICollectionReusableView() } + guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: StringLiteral.Challenge.Idetifier.titleHeaderViewId, withReuseIdentifier: TitleCollectionReusableView.identifier, for: indexPath) as? TitleCollectionReusableView + else { return UICollectionReusableView() } return header } else if kind == StringLiteral.Challenge.Idetifier.appListHeaderViewId { - guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: StringLiteral.Challenge.Idetifier.appListHeaderViewId, withReuseIdentifier: AppCollectionReusableView.identifier, for: indexPath) as? AppCollectionReusableView else { return UICollectionReusableView() } + guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: StringLiteral.Challenge.Idetifier.appListHeaderViewId, withReuseIdentifier: AppCollectionReusableView.identifier, for: indexPath) as? AppCollectionReusableView + else { return UICollectionReusableView() } return header } else { return UICollectionReusableView() @@ -152,7 +158,6 @@ extension ChallengeView { alignment: .topLeading) section.boundarySupplementaryItems = [headerElement] - // Background let sectionBackgroundDecoration = NSCollectionLayoutDecorationItem.background(elementKind: StringLiteral.Challenge.Idetifier.backgroundViewId) section.decorationItems = [sectionBackgroundDecoration] @@ -197,7 +202,6 @@ extension ChallengeView { } } - // Register decoration view layout.register(GrayBackgroundView.self, forDecorationViewOfKind: StringLiteral.Challenge.Idetifier.backgroundViewId)