education: remove onboarding screen
- Commit
5504b979b3b7169f83f756c699723471a5e372c2- Author
- Vayun Mathur <[email protected]>
- When
- 2026-07-16 18:18 UTC (4 months ago)
- Parents
c041dab
Diff
education/src/main/java/com/vayunmathur/education/MainActivity.kt
diff --git a/education/src/main/java/com/vayunmathur/education/MainActivity.kt b/education/src/main/java/com/vayunmathur/education/MainActivity.ktindex 9f10155294..4b71fbc70d 100644--- a/education/src/main/java/com/vayunmathur/education/MainActivity.kt+++ b/education/src/main/java/com/vayunmathur/education/MainActivity.kt@@ -28,7 +28,6 @@ import com.vayunmathur.education.ui.K2LessonPage import com.vayunmathur.education.ui.K2QuizPage import com.vayunmathur.education.ui.K2RewardPage import com.vayunmathur.education.ui.LessonPage-import com.vayunmathur.education.ui.OnboardingPage import com.vayunmathur.education.ui.ParentGatePage import com.vayunmathur.education.ui.ParentPage import com.vayunmathur.education.ui.QuizPage@@ -117,16 +116,12 @@ sealed interface Route : NavKey { data object Badges : Route } -/** Chooses onboarding vs. the main graph based on the (single) learner's state. */+/** Waits for the (single) learner row to load, then opens the catalog. */ @Composable fun RootNavigation(viewModel: EducationViewModel) { val learner by viewModel.learner.collectAsStateWithLifecycle()- val l = learner ?: return- if (!l.onboarded) {- OnboardingPage(viewModel)- } else {- MainGraph(viewModel)- }+ learner ?: return+ MainGraph(viewModel) } @Composable
education/src/main/java/com/vayunmathur/education/ui/HomePage.kt
diff --git a/education/src/main/java/com/vayunmathur/education/ui/HomePage.kt b/education/src/main/java/com/vayunmathur/education/ui/HomePage.ktindex 9de8a33fff..6eadf6dc79 100644--- a/education/src/main/java/com/vayunmathur/education/ui/HomePage.kt+++ b/education/src/main/java/com/vayunmathur/education/ui/HomePage.kt@@ -49,7 +49,7 @@ fun ScholarHomePage(backStack: NavBackStack<Route>, viewModel: EducationViewMode IconButton(onClick = { backStack.add(Route.Badges) }) { Icon(Icons.Filled.EmojiEvents, "Badges") }- IconButton(onClick = { backStack.add(Route.ParentGate) }) {+ IconButton(onClick = { openParentArea(backStack, viewModel) }) { IconSettings() } },@@ -150,3 +150,13 @@ fun navigateToModule(backStack: NavBackStack<Route>, type: ModuleType?, moduleId null -> {} } }++/**+ * Opens the parent area. Until a PIN has been set, this goes straight to the+ * parent settings (where the PIN can be created); once a PIN exists the entry+ * is protected by the PIN gate.+ */+fun openParentArea(backStack: NavBackStack<Route>, viewModel: EducationViewModel) {+ val route = if (viewModel.learner.value?.pinHash == null) Route.Parent else Route.ParentGate+ backStack.add(route)+}
education/src/main/java/com/vayunmathur/education/ui/OnboardingPage.kt
diff --git a/education/src/main/java/com/vayunmathur/education/ui/OnboardingPage.kt b/education/src/main/java/com/vayunmathur/education/ui/OnboardingPage.ktdeleted file mode 100644index 959cff154a..0000000000--- a/education/src/main/java/com/vayunmathur/education/ui/OnboardingPage.kt+++ /dev/null@@ -1,125 +0,0 @@-package com.vayunmathur.education.ui--import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Spacer-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.height-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.rememberScrollState-import androidx.compose.foundation.text.KeyboardOptions-import androidx.compose.foundation.verticalScroll-import androidx.compose.material3.Button-import androidx.compose.material3.DropdownMenuItem-import androidx.compose.material3.ExperimentalMaterial3Api-import androidx.compose.material3.ExposedDropdownMenuBox-import androidx.compose.material3.ExposedDropdownMenuDefaults-import androidx.compose.material3.ExposedDropdownMenuAnchorType-import androidx.compose.material3.MaterialTheme-import androidx.compose.material3.OutlinedTextField-import androidx.compose.material3.Scaffold-import androidx.compose.material3.Text-import androidx.compose.runtime.Composable-import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableIntStateOf-import androidx.compose.runtime.mutableStateOf-import androidx.compose.runtime.remember-import androidx.compose.runtime.setValue-import androidx.compose.ui.Modifier-import androidx.compose.ui.text.input.KeyboardType-import androidx.compose.ui.text.input.PasswordVisualTransformation-import androidx.compose.ui.unit.dp-import com.vayunmathur.education.content.Grades-import com.vayunmathur.education.util.EducationViewModel--@OptIn(ExperimentalMaterial3Api::class)-@Composable-fun OnboardingPage(viewModel: EducationViewModel) {- var name by remember { mutableStateOf("") }- var grade by remember { mutableIntStateOf(0) }- var pin by remember { mutableStateOf("") }- var gradeExpanded by remember { mutableStateOf(false) }-- Scaffold { padding ->- Column(- Modifier- .fillMaxSize()- .padding(padding)- .padding(24.dp)- .verticalScroll(rememberScrollState()),- verticalArrangement = Arrangement.spacedBy(16.dp),- ) {- Text("Welcome to Education", style = MaterialTheme.typography.headlineMedium)- Text(- "Let's set up this device for one learner. A grown-up sets a PIN to manage settings and deadlines.",- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )-- Spacer(Modifier.height(8.dp))-- OutlinedTextField(- value = name,- onValueChange = { name = it },- label = { Text("Learner's name") },- singleLine = true,- modifier = Modifier.fillMaxWidth(),- )-- ExposedDropdownMenuBox(- expanded = gradeExpanded,- onExpandedChange = { gradeExpanded = it },- ) {- OutlinedTextField(- value = Grades.label(grade),- onValueChange = {},- readOnly = true,- label = { Text("Grade") },- trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(gradeExpanded) },- modifier = Modifier- .fillMaxWidth()- .menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable),- )- ExposedDropdownMenu(- expanded = gradeExpanded,- onDismissRequest = { gradeExpanded = false },- ) {- Grades.all.forEach { g ->- DropdownMenuItem(- text = { Text(Grades.label(g)) },- onClick = {- grade = g- gradeExpanded = false- },- )- }- }- }-- Text(- "Band: ${bandLabel(Grades.bandForGrade(grade))}",- style = MaterialTheme.typography.bodySmall,- color = MaterialTheme.colorScheme.primary,- )-- OutlinedTextField(- value = pin,- onValueChange = { if (it.length <= 6 && it.all(Char::isDigit)) pin = it },- label = { Text("Parent PIN (4-6 digits)") },- singleLine = true,- visualTransformation = PasswordVisualTransformation(),- keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.NumberPassword),- modifier = Modifier.fillMaxWidth(),- )-- Button(- onClick = { viewModel.completeOnboarding(name, grade, pin) },- enabled = name.isNotBlank() && pin.length >= 4,- modifier = Modifier.fillMaxWidth(),- ) {- Text("Start learning")- }- }- }-}
education/src/main/java/com/vayunmathur/education/ui/Shell.kt
diff --git a/education/src/main/java/com/vayunmathur/education/ui/Shell.kt b/education/src/main/java/com/vayunmathur/education/ui/Shell.ktindex 4652c97284..0261c7763b 100644--- a/education/src/main/java/com/vayunmathur/education/ui/Shell.kt+++ b/education/src/main/java/com/vayunmathur/education/ui/Shell.kt@@ -9,19 +9,13 @@ import com.vayunmathur.education.util.EducationViewModel import com.vayunmathur.library.util.NavBackStack /**- * Band dispatchers. The same content spine is rendered by a different- * "shell" per band. Home and Course are the divergent entry surfaces; deeper- * screens (Unit/Lesson/Quiz/Results) are shared by the Explorer and Scholar- * shells. K-2 has its own fully bespoke, audio-first flow (see K2* screens)- * and does not use the shared Course/Unit/Lesson screens.+ * Band dispatchers. The catalog (Home) is a single, unified list of every+ * course and is shown to everyone. Deeper screens (Course/Unit/Lesson/Quiz/+ * Results) still adapt per band: Course diverges into Explorer/Scholar shells. */ @Composable fun HomePage(backStack: NavBackStack<Route>, viewModel: EducationViewModel) {- when (activeBand(viewModel)) {- Band.SCHOLAR -> ScholarHomePage(backStack, viewModel)- Band.ELEMENTARY -> ExplorerHomePage(backStack, viewModel)- Band.K2 -> K2HomePage(backStack, viewModel)- }+ ScholarHomePage(backStack, viewModel) } @Composable
education/src/main/java/com/vayunmathur/education/util/EducationViewModel.kt
diff --git a/education/src/main/java/com/vayunmathur/education/util/EducationViewModel.kt b/education/src/main/java/com/vayunmathur/education/util/EducationViewModel.ktindex 225db4143d..7641c0395e 100644--- a/education/src/main/java/com/vayunmathur/education/util/EducationViewModel.kt+++ b/education/src/main/java/com/vayunmathur/education/util/EducationViewModel.kt@@ -78,17 +78,6 @@ class EducationViewModel( // --- Onboarding + parent edits --------------------------------------- - fun completeOnboarding(name: String, gradeLevel: Int, pin: String) {- updateLearner {- it.copy(- name = name.trim(),- gradeLevel = gradeLevel,- pinHash = hashPin(pin),- onboarded = true,- )- }- }- fun setName(name: String) = updateLearner { it.copy(name = name.trim()) } fun setAvatar(avatar: String) = updateLearner { it.copy(avatar = avatar) } fun setGrade(gradeLevel: Int) = updateLearner { it.copy(gradeLevel = gradeLevel) }