Skip to content

Commit 99c83ba

Browse files
authored
Feat: notification cell 내용이 자연스럽게 줄바꿈 되도록 수정 (#95)
1 parent 271ce42 commit 99c83ba

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

Wastory/Wastory/View/NotificationView/NotificationCell.swift

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,8 @@ struct NotificationCell: View {
3333
.padding(.top, 5)
3434

3535
VStack(alignment: .leading, spacing: 0) {
36-
HStack(spacing: 0) {
37-
Text(notification.username.prefix(7) + ((notification.username.count > 7) ? "..." : ""))
38-
.font(.system(size: 15, weight: .semibold))
39-
40-
switch notification.type {
41-
case 1:
42-
Text("님이 새 글을 발행했습니다.")
43-
.font(.system(size: 15, weight: .light))
44-
case 2:
45-
Text("님이 내 블로그를 구독합니다.")
46-
.font(.system(size: 15, weight: .light))
47-
case 3:
48-
HStack(spacing: 0) {
49-
Text("님이 ")
50-
.font(.system(size: 15, weight: .light))
51-
Text((notification.postTitle ?? "").prefix(7) + ((notification.postTitle ?? "").count > 7 ? "..." : ""))
52-
.font(.system(size: 15, weight: .semibold))
53-
Text("에 댓글을 남겼습니다.")
54-
.font(.system(size: 15, weight: .light))
55-
}
56-
case 4:
57-
Text("님이 방명록을 남겼습니다.")
58-
.font(.system(size: 15, weight: .light))
59-
case 5:
60-
Text("님이 쪽지를 보냈습니다.")
61-
.font(.system(size: 15, weight: .light))
62-
default:
63-
Text("")
64-
}
65-
}
66-
.padding(.bottom, 8)
36+
notificationText
37+
.padding(.bottom, 8)
6738

6839
switch notification.type {
6940
case 1:
@@ -130,5 +101,37 @@ struct NotificationCell: View {
130101
viewModel.toggleIsAlertPresent()
131102
}
132103
}
104+
105+
private var notificationText: Text {
106+
let usernameText = Text(notification.username.prefix(7) + ((notification.username.count > 7) ? "..." : ""))
107+
.font(.system(size: 15, weight: .semibold))
108+
109+
let contentText: Text
110+
switch notification.type {
111+
case 1:
112+
contentText = Text("님이 새 글을 발행했습니다.")
113+
.font(.system(size: 15, weight: .light))
114+
case 2:
115+
contentText = Text("님이 내 블로그를 구독합니다.")
116+
.font(.system(size: 15, weight: .light))
117+
case 3:
118+
contentText = Text("님이 ")
119+
.font(.system(size: 15, weight: .light)) +
120+
Text((notification.postTitle ?? "").prefix(7) + ((notification.postTitle ?? "").count > 7 ? "..." : ""))
121+
.font(.system(size: 15, weight: .semibold)) +
122+
Text("에 댓글을 남겼습니다.")
123+
.font(.system(size: 15, weight: .light))
124+
case 4:
125+
contentText = Text("님이 방명록을 남겼습니다.")
126+
.font(.system(size: 15, weight: .light))
127+
case 5:
128+
contentText = Text("님이 쪽지를 보냈습니다.")
129+
.font(.system(size: 15, weight: .light))
130+
default:
131+
contentText = Text("")
132+
}
133+
134+
return usernameText + contentText
135+
}
133136
}
134137

0 commit comments

Comments
 (0)