Refactor: Clean up imports and formatting in UI components

This commit addresses minor code style issues by removing unused imports and standardizing formatting across several UI components within the `ui:quiz` module.

Key changes:

- **`ui/quiz/QuizScreen.kt`**:
    - Added `modifier` parameter to `QuizScreenLoading`'s `CircularProgressIndicator`.
- **`ui/quiz/QuizScreenViewModel.kt`**:
    - Improved code formatting for readability, particularly around `timerState` updates and retrieving question times.
- **`ui/quiz/components/TimerBar.kt`**:
    - Removed unused import `androidx.compose.ui.draw.clipToBounds`.
- **`ui/quiz/components/QuestionContent.kt`**:
    - Reordered imports alphabetically.
- **`ui/quiz/components/Choices.kt`**:
    - Removed unused import `androidx.compose.foundation.layout.width`.
- **`ui/quiz/components/Toolbar.kt`**:
    - Removed unused imports `androidx.compose.foundation.layout.fillMaxWidth` and `androidx.compose.foundation.layout.height`.
This commit is contained in:
2025-09-04 21:31:55 +02:00
parent 3194d2a813
commit 12638f33d8
6 changed files with 11 additions and 11 deletions

View File

@@ -84,7 +84,9 @@ private fun QuizScreen(
private fun QuizScreenLoading( private fun QuizScreenLoading(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
CircularProgressIndicator() CircularProgressIndicator(
modifier = modifier,
)
} }
@Composable @Composable

View File

@@ -42,7 +42,8 @@ class QuizScreenViewModel @Inject constructor(
if (quizState is QuizUiState.Success) { if (quizState is QuizUiState.Success) {
// Start only if timer hasn't been started yet and we are on the first question // Start only if timer hasn't been started yet and we are on the first question
if (timerJob == null && _currentQuestionIndex.value == 0) { if (timerJob == null && _currentQuestionIndex.value == 0) {
val firstQuestionTime = quizState.quiz.questions.getOrNull(0)?.time?.inWholeSeconds?.toInt() val firstQuestionTime =
quizState.quiz.questions.getOrNull(0)?.time?.inWholeSeconds?.toInt()
startCountdown(firstQuestionTime) startCountdown(firstQuestionTime)
} }
} }
@@ -69,7 +70,7 @@ class QuizScreenViewModel @Inject constructor(
timerState = TimerState( timerState = TimerState(
remainingTimeSeconds = remainingTimeSeconds, remainingTimeSeconds = remainingTimeSeconds,
totalTimeSeconds = currentQuestion?.time?.inWholeSeconds?.toInt() ?: 0, totalTimeSeconds = currentQuestion?.time?.inWholeSeconds?.toInt() ?: 0,
) ),
) )
} }
} }
@@ -96,7 +97,8 @@ class QuizScreenViewModel @Inject constructor(
if (nextIndex < total) { if (nextIndex < total) {
_selectedChoiceIndex.value = null _selectedChoiceIndex.value = null
_currentQuestionIndex.value = nextIndex _currentQuestionIndex.value = nextIndex
val nextQuestionTime = quizState.quiz.questions[nextIndex].time?.inWholeSeconds?.toInt() val nextQuestionTime =
quizState.quiz.questions[nextIndex].time?.inWholeSeconds?.toInt()
startCountdown(nextQuestionTime) startCountdown(nextQuestionTime)
} else { } else {
// Last question reached: stop timer and keep state (could navigate to results in the future) // Last question reached: stop timer and keep state (could navigate to results in the future)

View File

@@ -7,10 +7,9 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable

View File

@@ -4,16 +4,16 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat

View File

@@ -15,7 +15,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.draw.clipToBounds
import dev.adriankuta.kahootquiz.core.designsystem.Purple import dev.adriankuta.kahootquiz.core.designsystem.Purple
@Composable @Composable

View File

@@ -5,8 +5,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width