Skip to content

Commit

Permalink
[Feat] sopt-makers#237 - 친구 수에 따른 ChipView 텍스트 분기처리
Browse files Browse the repository at this point in the history
  • Loading branch information
lsj8706 committed Dec 20, 2023
1 parent 5e25812 commit ac76c6e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import DSKit

final public class PokeChipView: UIView {
public enum ChipType {
case newUser
case singleFriend(friendName: String)
case withPokeCount(relation: String, pokeCount: String)
case acquaintance(friendname: String, relationCount: String)
}
Expand Down Expand Up @@ -72,6 +74,10 @@ final public class PokeChipView: UIView {
extension PokeChipView {
public func configure(with pokechipType: ChipType) {
switch pokechipType {
case .newUser:
self.titleLabel.text = "새로운 친구"
case let .singleFriend(friendName):
self.titleLabel.text = "\(friendName)의 친구"
case let .withPokeCount(relation, pokeCount):
self.titleLabel.text = relation + Constant.dotWithWhiteSpace + pokeCount + ""
case let .acquaintance(friendname, relationCount):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,14 @@ extension PokeMainViewModel {

private func makeChipInfo(with model: PokeUserModel) -> PokeChipView.ChipType {
if model.isFirstMeet { // 친구가 아닌 경우
return .acquaintance(friendname: model.mutual.first ?? "", relationCount: "\(model.mutual.count)")
switch model.mutual.count {
case 0:
return .newUser
case 1:
return .singleFriend(friendName: model.mutual.first ?? "")
default:
return .acquaintance(friendname: model.mutual.first ?? "", relationCount: "\(model.mutual.count-1)")
}
}

return .withPokeCount(relation: model.relationName, pokeCount: String(model.pokeNum))
Expand Down

0 comments on commit ac76c6e

Please sign in to comment.