Skip to content

Commit

Permalink
update: rank screen loading & error & change year
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Nov 3, 2023
1 parent b765380 commit 900d5bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fun RankAnimeWidget(
.weight(1f)
.padding(8.dp)
.wrapContentWidth(Alignment.Start),
text = model.title,
text = "${model.no}. ${model.title}",
overflow = TextOverflow.Ellipsis,
maxLines = 1,
color = MaterialTheme.colorScheme.onBackground,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ fun RankScreen(
)
}
if (rankLD.type == LazyType.SUCCESS && !rankLD.data.isNullOrEmpty() && rankLD.data!!.size > 2) {
val dayList = rankLD.data!![0]
val weekList = rankLD.data!![1]
val totalList = rankLD.data!![2]
Row {
Column(
modifier = Modifier
Expand All @@ -89,7 +92,7 @@ fun RankScreen(
style = MaterialTheme.typography.titleLarge
)
TvLazyColumn {
items(rankLD.data!![0]) {
items(dayList) {
RankAnimeWidget(
model = it,
onClick = {
Expand Down Expand Up @@ -117,7 +120,7 @@ fun RankScreen(
style = MaterialTheme.typography.titleLarge
)
TvLazyColumn {
items(rankLD.data!![1]) {
items(weekList) {
RankAnimeWidget(
model = it,
onClick = {
Expand Down Expand Up @@ -146,7 +149,7 @@ fun RankScreen(
)

TvLazyColumn {
items(rankLD.data!![2]) {
items(totalList) {
RankAnimeWidget(
model = it,
onClick = {
Expand All @@ -161,12 +164,12 @@ fun RankScreen(
}
}
}
} else if (rankLD.type != LazyType.LOADING) {
} else if (rankLD.type == LazyType.LOADING) {
LoadingScreen()
} else {
ErrorScreen {
viewModel.fetchRank()
}
} else {
LoadingScreen()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class RankViewModel @Inject constructor(
val rankLDState = mutableStateOf<LazyData<List<List<RankAnimeModel>>>>(LazyData.init())

fun fetchRank() {
rankLDState.value = LazyData.init()
viewModelScope.launch(context = Dispatchers.IO) {
try {
rankLDState.value =
Expand Down

0 comments on commit 900d5bf

Please sign in to comment.