-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from 6QuizOnTheBlock/and/feat#362-ranking
And/feat#362 ๋ญํน ๊ธฐ๋ฅ ๊ตฌํ
- Loading branch information
Showing
21 changed files
with
699 additions
and
10 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
android/core/model/src/main/java/com/sixkids/model/MemberRankItem.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,7 @@ | ||
package com.sixkids.model | ||
|
||
data class MemberRankItem ( | ||
val name: String, | ||
val exp: Int, | ||
val rank: Int | ||
) |
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
18 changes: 18 additions & 0 deletions
18
android/data/src/main/java/com/sixkids/data/model/response/RankResponse.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,18 @@ | ||
package com.sixkids.data.model.response | ||
|
||
import com.sixkids.model.MemberRankItem | ||
|
||
data class RankResponse( | ||
val name: String, | ||
val point: Int, | ||
) | ||
|
||
fun List<RankResponse>.toModel(): List<MemberRankItem> { | ||
return this.mapIndexed { index, rankResponse -> | ||
MemberRankItem( | ||
rank = index + 1, | ||
name = rankResponse.name, | ||
exp = rankResponse.point, | ||
) | ||
} | ||
} |
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
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
12 changes: 12 additions & 0 deletions
12
android/domain/src/main/java/com/sixkids/domain/usecase/organization/GetClassRankUseCase.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,12 @@ | ||
package com.sixkids.domain.usecase.organization | ||
|
||
import com.sixkids.domain.repository.OrganizationRepository | ||
import javax.inject.Inject | ||
|
||
class GetClassRankUseCase @Inject constructor( | ||
private val organizationRepository: OrganizationRepository | ||
) { | ||
suspend operator fun invoke(organizationId: Int) = runCatching { | ||
organizationRepository.getOrganizationRank(organizationId) | ||
} | ||
} |
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
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
15 changes: 15 additions & 0 deletions
15
...d/feature/student/home/src/main/java/com/sixkids/student/home/rank/StudentRankContract.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,15 @@ | ||
package com.sixkids.student.home.rank | ||
|
||
import com.sixkids.model.MemberRankItem | ||
import com.sixkids.ui.base.SideEffect | ||
import com.sixkids.ui.base.UiState | ||
|
||
sealed interface StudentRankEffect : SideEffect { | ||
data class onShowSnackBar(val message: String): StudentRankEffect | ||
} | ||
|
||
data class StudentRankState( | ||
val isLoading: Boolean = false, | ||
val classString: String = "", | ||
val rankList: List<MemberRankItem> = emptyList(), | ||
): UiState |
166 changes: 166 additions & 0 deletions
166
...oid/feature/student/home/src/main/java/com/sixkids/student/home/rank/StudentRankScreen.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,166 @@ | ||
package com.sixkids.student.home.rank | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material3.HorizontalDivider | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
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.unit.dp | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
import com.sixkids.designsystem.component.appbar.UlbanDetailAppBar | ||
import com.sixkids.designsystem.component.screen.LoadingScreen | ||
import com.sixkids.designsystem.theme.Yellow | ||
import com.sixkids.model.MemberRankItem | ||
import com.sixkids.student.home.R | ||
import com.sixkids.student.home.rank.component.RankItem | ||
import com.sixkids.student.home.rank.component.StudentRankViewModel | ||
import com.sixkids.ui.SnackbarToken | ||
import com.sixkids.ui.extension.collectWithLifecycle | ||
import com.sixkids.designsystem.R as UlbanRes | ||
|
||
@Composable | ||
fun StudentRankRoute( | ||
viewModel: StudentRankViewModel = hiltViewModel(), | ||
padding: PaddingValues, | ||
onShowSnackBar: (SnackbarToken) -> Unit | ||
) { | ||
|
||
val uiState by viewModel.uiState.collectAsStateWithLifecycle() | ||
|
||
viewModel.sideEffect.collectWithLifecycle { | ||
when (it) { | ||
is StudentRankEffect.onShowSnackBar -> onShowSnackBar(SnackbarToken(it.message)) | ||
} | ||
} | ||
|
||
LaunchedEffect(Unit) { | ||
viewModel.getOrganizationName() | ||
viewModel.getClassRank() | ||
} | ||
|
||
Box( | ||
modifier = Modifier | ||
.padding(padding) | ||
.fillMaxSize() | ||
) { | ||
StudentRankScreen( | ||
studentRankState = uiState | ||
) | ||
if (uiState.isLoading) { | ||
LoadingScreen() | ||
} | ||
} | ||
|
||
} | ||
|
||
@Composable | ||
fun StudentRankScreen( | ||
modifier: Modifier = Modifier, | ||
studentRankState: StudentRankState = StudentRankState() | ||
) { | ||
Column( | ||
modifier = modifier | ||
.fillMaxSize() | ||
) { | ||
UlbanDetailAppBar( | ||
leftIcon = UlbanRes.drawable.rank, | ||
title = stringResource(id = R.string.student_home_main_rank), | ||
content = stringResource(id = R.string.student_home_main_rank), | ||
topDescription = "", | ||
bottomDescription = studentRankState.classString, | ||
color = Yellow | ||
) | ||
LazyColumn( | ||
modifier = Modifier | ||
.padding(16.dp) | ||
) { | ||
items(studentRankState.rankList.size) { index -> | ||
RankItem( | ||
rank = studentRankState.rankList[index].rank, | ||
name = studentRankState.rankList[index].name, | ||
exp = studentRankState.rankList[index].exp | ||
) | ||
if (index != studentRankState.rankList.size - 1) { | ||
HorizontalDivider( | ||
modifier = Modifier.padding(vertical = 4.dp), | ||
color = Color.Black, | ||
thickness = 2.dp | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun RankScreenPreview() { | ||
StudentRankScreen( | ||
studentRankState = StudentRankState( | ||
classString = "๊ตฌ๋ฏธ ์ด๋ฑํ๊ต 1ํ๋ 1๋ฐ", | ||
rankList = listOf( | ||
MemberRankItem( | ||
rank = 1, | ||
name = "๊น์ฒ ์", | ||
exp = 100 | ||
), | ||
MemberRankItem( | ||
rank = 2, | ||
name = "๋ฐ์ํฌ", | ||
exp = 90 | ||
), | ||
MemberRankItem( | ||
rank = 3, | ||
name = "์ด์์", | ||
exp = 80 | ||
), | ||
MemberRankItem( | ||
rank = 4, | ||
name = "์ต์ํฌ", | ||
exp = 70 | ||
), | ||
MemberRankItem( | ||
rank = 5, | ||
name = "ํ๊ธธ๋", | ||
exp = 60 | ||
), | ||
MemberRankItem( | ||
rank = 6, | ||
name = "๊น์ฒ ์", | ||
exp = 50 | ||
), | ||
MemberRankItem( | ||
rank = 7, | ||
name = "๋ฐ์ํฌ", | ||
exp = 40 | ||
), | ||
MemberRankItem( | ||
rank = 8, | ||
name = "์ด์์", | ||
exp = 30 | ||
), | ||
MemberRankItem( | ||
rank = 9, | ||
name = "์ต์ํฌ", | ||
exp = 20 | ||
), | ||
MemberRankItem( | ||
rank = 10, | ||
name = "ํ๊ธธ๋", | ||
exp = 10 | ||
) | ||
) | ||
) | ||
) | ||
} |
Oops, something went wrong.