-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
180 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
core/designsystem/src/main/java/com/withpeace/withpeace/core/designsystem/ui/Card.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
core/ui/src/main/java/com/withpeace/withpeace/core/ui/LocalDateTimeUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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일" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters