mirror of
				https://github.com/AdrianKuta/KahootQuiz.git
				synced 2025-10-31 00:43:40 +01:00 
			
		
		
		
	Refactor: Move background image to main App composable and cleanup
This commit refactors the placement of the background image, moving it from `QuizScreen` to the main `KahootQuizApp` composable. This ensures the background is consistently applied across the app.
Additionally, this commit includes:
- Removal of unused Detekt configuration file (`ui/quiz/config/detekt/detekt.yml`).
- Minor code cleanup:
    - Removed commented-out code in `Theme.kt` and `Type.kt`.
    - Removed trailing blank lines in various domain model files.
    - Added `@file:Suppress("TooManyFunctions")` to `QuizMapper.kt`.
    - Added `@file:Suppress("MatchingDeclarationName")` to `QuizNavigation.kt`.
    - Used `1.seconds` instead of `1000` (Long) for delay in `QuizScreenViewModel`.
			
			
This commit is contained in:
		| @@ -1,10 +0,0 @@ | ||||
| # Deviations from defaults | ||||
| formatting: | ||||
|   TrailingCommaOnCallSite: | ||||
|     active: true | ||||
|     autoCorrect: true | ||||
|     useTrailingCommaOnCallSite: true | ||||
|   TrailingCommaOnDeclarationSite: | ||||
|     active: true | ||||
|     autoCorrect: true | ||||
|     useTrailingCommaOnDeclarationSite: true | ||||
| @@ -1,7 +1,6 @@ | ||||
| package dev.adriankuta.kahootquiz.ui.quiz | ||||
|  | ||||
| import androidx.compose.animation.animateContentSize | ||||
| import androidx.compose.foundation.Image | ||||
| import androidx.compose.foundation.layout.Box | ||||
| import androidx.compose.foundation.layout.Spacer | ||||
| import androidx.compose.foundation.layout.fillMaxSize | ||||
| @@ -20,8 +19,6 @@ import androidx.compose.runtime.getValue | ||||
| import androidx.compose.ui.Alignment | ||||
| import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.graphics.Color | ||||
| import androidx.compose.ui.layout.ContentScale | ||||
| import androidx.compose.ui.res.painterResource | ||||
| import androidx.compose.ui.res.stringResource | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import androidx.compose.ui.unit.dp | ||||
| @@ -31,20 +28,18 @@ import dev.adriankuta.kahootquiz.core.designsystem.Grey | ||||
| import dev.adriankuta.kahootquiz.core.designsystem.KahootQuizTheme | ||||
| import dev.adriankuta.kahootquiz.domain.models.Choice | ||||
| import dev.adriankuta.kahootquiz.domain.models.Question | ||||
| import dev.adriankuta.kahootquiz.ui.quiz.components.Choices | ||||
| import dev.adriankuta.kahootquiz.ui.quiz.components.AnswerFeedbackBanner | ||||
| import dev.adriankuta.kahootquiz.ui.quiz.components.Choices | ||||
| import dev.adriankuta.kahootquiz.ui.quiz.components.QuestionContent | ||||
| import dev.adriankuta.kahootquiz.ui.quiz.components.TimerBar | ||||
| import dev.adriankuta.kahootquiz.ui.quiz.components.Toolbar | ||||
| import kotlin.time.Duration.Companion.seconds | ||||
| import dev.adriankuta.kahootquiz.core.designsystem.R as DesignR | ||||
|  | ||||
| @Composable | ||||
| fun QuizScreen( | ||||
|     modifier: Modifier = Modifier, | ||||
|     viewModel: QuizScreenViewModel = hiltViewModel(), | ||||
| ) { | ||||
|  | ||||
|     val uiState by viewModel.uiState.collectAsStateWithLifecycle() | ||||
|  | ||||
|     QuizScreen( | ||||
| @@ -63,12 +58,6 @@ private fun QuizScreen( | ||||
|     modifier: Modifier = Modifier, | ||||
| ) { | ||||
|     Box(modifier.fillMaxSize()) { | ||||
|         Image( | ||||
|             painter = painterResource(id = DesignR.drawable.bg_image), | ||||
|             contentDescription = null, | ||||
|             contentScale = ContentScale.Crop, | ||||
|             modifier = Modifier.fillMaxSize(), | ||||
|         ) | ||||
|         when (uiState) { | ||||
|             ScreenUiState.Loading -> QuizScreenLoading() | ||||
|             is ScreenUiState.Success -> QuizScreenSuccess( | ||||
| @@ -76,7 +65,6 @@ private fun QuizScreen( | ||||
|                 onSelect = onSelect, | ||||
|                 onContinue = onContinue, | ||||
|             ) | ||||
|  | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.flow | ||||
| import kotlinx.coroutines.flow.stateIn | ||||
| import kotlinx.coroutines.launch | ||||
| import javax.inject.Inject | ||||
| import kotlin.time.Duration.Companion.seconds | ||||
|  | ||||
| @HiltViewModel | ||||
| class QuizScreenViewModel @Inject constructor( | ||||
| @@ -78,7 +79,6 @@ class QuizScreenViewModel @Inject constructor( | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     } | ||||
|         .stateIn( | ||||
|             scope = viewModelScope, | ||||
| @@ -124,7 +124,7 @@ class QuizScreenViewModel @Inject constructor( | ||||
|         timerJob = viewModelScope.launch { | ||||
|             var remaining = totalSeconds | ||||
|             while (remaining > 0) { | ||||
|                 delay(1000) | ||||
|                 delay(1.seconds) | ||||
|                 remaining -= 1 | ||||
|                 _remainingTimeSeconds.value = remaining | ||||
|             } | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| @file:Suppress("MatchingDeclarationName") | ||||
|  | ||||
| package dev.adriankuta.kahootquiz.ui.quiz.navigation | ||||
|  | ||||
| import androidx.navigation.NavGraphBuilder | ||||
| @@ -12,4 +14,4 @@ fun NavGraphBuilder.quizScreen() { | ||||
|     composable<QuizRoute> { | ||||
|         QuizScreen() | ||||
|     } | ||||
| } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user