-
Notifications
You must be signed in to change notification settings - Fork 70
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
1 parent
24766b0
commit d2676a1
Showing
8 changed files
with
88 additions
and
72 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...-api/src/main/java/com/droidknights/app/core/data/repository/api/ContributorRepository.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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package com.droidknights.app.core.data.repository.api | ||
|
||
import com.droidknights.app.core.model.Contributor | ||
import com.droidknights.app.core.model.ContributorGroup | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface ContributorRepository { | ||
|
||
fun flowContributors( | ||
owner: String, | ||
name: String, | ||
): Flow<Map<Int, List<Contributor>>> | ||
): Flow<List<ContributorGroup>> | ||
} |
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
4 changes: 2 additions & 2 deletions
4
core/domain/src/main/java/com/droidknights/app/core/domain/usecase/GetContributorsUseCase.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
6 changes: 3 additions & 3 deletions
6
...omain/src/test/java/com/droidknights/app/core/domain/usecase/FakeContributorRepository.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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package com.droidknights.app.core.domain.usecase | ||
|
||
import com.droidknights.app.core.data.repository.api.ContributorRepository | ||
import com.droidknights.app.core.model.Contributor | ||
import com.droidknights.app.core.model.ContributorGroup | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flowOf | ||
|
||
internal class FakeContributorRepository( | ||
private val contributors: Map<Int, List<Contributor>>, | ||
private val contributors: List<ContributorGroup>, | ||
) : ContributorRepository { | ||
|
||
override fun flowContributors(owner: String, name: String): Flow<Map<Int, List<Contributor>>> = | ||
override fun flowContributors(owner: String, name: String): Flow<List<ContributorGroup>> = | ||
flowOf(contributors) | ||
} |
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
6 changes: 6 additions & 0 deletions
6
core/model/src/main/java/com/droidknights/app/core/model/ContributorGroup.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,6 @@ | ||
package com.droidknights.app.core.model | ||
|
||
data class ContributorGroup( | ||
val year: Int, | ||
val contributors: List<Contributor>, | ||
) |
33 changes: 11 additions & 22 deletions
33
...c/main/java/com/droidknights/app/feature/contributor/model/convert/ContributorsConvert.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 |
---|---|---|
@@ -1,32 +1,21 @@ | ||
package com.droidknights.app.feature.contributor.model.convert | ||
|
||
import com.droidknights.app.core.model.Contributor | ||
import com.droidknights.app.core.model.ContributorGroup | ||
import com.droidknights.app.feature.contributor.model.ContributorsUiState | ||
import kotlinx.collections.immutable.toPersistentList | ||
|
||
internal fun Map<Int, List<Contributor>>.toContributorsUiState(): ContributorsUiState { | ||
val newList = mutableListOf<ContributorsUiState.Contributors.Item>() | ||
|
||
// key, value 추가 | ||
forEach { (key, values) -> | ||
newList.add( | ||
ContributorsUiState.Contributors.Item.Section( | ||
title = key.toString(), | ||
) | ||
) | ||
values.forEach { item -> | ||
newList.add( | ||
internal fun List<ContributorGroup>.toContributorsUiState(): ContributorsUiState = | ||
ContributorsUiState.Contributors( | ||
contributors = flatMap { (year, contributors) -> | ||
sequenceOf( | ||
ContributorsUiState.Contributors.Item.Section(title = year.toString()) | ||
) + contributors.map { item -> | ||
ContributorsUiState.Contributors.Item.User( | ||
id = item.id, | ||
imageUrl = item.imageUrl, | ||
githubUrl = item.githubUrl, | ||
name = item.name, | ||
name = item.name | ||
) | ||
) | ||
} | ||
} | ||
|
||
return ContributorsUiState.Contributors( | ||
contributors = newList.toPersistentList(), | ||
) | ||
} | ||
} | ||
}.toPersistentList(), | ||
) |