-
Notifications
You must be signed in to change notification settings - Fork 0
[FIX] 서브지역 카테고리 라벨 상단이 짤리던 이슈 수정 #137
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
Merged
zzangzzangguy
merged 10 commits into
develop
from
fix/#130-fix-truncated-subregion-labels
May 12, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9b7b191
fix/#130: 매직넘버 상수화 및 Attributed String + Baseline Offset 적용
zzangzzangguy 64fe835
refactor/#130: Then 적용
zzangzzangguy 304ae77
style/#130: Apply SwiftLint autocorrect
github-actions[bot] 9b804a5
refactor/#130: UICollectionViewCell identifier extension 적용
zzangzzangguy b45ef4c
Merge branch 'develop' of https://github.com/PopPool/iOS into fix/#13…
zzangzzangguy 0c63c1f
Merge branch 'fix/#130-fix-truncated-subregion-labels' of https://git…
zzangzzangguy 43bbd14
style/#130: Apply SwiftLint autocorrect
github-actions[bot] 66e0d41
reafcator/#130: 메인지역 라벨 짤림이슈 수정 및 그라운드룰 적용
zzangzzangguy ea00043
Merge branch 'fix/#130-fix-truncated-subregion-labels' of https://git…
zzangzzangguy 29ab38f
style/#130: Apply SwiftLint autocorrect
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
205 changes: 124 additions & 81 deletions
205
...sentationLayer/Presentation/Presentation/Scene/Map/FillterSheetView/BalloonChipCell.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,88 +1,131 @@ | ||
| import SnapKit | ||
| import UIKit | ||
|
|
||
| import Infrastructure | ||
|
|
||
| import SnapKit | ||
| import Then | ||
|
|
||
| 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 | ||
| } | ||
| } | ||
|
|
||
| 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 | ||
| } | ||
|
|
||
| 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() | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사용할 값들을 Constant로 빼서 사용하는 룰!! 적용된 걸 보니 깔끔해서 좋습니다 :>