-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#17 home api 연동 #20
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
Merged
The head ref may contain hidden characters: "feat/#17-home_api_\uC5F0\uB3D9"
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9d4645d
feat: monthlyFriends fetch 로직 추가
rhkrwngud445 42ea159
feat: friend list data - ui 연동
rhkrwngud445 a84995c
feat: monthly friend api-ui 연동
rhkrwngud445 b8c06ca
feat: dropdown 추가
rhkrwngud445 550230e
refactor: Companion 네이밍 제거
rhkrwngud445 dd5f401
feat: home 에러 핸들링 추가
rhkrwngud445 eb8a39e
fix: navigation 인자 전달 로직 수정
rhkrwngud445 aef7ab2
refactor: API 엔드포인트 수정
rhkrwngud445 b2ec675
chore: 로그 제거
rhkrwngud445 6028ad9
refactor: 챙김 타입 매핑 로직 수정
rhkrwngud445 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
27 changes: 16 additions & 11 deletions
27
Near/app/src/main/java/com/alarmy/near/data/mapper/FriendMapper.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,16 +1,21 @@ | ||
| package com.alarmy.near.data.mapper | ||
|
|
||
| import com.alarmy.near.model.Friend | ||
| import com.alarmy.near.model.ContactFrequency | ||
| import com.alarmy.near.model.FriendSummary | ||
| import com.alarmy.near.network.response.FriendEntity | ||
|
|
||
| fun FriendEntity.toModel(): Friend = | ||
| Friend( | ||
| friendId = friendId, | ||
| position = position, | ||
| source = source, | ||
| fun FriendEntity.toModel(): FriendSummary = | ||
| FriendSummary( | ||
| id = friendId, | ||
| name = name, | ||
| imageUrl = imageUrl, | ||
| fileName = fileName, | ||
| checkRate = checkRate, | ||
| lastContactAt = lastContactAt, | ||
| ) | ||
| profileImageUrl = imageUrl, | ||
| lastContactedAt = lastContactAt, | ||
| isContacted = true, | ||
| contactFrequency = | ||
| when (checkRate) { | ||
| in 0..29 -> ContactFrequency.LOW | ||
| in 30..69 -> ContactFrequency.MIDDLE | ||
| in 70..100 -> ContactFrequency.HIGH | ||
| else -> ContactFrequency.LOW | ||
| }, | ||
| ) | ||
13 changes: 13 additions & 0 deletions
13
Near/app/src/main/java/com/alarmy/near/data/mapper/MonthlyFriendMapper.kt
This file contains hidden or 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,13 @@ | ||
| package com.alarmy.near.data.mapper | ||
|
|
||
| import com.alarmy.near.model.monthly.MonthlyFriend | ||
| import com.alarmy.near.model.monthly.MonthlyFriendType | ||
| import com.alarmy.near.network.response.MonthlyFriendEntity | ||
|
|
||
| fun MonthlyFriendEntity.toModel(): MonthlyFriend = | ||
| MonthlyFriend( | ||
| friendId = friendId, | ||
| name = name, | ||
| type = MonthlyFriendType.from(type), | ||
| nextContactAt = nextContactAt, | ||
| ) |
This file contains hidden or 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
7 changes: 5 additions & 2 deletions
7
Near/app/src/main/java/com/alarmy/near/data/repository/FriendRepository.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| package com.alarmy.near.data.repository | ||
|
|
||
| import com.alarmy.near.model.Friend | ||
| import com.alarmy.near.model.FriendSummary | ||
| import com.alarmy.near.model.monthly.MonthlyFriend | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| interface FriendRepository { | ||
| fun fetchFriends(): Flow<List<Friend>> | ||
| fun fetchFriends(): Flow<List<FriendSummary>> | ||
|
|
||
| fun fetchMonthlyFriends(): Flow<List<MonthlyFriend>> | ||
| } |
22 changes: 0 additions & 22 deletions
22
Near/app/src/main/java/com/alarmy/near/model/ContactSummary.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
Near/app/src/main/java/com/alarmy/near/model/FriendSummary.kt
This file contains hidden or 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,13 @@ | ||
| package com.alarmy.near.model | ||
|
|
||
| import androidx.compose.runtime.Immutable | ||
|
|
||
| @Immutable | ||
| data class FriendSummary( | ||
| val id: String, | ||
| val name: String, | ||
| val profileImageUrl: String?, | ||
| val lastContactedAt: String?, | ||
| val isContacted: Boolean, | ||
| val contactFrequency: ContactFrequency, | ||
| ) |
6 changes: 3 additions & 3 deletions
6
...a/com/alarmy/near/model/MonthlyContact.kt → ...larmy/near/model/monthly/MonthlyFriend.kt
This file contains hidden or 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
22 changes: 22 additions & 0 deletions
22
Near/app/src/main/java/com/alarmy/near/model/monthly/MonthlyFriendType.kt
This file contains hidden or 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,22 @@ | ||
| package com.alarmy.near.model.monthly | ||
|
|
||
| import androidx.annotation.DrawableRes | ||
| import com.alarmy.near.R | ||
|
|
||
| enum class MonthlyFriendType( | ||
| @param:DrawableRes val imageSrc: Int, | ||
| ) { | ||
| ANNIVERSARY(R.drawable.icon_visual_24_heart), | ||
| BIRTHDAY(R.drawable.icon_visual_cake), | ||
| MESSAGE(R.drawable.icon_visual_mail), | ||
| ; | ||
|
|
||
| companion object { | ||
| private const val ERROR_MESSAGE_NOT_FOUND_MONTHLY_TYPE = "일치하는 타입이 없습니다" | ||
|
|
||
| fun from(value: String): MonthlyFriendType = | ||
| runCatching { valueOf(value.uppercase()) }.getOrNull() ?: throw IllegalStateException( | ||
| ERROR_MESSAGE_NOT_FOUND_MONTHLY_TYPE, | ||
| ) | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
Near/app/src/main/java/com/alarmy/near/network/response/MonthlyFriendEntity.kt
This file contains hidden or 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,11 @@ | ||
| package com.alarmy.near.network.response | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class MonthlyFriendEntity( | ||
| val friendId: String, | ||
| val name: String, | ||
| val type: String, | ||
| val nextContactAt: String, | ||
| ) |
4 changes: 4 additions & 0 deletions
4
Near/app/src/main/java/com/alarmy/near/network/service/FriendService.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| package com.alarmy.near.network.service | ||
|
|
||
| import com.alarmy.near.network.response.FriendEntity | ||
| import com.alarmy.near.network.response.MonthlyFriendEntity | ||
| import retrofit2.http.GET | ||
|
|
||
| interface FriendService { | ||
| @GET("/friend/list") | ||
| suspend fun fetchFriends(): List<FriendEntity> | ||
|
|
||
| @GET("/friend/monthly") | ||
| suspend fun fetchMonthlyFriends(): List<MonthlyFriendEntity> | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
checkRate가 0..100 범위를 벗어나는 경우를else로 처리하여ContactFrequency.LOW를 반환하고 있습니다. 만약checkRate가 항상 0에서 100 사이의 값이라고 보장된다면 이else구문은 필요 없습니다. 만약 범위를 벗어나는 값이 들어올 수 있다면, 이는 예외적인 상황일 수 있으므로IllegalArgumentException을 던져서 잘못된 데이터가 시스템에 유입되는 것을 방지하는 것이 더 안전한 방법일 수 있습니다.