@@ -24,6 +24,7 @@ import androidx.compose.ui.unit.dp
2424import com.texthip.thip.R
2525import com.texthip.thip.ui.common.buttons.ActionBookButton
2626import com.texthip.thip.ui.common.header.ProfileBar
27+ import com.texthip.thip.ui.myPage.mock.FeedItem
2728import com.texthip.thip.ui.theme.Red
2829import com.texthip.thip.ui.theme.ThipTheme.colors
2930import com.texthip.thip.ui.theme.ThipTheme.typography
@@ -32,18 +33,9 @@ import com.texthip.thip.ui.theme.White
3233@Composable
3334fun SavedFeedCard (
3435 modifier : Modifier = Modifier ,
35- user_name : String ,
36- user_role : String ,
37- user_profile_image : Painter ? = null,
38- book_title : String ,
39- auth_name : String ,
40- imageRes : Painter ? = null,
41- time_ago : Int ,
42- content : String ,
43- like_count : Int ,
44- comment_count : Int ,
45- is_like : Boolean ,
46- is_saved : Boolean = true,
36+ feedItem : FeedItem ,
37+ bookImage : Painter ? = null,
38+ profileImage : Painter ? = null,
4739 onBookmarkClick : () -> Unit = {},
4840 onLikeClick : () -> Unit = {}
4941) {
@@ -53,25 +45,26 @@ fun SavedFeedCard(
5345 .padding(20 .dp)
5446 ) {
5547 ProfileBar (
56- profileImage = user_profile_image ,
57- topText = user_name ,
58- bottomText = user_role ,
48+ profileImage = profileImage ,
49+ topText = feedItem.userName ,
50+ bottomText = feedItem.userRole ,
5951 showSubscriberInfo = false ,
60- hoursAgo = time_ago
52+ hoursAgo = feedItem.timeAgo
6153 )
6254 Column (
6355 modifier = Modifier
6456 .fillMaxWidth()
6557 .padding(top = 16 .dp, bottom = 16 .dp)
6658 ) {
6759 ActionBookButton (
68- bookTitle = book_title,
69- bookAuthor = auth_name,
70- onClick = {})
60+ bookTitle = feedItem.bookTitle,
61+ bookAuthor = feedItem.authName,
62+ onClick = {}
63+ )
7164 }
72- if (imageRes != null ) {
65+ if (bookImage != null ) {
7366 Image (
74- painter = imageRes ,
67+ painter = bookImage ,
7568 contentDescription = null ,
7669 modifier = Modifier
7770 .fillMaxWidth()
@@ -81,7 +74,7 @@ fun SavedFeedCard(
8174 }
8275
8376 Text (
84- text = content,
77+ text = feedItem. content,
8578 style = typography.feedcopy_r400_s14_h20,
8679 color = White ,
8780 modifier = Modifier
@@ -95,10 +88,10 @@ fun SavedFeedCard(
9588 modifier = Modifier .clickable { onLikeClick() },
9689 painter = painterResource(R .drawable.ic_heart),
9790 contentDescription = null ,
98- tint = if (is_like ) Red else colors.White
91+ tint = if (feedItem.isLiked ) Red else colors.White
9992 )
10093 Text (
101- text = like_count .toString(),
94+ text = feedItem.likeCount .toString(),
10295 style = typography.feedcopy_r400_s14_h20,
10396 color = White ,
10497 modifier = Modifier .padding(start = 5 .dp, end = 12 .dp)
@@ -109,15 +102,15 @@ fun SavedFeedCard(
109102 tint = colors.White
110103 )
111104 Text (
112- text = comment_count .toString(),
105+ text = feedItem.commentCount .toString(),
113106 style = typography.feedcopy_r400_s14_h20,
114107 color = White ,
115108 modifier = Modifier .padding(start = 5 .dp, end = 12 .dp)
116109 )
117110 Spacer (modifier = Modifier .weight(1f ))
118111 Icon (
119112 modifier = Modifier .clickable { onBookmarkClick() },
120- painter = painterResource(if (is_saved ) R .drawable.ic_save_filled else R .drawable.ic_save),
113+ painter = painterResource(if (feedItem.isSaved ) R .drawable.ic_save_filled else R .drawable.ic_save),
121114 contentDescription = null ,
122115 tint = colors.White
123116 )
@@ -129,32 +122,50 @@ fun SavedFeedCard(
129122@Preview
130123@Composable
131124private fun SavedFeedCardPrev () {
125+ val feed1 = FeedItem (
126+ id = 1 ,
127+ userProfileImage = R .drawable.character_literature,
128+ userName = " user.01" ,
129+ userRole = stringResource(R .string.influencer),
130+ bookTitle = " 책 제목" ,
131+ authName = " 한강" ,
132+ timeAgo = 3 ,
133+ content = " 무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷" ,
134+ likeCount = 10 ,
135+ commentCount = 5 ,
136+ isLiked = false ,
137+ isSaved = true ,
138+ imageUrl = null
139+ )
140+
141+ val feed2 = FeedItem (
142+ id = 2 ,
143+ userProfileImage = R .drawable.character_art,
144+ userName = " user.01" ,
145+ userRole = stringResource(R .string.influencer),
146+ bookTitle = " 책 제목" ,
147+ authName = " 한강" ,
148+ timeAgo = 3 ,
149+ content = " 한줄만 입력 가능" ,
150+ likeCount = 10 ,
151+ commentCount = 5 ,
152+ isLiked = false ,
153+ isSaved = true ,
154+ imageUrl = R .drawable.bookcover_sample
155+ )
156+
132157 Column {
133158 SavedFeedCard (
134- user_name = " user.01" ,
135- user_role = stringResource(R .string.influencer),
136- book_title = " 책 제목" ,
137- auth_name = " 한강" ,
138- time_ago = 3 ,
139- content = " 무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷무한대로입력가능합니닷" ,
140- like_count = 10 ,
141- comment_count = 5 ,
142- is_like = false ,
143- user_profile_image = R .drawable.character_literature.let { painterResource(it) }
159+ feedItem = feed1,
160+ profileImage = painterResource(feed1.userProfileImage!! ),
161+ bookImage = null
144162 )
145163 SavedFeedCard (
146- user_name = " user.01" ,
147- user_role = stringResource(R .string.influencer),
148- book_title = " 책 제목" ,
149- auth_name = " 한강" ,
150- time_ago = 3 ,
151- content = " 한줄만 입력 가능" ,
152- like_count = 10 ,
153- comment_count = 5 ,
154- is_like = false ,
155- imageRes = R .drawable.bookcover_sample.let { painterResource(it) },
156- user_profile_image = R .drawable.character_art.let { painterResource(it) }
164+ feedItem = feed2,
165+ profileImage = painterResource(feed2.userProfileImage!! ),
166+ bookImage = painterResource(feed2.imageUrl!! )
157167 )
158168 }
159169
170+
160171}
0 commit comments