diff --git a/data/src/main/java/com/whyranoid/data/model/post/PostResponse.kt b/data/src/main/java/com/whyranoid/data/model/post/PostResponse.kt index 9bc5d9c2..a911cae3 100644 --- a/data/src/main/java/com/whyranoid/data/model/post/PostResponse.kt +++ b/data/src/main/java/com/whyranoid/data/model/post/PostResponse.kt @@ -22,9 +22,9 @@ data class PostResponse( val destructedHistoryContent = historyContent.split('_') println(destructedHistoryContent) return PostPreview( - poster = poster.toUser(), + author = poster.toUser(), id = this.poster.uid, - liked = this.liked, + isLiked = this.liked, likers = this.likers.map { it.toUser() }, imageUrl = this.photo, date = dateFormatter.parse(this.date.replace("T", " ")).time, diff --git a/domain/src/main/java/com/whyranoid/domain/model/post/PostPreview.kt b/domain/src/main/java/com/whyranoid/domain/model/post/PostPreview.kt index 826d4a24..6d07116a 100644 --- a/domain/src/main/java/com/whyranoid/domain/model/post/PostPreview.kt +++ b/domain/src/main/java/com/whyranoid/domain/model/post/PostPreview.kt @@ -3,9 +3,9 @@ package com.whyranoid.domain.model.post import com.whyranoid.domain.model.user.User data class PostPreview( - val poster: User, + val author: User, val id: Long, - val liked: Boolean = false, + val isLiked: Boolean = false, val likers: List = listOf(), val imageUrl: String, val date: Long = 0L, @@ -18,27 +18,27 @@ data class PostPreview( companion object { val DUMMY_LIST = listOf( PostPreview( - poster = User.DUMMY, + author = User.DUMMY, id = 0L, imageUrl = "https://picsum.photos/250/250", ), PostPreview( - poster = User.DUMMY, + author = User.DUMMY, id = 1L, imageUrl = "https://picsum.photos/250/250", ), PostPreview( - poster = User.DUMMY, + author = User.DUMMY, id = 2L, imageUrl = "https://picsum.photos/250/250", ), PostPreview( - poster = User.DUMMY, + author = User.DUMMY, id = 3L, imageUrl = "https://picsum.photos/250/250", ), PostPreview( - poster = User.DUMMY, + author = User.DUMMY, id = 4L, imageUrl = "https://picsum.photos/250/250", ), diff --git a/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/MyPageScreen.kt b/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/MyPageScreen.kt index 410e656d..4ff9d0d0 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/MyPageScreen.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/MyPageScreen.kt @@ -130,25 +130,19 @@ fun MyPageContent( val scrollState = rememberScrollState() Column( - modifier = Modifier - .padding(paddingValues) - .padding(top = 28.dp) + modifier = Modifier.padding(paddingValues).padding(top = 28.dp) .verticalScroll(scrollState), ) { state.userDetailState.getDataOrNull()?.let { userDetail -> Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 20.dp), + modifier = Modifier.fillMaxWidth().padding(horizontal = 20.dp), horizontalArrangement = Arrangement.Start, verticalAlignment = Alignment.CenterVertically, ) { AsyncImage( model = userDetail.user.imageUrl, contentDescription = "유저 프로필 이미지", - modifier = Modifier - .clip(shape = CircleShape) - .size(70.dp), + modifier = Modifier.clip(shape = CircleShape).size(70.dp), ) Spacer(modifier = Modifier.width(20.dp)) @@ -183,18 +177,14 @@ fun MyPageContent( state.userBadgesState.getDataOrNull()?.let { userBadges -> LazyRow( - modifier = Modifier - .fillMaxWidth() - .padding(start = 20.dp), + modifier = Modifier.fillMaxWidth().padding(start = 20.dp), ) { items(userBadges.size) { index -> AsyncImage( model = userBadges[index].imageUrl, contentDescription = "badge image", - modifier = Modifier - .padding(vertical = 8.dp) - .clip(RoundedCornerShape(8.dp)) - .size(56.dp), + modifier = Modifier.padding(vertical = 8.dp) + .clip(RoundedCornerShape(8.dp)).size(56.dp), ) Spacer(modifier = Modifier.width(16.dp)) } @@ -268,6 +258,7 @@ fun MyPageContent( } } } + 2 -> ChallengePage() } } diff --git a/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/tabs/PostPage.kt b/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/tabs/PostPage.kt index 6ae2ae8d..010dcce0 100644 --- a/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/tabs/PostPage.kt +++ b/presentation/src/main/java/com/whyranoid/presentation/screens/mypage/tabs/PostPage.kt @@ -15,21 +15,27 @@ import androidx.compose.material.icons.filled.Add import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import coil.compose.AsyncImage import com.whyranoid.domain.model.post.PostPreview import com.whyranoid.domain.model.post.TextVisibleState import com.whyranoid.domain.model.user.User import com.whyranoid.presentation.reusable.NonLazyGrid import com.whyranoid.presentation.theme.WalkieColor -import com.whyranoid.presentation.theme.WalkieTypography import java.text.SimpleDateFormat import java.util.* @@ -83,8 +89,17 @@ fun PostImagePreview( postPreview: PostPreview, onPostPreviewClicked: (id: Long) -> Unit = {}, ) { - // TODO modifier 크기 맞춰서 글자 크기 수정 - Box(modifier = modifier) { + var dynamicFontSize by remember { mutableStateOf(0.sp) } + var dynamicPaddingSize by remember { mutableStateOf(0.dp) } + + Box( + modifier = modifier.onGloballyPositioned { + val parentSize = it.size + dynamicFontSize = (parentSize.width / 60f).sp + dynamicPaddingSize = (parentSize.width / 50f).dp + it.providedAlignmentLines + }, + ) { AsyncImage( model = User.DUMMY.imageUrl, // TODO REMOVE postPreview.imageUrl, contentDescription = "postPreview Image", @@ -99,35 +114,37 @@ fun PostImagePreview( ) if (postPreview.textVisibleState != TextVisibleState.HIDE) { - val textColor = + val selectedTextColor = if (postPreview.textVisibleState == TextVisibleState.WHITE) Color.White else Color.Black Text( text = SimpleDateFormat("yyyy.MM.dd HH:mm").format(Date(postPreview.date)), modifier = Modifier - .padding(top = 12.dp) + .padding(top = dynamicPaddingSize) .align(Alignment.TopCenter), - style = WalkieTypography.Body2.copy(color = textColor), + color = selectedTextColor, + fontSize = dynamicFontSize, ) Row( modifier = Modifier - .padding(horizontal = 20.dp) .fillMaxWidth() .align(Alignment.BottomCenter) - .padding(bottom = 12.dp) - .padding(horizontal = 20.dp), - horizontalArrangement = Arrangement.SpaceBetween, + .padding(bottom = dynamicPaddingSize), + horizontalArrangement = Arrangement.SpaceAround, ) { listOf( "DISTANCE\n${postPreview.distanceText}", "TIME\n${postPreview.timeText}", - "PACE\n${postPreview.paceText}", + "PACE\n ${postPreview.paceText}", ).forEach { Text( - it, - style = WalkieTypography.Title.copy(color = textColor), + text = it, + color = selectedTextColor, + fontSize = dynamicFontSize, + lineHeight = dynamicFontSize, textAlign = TextAlign.Center, + fontWeight = FontWeight.Bold, ) } }