From 9b7b191945da07f59968180148f065382c8f03ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=80=E1=85=B5=E1=84=92?= =?UTF-8?q?=E1=85=A7=E1=86=AB?= Date: Sat, 3 May 2025 02:52:48 +0900 Subject: [PATCH 1/7] =?UTF-8?q?fix/#130:=20=EB=A7=A4=EC=A7=81=EB=84=98?= =?UTF-8?q?=EB=B2=84=20=EC=83=81=EC=88=98=ED=99=94=20=EB=B0=8F=20Attribute?= =?UTF-8?q?d=20String=20+=20Baseline=20Offset=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FillterSheetView/BalloonChipCell.swift | 181 +++++++++++------- 1 file changed, 111 insertions(+), 70 deletions(-) diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift index 81b1f4b5..d29dc6db 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift @@ -1,88 +1,129 @@ +import Infrastructure import SnapKit import UIKit final class BalloonChipCell: UICollectionViewCell { - static let identifier = "BalloonChipCell" + static let identifier = "BalloonChipCell" - private let button: PPButton = { - let button = PPButton( - style: .secondary, - text: "", - font: .korFont(style: .medium, size: 11), - cornerRadius: 15 - ) + private enum 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 + } - button.titleLabel?.lineBreakMode = .byTruncatingTail - button.titleLabel?.adjustsFontSizeToFitWidth = false - return button - }() + private let button: PPButton = { + let button = PPButton( + style: .secondary, + text: "", + font: .korFont(style: .medium, size: Constant.fontSize), + cornerRadius: 15 + ) + button.titleLabel?.lineBreakMode = .byTruncatingTail + button.titleLabel?.adjustsFontSizeToFitWidth = false + return button + }() - override init(frame: CGRect) { - super.init(frame: frame) - contentView.addSubview(button) - setupLayout() - } + private var currentAction: UIAction? - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } + override init(frame: CGRect) { + super.init(frame: frame) + contentView.addSubview(button) + setupLayout() + } - private func setupLayout() { - button.snp.makeConstraints { make in - make.edges.equalToSuperview() - } - } + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } - 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) + private func setupLayout() { + button.snp.makeConstraints { make in + make.edges.equalToSuperview() + } + } - } 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) + func configure(with title: String, isSelected: Bool) { + let attributedTitle = NSMutableAttributedString(string: title) + attributedTitle.addAttribute( + .baselineOffset, + value: Constant.baselineOffset, + range: NSRange(location: .zero, length: attributedTitle.length) + ) - } - } + if isSelected { + let checkImage = UIImage(named: "icon_check_white")? + .withRenderingMode(.alwaysOriginal) + .resize(to: Constant.checkIconSize) + self.button.setImage(checkImage, for: .normal) + self.button.semanticContentAttribute = .forceRightToLeft + self.button.imageEdgeInsets = .init( + top: .zero, + left: 1, + bottom: .zero, + right: .zero + ) + self.button.contentEdgeInsets = .init( + top: Constant.verticalInset, + left: Constant.selectedLeftInset, + bottom: Constant.verticalInset, + right: Constant.rightInset + ) + self.button.setBackgroundColor(.blu500, for: .normal) + self.button.setTitleColor(.white, for: .normal) + self.button.layer.borderWidth = .zero - private var currentAction: UIAction? + attributedTitle.addAttribute( + .font, + value: UIFont.korFont(style: .bold, size: Constant.fontSize)!, + range: NSRange(location: .zero, length: attributedTitle.length) + ) + } else { + self.button.setImage(nil, for: .normal) + self.button.semanticContentAttribute = .unspecified + self.button.imageEdgeInsets = .zero + self.button.contentEdgeInsets = .init( + top: Constant.verticalInset, + left: Constant.normalLeftInset, + bottom: Constant.verticalInset, + right: Constant.rightInset + ) + self.button.setBackgroundColor(.white, for: .normal) + self.button.setTitleColor(.g400, for: .normal) + self.button.layer.borderWidth = 1 + self.button.layer.borderColor = UIColor.g200.cgColor - var buttonAction: (() -> Void)? { - didSet { - if let oldAction = currentAction { - button.removeAction(oldAction, for: .touchUpInside) - } + attributedTitle.addAttribute( + .font, + value: UIFont.korFont(style: .medium, size: Constant.fontSize)!, + range: NSRange(location: .zero, length: attributedTitle.length) + ) + } - let action = UIAction { [weak self] _ in - self?.buttonAction?() - } - button.addAction(action, for: .touchUpInside) - currentAction = action - } - } -} + 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() + } } From 64fe835f3fb9dcca70cbbeefab7a6228c2dfbc13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=80=E1=85=B5=E1=84=92?= =?UTF-8?q?=E1=85=A7=E1=86=AB?= Date: Sat, 3 May 2025 02:57:45 +0900 Subject: [PATCH 2/7] =?UTF-8?q?refactor/#130:=20Then=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FillterSheetView/BalloonChipCell.swift | 101 +++++++++--------- .../Scene/Map/MapView/MapViewController.swift | 2 - 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift index d29dc6db..711f1fd3 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift @@ -1,6 +1,7 @@ import Infrastructure import SnapKit import UIKit +import Then final class BalloonChipCell: UICollectionViewCell { static let identifier = "BalloonChipCell" @@ -15,17 +16,15 @@ final class BalloonChipCell: UICollectionViewCell { static let fontSize: CGFloat = 11 } - private let button: PPButton = { - let button = PPButton( - style: .secondary, - text: "", - font: .korFont(style: .medium, size: Constant.fontSize), - cornerRadius: 15 - ) - button.titleLabel?.lineBreakMode = .byTruncatingTail - button.titleLabel?.adjustsFontSizeToFitWidth = false - return button - }() + 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? @@ -46,34 +45,31 @@ final class BalloonChipCell: UICollectionViewCell { } func configure(with title: String, isSelected: Bool) { - let attributedTitle = NSMutableAttributedString(string: title) - attributedTitle.addAttribute( - .baselineOffset, - value: Constant.baselineOffset, - range: NSRange(location: .zero, length: attributedTitle.length) - ) + 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) - self.button.setImage(checkImage, for: .normal) - self.button.semanticContentAttribute = .forceRightToLeft - self.button.imageEdgeInsets = .init( - top: .zero, - left: 1, - bottom: .zero, - right: .zero - ) - self.button.contentEdgeInsets = .init( - top: Constant.verticalInset, - left: Constant.selectedLeftInset, - bottom: Constant.verticalInset, - right: Constant.rightInset - ) - self.button.setBackgroundColor(.blu500, for: .normal) - self.button.setTitleColor(.white, for: .normal) - self.button.layer.borderWidth = .zero + 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, @@ -81,19 +77,21 @@ final class BalloonChipCell: UICollectionViewCell { range: NSRange(location: .zero, length: attributedTitle.length) ) } else { - self.button.setImage(nil, for: .normal) - self.button.semanticContentAttribute = .unspecified - self.button.imageEdgeInsets = .zero - self.button.contentEdgeInsets = .init( - top: Constant.verticalInset, - left: Constant.normalLeftInset, - bottom: Constant.verticalInset, - right: Constant.rightInset - ) - self.button.setBackgroundColor(.white, for: .normal) - self.button.setTitleColor(.g400, for: .normal) - self.button.layer.borderWidth = 1 - self.button.layer.borderColor = UIColor.g200.cgColor + 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, @@ -110,15 +108,18 @@ final class BalloonChipCell: UICollectionViewCell { 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) diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/MapView/MapViewController.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/MapView/MapViewController.swift index 6e6923b8..88ce0efa 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/MapView/MapViewController.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/MapView/MapViewController.swift @@ -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 } From 304ae7771926f3402ed0780f29cbe6c829fe44df Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 May 2025 09:39:09 +0000 Subject: [PATCH 3/7] style/#130: Apply SwiftLint autocorrect --- .../Scene/Map/FillterSheetView/BalloonChipCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift index 711f1fd3..70409a3f 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift @@ -1,7 +1,7 @@ import Infrastructure import SnapKit -import UIKit import Then +import UIKit final class BalloonChipCell: UICollectionViewCell { static let identifier = "BalloonChipCell" From 9b804a56c0bb0e3e519861ec43e77bd61712dd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=80=E1=85=B5=E1=84=92?= =?UTF-8?q?=E1=85=A7=E1=86=AB?= Date: Wed, 7 May 2025 13:22:54 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor/#130:=20UICollectionViewCell=20ide?= =?UTF-8?q?ntifier=20extension=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scene/Map/FillterSheetView/BalloonBackgroundView.swift | 4 ++-- .../Scene/Map/FillterSheetView/BalloonChipCell.swift | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonBackgroundView.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonBackgroundView.swift index e5cc9467..fff36989 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonBackgroundView.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonBackgroundView.swift @@ -34,7 +34,7 @@ final class BalloonBackgroundView: UIView { let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.backgroundColor = .clear collectionView.isScrollEnabled = false - collectionView.register(BalloonChipCell.self, forCellWithReuseIdentifier: BalloonChipCell.identifier) + collectionView.register(BalloonChipCell.self, forCellWithReuseIdentifier: BalloonChipCell.identifiers) return collectionView }() @@ -289,7 +289,7 @@ extension BalloonBackgroundView: UICollectionViewDataSource { cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell( - withReuseIdentifier: BalloonChipCell.identifier, + withReuseIdentifier: BalloonChipCell.identifiers, for: indexPath ) as? BalloonChipCell, let input = tagSection?.inputDataList[indexPath.item] diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift index 711f1fd3..558af950 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift @@ -1,10 +1,11 @@ +import UIKit + import Infrastructure + import SnapKit -import UIKit import Then final class BalloonChipCell: UICollectionViewCell { - static let identifier = "BalloonChipCell" private enum Constant { static let verticalInset: CGFloat = 6 From 43bbd14d5f3432bd086cb1a4a7fc24f553d976bb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 7 May 2025 04:24:25 +0000 Subject: [PATCH 5/7] style/#130: Apply SwiftLint autocorrect --- .../Scene/Map/FillterSheetView/BalloonChipCell.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift index 1a0212e3..11c8dc01 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift @@ -4,8 +4,6 @@ import Infrastructure import SnapKit import Then -import UIKit - final class BalloonChipCell: UICollectionViewCell { private enum Constant { From 66e0d410945f9dd91a42fa53bcaa9dc3e0556ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=80=E1=85=B5=E1=84=92?= =?UTF-8?q?=E1=85=A7=E1=86=AB?= Date: Wed, 7 May 2025 18:08:25 +0900 Subject: [PATCH 6/7] =?UTF-8?q?reafcator/#130:=20=EB=A9=94=EC=9D=B8?= =?UTF-8?q?=EC=A7=80=EC=97=AD=20=EB=9D=BC=EB=B2=A8=20=EC=A7=A4=EB=A6=BC?= =?UTF-8?q?=EC=9D=B4=EC=8A=88=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EA=B7=B8?= =?UTF-8?q?=EB=9D=BC=EC=9A=B4=EB=93=9C=EB=A3=B0=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FillterSheetView/BalloonChipCell.swift | 1 - .../FilterBottomSheetView.swift | 177 +++++++++--------- 2 files changed, 87 insertions(+), 91 deletions(-) diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift index 1a0212e3..558af950 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift @@ -4,7 +4,6 @@ import Infrastructure import SnapKit import Then -import UIKit final class BalloonChipCell: UICollectionViewCell { diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/FilterBottomSheetView.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/FilterBottomSheetView.swift index 0ecff3df..7be75de4 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/FilterBottomSheetView.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/FilterBottomSheetView.swift @@ -1,39 +1,43 @@ -import SnapKit import UIKit +import SnapKit +import Then + final class FilterBottomSheetView: UIView { - // MARK: - UI Components - private let containerView: UIView = { - let view = UIView() - view.backgroundColor = .white - view.layer.cornerRadius = 20 - view.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] - view.layer.masksToBounds = true - return view - }() + private enum Constant { + static let cornerRadius: CGFloat = 20 + static let topInset: CGFloat = 30 + static let horizontalInset: CGFloat = 16 + static let segmentedTopOffset: CGFloat = 16 + static let scrollViewHeight: CGFloat = 36 + static let categoryHeight: CGFloat = 160 + static let balloonTopOffset: CGFloat = 16 + static let filterChipsHeight: CGFloat = 80 + static let buttonStackSpacing: CGFloat = 12 + static let buttonStackHeight: CGFloat = 52 + } - let titleLabel: PPLabel = { - let label = PPLabel(style: .bold, fontSize: 18, text: "보기 옵션을 선택해주세요") - label.textColor = .black - return label - }() + private let containerView = UIView().then { + $0.backgroundColor = .white + $0.layer.cornerRadius = Constant.cornerRadius + $0.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] + $0.layer.masksToBounds = true + } - let closeButton: UIButton = { - let button = UIButton(type: .system) - button.setImage(UIImage(named: "icon_xmark"), for: .normal) - button.tintColor = .black - return button - }() + let titleLabel = PPLabel(style: .bold, fontSize: 18, text: "보기 옵션을 선택해주세요").then { + $0.textColor = .black + } - let segmentedControl: PPSegmentedControl = { - return PPSegmentedControl(type: .tab, segments: ["지역", "카테고리"], selectedSegmentIndex: 0) - }() + let closeButton = UIButton(type: .system).then { + $0.setImage(UIImage(named: "icon_xmark"), for: .normal) + $0.tintColor = .black + } - let locationScrollView: UIScrollView = { - let scrollView = UIScrollView() - scrollView.showsHorizontalScrollIndicator = false - return scrollView - }() + let segmentedControl = PPSegmentedControl(type: .tab, segments: ["지역", "카테고리"], selectedSegmentIndex: 0) + + let locationScrollView = UIScrollView().then { + $0.showsHorizontalScrollIndicator = false + } let locationContentView = UIView() var categoryHeightConstraint: Constraint? @@ -42,13 +46,13 @@ final class FilterBottomSheetView: UIView { let layout = UICollectionViewCompositionalLayout { section, _ in let itemSize = NSCollectionLayoutSize( widthDimension: .estimated(26), - heightDimension: .estimated(36) + heightDimension: .estimated(Constant.scrollViewHeight) ) let item = NSCollectionLayoutItem(layoutSize: itemSize) let groupSize = NSCollectionLayoutSize( widthDimension: .fractionalWidth(1.0), - heightDimension: .estimated(36) + heightDimension: .estimated(Constant.scrollViewHeight) ) let group = NSCollectionLayoutGroup.horizontal( layoutSize: groupSize, @@ -67,35 +71,25 @@ final class FilterBottomSheetView: UIView { return section } - - let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) - collectionView.backgroundColor = .clear - collectionView.isScrollEnabled = false - collectionView.register(TagSectionCell.self, forCellWithReuseIdentifier: TagSectionCell.identifiers) - return collectionView + return UICollectionView(frame: .zero, collectionViewLayout: layout).then { + $0.backgroundColor = .clear + $0.isScrollEnabled = false + $0.register(TagSectionCell.self, forCellWithReuseIdentifier: TagSectionCell.identifiers) + } }() let balloonBackgroundView = BalloonBackgroundView() - let resetButton: PPButton = { - return PPButton(style: .secondary, text: "초기화") - }() - - let saveButton: PPButton = { - return PPButton(style: .primary, text: "옵션저장", disabledText: "옵션저장") - }() + let resetButton = PPButton(style: .secondary, text: "초기화") + let saveButton = PPButton(style: .primary, text: "옵션저장", disabledText: "옵션저장") - private let buttonStack: UIStackView = { - let stack = UIStackView() - stack.axis = .horizontal - stack.spacing = 12 - stack.distribution = .fillEqually - return stack - }() + private let buttonStack = UIStackView().then { + $0.axis = .horizontal + $0.spacing = Constant.buttonStackSpacing + $0.distribution = .fillEqually + } - let filterChipsView: FilterChipsView = { - return FilterChipsView() - }() + let filterChipsView = FilterChipsView() private var balloonHeightConstraint: Constraint? @@ -142,25 +136,25 @@ final class FilterBottomSheetView: UIView { } titleLabel.snp.makeConstraints { make in - make.leading.equalToSuperview().offset(16) - make.top.equalToSuperview().offset(30) + make.leading.equalToSuperview().offset(Constant.horizontalInset) + make.top.equalToSuperview().offset(Constant.topInset) } closeButton.snp.makeConstraints { make in - make.trailing.equalToSuperview().inset(16) + make.trailing.equalToSuperview().inset(Constant.horizontalInset) make.centerY.equalTo(titleLabel) make.size.equalTo(24) } segmentedControl.snp.makeConstraints { make in - make.top.equalTo(titleLabel.snp.bottom).offset(16) + make.top.equalTo(titleLabel.snp.bottom).offset(Constant.segmentedTopOffset) make.leading.trailing.equalToSuperview() } locationScrollView.snp.makeConstraints { make in make.top.equalTo(segmentedControl.snp.bottom).offset(20) make.leading.trailing.equalToSuperview() - make.height.equalTo(36) + make.height.equalTo(Constant.scrollViewHeight) } locationContentView.snp.makeConstraints { make in @@ -169,28 +163,28 @@ final class FilterBottomSheetView: UIView { } categoryCollectionView.snp.makeConstraints { make in - make.top.equalTo(segmentedControl.snp.bottom).offset(16) + make.top.equalTo(segmentedControl.snp.bottom).offset(Constant.segmentedTopOffset) make.leading.trailing.equalToSuperview() - categoryHeightConstraint = make.height.equalTo(160).constraint + categoryHeightConstraint = make.height.equalTo(Constant.categoryHeight).constraint } balloonBackgroundView.snp.makeConstraints { make in - make.top.equalTo(locationScrollView.snp.bottom).offset(16) - make.leading.trailing.equalToSuperview().inset(16) + make.top.equalTo(locationScrollView.snp.bottom).offset(Constant.balloonTopOffset) + make.leading.trailing.equalToSuperview().inset(Constant.horizontalInset) balloonHeightConstraint = make.height.equalTo(0).constraint } filterChipsView.snp.makeConstraints { make in make.top.equalTo(balloonBackgroundView.snp.bottom).offset(24) - make.leading.trailing.equalToSuperview().inset(16) - make.height.equalTo(80) + make.leading.trailing.equalToSuperview().inset(Constant.horizontalInset) + make.height.equalTo(Constant.filterChipsHeight) } buttonStack.snp.makeConstraints { make in make.top.equalTo(filterChipsView.snp.bottom).offset(24) - make.leading.trailing.equalToSuperview().inset(16) + make.leading.trailing.equalToSuperview().inset(Constant.horizontalInset) make.bottom.equalToSuperview().inset(40) - make.height.equalTo(52) + make.height.equalTo(Constant.buttonStackHeight) } } @@ -305,41 +299,44 @@ final class FilterBottomSheetView: UIView { let button = PPButton( style: .secondary, text: title, - font: .korFont(style: .medium, size: 13), + font: .korFont(style: isSelected ? .bold : .medium, size: 13), cornerRadius: 18 ) - button.setBackgroundColor(.w100, for: .normal) - button.setTitleColor(.g400, for: .normal) + button.setBackgroundColor(isSelected ? .blu500 : .w100, for: .normal) + button.setTitleColor(isSelected ? .w100 : .g400, for: .normal) + button.layer.borderWidth = isSelected ? 0 : 1 button.layer.borderColor = UIColor.g200.cgColor - button.layer.borderWidth = 1 - - if isSelected { - button.setBackgroundColor(.blu500, for: .normal) - button.setTitleColor(.w100, for: .normal) - button.layer.borderWidth = 0 - } - button.contentEdgeInsets = UIEdgeInsets(top: 9, left: 16, bottom: 9, right: 16) + button.titleLabel?.setLineHeightText( + text: title, + font: .korFont(style: isSelected ? .bold : .medium, size: 13), + lineHeight: 1.2 + ) + return button } + func updateMainLocationSelection(_ index: Int) { locationContentView.subviews.enumerated().forEach { (idx, view) in guard let button = view as? PPButton else { return } - if idx == index { - button.setBackgroundColor(.blu500, for: .normal) - button.setTitleColor(.w100, for: .normal) - button.layer.borderWidth = 0 - button.titleLabel?.font = .korFont(style: .bold, size: 13) - } else { - button.setBackgroundColor(.w100, for: .normal) - button.setTitleColor(.g400, for: .normal) - button.layer.borderColor = UIColor.g200.cgColor - button.titleLabel?.font = .korFont(style: .medium, size: 13) - button.layer.borderWidth = 1 - } + + let isSelected = idx == index + button.setBackgroundColor(isSelected ? .blu500 : .w100, for: .normal) + button.setTitleColor(isSelected ? .w100 : .g400, for: .normal) + button.layer.borderWidth = isSelected ? 0 : 1 + button.layer.borderColor = UIColor.g200.cgColor + + // 버튼의 타이틀 레이블에 setLineHeightText 적용 + let title = button.currentTitle ?? "" + button.titleLabel?.setLineHeightText( + text: title, + font: .korFont(style: isSelected ? .bold : .medium, size: 13), + lineHeight: 1.2 + ) } + } func updateBalloonHeight(isHidden: Bool, dynamicHeight: CGFloat = 160) { From 29ab38fd8fd9069b6b6b7e9769599f2da471a1be Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 7 May 2025 09:09:46 +0000 Subject: [PATCH 7/7] style/#130: Apply SwiftLint autocorrect --- .../Scene/Map/FillterSheetView/FilterBottomSheetView.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/FilterBottomSheetView.swift b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/FilterBottomSheetView.swift index 7be75de4..a1b0dca4 100644 --- a/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/FilterBottomSheetView.swift +++ b/Poppool/PresentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/FilterBottomSheetView.swift @@ -317,7 +317,6 @@ final class FilterBottomSheetView: UIView { return button } - func updateMainLocationSelection(_ index: Int) { locationContentView.subviews.enumerated().forEach { (idx, view) in guard let button = view as? PPButton else { return }