-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/#57-게시글 목록 조회 UI를 구현한다 #60
The head ref may contain hidden characters: "Feat/57-\uAC8C\uC2DC\uAE00_\uBAA9\uB85D_\uC870\uD68C_ui\uB97C_\uAD6C\uD604\uD55C\uB2E4"
Changes from 1 commit
b4868ff
27c6192
038eb3c
16fadaa
10a6e5f
d7c8136
a09216d
5f024c0
f206048
0454238
1e7f6a7
92d3e28
700f690
7929d99
b969197
4a19142
6b02cfe
29611b1
419f456
94865c7
5940514
2153afc
022192c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.withpeace.withpeace.core.designsystem.ui | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.CardDefaults | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme | ||
|
||
@Composable | ||
fun WithpeaceCard( | ||
modifier: Modifier = Modifier, | ||
content: @Composable () -> Unit, | ||
) { | ||
Card( | ||
modifier = modifier, | ||
shape = RoundedCornerShape(5.dp), | ||
border = BorderStroke(width = 1.dp, color = WithpeaceTheme.colors.SystemGray2), | ||
colors = CardDefaults.cardColors( | ||
containerColor = WithpeaceTheme.colors.SystemWhite, | ||
), | ||
) { | ||
content() | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
private fun WithpeaceCardPreview() { | ||
WithpeaceTheme { | ||
WithpeaceCard { | ||
Text("haha") | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.withpeace.withpeace.core.ui | ||
|
||
import android.content.Context | ||
import java.time.Duration | ||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
fun LocalDateTime.toRelativeString(context: Context): String { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 코드는 View에서만 사용되는게 맞을까요?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 단위를 구분하는건 domain이고 글자를 표시하는 건 view라고 생각합니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 어디에 위치해야 할지 조금 애매했는데요, isLessThanOneDay 같은 함수들을 Post 도메인 로직으로 옮기는게 좋아보일까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. domain 사용성을 위해서 옮기는 것도 좋아보입니다! Date 관련 도메인 로직이 될 것 같은데 어떠신가요?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PostDate라는 도메인 모델에 적용하고, Post객체가 PostDate를 사용하게끔 하면 될 것 같습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋습니다! 👍 🥇 💯 |
||
val currentTime = LocalDateTime.now() | ||
val duration = Duration.between(this, currentTime) | ||
return when { | ||
duration.isLessThanOneMinute() -> context.getString( | ||
R.string.second_format, | ||
duration.seconds, | ||
) | ||
|
||
duration.isLessThanOneHour() -> context.getString( | ||
R.string.minute_format, | ||
duration.toMinutes(), | ||
) | ||
|
||
duration.isLessThanOneDay() -> context.getString( | ||
R.string.hour_format, | ||
duration.toHours(), | ||
) | ||
|
||
duration.isLessThanSevenDays() -> context.getString(R.string.day_format, duration.toDays()) | ||
else -> format(DateTimeFormatter.ofPattern(DATE_FORMAT)) | ||
} | ||
} | ||
|
||
private fun Duration.isLessThanOneMinute() = toMinutes() < 1 | ||
private fun Duration.isLessThanOneHour() = toHours() < 1 | ||
private fun Duration.isLessThanOneDay() = toDays() < 1 | ||
private fun Duration.isLessThanSevenDays() = toDays() < 7 | ||
|
||
private const val DATE_FORMAT = "MM월 DD일" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어디에 쓰이는 카드인가요?!
캡쳐 해주시면 감사합니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
게시글 내용을 감싸는 테두리 라고 생각하시면 될 것 같습니다! 보통 저 테두리는 공통으로 쓰이기 때문에 designSystem으로 빼놨습니다