mirror of
https://github.com/AdrianKuta/KahootQuiz.git
synced 2025-09-15 01:24:23 +02:00
feat: Display "Continue" button after answer selection and hide timer
This commit modifies the `QuizScreen` to show a "Continue" button once an answer is selected for the current question. The timer bar is hidden when an answer is chosen. Key changes: - **UI Layer (`ui:quiz` module):** - In `QuizScreen.kt`: - Conditionally display either the `TimerBar` or a `FilledTonalButton` with the text "Continue" based on whether `uiState.answer` is null. - The "Continue" button is styled with a grey background and black text. - Added a new string resource `continue_text` in `ui/quiz/src/main/res/values/strings.xml`.
This commit is contained in:
@@ -24,6 +24,8 @@ import androidx.compose.foundation.lazy.grid.GridCells
|
|||||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
import androidx.compose.foundation.lazy.grid.itemsIndexed
|
import androidx.compose.foundation.lazy.grid.itemsIndexed
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
import androidx.compose.material3.FilledTonalButton
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@@ -109,11 +111,27 @@ private fun QuizScreen(
|
|||||||
onSelect = onSelect,
|
onSelect = onSelect,
|
||||||
)
|
)
|
||||||
// Timer below choices
|
// Timer below choices
|
||||||
TimerBar(
|
if (uiState.answer == null) {
|
||||||
totalSeconds = uiState.totalTimeSeconds,
|
TimerBar(
|
||||||
remainingSeconds = uiState.remainingTimeSeconds,
|
totalSeconds = uiState.totalTimeSeconds,
|
||||||
modifier = Modifier.padding(8.dp),
|
remainingSeconds = uiState.remainingTimeSeconds,
|
||||||
)
|
modifier = Modifier.padding(8.dp),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
FilledTonalButton(
|
||||||
|
onClick = {},
|
||||||
|
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||||
|
colors = ButtonDefaults.filledTonalButtonColors().copy(
|
||||||
|
containerColor = Grey,
|
||||||
|
contentColor = Color.Black
|
||||||
|
),
|
||||||
|
shape = RoundedCornerShape(4.dp),
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.continue_text),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="quiz">Quiz</string>
|
<string name="quiz">Quiz</string>
|
||||||
|
<string name="continue_text">Continue</string>
|
||||||
</resources>
|
</resources>
|
Reference in New Issue
Block a user