Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
@@ -1,88 +1,130 @@
import Infrastructure
import SnapKit
import Then
import UIKit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import 순서 및 띄워쓰기를 팀 룰에 맞게 수정하면 좋을 것 같습니다 :>


final class BalloonChipCell: UICollectionViewCell {
static let identifier = "BalloonChipCell"

private let button: PPButton = {
let button = PPButton(
style: .secondary,
text: "",
font: .korFont(style: .medium, size: 11),
cornerRadius: 15
)

button.titleLabel?.lineBreakMode = .byTruncatingTail
button.titleLabel?.adjustsFontSizeToFitWidth = false
return button
}()

override init(frame: CGRect) {
super.init(frame: frame)
contentView.addSubview(button)
setupLayout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupLayout() {
button.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}

func configure(with title: String, isSelected: Bool) {
button.setTitle(title, for: .normal)
if isSelected {
let checkImage = UIImage(named: "icon_check_white")?.withRenderingMode(.alwaysOriginal)
let resizedImage = checkImage?.resize(to: CGSize(width: 16, height: 16))
button.setImage(resizedImage, for: .normal)
button.semanticContentAttribute = .forceRightToLeft
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: 2, bottom: 0, right: 0)
button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 10, bottom: 6, right: 12)
button.setBackgroundColor(.blu500, for: .normal)
button.setTitleColor(.white, for: .normal)
button.layer.borderWidth = 0
button.titleLabel?.font = .korFont(style: .bold, size: 11)

} else {
button.setImage(nil, for: .normal)
button.semanticContentAttribute = .unspecified
button.imageEdgeInsets = .zero
button.contentEdgeInsets = UIEdgeInsets(top: 4, left: 12, bottom: 6, right: 12)
button.setBackgroundColor(.white, for: .normal)
button.setTitleColor(.g400, for: .normal)
button.layer.borderWidth = 1
button.layer.borderColor = UIColor.g200.cgColor
button.titleLabel?.font = .korFont(style: .medium, size: 11)

}
}

private var currentAction: UIAction?

var buttonAction: (() -> Void)? {
didSet {
if let oldAction = currentAction {
button.removeAction(oldAction, for: .touchUpInside)
}

let action = UIAction { [weak self] _ in
self?.buttonAction?()
}
button.addAction(action, for: .touchUpInside)
currentAction = action
}
}
static let identifier = "BalloonChipCell"
Copy link
Member

@dongglehada dongglehada May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UICollectionViewCell에 identifiers가 이미 존재하는 것으로 알고 있어서 해당 프로퍼티 사용하면 좋을 것 같습니다!!
디자인시스템 내 UICollectionViewCell+

extension UICollectionViewCell {
    static var identifiers: String {
        return String(describing: self)
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인후 적용되었습니다.


private enum Constant {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용할 값들을 Constant로 빼서 사용하는 룰!! 적용된 걸 보니 깔끔해서 좋습니다 :>

static let verticalInset: CGFloat = 6
static let selectedLeftInset: CGFloat = 10
static let normalLeftInset: CGFloat = 12
static let rightInset: CGFloat = 12
static let checkIconSize: CGSize = .init(width: 16, height: 16)
static let baselineOffset: CGFloat = -1
static let fontSize: CGFloat = 11
}

private let button = PPButton(
style: .secondary,
text: "",
font: .korFont(style: .medium, size: Constant.fontSize),
cornerRadius: 15
).then {
$0.titleLabel?.lineBreakMode = .byTruncatingTail
$0.titleLabel?.adjustsFontSizeToFitWidth = false
}

private var currentAction: UIAction?

override init(frame: CGRect) {
super.init(frame: frame)
contentView.addSubview(button)
setupLayout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setupLayout() {
button.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}

func configure(with title: String, isSelected: Bool) {
let attributedTitle = NSMutableAttributedString(string: title).then {
$0.addAttribute(
.baselineOffset,
value: Constant.baselineOffset,
range: NSRange(location: .zero, length: $0.length)
)
}

if isSelected {
let checkImage = UIImage(named: "icon_check_white")?.withRenderingMode(.alwaysOriginal).resize(to: Constant.checkIconSize)

button.then {
$0.setImage(checkImage, for: .normal)
$0.semanticContentAttribute = .forceRightToLeft
$0.imageEdgeInsets = .init(top: .zero, left: 1, bottom: .zero, right: .zero)
$0.contentEdgeInsets = .init(
top: Constant.verticalInset,
left: Constant.selectedLeftInset,
bottom: Constant.verticalInset,
right: Constant.rightInset
)
$0.setBackgroundColor(.blu500, for: .normal)
$0.setTitleColor(.white, for: .normal)
$0.layer.borderWidth = .zero
}

attributedTitle.addAttribute(
.font,
value: UIFont.korFont(style: .bold, size: Constant.fontSize)!,
range: NSRange(location: .zero, length: attributedTitle.length)
)
} else {
button.then {
$0.setImage(nil, for: .normal)
$0.semanticContentAttribute = .unspecified
$0.imageEdgeInsets = .zero
$0.contentEdgeInsets = .init(
top: Constant.verticalInset,
left: Constant.normalLeftInset,
bottom: Constant.verticalInset,
right: Constant.rightInset
)
$0.setBackgroundColor(.white, for: .normal)
$0.setTitleColor(.g400, for: .normal)
$0.layer.borderWidth = 1
$0.layer.borderColor = UIColor.g200.cgColor
}

attributedTitle.addAttribute(
.font,
value: UIFont.korFont(style: .medium, size: Constant.fontSize)!,
range: NSRange(location: .zero, length: attributedTitle.length)
)
}

self.button.setAttributedTitle(attributedTitle, for: .normal)
}

var buttonAction: (() -> Void)? {
didSet {
if let oldAction = currentAction {
self.button.removeAction(oldAction, for: .touchUpInside)
}

let action = UIAction { [weak self] _ in
guard let self = self else { return }
self.buttonAction?()
}

self.button.addAction(action, for: .touchUpInside)
self.currentAction = action
}
}
}

extension UIImage {
func resize(to size: CGSize) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
defer { UIGraphicsEndImageContext() }
draw(in: CGRect(origin: .zero, size: size))
return UIGraphicsGetImageFromCurrentImageContext()
}
func resize(to size: CGSize) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
defer { UIGraphicsEndImageContext() }
self.draw(in: CGRect(origin: .zero, size: size))
return UIGraphicsGetImageFromCurrentImageContext()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,10 @@ class MapViewController: BaseViewController, View, CLLocationManagerDelegate, NM
self.configureTooltip(for: markerToFocus, stores: storeArray)
}

// 툴팁에서 선택된 스토어 업데이트
if let tooltipIndex = storeArray.firstIndex(where: { $0.id == store.id }) {
(self.currentTooltipView as? MarkerTooltipView)?.selectStore(at: tooltipIndex)
}
} else {
// 단일 마커면 기존 툴팁 제거
self.currentTooltipView?.removeFromSuperview()
self.currentTooltipView = nil
}
Expand Down