@@ -17,64 +17,66 @@ struct CertificateCommentView: View {
1717 var body : some View {
1818 VStack ( alignment: . center, spacing: 0 ) {
1919 ScrollView ( . vertical) {
20- HStack ( alignment: . center, spacing: 0 ) {
21- CommentSortButton ( isSelectedPopularity: isSelectedPopularity) {
22- isSelectedPopularity. toggle ( )
23- Task {
24- await viewModel. refreshComments ( certificationId: certificationId)
20+ VStack ( alignment: . center, spacing: 0 ) {
21+ HStack ( alignment: . center, spacing: 0 ) {
22+ CommentSortButton ( isSelectedPopularity: isSelectedPopularity) {
23+ isSelectedPopularity. toggle ( )
24+ Task {
25+ await viewModel. refreshComments ( certificationId: certificationId)
26+ }
2527 }
28+ . padding ( . leading, 20 )
29+
30+ Spacer ( )
31+
32+ Text ( " 댓글 ( \( totalCommentCount) ) " )
33+ . applyCertiFont ( . caption_regular_14)
34+ . foregroundStyle ( . grayscale400)
35+ . padding ( . trailing, 20 )
2636 }
27- . padding ( . leading , 20 )
37+ . padding ( . top , 36 )
2838
29- Spacer ( )
30-
31- Text ( " 댓글 ( \( totalCommentCount) ) " )
32- . applyCertiFont ( . caption_regular_14)
33- . foregroundStyle ( . grayscale400)
34- . padding ( . trailing, 20 )
35- }
36- . padding ( . bottom, 12 )
37- . padding ( . top, 36 )
38-
39- LazyVStack ( spacing: 0 ) {
40- if viewModel. comments. isEmpty {
41- VStack ( alignment: . center, spacing: 0 ) {
42- Image ( . imageEmpty)
43- . padding ( . top, 134 )
44-
45- Text ( " 아직 댓글이 없습니다. \n 가장 먼저 댓글을 작성해보세요. " )
46- . multilineTextAlignment ( . center)
47- . applyCertiFont ( . caption_regular_14)
48- . foregroundStyle ( . grayscale400)
49- . frame ( height: 40 )
39+ LazyVStack ( spacing: 0 ) {
40+ if viewModel. comments. isEmpty {
41+ VStack ( alignment: . center, spacing: 0 ) {
42+ Image ( . imageEmpty)
43+ . padding ( . top, 134 )
44+
45+ Text ( " 아직 댓글이 없습니다. \n 가장 먼저 댓글을 작성해보세요. " )
46+ . multilineTextAlignment ( . center)
47+ . applyCertiFont ( . caption_regular_14)
48+ . foregroundStyle ( . grayscale400)
49+ . frame ( height: 40 )
50+ . padding ( . top, 20 )
51+ }
52+ . frame ( maxWidth: . infinity)
53+ } else {
54+ ForEach ( viewModel. comments) { comment in
55+ CommentComponent (
56+ model: comment,
57+ certificationState: comment. state == " 취득 완료 " ? . completed : . expected,
58+ userName: comment. nickName == nil ? . unknown : . normal( userName: comment. nickName!) ,
59+ canDelete: comment. userId == viewModel. currentUserId,
60+ onTapLike: {
61+ Task {
62+ await viewModel. toggleLike ( commentId: comment. commentId)
63+ }
64+ } , onTapDelete: {
65+ viewModel. showDeleteCommentModal ( commentId: comment. commentId)
66+ } , onTapReport: {
67+ viewModel. showCommentReportModal ( commentId: comment. commentId)
68+ }
69+ )
5070 . padding ( . top, 20 )
51- }
52- . frame ( maxWidth: . infinity)
53- } else {
54- ForEach ( viewModel. comments) { comment in
55- CommentComponent (
56- model: comment,
57- certificationState: comment. state == " 취득 완료 " ? . completed : . expected,
58- userName: comment. nickName == nil ? . unknown : . normal( userName: comment. nickName!) ,
59- canDelete: comment. userId == viewModel. currentUserId,
60- onTapLike: {
61- Task {
62- await viewModel. toggleLike ( commentId: comment. commentId)
71+ . padding ( . horizontal, 20 )
72+ }
73+ if !viewModel. isLastPage {
74+ ProgressView ( )
75+ . padding ( . vertical, 16 )
76+ . task {
77+ await viewModel. fetchComment ( certificationId: certificationId)
6378 }
64- } , onTapDelete: {
65- viewModel. showDeleteCommentModal ( commentId: comment. commentId)
66- } , onTapReport: {
67- viewModel. showCommentReportModal ( commentId: comment. commentId)
68- }
69- )
70- . padding ( . horizontal, 20 )
71- }
72- if !viewModel. isLastPage {
73- ProgressView ( )
74- . padding ( . vertical, 16 )
75- . task {
76- await viewModel. fetchComment ( certificationId: certificationId)
77- }
79+ }
7880 }
7981 }
8082 }
0 commit comments