Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature home #108

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ final class HomeCapsuleCell: UICollectionViewCell, UnOpenable {
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}


override func prepareForReuse() {
super.prepareForReuse()
thumbnailImageView.imageView.subviews.forEach {
$0.removeFromSuperview()
}
}

func addSubviews() {
[thumbnailImageView, titleLabel, descriptionLabel].forEach {
self.contentView.addSubview($0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum CapsuleType: CaseIterable {
case nearest
case farthest
case leastOpened
case mostOpened

var title: String {
switch self {
Expand All @@ -33,6 +34,8 @@ enum CapsuleType: CaseIterable {
return "가장 먼 위치의 캡슐"
case .leastOpened:
return "열어본 횟수가 가장 적은 캡슐"
case .mostOpened:
return "열어본 횟수가 가장 많은 캡슐"
}
}
}
Expand Down Expand Up @@ -86,7 +89,7 @@ struct HomeCapsuleCellItem: Hashable, Equatable {
} else {
return "\(memoryDate.dotDateString) \(address)에서\n약 \(String(format: "%.2f", distance))m"
}
case .leastOpened:
case .leastOpened, .mostOpened:
return "\(memoryDate.dotDateString) \(address)에서\n\(openCount)번"
}
}
Expand Down
2 changes: 1 addition & 1 deletion SpaceCapsule/SpaceCapsule/Scene/TabBar/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
final class HomeView: UIView, BaseView {
// MARK: - UIComponents
lazy var mainLabel: ThemeLabel = ThemeLabel(
text: "none님의 공간캡슐 10개",
text: "",
size: 32,
color: .themeGray300
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ final class HomeViewModel: BaseViewModel {
case .leastOpened:
let capsule = getLeastOpened(capsules: capsules)
return makeHomeCapsuleCellItem(capsule: capsule, type: type)
case .mostOpened:
let capsule = getMostOpened(capsules: capsules)
return makeHomeCapsuleCellItem(capsule: capsule, type: type)
}
}

Expand Down Expand Up @@ -178,4 +181,8 @@ final class HomeViewModel: BaseViewModel {
func getLeastOpened(capsules: [Capsule]) -> Capsule? {
return capsules.min(by: { $0.openCount < $1.openCount })
}

func getMostOpened(capsules: [Capsule]) -> Capsule? {
return capsules.min(by: { $0.openCount > $1.openCount })
}
}