Skip to content

๐Ÿš€ 4๋‹จ๊ณ„ - GitHub(์ธ๊ธฐ ์ €์žฅ์†Œ) #79

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

Open
wants to merge 8 commits into
base: hyemdooly
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@
- [x] Loading : Indicator ์ถœ๋ ฅ, ์—๋Ÿฌ ์‹œ ์Šค๋‚ต๋ฐ” ์ถœ๋ ฅ
- [x] Empty : "๋ชฉ๋ก์ด ๋น„์—ˆ์Šต๋‹ˆ๋‹ค" ์ถœ๋ ฅ
- [x] Success : ๋ฆฌ์ŠคํŠธ ์ถœ๋ ฅ

## 4๋‹จ๊ณ„
- [x] ์ €์žฅ์†Œ์˜ Star ๊ฐœ์ˆ˜ ๋…ธ์ถœ
- [x] ์ €์žฅ์†Œ์˜ Star ๊ฐœ์ˆ˜๊ฐ€ 50๊ฐœ ์ด์ƒ์ด๋ฉด HOT ํ…์ŠคํŠธ ๋…ธ์ถœ
- [x] (์„ ํƒ) ๋„๋ฉ”์ธ ๊ณ„์ธต ๊ตฌํ˜„
5 changes: 5 additions & 0 deletions app/src/main/java/nextstep/AppContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import kotlinx.serialization.json.Json
import nextstep.github.data.repository.GithubRepoRepository
import nextstep.github.data.repository.impl.DefaultGithubRepoRepository
import nextstep.github.data.service.GithubService
import nextstep.github.domain.usecase.DefaultGetRepositoriesUseCase
import nextstep.github.domain.usecase.GetRepositoriesUseCase
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
Expand All @@ -29,6 +31,9 @@ class AppContainer {

val githubRepoRepository: GithubRepoRepository = DefaultGithubRepoRepository(githubService)

val getRepositoriesUseCase: GetRepositoriesUseCase =
DefaultGetRepositoriesUseCase(githubRepoRepository)

companion object {
private const val CONTENT_TYPE = "application/json"
private const val BASE_URL = "https://api.github.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ data class RepositoryEntity(
@SerialName("id") val id: Long,
@SerialName("full_name") val fullName: String?,
@SerialName("description") val description: String?,
@SerialName("stargazers_count") val stars: Int?,
)
26 changes: 26 additions & 0 deletions app/src/main/java/nextstep/github/domain/model/Repository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package nextstep.github.domain.model

import nextstep.github.data.repository.model.RepositoryEntity
import nextstep.github.util.orZero

data class Repository(
val id: Long,
val fullName: String,
val description: String,
val stars: Int,
) {
val isHot: Boolean = stars >= HOT_STANDARD

Comment on lines +11 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ฒ˜์Œ์—๋Š” 50๊ฐœ ์ด์ƒ์ด๋ฉด HOT์„ ๋ณด์—ฌ์ค€๋‹ค๋Š” ๊ฒƒ์ด ๋ทฐ์˜ ๊ด€์‹ฌ์‚ฌ์ด๊ธฐ์—, ๋ทฐ์—์„œ ํŒ๋‹จํ•˜๋ฉด ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ฒ˜์Œ์—๋Š” ๋ทฐ์˜ ๋กœ์ง์œผ๋กœ ์ž‘์„ฑํ–ˆ๋Š”๋ฐ์š”.
๋งŒ์•ฝ ๋„๋ฉ”์ธ ๊ณ„์ธต์„ ๊ฐ€์ง€๊ณ  ๋‹ค๋ฅธ ํ”Œ๋žซํผ์œผ๋กœ ์˜ฎ๊ฒผ์„ ๋•Œ๋„ ๋™์ผํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์žฅํ•ด์•ผํ•˜์ง€ ์•Š์„๊นŒ, ๋ทฐ๋Š” ์ตœ๋Œ€ํ•œ ๋ฉ์ฒญํ•ด์•ผํ•˜์ง€ ์•Š์„๊นŒ? ์ƒ๊ฐ์ด ๋“ค์–ด์„œ ๋„๋ฉ”์ธ ๊ณ„์ธต์œผ๋กœ ์ƒ๊ฐ์„ ๋ฐ”๊พธ์–ด ๋ฆฌํŒฉํ„ฐ๋ง ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
์ด ๋ถ€๋ถ„์— ๋Œ€ํ•œ ํ˜๋‹˜์˜ ์ƒ๊ฐ๋„ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค. ๐Ÿ˜„

์ €๋„ ์ฐธ ๊ณ ๋ฏผ์ด ๋งŽ์•˜๋Š”๋ฐ์š”,
์ €๋„ ๋˜‘๊ฐ™์€ ์ƒ๊ฐ์˜ ํ๋ฆ„์œผ๋กœ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ์–ด์š”.

๋ทฐ์— ๋ณด์—ฌ์ฃผ๋Š” ๊ฒƒ์ด๋ผ๋Š” ๊ฒƒ์€ ๋งž์œผ๋‚˜, HOT์ด๋ผ๋Š” ๋”ฑ์ง€๋ฅผ ๋ถ™์—ฌ์ฃผ๋Š” ๊ธฐํš์€ ๊ฒฐ๊ตญ ๋„๋ฉ”์ธ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ด์š”.
๋ทฐ์˜ ์š”์†Œ๋Š” HOT์„ ์–ด๋””์— ์–ด๋–ป๊ฒŒ ๋ณด์—ฌ์ค„ ๊ฒƒ์ด๋ƒ์˜ ๋กœ์ง์ด๋ž€ ์ƒ๊ฐ์ด ๋“ค์–ด ์ €๋„ ๋„๋ฉ”์ธ์— isHot์„ ๋†“๋Š”๊ฒŒ ์ ์ ˆํ•˜๋‹ค ์ƒ๊ฐํ–ˆ์–ด์š”.

๋ฐฑ์—”๋“œ์—์„œ HOT์„ ๋ทฐ์˜ ์š”์†Œ๋กœ ๋ณผ ๊ฒƒ์ด๋ƒ? ๋ผ๊ณ  ํ–ˆ์„๋•Œ, ์ €๋Š” ์•„๋‹ˆ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ์–ด์š”.
์˜คํžˆ๋ ค HOT์ธ ์กฐ๊ฑด์„ ๋ฐฑ์—”๋“œ์— ๋ฐ•์•„ ๋„ฃ๋Š”๊ฒŒ, ํ•ซํ”ฝ์Šค๋‚˜ ๋‹ค๋ฅธ ๋ฐฐํฌ๋กœ ํ•˜์—ฌ๊ธˆ ๋” ์œ ๋™์ ์œผ๋กœ ๋Œ€์ฒ˜ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ’์ด๋ผ ์ƒ๊ฐ์ด ๋“ค์–ด์„œ์š”.
๋ฐฑ์—”๋“œ๊ฐ€ ์—ฐ๊ฒฐ๋œ๋‹ค๋ฉด, isHot๋„ ์‘๋‹ต์œผ๋กœ ๋ณด๋‚ด์ฃผ์ง€ ์•Š์„๊นŒ ํ•˜๋Š” ๊ฐœ์ธ์ ์ธ ์ƒ๊ฐ์ด ์žˆ์—ˆ์–ด์š” :)

companion object {
private const val HOT_STANDARD = 50
}
}

