mirror of
https://github.com/AdrianKuta/KahootQuiz.git
synced 2025-09-14 09:15:59 +02:00
Refactor: Clean up QuizScreen and adjust image scaling
This commit includes several refactoring changes and a minor UI adjustment: - **UI Layer (`ui:quiz` module):** - In `QuizScreen.kt`: - Removed the unused `timer` extension function for `LazyListScope`. - Applied `@Suppress("LongMethod")` to `QuizScreenSuccess` composable. - Simplified the `modifier` usage within the `Box` in `QuizScreenSuccess`. - In `components/QuestionContent.kt`: - Changed `ContentScale` for `AsyncImage` from `FillWidth` to `Fit`. - Aligned the `AsyncImage` to `Alignment.CenterHorizontally`. - **Data Layer (`data` module):** - In `QuizRepositoryImpl.kt`: - Reordered import statements. Note: The commit also includes changes to a binary file `App.apk`, which are not detailed here.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package dev.adriankuta.kahootquiz.data
|
||||
|
||||
import dev.adriankuta.kahootquiz.core.network.retrofit.QuizApi
|
||||
import dev.adriankuta.kahootquiz.data.mappers.toDomainModel
|
||||
import dev.adriankuta.kahootquiz.domain.models.Quiz
|
||||
import dev.adriankuta.kahootquiz.domain.repositories.QuizRepository
|
||||
import dev.adriankuta.kahootquiz.data.mappers.toDomainModel
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class QuizRepositoryImpl @Inject constructor(
|
||||
|
@@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
@@ -79,6 +78,7 @@ private fun QuizScreenLoading(
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Suppress("LongMethod")
|
||||
private fun QuizScreenSuccess(
|
||||
uiState: ScreenUiState.Success,
|
||||
onSelect: (Int) -> Unit,
|
||||
@@ -90,7 +90,7 @@ private fun QuizScreenSuccess(
|
||||
.fillMaxWidth(),
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.height(72.dp),
|
||||
) {
|
||||
Toolbar(
|
||||
@@ -115,7 +115,6 @@ private fun QuizScreenSuccess(
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
|
||||
Choices(
|
||||
choices = uiState.currentQuestion.choices,
|
||||
selectedChoiceIndex = uiState.selectedChoiceIndex,
|
||||
@@ -150,22 +149,10 @@ private fun QuizScreenSuccess(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun LazyListScope.timer(uiState: ScreenUiState.Success) {
|
||||
item(key = "timer_${uiState.currentQuestionIndex}") {
|
||||
TimerBar(
|
||||
totalSeconds = uiState.timerState.totalTimeSeconds,
|
||||
remainingSeconds = uiState.timerState.remainingTimeSeconds,
|
||||
modifier = Modifier.padding(8.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun QuizScreenPreview() {
|
||||
|
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@@ -31,9 +32,10 @@ fun QuestionContent(
|
||||
AsyncImage(
|
||||
model = question.image,
|
||||
contentDescription = question.imageMetadata?.altText,
|
||||
contentScale = ContentScale.FillWidth,
|
||||
contentScale = ContentScale.Fit,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.clip(shape = RoundedCornerShape(4.dp)),
|
||||
)
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
Reference in New Issue
Block a user