mirror of
https://github.com/AdrianKuta/KahootQuiz.git
synced 2025-09-14 17:24:21 +02:00
This commit enhances the `QuizScreen` to be interactive, allowing users to select choices and view revealed answers. It also introduces HTML parsing for question text and adds new design elements like icons and colors. Key changes: - **UI Layer (`ui:quiz` module):** - `QuizScreen`: - Now takes an `onSelect` callback to handle choice selection. - `Choices` composable updated to display choices in a `LazyVerticalGrid` and handles click events. - Introduced `ChoiceItem` which branches into `ChoiceItemDefault` (for selectable choices) and `ChoiceItemRevealed` (for displaying correct/incorrect answers). - `ChoiceItemDefault` displays choices with background colors and icons based on their index. - `ChoiceItemRevealed` displays choices with background colors indicating correctness (green for correct, red for incorrect selected, pink for incorrect unselected) and appropriate icons (tick for correct, cross for wrong). - `QuestionContent` now parses HTML in the question text using `HtmlCompat` and a new `toAnnotatedString` extension. - Image loading in `QuestionContent` uses `ContentScale.FillWidth` and `heightIn(min = 200.dp)`. - Added a new preview `QuizScreenRevealedAnswerPreview` to showcase the revealed answer state. - `QuizScreenViewModel`: - Now manages `_selectedChoiceIndex` to track the user's answer. - `uiState` is now a combination of the fetched quiz and the `_selectedChoiceIndex`, producing `QuizUiState` which includes an `AnswerUiState`. - `AnswerUiState` holds the `selectedChoiceIndex`. - Implemented `onChoiceSelected(index: Int)` to update the selected choice. - **Design System (`core:designsystem` module):** - Added `TextUtils.kt` with a `Spanned.toAnnotatedString()` extension function to convert HTML formatted text (from `HtmlCompat`) into Jetpack Compose `AnnotatedString`. - Added new color definitions: `Pink`, `Red`, `Red2`, `Blue2`, `Yellow3`, `Green`, `Green2`. - Added a `contrastiveTo(color: Color)` utility function to determine a contrasting text color (black or white) for a given background color. - Added new vector drawables for choice shapes and correctness indicators: - `ic_circle.xml` - `ic_correct.xml` - `ic_diamond.xml` - `ic_square.xml` - `ic_triangle.xml` - `ic_wrong.xml` - Added Detekt configuration file (`config/detekt/detekt.yml`) for the design system module. - **Domain Layer (`domain` module):** - `Question.image` is now nullable (`String?`). - `Choice.correct` is now non-nullable (`Boolean`). - **Network Layer (`core:network` module):** - `ChoiceDto.correct` is now non-nullable (`Boolean`) to align with the domain model. - **Project Configuration:** - Added `.editorconfig` with Kotlin specific trailing comma settings. - Minor reordering of dependencies in `gradle/libs.versions.toml`.
33 lines
810 B
YAML
33 lines
810 B
YAML
# Exceptions for compose. See https://detekt.dev/docs/introduction/compose
|
|
naming:
|
|
FunctionNaming:
|
|
functionPattern: '[a-zA-Z][a-zA-Z0-9]*'
|
|
|
|
TopLevelPropertyNaming:
|
|
constantPattern: '[A-Z][A-Za-z0-9]*'
|
|
|
|
complexity:
|
|
LongParameterList:
|
|
ignoreAnnotated: ['Composable']
|
|
TooManyFunctions:
|
|
ignoreAnnotatedFunctions: ['Preview']
|
|
|
|
style:
|
|
MagicNumber:
|
|
ignorePropertyDeclaration: true
|
|
ignoreCompanionObjectPropertyDeclaration: true
|
|
ignoreAnnotated: ['Composable']
|
|
|
|
UnusedPrivateMember:
|
|
ignoreAnnotated: ['Composable']
|
|
|
|
# Deviations from defaults
|
|
formatting:
|
|
TrailingCommaOnCallSite:
|
|
active: true
|
|
autoCorrect: true
|
|
useTrailingCommaOnCallSite: true
|
|
TrailingCommaOnDeclarationSite:
|
|
active: true
|
|
autoCorrect: true
|
|
useTrailingCommaOnDeclarationSite: true |