Skip to content

Commit 7531258

Browse files
authored
Merge pull request #37 from LearnMate-Dev/fix/#36
[Fix/#36] QA 반영
2 parents d82bff3 + 3595f3c commit 7531258

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+326
-132
lines changed

Projects/Chat/Sources/View/ChatViewController.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class ChatViewController: BaseViewController {
4444

4545
// 초기에 endButton 숨기기
4646
chatView.hideEndButton()
47+
setupTapGesture()
4748
}
4849

4950
public override func setupViewProperty() {
@@ -242,4 +243,14 @@ public class ChatViewController: BaseViewController {
242243
// 이전 화면으로 이동
243244
navigationController?.popViewController(animated: true)
244245
}
246+
247+
private func setupTapGesture() {
248+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
249+
tapGesture.cancelsTouchesInView = false
250+
view.addGestureRecognizer(tapGesture)
251+
}
252+
253+
@objc private func dismissKeyboard() {
254+
view.endEditing(true)
255+
}
245256
}

Projects/CommonUI/Derived/Sources/TuistAssets+CommonUI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public enum CommonUIAsset: Sendable {
3939
public static let lmRed02 = CommonUIColors(name: "LMRed02")
4040
}
4141
public enum Images {
42-
public static let add = CommonUIImages(name: "add")
42+
public static let add = CommonUIImages(name: "add")
4343
public static let back = CommonUIImages(name: "back")
4444
public static let bubble = CommonUIImages(name: "bubble")
4545
public static let close = CommonUIImages(name: "close")
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"filename" : "[email protected]",
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"filename" : "[email protected]",
14+
"idiom" : "universal",
15+
"scale" : "3x"
16+
}
17+
],
18+
"info" : {
19+
"author" : "xcode",
20+
"version" : 1
21+
}
22+
}
2.63 KB
Loading
3.83 KB
Loading

Projects/CommonUI/Sources/Component/LMAlert.swift

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public class LMAlert: UIView {
5757
// MARK: - Properties
5858
private var cancelAction: (() -> Void)?
5959
private var confirmAction: (() -> Void)?
60+
private var titleTopConstraint: Constraint?
61+
private var buttonTopConstraint: Constraint?
6062

6163
// MARK: - Initialization
6264
public init(title: String, cancelTitle: String = "아니요", confirmTitle: String = "") {
@@ -102,7 +104,7 @@ public class LMAlert: UIView {
102104
}
103105

104106
titleLabel.snp.makeConstraints {
105-
$0.top.equalToSuperview().inset(24)
107+
self.titleTopConstraint = $0.top.equalToSuperview().inset(24).constraint
106108
$0.horizontalEdges.equalToSuperview().inset(20)
107109
$0.bottom.lessThanOrEqualTo(buttonStackView.snp.top).offset(-16)
108110
}
@@ -111,7 +113,7 @@ public class LMAlert: UIView {
111113
$0.bottom.equalToSuperview().inset(20)
112114
$0.horizontalEdges.equalToSuperview().inset(20)
113115
$0.height.equalTo(44)
114-
$0.top.greaterThanOrEqualTo(titleLabel.snp.bottom).offset(16)
116+
self.buttonTopConstraint = $0.top.greaterThanOrEqualTo(titleLabel.snp.bottom).offset(16).constraint
115117
}
116118
}
117119

@@ -137,7 +139,10 @@ public class LMAlert: UIView {
137139
// cancelTitle이 비어있으면 취소 버튼 숨기기
138140
if cancelTitle.isEmpty {
139141
cancelButton.isHidden = true
142+
} else {
143+
cancelButton.isHidden = false
140144
}
145+
updateSpacing(for: attributedString)
141146
}
142147

143148
// MARK: - Actions
@@ -195,4 +200,40 @@ public class LMAlert: UIView {
195200
completion()
196201
}
197202
}
203+
204+
// MARK: - Layout Helpers
205+
private func updateSpacing(for attributedString: NSAttributedString) {
206+
let contentWidth: CGFloat = 280 - 40 // container width - horizontal inset
207+
let lineCount = calculateLineCount(for: attributedString, maxWidth: contentWidth)
208+
let spacing = spacingConfiguration(for: lineCount)
209+
titleTopConstraint?.update(offset: spacing.topInset)
210+
buttonTopConstraint?.update(offset: spacing.betweenSpacing)
211+
layoutIfNeeded()
212+
}
213+
214+
private func spacingConfiguration(for lineCount: Int) -> (topInset: CGFloat, betweenSpacing: CGFloat) {
215+
switch lineCount {
216+
case ..<2:
217+
return (32, 24)
218+
case 2:
219+
return (28, 20)
220+
default:
221+
return (24, 16)
222+
}
223+
}
224+
225+
private func calculateLineCount(for attributedString: NSAttributedString, maxWidth: CGFloat) -> Int {
226+
guard attributedString.length > 0 else { return 1 }
227+
let boundingRect = attributedString.boundingRect(
228+
with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude),
229+
options: [.usesLineFragmentOrigin, .usesFontLeading],
230+
context: nil
231+
)
232+
let font = (attributedString.attribute(.font, at: 0, effectiveRange: nil) as? UIFont) ?? titleLabel.font ?? .systemFont(ofSize: 16)
233+
let paragraphStyle = attributedString.attribute(.paragraphStyle, at: 0, effectiveRange: nil) as? NSParagraphStyle
234+
let lineHeight = font.lineHeight + (paragraphStyle?.lineSpacing ?? 0)
235+
if lineHeight == 0 { return 1 }
236+
let rawCount = Int(ceil(boundingRect.height / lineHeight))
237+
return max(1, rawCount)
238+
}
198239
}

