mirror of
https://github.com/AdrianKuta/KahootQuiz.git
synced 2025-09-14 17:24:21 +02:00
f0bd963d2d2f9c681ceb5bbd13dce70550b89ccb
This commit introduces a timer for questions in the `QuizScreen` and updates the toolbar to display the current question number out of the total. Key changes: - **UI Layer (`ui:quiz` module):** - In `QuizScreen.kt`: - Added a `TimerBar` composable to visually represent the remaining time for a question. This bar animates its width and displays the remaining seconds. - Updated the `Toolbar` composable to display the current question index and total number of questions (e.g., "1/10"). - Passed `currentQuestionIndex`, `totalQuestions`, `totalTimeSeconds`, and `remainingTimeSeconds` from `QuizUiState` to the respective composables. - Updated previews to reflect new `QuizUiState` properties. - Used `RoundedCornerShape(percent = 50)` for more consistent rounded corners in the `Toolbar`. - In `QuizScreenViewModel.kt`: - Added `_remainingTimeSeconds` MutableStateFlow to track the countdown. - Modified `QuizUiState` to include `currentQuestionIndex`, `totalQuestions`, `totalTimeSeconds`, and `remainingTimeSeconds`. - Implemented `startCountdown()` logic to decrease `_remainingTimeSeconds` every second. - The timer is started when the ViewModel is initialized and for each new question. - When a choice is selected, the timer is cancelled. - If the timer runs out before a choice is selected, `_selectedChoiceIndex` is set to -1 to indicate a timeout. - The `uiState` flow now combines `getQuizUseCase()`, `_selectedChoiceIndex`, and `_remainingTimeSeconds` to derive the `QuizUiState`. - **Design System (`core:designsystem` module):** - Added `Purple` color definition in `Color.kt` for use in the `TimerBar`. - Reordered color definitions alphabetically.
Description
No description provided
Languages
Kotlin
100%