mirror of
https://github.com/AdrianKuta/KahootQuiz.git
synced 2025-09-16 18:14:22 +02:00
feat: Enhance QuizScreen UI and introduce core design system module
This commit significantly revamps the `QuizScreen` UI to display question details including image and text, and introduces a new `core:designsystem` module to centralize theme, colors, typography, and drawable resources. Key changes: - **UI Layer (`ui:quiz` module):** - Updated `QuizScreen.kt`: - Implemented a background image for the screen. - Added a `Toolbar` composable to display question progress and type. - Created `QuestionContent` composable to show the question image (using Coil for image loading) and text. - Added a placeholder `Choices` composable (currently an empty `LazyVerticalGrid`). - Applied `fillMaxSize()` to the main `QuizScreen` modifier. - Included a `@Preview` for `QuizScreen` with sample data. - Modified `QuizScreenViewModel.kt` to update `QuizUiState` with the first `Question` from the fetched quiz. - Added a `quiz` string resource in `strings.xml`. - Added dependencies for Coil (compose and okhttp) in `ui/quiz/build.gradle.kts`. - **Core Design System (`core:designsystem` module):** - Created a new Android library module `core:designsystem`. - Moved `Color.kt`, `Theme.kt`, and `Type.kt` from `app/src/main/java/dev/adriankuta/kahootquiz/ui/theme` to this new module. - Added a new `Grey` color to `Color.kt`. - Added `bg_image.webp` and `ic_type.xml` drawable resources. - Configured the module with `kahootquiz.android.library.compose` plugin. - **App Module (`app` module):** - Updated `MainActivity.kt` to import `KahootQuizTheme` from the new `core.designsystem` package. - Added `implementation(projects.core.designsystem)` dependency in `app/build.gradle.kts`. - **Domain Layer (`domain` module):** - Made several fields in `Question.kt` and `Choice.kt` nullable and provided default null values to accommodate potential missing data from the API. - Specifically, `Question.image` is now non-nullable (`String`). - **Build System:** - Added `coilCompose` and `coilNetworkOkhttp` versions to `gradle/libs.versions.toml`. - Included `:core:designsystem` in `settings.gradle.kts`.
This commit is contained in:
@@ -27,10 +27,10 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.ui.quiz)
|
||||
implementation(projects.core.designsystem)
|
||||
implementation(projects.domain)
|
||||
|
||||
implementation(projects.model.data)
|
||||
implementation(projects.ui.quiz)
|
||||
|
||||
implementation(libs.androidx.activity.compose)
|
||||
implementation(libs.androidx.hilt.navigation.compose)
|
||||
|
@@ -5,7 +5,7 @@ import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import dev.adriankuta.kahootquiz.ui.theme.KahootQuizTheme
|
||||
import dev.adriankuta.kahootquiz.core.designsystem.KahootQuizTheme
|
||||
|
||||
@AndroidEntryPoint
|
||||
class MainActivity : ComponentActivity() {
|
||||
|
@@ -1,11 +0,0 @@
|
||||
package dev.adriankuta.kahootquiz.ui.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val Purple80 = Color(0xFFD0BCFF)
|
||||
val PurpleGrey80 = Color(0xFFCCC2DC)
|
||||
val Pink80 = Color(0xFFEFB8C8)
|
||||
|
||||
val Purple40 = Color(0xFF6650a4)
|
||||
val PurpleGrey40 = Color(0xFF625b71)
|
||||
val Pink40 = Color(0xFF7D5260)
|
@@ -1,58 +0,0 @@
|
||||
package dev.adriankuta.kahootquiz.ui.theme
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = Purple80,
|
||||
secondary = PurpleGrey80,
|
||||
tertiary = Pink80
|
||||
)
|
||||
|
||||
private val LightColorScheme = lightColorScheme(
|
||||
primary = Purple40,
|
||||
secondary = PurpleGrey40,
|
||||
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
|
||||
fun KahootQuizTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
// Dynamic color is available on Android 12+
|
||||
dynamicColor: Boolean = true,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val colorScheme = when {
|
||||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||
val context = LocalContext.current
|
||||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||
}
|
||||
|
||||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
typography = Typography,
|
||||
content = content
|
||||
)
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
package dev.adriankuta.kahootquiz.ui.theme
|
||||
|
||||
import androidx.compose.material3.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.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
|
||||
)
|
||||
*/
|
||||
)
|
Reference in New Issue
Block a user