Skip to content

Commit

Permalink
♻️ PostPreview.kt 변수 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
yonghanJu committed Nov 22, 2023
1 parent 41f7aef commit fdc0265
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<User> = listOf(),
val imageUrl: String,
val date: Long = 0L,
Expand All @@ -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",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -268,6 +258,7 @@ fun MyPageContent(
}
}
}

2 -> ChallengePage()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*

Expand Down Expand Up @@ -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",
Expand All @@ -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,
)
}
}
Expand Down

0 comments on commit fdc0265

Please sign in to comment.