-
Notifications
You must be signed in to change notification settings - Fork 1
Публичный тренажер, экран результатов. ANDR-63 Верстка экрана #125
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
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e47f934
ANDR-63
arte123ras da2b9e8
ANDR-63
arte123ras 571ed93
ANDR-63:
arte123ras f9e7c18
ANDR-63:
arte123ras ca06334
ANDR-63:
arte123ras 143c3b7
ANDR-63:
arte123ras 6e9d90c
ANDR-63:
arte123ras 1b8187e
ANDR-93: вынос в core-ui кнопок Знаю/Не знаю. Исползование в QuizScreen
Deyryl 4eb1feb
ANDR-63:
arte123ras c61cd89
Merge remote-tracking branch 'origin/feature/ANDR-93' into feature/AN…
arte123ras 9fa7a02
ANDR-63:
arte123ras 259ce61
ANDR-63:
arte123ras ed8bd4a
ANDR-63:
arte123ras b97cd6d
ANDR-63:
arte123ras 6595812
ANDR-63:
arte123ras 0caaa06
ANDR-63:
arte123ras f217ffa
ANDR-63:
arte123ras d9ac5f3
ANDR-63:
arte123ras f6765e0
ANDR-63: Изменил ViewModel на BaseViewModel
arte123ras 3ec9bcb
ANDR-63: Оптимизация ktlint
arte123ras 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
151 changes: 151 additions & 0 deletions
151
core/ui/src/main/java/ru/yeahub/core_ui/component/QuizAnswerButton.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,151 @@ | ||
| package ru.yeahub.core_ui.component | ||
|
|
||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.width | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.material3.Button | ||
| import androidx.compose.material3.ButtonDefaults | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import ru.yeahub.core_ui.example.staticPreview.StaticPreview | ||
| import ru.yeahub.core_ui.theme.Theme | ||
| import ru.yeahub.core_utils.common.TextOrResource | ||
| import ru.yeahub.ui.R | ||
|
|
||
| private val FIGMA_LOW_PADDING = 8.dp | ||
| private val FIGMA_RADIUS = 12.dp | ||
|
|
||
| @Composable | ||
| fun KnownAnswerButton( | ||
| enabled: Boolean, | ||
| isHighlighted: Boolean, | ||
| onClick: () -> Unit, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| QuizAnswerButton( | ||
| iconRes = R.drawable.thumbs_up_icon, | ||
| text = TextOrResource.Resource(R.string.quiz_answer_known), | ||
| enabled = enabled, | ||
| isHighlighted = isHighlighted, | ||
| onClick = onClick, | ||
| modifier = modifier | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| fun UnknownAnswerButton( | ||
| enabled: Boolean, | ||
| isHighlighted: Boolean, | ||
| onClick: () -> Unit, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| QuizAnswerButton( | ||
| iconRes = R.drawable.thumbs_down_icon, | ||
| text = TextOrResource.Resource(R.string.quiz_answer_unknown), | ||
| enabled = enabled, | ||
| isHighlighted = isHighlighted, | ||
| onClick = onClick, | ||
| modifier = modifier | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| private fun QuizAnswerButton( | ||
| iconRes: Int, | ||
| text: TextOrResource, | ||
| enabled: Boolean, | ||
| isHighlighted: Boolean, | ||
| onClick: () -> Unit, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| val context = LocalContext.current | ||
|
|
||
| val contentColor = if (isHighlighted) { | ||
| Theme.colors.purple700 | ||
| } else { | ||
| Theme.colors.black700 | ||
| } | ||
|
|
||
| Button( | ||
| onClick = onClick, | ||
| modifier = modifier | ||
| .width(120.dp) | ||
| .height(48.dp), | ||
| shape = RoundedCornerShape(FIGMA_RADIUS), | ||
| colors = ButtonDefaults.buttonColors( | ||
| containerColor = Theme.colors.black10, | ||
| contentColor = contentColor, | ||
| disabledContainerColor = Theme.colors.black10, | ||
| disabledContentColor = contentColor | ||
| ), | ||
| contentPadding = PaddingValues( | ||
| horizontal = 12.dp, | ||
| vertical = FIGMA_LOW_PADDING | ||
| ), | ||
| enabled = enabled | ||
| ) { | ||
| Icon( | ||
| painter = painterResource(iconRes), | ||
| contentDescription = null, | ||
| modifier = Modifier.padding(end = FIGMA_LOW_PADDING) | ||
| ) | ||
| Text( | ||
| text = when (text) { | ||
| is TextOrResource.Text -> text.text | ||
| is TextOrResource.Resource -> text.getString(context) | ||
| }, | ||
| style = Theme.typography.body2 | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @StaticPreview | ||
| @Composable | ||
| fun KnownAnswerHighlightedButtonPreview() { | ||
| KnownAnswerButton( | ||
| enabled = true, | ||
| isHighlighted = true, | ||
| onClick = {}, | ||
| modifier = Modifier | ||
| ) | ||
| } | ||
|
|
||
| @StaticPreview | ||
| @Composable | ||
| fun KnownAnswerButtonPreview() { | ||
| KnownAnswerButton( | ||
| enabled = true, | ||
| isHighlighted = false, | ||
| onClick = {}, | ||
| modifier = Modifier | ||
| ) | ||
| } | ||
|
|
||
| @StaticPreview | ||
| @Composable | ||
| fun UnknownAnswerHighlightedButtonPreview() { | ||
| UnknownAnswerButton( | ||
| enabled = true, | ||
| isHighlighted = true, | ||
| onClick = {}, | ||
| modifier = Modifier | ||
| ) | ||
| } | ||
|
|
||
| @StaticPreview | ||
| @Composable | ||
| fun UnknownAnswerButtonPreview() { | ||
| UnknownAnswerButton( | ||
| enabled = true, | ||
| isHighlighted = true, | ||
| onClick = {}, | ||
| modifier = Modifier | ||
| ) | ||
| } |
File renamed without changes.
File renamed without changes.
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
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
6 changes: 6 additions & 0 deletions
6
...ain/java/ru/yeahub/interview_trainer/impl/interviewQuizResult/InterviewQuizResultEvent.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,6 @@ | ||
| package ru.yeahub.interview_trainer.impl.interviewQuizResult | ||
|
|
||
| sealed interface InterviewQuizResultEvent { | ||
|
arte123ras marked this conversation as resolved.
|
||
|
|
||
| data object Todo : InterviewQuizResultEvent // TODO: сделать ивенты | ||
| } | ||
39 changes: 39 additions & 0 deletions
39
...a/ru/yeahub/interview_trainer/impl/interviewQuizResult/InterviewQuizResultScreenMapper.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,39 @@ | ||
| package ru.yeahub.interview_trainer.impl.interviewQuizResult | ||
|
|
||
| import InterviewQuizResultState | ||
| import kotlinx.collections.immutable.persistentListOf | ||
|
|
||
| private const val DEFAULT_PERCENTAGE = 0.75f | ||
| private const val DEFAULT_TOTAL_QUESTIONS = 20 | ||
| private const val DEFAULT_NEW_QUESTIONS = 50 | ||
| private const val DEFAULT_IN_PROGRESS = 120 | ||
| private const val DEFAULT_STUDIED = 12 | ||
| private const val DEFAULT_SKILL_SCORE = 60 | ||
| private const val DEFAULT_SKILL_MAX = 120 | ||
|
|
||
| class InterviewQuizResultScreenMapper { | ||
|
|
||
| fun getScreenState(): InterviewQuizResultState = InterviewQuizResultState.Loaded( | ||
| overallPercentage = DEFAULT_PERCENTAGE, | ||
| totalQuestions = DEFAULT_TOTAL_QUESTIONS, | ||
| newQuestions = DEFAULT_NEW_QUESTIONS, | ||
| inProgress = DEFAULT_IN_PROGRESS, | ||
| studied = DEFAULT_STUDIED, | ||
| skills = persistentListOf( | ||
| InterviewQuizResultState.Loaded.VoSkillStat("HTML", DEFAULT_SKILL_SCORE, DEFAULT_SKILL_MAX), | ||
| InterviewQuizResultState.Loaded.VoSkillStat("CSS", DEFAULT_SKILL_SCORE, DEFAULT_SKILL_MAX), | ||
| InterviewQuizResultState.Loaded.VoSkillStat("JavaScript", DEFAULT_SKILL_SCORE, DEFAULT_SKILL_MAX), | ||
| InterviewQuizResultState.Loaded.VoSkillStat("React", DEFAULT_SKILL_SCORE, DEFAULT_SKILL_MAX), | ||
| InterviewQuizResultState.Loaded.VoSkillStat("PHP", DEFAULT_SKILL_SCORE, DEFAULT_SKILL_MAX), | ||
| InterviewQuizResultState.Loaded.VoSkillStat("JavaScript", DEFAULT_SKILL_SCORE, DEFAULT_SKILL_MAX) | ||
| ), | ||
| questions = persistentListOf( | ||
| InterviewQuizResultState.Loaded.VoQuestionResult("Что такое Virtual DOM, и как он работает?", false), | ||
| InterviewQuizResultState.Loaded.VoQuestionResult("Что такое Virtual DOM, и как он работает?", true), | ||
| InterviewQuizResultState.Loaded.VoQuestionResult("Что такое Virtual DOM, и как он работает?", true), | ||
| InterviewQuizResultState.Loaded.VoQuestionResult("Что такое Virtual DOM, и как он работает?", false), | ||
| InterviewQuizResultState.Loaded.VoQuestionResult("Что такое Virtual DOM, и как он работает?", true), | ||
| InterviewQuizResultState.Loaded.VoQuestionResult("Что такое Virtual DOM, и как он работает?", false) | ||
| ) | ||
| ) | ||
| } |
32 changes: 32 additions & 0 deletions
32
...ain/java/ru/yeahub/interview_trainer/impl/interviewQuizResult/InterviewQuizResultState.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,32 @@ | ||
| import androidx.compose.runtime.Immutable | ||
| import kotlinx.collections.immutable.PersistentList | ||
|
|
||
|
arte123ras marked this conversation as resolved.
|
||
| @Immutable | ||
| sealed interface InterviewQuizResultState { | ||
| data object Loading : InterviewQuizResultState | ||
|
|
||
| data class Loaded( | ||
| val overallPercentage: Float, | ||
| val totalQuestions: Int, | ||
| val newQuestions: Int, | ||
| val inProgress: Int, | ||
| val studied: Int, | ||
| val skills: PersistentList<VoSkillStat>, | ||
| val questions: PersistentList<VoQuestionResult> | ||
| ) : InterviewQuizResultState { | ||
| @Immutable | ||
| data class VoSkillStat( | ||
| val name: String, | ||
| val current: Int, | ||
| val max: Int | ||
| ) | ||
|
|
||
| @Immutable | ||
| data class VoQuestionResult( | ||
| val questionText: String, | ||
| val isCorrect: Boolean | ||
| ) | ||
| } | ||
|
|
||
| data class Error(val throwable: Throwable) : InterviewQuizResultState | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
...java/ru/yeahub/interview_trainer/impl/interviewQuizResult/InterviewQuizResultViewModel.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,29 @@ | ||
| import androidx.lifecycle.viewModelScope | ||
| import kotlinx.coroutines.flow.SharingStarted | ||
| import kotlinx.coroutines.flow.StateFlow | ||
| import kotlinx.coroutines.flow.flow | ||
| import kotlinx.coroutines.flow.stateIn | ||
| import ru.yeahub.core_utils.BaseViewModel | ||
| import ru.yeahub.interview_trainer.impl.interviewQuizResult.InterviewQuizResultEvent | ||
| import ru.yeahub.interview_trainer.impl.interviewQuizResult.InterviewQuizResultScreenMapper | ||
|
|
||
| private const val STOP_TIMEOUT_MILLIS = 5000L | ||
|
|
||
| class InterviewQuizResultViewModel( | ||
| private val mapper: InterviewQuizResultScreenMapper | ||
| ) : BaseViewModel() { | ||
|
|
||
| val state: StateFlow<InterviewQuizResultState> = | ||
| flow { | ||
| emit(mapper.getScreenState()) | ||
| } | ||
| .stateIn( | ||
| scope = viewModelScope, | ||
| started = SharingStarted.WhileSubscribed(STOP_TIMEOUT_MILLIS), | ||
| initialValue = InterviewQuizResultState.Loading | ||
| ) | ||
|
|
||
| fun onEvent(event: InterviewQuizResultEvent) { | ||
| // TODO: | ||
| } | ||
| } |
Oops, something went wrong.
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.
А почему не твой экран с изменениями? Откати изменения чтоб не было конфликта (но вообще странно, что изменения показываются как дифф. По идеи вроде Иван подлил и конфликтов не будет, но хз. Мб у Антона уточнить(?))