From 754e89f26c92f75aa429a1783e7e1e8abc698422 Mon Sep 17 00:00:00 2001 From: JinUng41 Date: Tue, 13 Aug 2024 11:59:06 +0900 Subject: [PATCH] =?UTF-8?q?fix/#286=20=EB=B9=88=20=EB=AC=B8=EC=9E=90?= =?UTF-8?q?=EC=97=B4=20=EC=8B=9C,=20=EB=9F=B0=ED=83=80=EC=9E=84=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EA=B0=80=20=EB=B0=9C=EC=83=9D=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KkuMulKum/Resource/Extension/UILabel+.swift | 17 +++++++------ .../AddPromise/Cell/PlaceListCell.swift | 24 +++++-------------- .../AddPromise/Cell/SelectMemberCell.swift | 2 +- .../MeetingInfo/Cell/MeetingMemberCell.swift | 6 ++--- .../MeetingInfo/Cell/MeetingPromiseCell.swift | 16 ++++++------- .../View/MeetingInfoBannerView.swift | 4 ++-- .../MeetingInfo/View/MeetingInfoView.swift | 2 +- 7 files changed, 29 insertions(+), 42 deletions(-) diff --git a/KkuMulKum/Resource/Extension/UILabel+.swift b/KkuMulKum/Resource/Extension/UILabel+.swift index 8b93d9f2..b4348b2f 100644 --- a/KkuMulKum/Resource/Extension/UILabel+.swift +++ b/KkuMulKum/Resource/Extension/UILabel+.swift @@ -9,12 +9,12 @@ import UIKit extension UILabel { func setText( - _ text: String, + _ text: String = " ", style: UIFont.Pretendard, color: UIColor = .black, isSingleLine: Bool = false ) { - attributedText = .pretendardString(text, style: style) + attributedText = .pretendardString(text.isEmpty ? " " : text, style: style) textColor = color if isSingleLine { numberOfLines = 1 @@ -24,23 +24,22 @@ extension UILabel { } } - func updateText(_ text: String) { + func updateText(_ text: String?) { guard let currentAttributes = attributedText?.attributes(at: 0, effectiveRange: nil) else { self.text = text return } - attributedText = NSAttributedString(string: text, attributes: currentAttributes) + attributedText = NSAttributedString(string: text ?? " ", attributes: currentAttributes) } func setHighlightText(_ words: String..., style: UIFont.Pretendard, color: UIColor? = nil) { - guard let currentText = attributedText?.string else { return } - let mutableAttributedString = NSMutableAttributedString( - attributedString: attributedText ?? NSAttributedString() - ) + guard let currentAttributedText = attributedText else { return } + + let mutableAttributedString = NSMutableAttributedString(attributedString: currentAttributedText) let textColor = textColor ?? .black for word in words { - let range = (currentText as NSString).range(of: word) + let range = (currentAttributedText.string as NSString).range(of: word) if range.location != NSNotFound { let highlightedAttributes: [NSAttributedString.Key: Any] = [ diff --git a/KkuMulKum/Source/AddPromise/Cell/PlaceListCell.swift b/KkuMulKum/Source/AddPromise/Cell/PlaceListCell.swift index d8dfce00..6ebda52a 100644 --- a/KkuMulKum/Source/AddPromise/Cell/PlaceListCell.swift +++ b/KkuMulKum/Source/AddPromise/Cell/PlaceListCell.swift @@ -15,7 +15,7 @@ final class PlaceListCell: BaseCollectionViewCell { static let defaultHeight = Screen.height(118) private let titleLabel = UILabel().then { - $0.setText("", style: .body05, color: .gray8) + $0.setText(style: .body05, color: .gray8) } private let roadAddressTitleLabel = UILabel().then { @@ -28,7 +28,7 @@ final class PlaceListCell: BaseCollectionViewCell { } private let roadAddressNameLabel = UILabel().then { - $0.setText(" ", style: .caption02, color: .gray6) + $0.setText(style: .caption02, color: .gray6, isSingleLine: true) } private let addressTitleLabel = UILabel().then { @@ -41,7 +41,7 @@ final class PlaceListCell: BaseCollectionViewCell { } private let addressNameLabel = UILabel().then { - $0.setText(" ", style: .caption02, color: .gray6) + $0.setText(style: .caption02, color: .gray6, isSingleLine: true) } @@ -116,20 +116,8 @@ extension PlaceListCell { private extension PlaceListCell { func configureCell(title: String, roadAddress: String?, address: String?) { - titleLabel.setText(title, style: .body05, color: .gray8) - - roadAddressNameLabel.setText( - roadAddress ?? " ", - style: .caption02, - color: .gray6, - isSingleLine: true - ) - - addressNameLabel.setText( - address ?? " ", - style: .caption02, - color: .gray6, - isSingleLine: true - ) + titleLabel.updateText(title) + roadAddressNameLabel.updateText(roadAddress) + addressNameLabel.updateText(address) } } diff --git a/KkuMulKum/Source/AddPromise/Cell/SelectMemberCell.swift b/KkuMulKum/Source/AddPromise/Cell/SelectMemberCell.swift index 80bddc9a..910146eb 100644 --- a/KkuMulKum/Source/AddPromise/Cell/SelectMemberCell.swift +++ b/KkuMulKum/Source/AddPromise/Cell/SelectMemberCell.swift @@ -62,7 +62,7 @@ extension SelectMemberCell { func configure(with member: Member) { self.member = member - nameLabel.setText(member.name ?? " ", style: .body06, color: .gray6) + nameLabel.updateText(member.name) let imageURL = member.profileImageURL.flatMap { URL(string: $0) } profileImageView.kf.setImage(with: imageURL, placeholder: UIImage.imgProfile.withRenderingMode(.alwaysOriginal)) diff --git a/KkuMulKum/Source/MeetingInfo/Cell/MeetingMemberCell.swift b/KkuMulKum/Source/MeetingInfo/Cell/MeetingMemberCell.swift index 69573823..0f9c31b5 100644 --- a/KkuMulKum/Source/MeetingInfo/Cell/MeetingMemberCell.swift +++ b/KkuMulKum/Source/MeetingInfo/Cell/MeetingMemberCell.swift @@ -23,7 +23,7 @@ final class MeetingMemberCell: BaseCollectionViewCell { } private let nameLabel = UILabel().then { - $0.setText(" ", style: .caption02, color: .gray6) + $0.setText(style: .caption02, color: .gray6) $0.textAlignment = .center } @@ -38,7 +38,7 @@ final class MeetingMemberCell: BaseCollectionViewCell { $0.isEnabled = false } - nameLabel.setText(" ", style: .caption02, color: .gray6) + nameLabel.setText(style: .caption02, color: .gray6) } override func setupView() { @@ -94,7 +94,7 @@ private extension MeetingMemberCell { $0.isEnabled = true } - nameLabel.setText(" ", style: .caption02, color: .gray6) + nameLabel.setText(style: .caption02, color: .gray6) } func configureForProfile(with member: Member) { diff --git a/KkuMulKum/Source/MeetingInfo/Cell/MeetingPromiseCell.swift b/KkuMulKum/Source/MeetingInfo/Cell/MeetingPromiseCell.swift index 2c81a71d..496b9983 100644 --- a/KkuMulKum/Source/MeetingInfo/Cell/MeetingPromiseCell.swift +++ b/KkuMulKum/Source/MeetingInfo/Cell/MeetingPromiseCell.swift @@ -12,7 +12,7 @@ import Then final class MeetingPromiseCell: BaseCollectionViewCell { private let dDayLabel = UILabel().then { - $0.setText("", style: .body05, color: .mainorange) + $0.setText(style: .body05, color: .mainorange) } private let nameLabel = UILabel().then { @@ -26,7 +26,7 @@ final class MeetingPromiseCell: BaseCollectionViewCell { } private let dateLabel = UILabel().then { - $0.setText("", style: .body06, color: .gray7) + $0.setText(style: .body06, color: .gray7) } private let dateStackView = UIStackView(axis: .horizontal).then { @@ -40,7 +40,7 @@ final class MeetingPromiseCell: BaseCollectionViewCell { } private let timeLabel = UILabel().then { - $0.setText("", style: .body06, color: .gray7) + $0.setText(style: .body06, color: .gray7) } private let timeStackView = UIStackView(axis: .horizontal).then { @@ -54,7 +54,7 @@ final class MeetingPromiseCell: BaseCollectionViewCell { } private let placeLabel = UILabel().then { - $0.setText("", style: .body06, color: .gray7) + $0.setText(style: .body06, color: .gray7) } private let placeStackView = UIStackView(axis: .horizontal).then { @@ -110,9 +110,9 @@ extension MeetingPromiseCell { func configure(dDay: Int, name: String, date: String, time: String, place: String) { let dDayText = dDay == 0 ? "DAY" : "\(dDay)" dDayLabel.setText("D-\(dDayText)", style: .body05, color: dDay == 0 ? .mainorange : .gray5) - nameLabel.setText(name, style: .body03, color: .gray8) - dateLabel.setText(date, style: .body06, color: .gray7) - timeLabel.setText(time, style: .body06, color: .gray7) - placeLabel.setText(place, style: .body06, color: .gray7, isSingleLine: true) + nameLabel.updateText(name) + dateLabel.updateText(date) + timeLabel.updateText(time) + placeLabel.updateText(place) } } diff --git a/KkuMulKum/Source/MeetingInfo/View/MeetingInfoBannerView.swift b/KkuMulKum/Source/MeetingInfo/View/MeetingInfoBannerView.swift index d0dfed8a..529c2b7f 100644 --- a/KkuMulKum/Source/MeetingInfo/View/MeetingInfoBannerView.swift +++ b/KkuMulKum/Source/MeetingInfo/View/MeetingInfoBannerView.swift @@ -69,10 +69,10 @@ final class MeetingInfoBannerView: BaseView { extension MeetingInfoBannerView { func configure(createdAt: String, metCount: Int) { - createdAtLabel.setText(createdAt, style: .label01, color: .gray4) + createdAtLabel.updateText(createdAt) metCountLabel.do { - $0.setText("이 모임의 꾸물이들은 \(metCount)번 만났어요!", style: .body03, color: .gray8) + $0.updateText("이 모임의 꾸물이들은 \(metCount)번 만났어요!") $0.setHighlightText("\(metCount)번", style: .body03, color: .maincolor) } } diff --git a/KkuMulKum/Source/MeetingInfo/View/MeetingInfoView.swift b/KkuMulKum/Source/MeetingInfo/View/MeetingInfoView.swift index 356f509c..4f6d3378 100644 --- a/KkuMulKum/Source/MeetingInfo/View/MeetingInfoView.swift +++ b/KkuMulKum/Source/MeetingInfo/View/MeetingInfoView.swift @@ -174,7 +174,7 @@ extension MeetingInfoView { func configureMemberCount(_ memberCount: Int) { memberCountLabel.do { - $0.setText("모임 참여 인원 \(memberCount)명", style: .body01, color: .gray8) + $0.updateText("모임 참여 인원 \(memberCount)명") $0.setHighlightText("\(memberCount)명", style: .body01, color: .maincolor) } }