Skip to content

Commit f36a1cb

Browse files
authored
Merge pull request #181 from YAPP-Github/BOOK-268-fix/#175
fix: 디자인 QA 반영
2 parents d5e1ff0 + df7471b commit f36a1cb

36 files changed

Lines changed: 454 additions & 110 deletions

src/Projects/BKDesign/Sources/Components/BottomSheet/BKBottomSheetTitleView.swift

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import UIKit
55

66
public final class BKBottomSheetTitleView: UIView {
77
private let style: BKBottomSheetStyle
8-
private let titleLabel = UILabel()
9-
private let subtitleLabel = UILabel()
8+
private let titleLabel = BKLabel()
9+
private let subtitleLabel = BKLabel()
1010
private let closeButton = UIButton(type: .system)
1111

1212
private let title: String
@@ -33,20 +33,23 @@ public final class BKBottomSheetTitleView: UIView {
3333

3434
private extension BKBottomSheetTitleView {
3535
func configure() {
36-
titleLabel.text = title
36+
titleLabel.setText(text: title)
3737
titleLabel.numberOfLines = .zero
38-
titleLabel.font = BKTextStyle
39-
.heading2(weight: .semiBold).uiFont
40-
titleLabel.textColor = .bkContentColor(.primary)
38+
titleLabel.setFontStyle(style: .heading2(weight: .semiBold))
39+
titleLabel.setColor(color: .bkContentColor(.primary))
4140

42-
subtitleLabel.text = subtitle
43-
subtitleLabel.numberOfLines = .zero
44-
subtitleLabel.font = (
45-
style == .leadingCloseButton
46-
? BKTextStyle.label2(weight: .regular)
47-
: BKTextStyle.body1(weight: .medium))
48-
.uiFont
49-
subtitleLabel.textColor = .bkContentColor(.secondary)
41+
if let subtitle = subtitle {
42+
subtitleLabel.setText(text: subtitle)
43+
subtitleLabel.numberOfLines = .zero
44+
subtitleLabel.setColor(color: .bkContentColor(.secondary))
45+
46+
switch style {
47+
case .leadingCloseButton:
48+
subtitleLabel.setFontStyle(style: .label1(weight: .medium))
49+
case .centered:
50+
subtitleLabel.setFontStyle(style: .body1(weight: .medium))
51+
}
52+
}
5053

5154
closeButton.setImage(
5255
style == .leadingCloseButton
@@ -76,12 +79,12 @@ private extension BKBottomSheetTitleView {
7679
].compactMap { $0 })
7780
labelStack.axis = .vertical
7881
labelStack.alignment = .leading
79-
labelStack.spacing = LayoutConstants.leadingContentSpacing
82+
labelStack.spacing = LayoutConstants.contentSpacing
8083

8184
let hStack = UIStackView(arrangedSubviews: [labelStack, closeButton])
8285
hStack.axis = .horizontal
8386
hStack.alignment = .top
84-
hStack.spacing = LayoutConstants.leadingContentSpacing
87+
hStack.spacing = LayoutConstants.contentSpacing
8588

8689
addSubview(hStack)
8790
hStack.snp.makeConstraints {
@@ -102,7 +105,7 @@ private extension BKBottomSheetTitleView {
102105
].compactMap { $0 })
103106
vStack.axis = .vertical
104107
vStack.alignment = .fill
105-
vStack.spacing = LayoutConstants.centeredContentSpacing
108+
vStack.spacing = LayoutConstants.contentSpacing
106109

107110
addSubview(vStack)
108111
vStack.snp.makeConstraints {
@@ -117,8 +120,6 @@ private extension BKBottomSheetTitleView {
117120

118121
private extension BKBottomSheetTitleView {
119122
enum LayoutConstants {
120-
static let leadingContentSpacing: CGFloat = 2
121-
static let centeredContentSpacing: CGFloat = 4
122-
static let labelHeight: CGFloat = 24
123+
static let contentSpacing: CGFloat = 4
123124
}
124125
}

src/Projects/BKDesign/Sources/Components/Button/BKButtonGroup.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ extension BKButtonGroup {
168168
leftAction: (() -> Void)? = nil,
169169
rightAction: (() -> Void)? = nil
170170
) -> BKButtonGroup {
171-
let leftButton = BKButton.secondary(title: leftTitle)
172-
let rightButton = BKButton.primary(title: rightTitle)
171+
let leftButton = BKButton.secondary(title: leftTitle, size: .large)
172+
let rightButton = BKButton.primary(title: rightTitle, size: .large)
173173

174174
if let action = leftAction {
175175
leftButton.addAction(UIAction { _ in action() }, for: .touchUpInside)
@@ -237,4 +237,4 @@ extension BKButtonGroup {
237237
buttons.forEach { $0.isFullWidth = true }
238238
return BKButtonGroup(buttons: buttons, layout: .vertical, spacing: spacing)
239239
}
240-
}
240+
}

src/Projects/BKDesign/Sources/Components/Chip/BKChip.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import UIKit
44

55
public final class BKChip: UIView {
6-
private var titleLabel = BKLabel()
7-
private var countLabel = BKLabel()
6+
private var titleLabel = BKLabel2()
7+
private var countLabel = BKLabel2()
88
private let labelContainer = UIView()
99
public var onTap: (() -> Void)?
1010

src/Projects/BKDesign/Sources/Components/Dialog/BKDialog.swift

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ public final class BKDialog: UIView {
5757

5858
private let buttonGroup: BKButtonGroup
5959
private let titleText: String
60-
private let subtitleText: String
60+
private let subtitleText: String?
6161

6262
public init(
6363
title: String,
64-
subtitle: String,
64+
subtitle: String? = nil,
6565
config: BKDialogConfiguration,
6666
suppliedContentStyle: SuppliedContentStyle? = nil
6767
) {
@@ -108,14 +108,27 @@ private extension BKDialog {
108108
private extension BKDialog {
109109
func setup() {
110110
addSubviews(rootStack, buttonGroup)
111-
[titleLabel, subtitleLabel].forEach(titleStack.addArrangedSubview(_:))
111+
112+
// 타이틀은 항상 추가
113+
titleStack.addArrangedSubview(titleLabel)
114+
115+
// subtitle이 있을 때만 추가
116+
if subtitleText != nil {
117+
titleStack.addArrangedSubview(subtitleLabel)
118+
}
112119
}
113120

114121
func configure() {
115122
layer.cornerRadius = BKRadius.large
116123
backgroundColor = .bkBaseColor(.primary)
117124
titleLabel.setText(text: titleText)
118-
subtitleLabel.setText(text: subtitleText)
125+
126+
if let subtitle = subtitleText, !subtitle.isEmpty {
127+
subtitleLabel.setText(text: subtitle)
128+
subtitleLabel.isHidden = false
129+
} else {
130+
subtitleLabel.isHidden = true
131+
}
119132

120133
titleLabel.numberOfLines = 0
121134
subtitleLabel.numberOfLines = 0
@@ -134,7 +147,7 @@ private extension BKDialog {
134147
.offset(LayoutConstants.buttonTopInset)
135148
$0.leading.trailing.equalToSuperview()
136149
$0.height.equalTo(84)
137-
$0.bottom.equalToSuperview()
150+
$0.bottom.equalToSuperview().inset(4)
138151
}
139152
}
140153

@@ -182,7 +195,7 @@ private extension BKDialog {
182195
private extension BKDialog {
183196
enum LayoutConstants {
184197
static let titleTopInset = BKInset.inset8
185-
static let buttonTopInset = BKInset.inset6
198+
static let buttonTopInset = BKInset.inset2
186199
static let horizontalInset = BKInset.inset5
187200
static let buttonBottomInset = BKInset.inset5
188201
static let titleStackSpacing = BKSpacing.spacing2

src/Projects/BKDesign/Sources/Components/Label/BKLabel.swift

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public final class BKLabel: UILabel {
2727
get { super.textColor }
2828
set { super.textColor = newValue }
2929
}
30-
30+
3131
@available(*, unavailable, message: "Implement `setFont(_:)` instead.")
3232
override public var font: UIFont! {
3333
get { super.font }
@@ -36,19 +36,22 @@ public final class BKLabel: UILabel {
3636

3737
public var highlightedWord: String? {
3838
didSet {
39-
apply()
39+
// apply()
40+
applyRecommended()
4041
}
4142
}
4243

4344
public var highlightColor: UIColor {
4445
didSet {
45-
apply()
46+
// apply()
47+
applyRecommended()
4648
}
4749
}
4850

4951
public var highlightFont: UIFont? {
5052
didSet {
51-
apply()
53+
// apply()
54+
applyRecommended()
5255
}
5356
}
5457

@@ -70,7 +73,8 @@ public final class BKLabel: UILabel {
7073
self.highlightColor = highlightColor
7174
self.highlightFont = highlightFont
7275
super.init(frame: frame)
73-
apply()
76+
// apply()
77+
applyRecommended()
7478
}
7579

7680
convenience public init(
@@ -98,17 +102,21 @@ public final class BKLabel: UILabel {
98102

99103
public func setFontStyle(style: BKTextStyle) {
100104
self.fontStyle = style
101-
apply()
105+
// apply()
106+
applyRecommended()
102107
}
103108

104109
public func setText(text: String) {
105110
self.labelText = text
106-
apply()
111+
// apply()
112+
applyRecommended()
107113
}
108114

109115
public func setColor(color: UIColor) {
110116
self.labelColor = color
111-
apply()
117+
// apply()
118+
119+
applyRecommended()
112120
}
113121
}
114122

@@ -142,6 +150,35 @@ private extension BKLabel {
142150

143151
attributedText = attributedString
144152
}
153+
154+
func applyRecommended() {
155+
let customParagraphStyle = fontStyle.paragraphStyle
156+
customParagraphStyle.alignment = alignment
157+
customParagraphStyle.lineBreakMode = self.lineBreakMode
158+
159+
let extraAttributes: [NSAttributedString.Key: Any] = [
160+
.paragraphStyle: customParagraphStyle
161+
]
162+
163+
let attributedString = fontStyle.mutableAttributedString(
164+
from: labelText,
165+
color: labelColor,
166+
extraAttributes: extraAttributes
167+
)
168+
169+
// 하이라이트 단어 처리
170+
if let word = highlightedWord, !word.isEmpty {
171+
let wordRange = (labelText as NSString).range(of: word)
172+
if wordRange.location != NSNotFound {
173+
attributedString.addAttribute(.foregroundColor, value: highlightColor, range: wordRange)
174+
if let highlightFont = highlightFont {
175+
attributedString.addAttribute(.font, value: highlightFont, range: wordRange)
176+
}
177+
}
178+
}
179+
180+
attributedText = attributedString
181+
}
145182
}
146183

147184
extension BKLabel.LabelType {

0 commit comments

Comments
 (0)