Skip to content

Commit

Permalink
Merge branch 'feat/#19-challengeViewUI' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe0929 committed Jan 8, 2024
2 parents 29a28b2 + a6a1a40 commit 02f1b54
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit
import SnapKit
import Then

class TitleCollectionReusableView: UICollectionReusableView {
final class TitleCollectionReusableView: UICollectionReusableView {

static let identifier = "TitleCollectionReusableView"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Then

final class ChallengeViewController: UIViewController {


private let navigationBar = HMHNavigationBar(leftItem: .normal,
isBackButton: false,
isTitleLabel: true,
Expand All @@ -27,7 +26,6 @@ final class ChallengeViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
setUI()
setDelegate()
}

private func setUI(){
Expand All @@ -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
})
}
}
}
34 changes: 19 additions & 15 deletions HMH_iOS/HMH_iOS/Presentation/Challenge/Views/ChallengeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand All @@ -67,9 +73,7 @@ final class ChallengeView: UIView {
challengeCollectionView.dataSource = self
}

func addTarget() {

}
func addTarget() {}
}

extension ChallengeView: UICollectionViewDataSource {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -152,7 +158,6 @@ extension ChallengeView {
alignment: .topLeading)
section.boundarySupplementaryItems = [headerElement]

// Background
let sectionBackgroundDecoration = NSCollectionLayoutDecorationItem.background(elementKind: StringLiteral.Challenge.Idetifier.backgroundViewId)
section.decorationItems = [sectionBackgroundDecoration]

Expand Down Expand Up @@ -197,7 +202,6 @@ extension ChallengeView {
}
}

// Register decoration view
layout.register(GrayBackgroundView.self,
forDecorationViewOfKind: StringLiteral.Challenge.Idetifier.backgroundViewId)

Expand Down

0 comments on commit 02f1b54

Please sign in to comment.