mirror of
https://github.com/AdrianKuta/KahootQuiz.git
synced 2025-09-14 17:24:21 +02: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,11 +1,16 @@
|
|||||||
package dev.adriankuta.kahootquiz
|
package dev.adriankuta.kahootquiz
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.safeDrawing
|
import androidx.compose.foundation.layout.safeDrawing
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.layout.ContentScale
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import dev.adriankuta.kahootquiz.core.designsystem.R as DesignR
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun KahootQuizApp(
|
fun KahootQuizApp(
|
||||||
@@ -15,6 +20,12 @@ fun KahootQuizApp(
|
|||||||
contentWindowInsets = WindowInsets.safeDrawing,
|
contentWindowInsets = WindowInsets.safeDrawing,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
KahootQuizNavGraph(modifier = modifier.padding(paddingValues))
|
Image(
|
||||||
|
painter = painterResource(id = DesignR.drawable.bg_image),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
)
|
||||||
|
KahootQuizNavGraph(modifier = Modifier.padding(paddingValues))
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -28,7 +28,8 @@ fun Spanned.toAnnotatedString(): AnnotatedString = buildAnnotatedString {
|
|||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
fontStyle = FontStyle.Italic,
|
fontStyle = FontStyle.Italic,
|
||||||
),
|
),
|
||||||
start, end,
|
start,
|
||||||
|
end,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,16 +20,6 @@ private val LightColorScheme = lightColorScheme(
|
|||||||
primary = Purple40,
|
primary = Purple40,
|
||||||
secondary = PurpleGrey40,
|
secondary = PurpleGrey40,
|
||||||
tertiary = Pink40,
|
tertiary = Pink40,
|
||||||
|
|
||||||
/* Other default colors to override
|
|
||||||
background = Color(0xFFFFFBFE),
|
|
||||||
surface = Color(0xFFFFFBFE),
|
|
||||||
onPrimary = Color.White,
|
|
||||||
onSecondary = Color.White,
|
|
||||||
onTertiary = Color.White,
|
|
||||||
onBackground = Color(0xFF1C1B1F),
|
|
||||||
onSurface = Color(0xFF1C1B1F),
|
|
||||||
*/
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@@ -15,20 +15,4 @@ val Typography = Typography(
|
|||||||
lineHeight = 24.sp,
|
lineHeight = 24.sp,
|
||||||
letterSpacing = 0.5.sp,
|
letterSpacing = 0.5.sp,
|
||||||
),
|
),
|
||||||
/* Other default text styles to override
|
|
||||||
titleLarge = TextStyle(
|
|
||||||
fontFamily = FontFamily.Default,
|
|
||||||
fontWeight = FontWeight.Normal,
|
|
||||||
fontSize = 22.sp,
|
|
||||||
lineHeight = 28.sp,
|
|
||||||
letterSpacing = 0.sp
|
|
||||||
),
|
|
||||||
labelSmall = TextStyle(
|
|
||||||
fontFamily = FontFamily.Default,
|
|
||||||
fontWeight = FontWeight.Medium,
|
|
||||||
fontSize = 11.sp,
|
|
||||||
lineHeight = 16.sp,
|
|
||||||
letterSpacing = 0.5.sp
|
|
||||||
)
|
|
||||||
*/
|
|
||||||
)
|
)
|
@@ -1,3 +1,5 @@
|
|||||||
|
@file:Suppress("TooManyFunctions")
|
||||||
|
|
||||||
package dev.adriankuta.kahootquiz.model.data.mappers
|
package dev.adriankuta.kahootquiz.model.data.mappers
|
||||||
|
|
||||||
import dev.adriankuta.kahootquiz.core.network.models.AccessDto
|
import dev.adriankuta.kahootquiz.core.network.models.AccessDto
|
||||||
|
@@ -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
|
package dev.adriankuta.kahootquiz.ui.quiz
|
||||||
|
|
||||||
import androidx.compose.animation.animateContentSize
|
import androidx.compose.animation.animateContentSize
|
||||||
import androidx.compose.foundation.Image
|
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
@@ -20,8 +19,6 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.ui.Alignment
|
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.layout.ContentScale
|
|
||||||
import androidx.compose.ui.res.painterResource
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
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.core.designsystem.KahootQuizTheme
|
||||||
import dev.adriankuta.kahootquiz.domain.models.Choice
|
import dev.adriankuta.kahootquiz.domain.models.Choice
|
||||||
import dev.adriankuta.kahootquiz.domain.models.Question
|
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.AnswerFeedbackBanner
|
||||||
|
import dev.adriankuta.kahootquiz.ui.quiz.components.Choices
|
||||||
import dev.adriankuta.kahootquiz.ui.quiz.components.QuestionContent
|
import dev.adriankuta.kahootquiz.ui.quiz.components.QuestionContent
|
||||||
import dev.adriankuta.kahootquiz.ui.quiz.components.TimerBar
|
import dev.adriankuta.kahootquiz.ui.quiz.components.TimerBar
|
||||||
import dev.adriankuta.kahootquiz.ui.quiz.components.Toolbar
|
import dev.adriankuta.kahootquiz.ui.quiz.components.Toolbar
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
import dev.adriankuta.kahootquiz.core.designsystem.R as DesignR
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun QuizScreen(
|
fun QuizScreen(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
viewModel: QuizScreenViewModel = hiltViewModel(),
|
viewModel: QuizScreenViewModel = hiltViewModel(),
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
|
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
QuizScreen(
|
QuizScreen(
|
||||||
@@ -63,12 +58,6 @@ private fun QuizScreen(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Box(modifier.fillMaxSize()) {
|
Box(modifier.fillMaxSize()) {
|
||||||
Image(
|
|
||||||
painter = painterResource(id = DesignR.drawable.bg_image),
|
|
||||||
contentDescription = null,
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
)
|
|
||||||
when (uiState) {
|
when (uiState) {
|
||||||
ScreenUiState.Loading -> QuizScreenLoading()
|
ScreenUiState.Loading -> QuizScreenLoading()
|
||||||
is ScreenUiState.Success -> QuizScreenSuccess(
|
is ScreenUiState.Success -> QuizScreenSuccess(
|
||||||
@@ -76,7 +65,6 @@ private fun QuizScreen(
|
|||||||
onSelect = onSelect,
|
onSelect = onSelect,
|
||||||
onContinue = onContinue,
|
onContinue = onContinue,
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.flow
|
|||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class QuizScreenViewModel @Inject constructor(
|
class QuizScreenViewModel @Inject constructor(
|
||||||
@@ -78,7 +79,6 @@ class QuizScreenViewModel @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
.stateIn(
|
.stateIn(
|
||||||
scope = viewModelScope,
|
scope = viewModelScope,
|
||||||
@@ -124,7 +124,7 @@ class QuizScreenViewModel @Inject constructor(
|
|||||||
timerJob = viewModelScope.launch {
|
timerJob = viewModelScope.launch {
|
||||||
var remaining = totalSeconds
|
var remaining = totalSeconds
|
||||||
while (remaining > 0) {
|
while (remaining > 0) {
|
||||||
delay(1000)
|
delay(1.seconds)
|
||||||
remaining -= 1
|
remaining -= 1
|
||||||
_remainingTimeSeconds.value = remaining
|
_remainingTimeSeconds.value = remaining
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
@file:Suppress("MatchingDeclarationName")
|
||||||
|
|
||||||
package dev.adriankuta.kahootquiz.ui.quiz.navigation
|
package dev.adriankuta.kahootquiz.ui.quiz.navigation
|
||||||
|
|
||||||
import androidx.navigation.NavGraphBuilder
|
import androidx.navigation.NavGraphBuilder
|
||||||
|
Reference in New Issue
Block a user