11package com.ninecraft.booket.feature.detail.book.component
22
3+ import androidx.compose.foundation.border
4+ import androidx.compose.foundation.layout.BoxWithConstraints
35import androidx.compose.foundation.layout.Column
46import androidx.compose.foundation.layout.Row
57import androidx.compose.foundation.layout.Spacer
68import androidx.compose.foundation.layout.fillMaxWidth
79import androidx.compose.foundation.layout.height
810import androidx.compose.foundation.layout.padding
911import androidx.compose.foundation.layout.width
12+ import androidx.compose.foundation.layout.widthIn
1013import androidx.compose.foundation.shape.RoundedCornerShape
1114import androidx.compose.material3.Text
1215import androidx.compose.material3.VerticalDivider
@@ -18,6 +21,7 @@ import androidx.compose.ui.res.painterResource
1821import androidx.compose.ui.text.style.TextOverflow
1922import androidx.compose.ui.unit.dp
2023import com.ninecraft.booket.core.common.extensions.formatPublishYear
24+ import com.ninecraft.booket.core.designsystem.ComponentPreview
2125import com.ninecraft.booket.core.designsystem.component.NetworkImage
2226import com.ninecraft.booket.core.designsystem.theme.ReedTheme
2327import com.ninecraft.booket.core.model.BookDetailModel
@@ -41,7 +45,12 @@ internal fun BookItem(
4145 .padding(end = ReedTheme .spacing.spacing4)
4246 .width(70 .dp)
4347 .height(99 .dp)
44- .clip(RoundedCornerShape (size = ReedTheme .radius.xs)),
48+ .clip(RoundedCornerShape (size = ReedTheme .radius.xs))
49+ .border(
50+ width = 1 .dp,
51+ color = ReedTheme .colors.borderPrimary,
52+ shape = RoundedCornerShape (ReedTheme .radius.xs),
53+ ),
4554 placeholder = painterResource(designR.drawable.ic_placeholder),
4655 )
4756 Column (modifier = Modifier .weight(1f )) {
@@ -53,35 +62,38 @@ internal fun BookItem(
5362 style = ReedTheme .typography.headline1SemiBold,
5463 )
5564 Spacer (modifier = Modifier .height(ReedTheme .spacing.spacing2))
56- Row (
57- modifier = Modifier .fillMaxWidth(),
58- verticalAlignment = Alignment .CenterVertically ,
59- ) {
60- Text (
61- text = bookDetail.author,
62- color = ReedTheme .colors.contentTertiary,
63- overflow = TextOverflow .Ellipsis ,
64- maxLines = 1 ,
65- style = ReedTheme .typography.label2Regular,
66- modifier = Modifier .weight(0.7f , fill = false ),
67- )
68- Spacer (Modifier .width(ReedTheme .spacing.spacing1))
69- VerticalDivider (
70- modifier = Modifier .height(14 .dp),
71- thickness = 1 .dp,
72- color = ReedTheme .colors.contentTertiary,
73- )
74- Spacer (Modifier .width(ReedTheme .spacing.spacing1))
75- Text (
76- text = bookDetail.publisher,
77- color = ReedTheme .colors.contentTertiary,
78- overflow = TextOverflow .Ellipsis ,
79- maxLines = 1 ,
80- style = ReedTheme .typography.label2Regular,
81- modifier = Modifier .weight(0.3f , fill = false ),
82- )
65+ BoxWithConstraints {
66+ val authorMaxWidth = maxWidth * 0.7f
67+
68+ Row (
69+ modifier = Modifier .fillMaxWidth(),
70+ verticalAlignment = Alignment .CenterVertically ,
71+ ) {
72+ Text (
73+ text = bookDetail.author,
74+ color = ReedTheme .colors.contentTertiary,
75+ overflow = TextOverflow .Ellipsis ,
76+ maxLines = 1 ,
77+ style = ReedTheme .typography.label2Regular,
78+ modifier = Modifier .widthIn(max = authorMaxWidth),
79+ )
80+ Spacer (Modifier .width(ReedTheme .spacing.spacing1))
81+ VerticalDivider (
82+ modifier = Modifier .height(14 .dp),
83+ thickness = 1 .dp,
84+ color = ReedTheme .colors.contentTertiary,
85+ )
86+ Spacer (Modifier .width(ReedTheme .spacing.spacing1))
87+ Text (
88+ text = bookDetail.publisher,
89+ color = ReedTheme .colors.contentTertiary,
90+ overflow = TextOverflow .Ellipsis ,
91+ maxLines = 1 ,
92+ style = ReedTheme .typography.label2Regular,
93+ modifier = Modifier .weight(1f , fill = false ),
94+ )
95+ }
8396 }
84- Spacer (Modifier .width(ReedTheme .spacing.spacing05))
8597 Text (
8698 text = bookDetail.pubDate.formatPublishYear(),
8799 color = ReedTheme .colors.contentTertiary,
@@ -92,3 +104,19 @@ internal fun BookItem(
92104 }
93105 }
94106}
107+
108+ @ComponentPreview
109+ @Composable
110+ private fun BookItemPreview () {
111+ ReedTheme {
112+ BookItem (
113+ bookDetail = BookDetailModel (
114+ title = " 데미안" ,
115+ author = " 헤르만 헤세" ,
116+ publisher = " 민음사" ,
117+ pubDate = " 2023-01-01" ,
118+ coverImageUrl = " "
119+ )
120+ )
121+ }
122+ }
0 commit comments