-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#12 home 구현 #16
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
The head ref may contain hidden characters: "feat/#12-Home_\uAD6C\uD604"
Feat/#12 home 구현 #16
Changes from 22 commits
b87c36b
6a34e47
2dcad66
43baec1
4ac3e3f
5a9e312
d27a66a
db8a3ad
9529884
c87143b
1c770b5
b4b77dc
8da9be0
066fb81
27279e4
dca3714
34d2043
d5f62d0
51e9702
b528a68
a57ea2e
3c6ea4b
9934d47
8d955ce
b0db42c
c8f9d56
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,7 @@ | ||
| package com.alarmy.near.model | ||
|
|
||
| enum class ContactFrequency { | ||
| LOW, | ||
| MIDDLE, | ||
| HIGH, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.alarmy.near.model | ||
|
|
||
| import androidx.compose.runtime.Immutable | ||
| import java.time.LocalDate | ||
| import java.time.format.DateTimeFormatter | ||
|
|
||
| @Immutable | ||
| data class ContactSummary( | ||
| val id: String, | ||
| val name: String, | ||
| val profileImageUrl: String, | ||
| val lastContactedAt: LocalDate, | ||
| val isContacted: Boolean, | ||
| val contactFrequency: ContactFrequency, | ||
| ) { | ||
| val formattedDate: String | ||
| get() { | ||
| val formatter = DateTimeFormatter.ofPattern("yy.MM.dd") | ||
| val formattedDate = lastContactedAt.format(formatter) | ||
| return formattedDate | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.alarmy.near.model | ||
|
|
||
| import java.time.LocalDate | ||
| import java.time.format.DateTimeFormatter | ||
| import java.time.temporal.ChronoUnit | ||
|
|
||
| data class MonthlyContact( | ||
| val friendId: String, | ||
| val name: String, | ||
| val type: String, | ||
| val nextContactAt: String, | ||
| ) { | ||
| val dDay: String | ||
| get() { | ||
| val daysBetween = getDaysBetween() | ||
| return when { | ||
| daysBetween == 0L -> "D-day" | ||
| daysBetween > 0L -> "D-$daysBetween" | ||
| else -> "D+${-daysBetween}" // 과거 날짜 | ||
| } | ||
| } | ||
|
|
||
| val isDDay: Boolean | ||
| get() = getDaysBetween() == 0L | ||
|
||
|
|
||
| private fun getDaysBetween(): Long { | ||
| val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") | ||
| val targetDate = LocalDate.parse(nextContactAt, formatter) | ||
| val today = LocalDate.now() | ||
| return ChronoUnit.DAYS.between(today, targetDate) | ||
| } | ||
|
||
| } | ||
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.
Creating
DateTimeFormatteron every property access is inefficient. It's better to create it once and reuse it. You can define it as a top-level private constant in this file, outside the class.