Projects/CommonUI/Sources/Enum/CommonUIAssets.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public enum CommonUIAssets {
5858
public static let IconNext = image(named: "next")
5959
public static let IconNext2 = image(named: "next2")
6060
public static let IconAdd = image(named: "add")
61+
public static let IconProfile = image(named: "profile")
6162

6263
/// color
6364
public static let LMOrange0 = color(named: "LMOrange00")

Projects/CommonUI/Sources/View/Chat/ChatView.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,19 @@ open class ChatView: UIView {
156156
$0.center.equalToSuperview()
157157
$0.leading.trailing.equalToSuperview().inset(16)
158158
}
159+
160+
// 탭 이벤트 설정
161+
view.tag = index
162+
view.isUserInteractionEnabled = true
163+
let tap = UITapGestureRecognizer(target: self, action: #selector(handleRecommendTap(_:)))
164+
view.addGestureRecognizer(tap)
159165
}
160166

161167
titleLabel.snp.makeConstraints {
162168
$0.top.equalTo(self.safeAreaLayoutGuide).offset(20)
163169
$0.leading.equalToSuperview().inset(20)
164170
}
165-
171+
166172
subtitleLabel.snp.makeConstraints {
167173
$0.top.equalTo(titleLabel.snp.bottom).offset(10)
168174
$0.leading.equalToSuperview().inset(20)
@@ -213,6 +219,18 @@ open class ChatView: UIView {
213219
}
214220
}
215221

222+
@objc private func handleRecommendTap(_ gesture: UITapGestureRecognizer) {
223+
guard let view = gesture.view else { return }
224+
let index = view.tag
225+
guard index >= 0 && index < recommendLabels.count else { return }
226+
let text = recommendLabels[index].text ?? ""
227+
guard !text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { return }
228+
229+
// 추천 섹션 숨기고 바로 전송 콜백 호출
230+
hideRecommendSection()
231+
onSendButtonTapped?(text)
232+
}
233+
216234
// 추천 섹션 숨기기 메서드
217235
public func hideRecommendSection() {
218236
UIView.animate(withDuration: 0.3) {

Projects/CommonUI/Sources/View/Diary/DiaryView.swift

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,12 @@ open class DiaryView: UIView {
5656
bindEvents()
5757
calendarView.configureSubviews()
5858
calendarView.makeConstraints()
59-
setupSampleEmotionData()
6059
updateMonthButtonTitle()
6160
}
6261

6362
required public init?(coder: NSCoder) {
6463
fatalError("init(coder:) has not been implemented")
6564
}
66-
67-
private func setupSampleEmotionData() {
68-
// 샘플 이모지 데이터 설정 (이미지와 동일하게)
69-
let sampleEmotions: [Int: String] = [
70-
1: "😢", // 우는 얼굴
71-
7: "😐", // 무표정한 얼굴
72-
12: "🥳", // 파티 모자
73-
13: "😡" // 화난 얼굴
74-
]
75-
calendarView.setEmotionData(sampleEmotions)
76-
}
7765

7866
// MARK: Configuration
7967
func configureSubviews() {
@@ -108,11 +96,11 @@ open class DiaryView: UIView {
10896
$0.height.width.equalTo(monthLabel.snp.height)
10997
}
11098

111-
addButton.snp.makeConstraints {
112-
$0.centerY.equalTo(monthLabel)
113-
$0.trailing.equalToSuperview().inset(20)
114-
$0.height.width.equalTo(monthLabel.snp.height)
115-
}
99+
// addButton.snp.makeConstraints {
100+
// $0.centerY.equalTo(monthLabel)
101+
// $0.trailing.equalToSuperview().inset(20)
102+
// $0.height.width.equalTo(monthLabel.snp.height)
103+
// }
116104

117105
calendarView.snp.makeConstraints {
118106
$0.top.equalTo(monthLabel.snp.bottom).offset(17)
@@ -121,7 +109,7 @@ open class DiaryView: UIView {
121109
}
122110

123111
diaryTodayView.snp.makeConstraints {
124-
$0.top.equalTo(calendarView.snp.bottom).offset(3)
112+
$0.top.equalTo(calendarView.snp.bottom).offset(30)
125113
$0.centerX.equalToSuperview()
126114
$0.width.equalToSuperview().inset(20)
127115
$0.height.equalTo(141)

Projects/CommonUI/Sources/View/Home/HomeProgressView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ open class HomeProgressView: UIView {
126126
self.layer.cornerRadius = 12
127127

128128
courseLabel = courseLabel.then {
129-
$0.text = "한국어 훈련 1단계"
130129
$0.textColor = CommonUIAssets.LMBlack
131130
$0.font = .systemFont(ofSize: 18, weight: .semibold)
132131
}

0 commit comments

Comments
 (0)