fun RepositoryEntity.toDomain(): Repository {
return Repository(
id = id,
fullName = fullName.orEmpty(),
description = description.orEmpty(),
stars = stars.orZero()
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package nextstep.github.domain.usecase

import nextstep.github.data.repository.GithubRepoRepository
import nextstep.github.domain.model.Repository
import nextstep.github.domain.model.toDomain

fun interface GetRepositoriesUseCase {
suspend operator fun invoke(organization: String): List<Repository>
}

class DefaultGetRepositoriesUseCase(
private val githubRepoRepository: GithubRepoRepository,
) : GetRepositoriesUseCase {
override suspend operator fun invoke(organization: String): List<Repository> {
return githubRepoRepository.getRepositories(organization).map { it.toDomain() }
}
}
Comment on lines +7 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UseCase์˜ ์ธํ„ฐํŽ˜์ด์Šค๋ผ.... ์˜›๋‚ ๋ถ€ํ„ฐ ์ƒ๊ฐํ•ด๋ดค๋˜ ๊ฒƒ์ด๊ธด ํ•œ๋ฐ ์ •๋ง ๋ณด์ผ๋Ÿฌํ”Œ๋ ˆ์ดํŠธ๊ฐ€ ๋งŽ์€ ์ฝ”๋“œ๋ผ ์ €๋Š” ์•ˆํ•˜๋Š” ๊ฒŒ ๋‚ซ๊ฒ ๋‹ค ๋ผ๊ณ  ๊ฒฐ๋ก ์ง€์—ˆ๋Š”๋ฐ์š”,
์ด ๋ฐฉ๋ฒ•์„ ํƒํ•œ ์ด์œ ๊ฐ€ ์žˆ์œผ์…จ๋‚˜์š”?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ทธ๋Ÿฌ๊ณ ๋ณด๋‹ˆ .toDomain์„ ๋ณด๋‹ˆ,
๋„๋ฉ”์ธ์€ GithubRepoRepository๋ฅผ ํ†ต๊ณผํ•ด์„œ ๋ฐ˜ํ™˜๋  ๋•Œ๋ถ€ํ„ฐ ๋„๋ฉ”์ธ์ด์–ด์•ผ ์ž์—ฐ์Šค๋Ÿฝ๋‹จ ์ƒ๊ฐ์ด ๋“œ๋„ค์š”~

52 changes: 34 additions & 18 deletions app/src/main/java/nextstep/github/ui/RepositoryListViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,59 @@ import androidx.lifecycle.ViewModelProvider.AndroidViewModelFactory.Companion.AP
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.stateIn
import nextstep.github.GithubApplication
import nextstep.github.data.repository.GithubRepoRepository
import nextstep.github.R
import nextstep.github.domain.usecase.GetRepositoriesUseCase
import nextstep.github.ui.model.RepositoryListEvent
import nextstep.github.ui.model.RepositoryListUiState

class RepositoryListViewModel(
private val githubRepoRepository: GithubRepoRepository
private val getRepositoryUseCase: GetRepositoriesUseCase
) : ViewModel() {
val uiState = flow {
emit(RepositoryListUiState.Loading(error = false))

val repositories = githubRepoRepository.getRepositories(ORGANIZATION)
if (repositories.isEmpty()) {
emit(RepositoryListUiState.Empty)
} else {
emit(RepositoryListUiState.Success(items = repositories))
}
}.catch {
emit(RepositoryListUiState.Loading(error = true))
}.stateIn(
val uiState = getRepositoriesFlow().stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(5_000),
initialValue = RepositoryListUiState.Loading(error = false)
initialValue = RepositoryListUiState.Loading
)

private val _event = MutableSharedFlow<RepositoryListEvent>()
val event = _event.asSharedFlow()

private fun getRepositoriesFlow(): Flow<RepositoryListUiState> {
return flow {
val repositories = getRepositoryUseCase(ORGANIZATION)
Comment on lines +35 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๋ฅผ ์œ ๋™์ ์œผ๋กœ ๋ณ€๊ฒฝํ•ด์•ผํ• ๋•Œ ๋ณ€๊ฒฝ์ ์ด ์ปค์งˆ ๊ฑฐ๋ผ ์˜ˆ์ƒ๋ผ์š”.
์ฒซ ๊ฐ’์€ savedstatehandle์„ ํ™œ์šฉํ•œ๋‹ค๋˜์ง€, ํ˜น์€ ๋‹ค๋ฅธ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ํ™•์žฅํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌ์„ฑํ•ด๋ณด๋Š” ๊ฑด ์–ด๋–จ๊นŒ์š”?

if (repositories.isEmpty()) {
emit(RepositoryListUiState.Empty)
} else {
emit(RepositoryListUiState.Success(items = repositories))
}
}.catch {
emit(RepositoryListUiState.Loading)
_event.tryEmit(
RepositoryListEvent.ShowSnackBar(
msgRes = R.string.repository_list_fetch_error,
actionLabelRes = R.string.retry
)
Comment on lines +45 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Viewmodel์€ ์•ˆ๋“œ๋กœ์ด๋“œ ํ”„๋ ˆ์ž„์›Œํฌ์— ์กฐ๊ธˆ์€ ์ž์œ ๋กœ์›Œ์„œ ์œ ๋‹›ํ…Œ์ŠคํŠธ๊ฐ€ ๊ฐ€๋Šฅํ•œ๋ฐ์š”,
R๊ฐ’์ด ์žˆ๋Š” ์ˆœ๊ฐ„๋ถ€ํ„ฐ ๋‹ค๋ฅธ ํ…Œ์ŠคํŠธ ๋„๊ตฌ์˜ ๋„์›€ ์—†์ด๋Š” ์œ ๋‹›ํ…Œ์ŠคํŠธ๋ฅผ ํ•˜๊ธฐ๊ฐ€ ์–ด๋ ค์›Œ์ ธ์š”.
๊ทธ๋ž˜์„œ ์ €๋Š” ์ตœ๋Œ€ํ•œ ์œ ๋‹› ํ…Œ์ŠคํŠธ๋ฅผ ์–ด๋ ต๊ฒŒ ํ•˜๋Š” ์š”์†Œ๋ฅผ ๋ทฐ๋ชจ๋ธ์— ์ง‘์–ด๋„ฃ์ง€ ์•Š์œผ๋ ค๊ณ  ํ•ด์š”.

)
}
}

companion object {
private const val ORGANIZATION = "next-step"

val Factory: ViewModelProvider.Factory = viewModelFactory {
initializer {
val githubRepository = (this[APPLICATION_KEY] as GithubApplication)
val getRepositoriesUseCase = (this[APPLICATION_KEY] as GithubApplication)
.appContainer
.githubRepoRepository
RepositoryListViewModel(githubRepository)
.getRepositoriesUseCase
RepositoryListViewModel(getRepositoriesUseCase)
}
}
}
Expand Down
96 changes: 85 additions & 11 deletions app/src/main/java/nextstep/github/ui/component/RepositoryItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,83 @@ package nextstep.github.ui.component

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Star
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.dp
import nextstep.github.data.repository.model.RepositoryEntity
import nextstep.github.R
import nextstep.github.domain.model.Repository
import nextstep.github.ui.theme.GithubTheme

@Composable
fun RepositoryItem(
repository: RepositoryEntity,
repository: Repository,
modifier: Modifier = Modifier
) {
RepositoryItem(
fullName = repository.fullName,
description = repository.description,
stars = repository.stars,
isHot = repository.isHot,
modifier = modifier
)
}

@Composable
fun RepositoryItem(
fullName: String,
description: String,
stars: Int,
isHot: Boolean,
Comment on lines 30 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์˜ค~ ์ €๋„ ์ปดํฌ์ฆˆ ์ปดํฌ๋„ŒํŠธ ๊ตฌ์„ฑํ•  ๋•Œ ์ด๋Ÿฐ ๋ฐฉ์‹์œผ๋กœ ๊ตฌ์„ฑํ•˜๋Š”๋ฐ, ํŒ์„ ๋“œ๋ฆฌ๊ธฐ๋„์ „์— ์ด๋ ‡๊ฒŒ ๊ตฌ์„ฑํ•ด์ฃผ์…จ๋„ค์š”

์›ํ˜• ์ปดํฌ๋„ŒํŠธ๋Š” ์ตœ๋Œ€ํ•œ ์›์‹œ๊ฐ’๋“ค์„ ํ™œ์šฉํ•˜๊ณ , ๋„๋ฉ”์ธ์ด ๋“ค์–ด๊ฐ€๊ฒŒ ํŽธ์˜์„ฑ์„ ์ œ๊ณตํ•˜๋Š” ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋”ฐ๋กœ ๊ตฌ์„ฑํ•˜๋Š” ํ˜•ํƒœ๋ฅผ ์ „ ์„ ํ˜ธํ•ด์š”.
์ด๋Ÿฌ๋ฉด ์žฌํ™œ์šฉํ•  ๋•Œ ์ •๋ง ์œ ์šฉํ•˜๋”๋ผ๊ตฌ์š”.

modifier: Modifier = Modifier
) {
Column(
modifier = modifier
.background(color = MaterialTheme.colorScheme.surface)
) {
Column(
modifier = Modifier.padding(16.dp)
modifier = Modifier
.padding(16.dp)
.fillMaxWidth()
) {
Row(
modifier = Modifier.fillMaxWidth(),
) {
if (isHot) {
Text(
text = stringResource(R.string.repository_item_hot),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary
)
}
Spacer(modifier = Modifier.weight(1f))
Comment on lines +69 to +70
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VerticalDivider, HorizontalDivider ์ด๋Ÿฐ๊ฑด ๋งŒ๋“ค์–ด์ฃผ๋ฉด์„œ VerticalSpacer ์ด๋Ÿฐ๊ฑด ์•ˆ๋งŒ๋“ค์–ด์ฃผ๋”๋ผ๊ตฌ์š”
์ „ ํšŒ์‚ฌ์—์„œ VerticalSpacer, HorizontalSpacer ๋งŒ๋“ค์–ด์„œ ์‚ฌ์šฉํ•˜๋Š”๋ฐ, Modifier ๋งค๋ฒˆ ์•ˆ๋งŒ๋“ค์–ด์„œ ์ •๋ง ํŽธํ•ด์š”. ๋‚˜์ค‘์— ๋งŒ๋“ค์–ด์„œ ์žก์†จ๋ณด์„ธ์š”~

ex)

~~~
VerticalSpacer(height = 8.dp)

์Œ ๋‹ค ์“ฐ๊ณ  ๋ณด๋‹ˆ ์ด๊ฑด weight ๊ฑธ๋ ค์žˆ๋„ค์š”
์ด๊ฒƒ๋„ ๋งŒ๋“ค๋ฉด ์ข‹๊ฒ ๋Š”๋ฐ์š”? WeightedSpacer ๊ฐ™์€๊ฑธ ํ•„์š”ํ• ๋•Œ ์จ๋จน์–ด์•ผ๊ฒ ๊ตฐ์š”

StarCount(
count = stars,
)
}
Text(
text = repository.fullName.orEmpty(),
text = fullName,
style = MaterialTheme.typography.titleLarge,
color = Color.Black
)
Text(
text = repository.description.orEmpty(),
text = description,
style = MaterialTheme.typography.bodyMedium,
color = Color.Black
)
Expand All @@ -42,16 +87,45 @@ fun RepositoryItem(
}
}

@Composable
fun StarCount(
count: Int,
modifier: Modifier = Modifier
) {
Row(
modifier = modifier,
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
modifier = Modifier.size(18.dp),
imageVector = Icons.Filled.Star,
contentDescription = null
)
Text(
text = count.toString(),
style = MaterialTheme.typography.labelLarge,
)
}
}

private class RepositoryItemPreviewParameterProvider : PreviewParameterProvider<Boolean> {
override val values = sequenceOf(
true,
false
)
}

@Preview
@Composable
private fun RepositoryItemPreview() {
private fun RepositoryItemPreview(
@PreviewParameter(RepositoryItemPreviewParameterProvider::class) value: Boolean
) {
GithubTheme {
RepositoryItem(
RepositoryEntity(
id = 0,
fullName = "next-step/nextstep-docs",
description = "nextstep ๋งค๋‰ด์–ผ ๋ฐ ๋ฌธ์„œ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ €์žฅ์†Œ"
),
fullName = "next-step/nextstep-docs",
description = "nextstep ๋งค๋‰ด์–ผ ๋ฐ ๋ฌธ์„œ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ €์žฅ์†Œ",
stars = 100,
isHot = value,
modifier = Modifier.fillMaxWidth()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import nextstep.github.data.repository.model.RepositoryEntity
import nextstep.github.domain.model.Repository
import nextstep.github.ui.theme.GithubTheme

@Composable
fun RepositoryList(
repositories: List<RepositoryEntity>,
repositories: List<Repository>,
modifier: Modifier = Modifier
) {
LazyColumn(
Expand All @@ -33,10 +33,11 @@ private fun RepositoryListPreview() {
GithubTheme {
RepositoryList(
repositories = List(10) {
RepositoryEntity(
Repository(
id = it.toLong(),
fullName = "next-step/nextstep-docs",
description = "nextstep ๋งค๋‰ด์–ผ ๋ฐ ๋ฌธ์„œ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ €์žฅ์†Œ"
description = "nextstep ๋งค๋‰ด์–ผ ๋ฐ ๋ฌธ์„œ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ €์žฅ์†Œ",
stars = 500,
)
},
modifier = Modifier.fillMaxSize()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package nextstep.github.ui.model

import androidx.annotation.StringRes

sealed interface RepositoryListEvent {
data class ShowSnackBar(@StringRes val msgRes: Int, @StringRes val actionLabelRes: Int): RepositoryListEvent
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package nextstep.github.ui.model

import nextstep.github.data.repository.model.RepositoryEntity
import nextstep.github.domain.model.Repository

sealed interface RepositoryListUiState {
data class Loading(val error: Boolean): RepositoryListUiState
data object Loading : RepositoryListUiState
data object Empty: RepositoryListUiState
data class Success(val items: List<RepositoryEntity>): RepositoryListUiState
data class Success(val items: List<Repository>): RepositoryListUiState
}
Loading