Modern Apps git

← Modern-Apps.git

pipes: use shared scaffolds (no raw Scaffold)

Commit
5dbeaa6f971826ac600755dd926cefa60b9bf46b
Author
vayun-mathur <[email protected]>
When
2026-08-16 03:06 UTC (3 months ago)
Parents
53247d3

Diff

games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/DailyLevelScreen.kt
diff --git a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/DailyLevelScreen.kt b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/DailyLevelScreen.ktindex 1e518258ac..fadb0c3c4f 100644--- a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/DailyLevelScreen.kt+++ b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/DailyLevelScreen.kt@@ -23,16 +23,14 @@ import androidx.compose.ui.unit.dp import com.vayunmathur.games.pipes.R import com.vayunmathur.games.pipes.Route import com.vayunmathur.games.pipes.platform.PipesViewModel+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.CircularProgressIndicator import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.IconCheck-import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.library.ui.IconStar-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar import com.vayunmathur.library.util.NavBackStack  @OptIn(ExperimentalMaterial3Api::class)@@ -41,9 +39,9 @@ fun DailyLevelScreen(backStack: NavBackStack<Route>, viewModel: PipesViewModel)     val dailyPack by viewModel.dailyPack.collectAsState()     val dailyStats by viewModel.dailyStats.collectAsState()     LaunchedEffect(Unit) { viewModel.refreshDaily() }-    Scaffold(topBar = { TopAppBar({ Text(stringResource(R.string.daily_challenge)) }, navigationIcon = { IconNavigation(backStack) }) }) { paddingValues ->+    AppScaffold(title = stringResource(R.string.daily_challenge), backStack = backStack) { paddingValues ->         val levels = dailyPack?.levels-        if (levels == null) { Box(Modifier.fillMaxSize().padding(paddingValues), Alignment.Center) { CircularProgressIndicator() }; return@Scaffold }+        if (levels == null) { Box(Modifier.fillMaxSize().padding(paddingValues), Alignment.Center) { CircularProgressIndicator() }; return@AppScaffold }         LazyVerticalGrid(GridCells.Adaptive(88.dp), Modifier.fillMaxSize(), contentPadding = paddingValues + PaddingValues(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 0.dp), verticalArrangement = Arrangement.spacedBy(12.dp), horizontalArrangement = Arrangement.spacedBy(12.dp)) {             itemsIndexed(levels) { index, levelData -> Card(Modifier.fillMaxWidth().clickable { backStack.add(Route.DailyGame(index)) }, colors = CardDefaults.cardColors(com.vayunmathur.library.ui.MaterialTheme.colorScheme.surface)) { Box(Modifier.fillMaxSize().padding(8.dp)) { Text("${index + 1}", Modifier.align(Alignment.Center)); val levelStat = dailyStats[levelData.id]; Box(Modifier.size(20.dp).align(Alignment.CenterEnd), Alignment.Center) { when { levelStat == null -> return@Box; levelStat.bestScore <= levelData.optimalMoves -> IconStar(); else -> IconCheck() } } } } }         }
games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoardScreen.kt
diff --git a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoardScreen.kt b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoardScreen.ktindex ea1ae66174..37aecdc958 100644--- a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoardScreen.kt+++ b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoardScreen.kt@@ -19,20 +19,18 @@ import com.vayunmathur.games.pipes.platform.GameBoardUiState import com.vayunmathur.games.pipes.platform.PipesActions import com.vayunmathur.games.pipes.ui.components.MovesInfoBox import com.vayunmathur.games.pipes.ui.components.PuzzleInfoBox+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar import com.vayunmathur.library.ui.R as UiR  @OptIn(ExperimentalMaterial3Api::class) @Composable fun GameBoardScreen(state: GameBoardUiState, actions: PipesActions, onBack: () -> Unit, onLevelChange: (Int) -> Unit) {-    Scaffold(topBar = { TopAppBar({}, navigationIcon = { IconNavigation(onBack) }) }) { innerPadding ->+    AppScaffold(title = "", onNavigateBack = onBack) { innerPadding ->         Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {             val infoBoxes = @Composable { PuzzleInfoBox(levelIndex = state.levelIndex, onLevelChange = onLevelChange, isCompleted = state.isCompleted, maxLevelIndex = state.maxLevelIndex); MovesInfoBox(moves = state.moves, bestScore = state.bestScore, optimalMoves = state.levelData.optimalMoves) }             val actionButtons = @Composable { if (!state.isLevelWon) { Button(onClick = { actions.onUndo() }, enabled = state.canUndo) { Text(stringResource(UiR.string.undo)) }; Button(onClick = { actions.onRestart() }, enabled = state.canUndo) { Text(stringResource(R.string.restart)) } } else if (state.levelIndex < state.maxLevelIndex) { Button(onClick = { onLevelChange(state.levelIndex + 1) }) { Text(stringResource(R.string.next_level)) } } }
games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/LevelScreen.kt
diff --git a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/LevelScreen.kt b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/LevelScreen.ktindex ee8dcb64cc..dad7d9b16b 100644--- a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/LevelScreen.kt+++ b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/LevelScreen.kt@@ -24,15 +24,13 @@ import com.vayunmathur.games.pipes.Route import com.vayunmathur.games.pipes.data.LevelPack import com.vayunmathur.games.pipes.platform.PipesViewModel import com.vayunmathur.games.pipes.ui.components.LevelThumbnail+import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.IconCheck-import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.library.ui.IconStar-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar import com.vayunmathur.library.util.NavBackStack  @OptIn(ExperimentalMaterial3Api::class)@@ -40,7 +38,7 @@ import com.vayunmathur.library.util.NavBackStack fun LevelScreen(backStack: NavBackStack<Route>, viewModel: PipesViewModel, packIndex: Int) {     val pack = LevelPack.PACKS[packIndex]     val levelStats by viewModel.levelStats.collectAsState()-    Scaffold(topBar = { TopAppBar({ Text(stringResource(R.string.level_selector)) }, navigationIcon = { IconNavigation(backStack) }) }) { paddingValues ->+    AppScaffold(title = stringResource(R.string.level_selector), backStack = backStack) { paddingValues ->         LazyVerticalGrid(GridCells.Adaptive(88.dp), Modifier.fillMaxSize(), contentPadding = paddingValues + PaddingValues(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 0.dp), verticalArrangement = Arrangement.spacedBy(12.dp), horizontalArrangement = Arrangement.spacedBy(12.dp)) {             itemsIndexed(pack.levels) { index, levelData -> Card(Modifier.fillMaxWidth().clickable { backStack.add(Route.Game(packIndex, index)) }, colors = CardDefaults.cardColors(com.vayunmathur.library.ui.MaterialTheme.colorScheme.surface)) { Box(Modifier.fillMaxSize().padding(8.dp)) { if (levelData.cells.size < levelData.rows * levelData.cols) { LevelThumbnail(levelData, Modifier.size(24.dp).align(Alignment.CenterStart)) }; Text("${index + 1}", Modifier.align(Alignment.Center)); val levelStat = levelStats[levelData.id]; Box(Modifier.size(20.dp).align(Alignment.CenterEnd), Alignment.Center) { when { levelStat == null -> return@Box; levelStat.bestScore <= levelData.optimalMoves -> IconStar(); else -> IconCheck() } } } } }         }
games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/PackListScreen.kt
diff --git a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/PackListScreen.kt b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/PackListScreen.ktindex 3d15d5a2ae..7448f67724 100644--- a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/PackListScreen.kt+++ b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/PackListScreen.kt@@ -3,13 +3,9 @@ package com.vayunmathur.games.pipes.ui import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.plus-import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment@@ -23,22 +19,19 @@ import com.vayunmathur.games.pipes.platform.PackProgress import com.vayunmathur.games.pipes.ui.components.DailyCard import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.CardDefaults+import com.vayunmathur.library.ui.DetailLazyColumn import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.Icon import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconSettings import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar  @OptIn(ExperimentalMaterial3Api::class) @Composable fun PackListScreen(packs: List<PackProgress>, onOpenPack: (Int) -> Unit, onOpenSettings: () -> Unit, onOpenGameCenter: () -> Unit, daily: DailyProgress? = null, onOpenDaily: () -> Unit = {}) {-    Scaffold(topBar = { TopAppBar(title = { Text(stringResource(R.string.pack_selector)) }, actions = { IconButton(onClick = onOpenSettings) { IconSettings() }; IconButton(onClick = onOpenGameCenter) { Icon(painterResource(id = android.R.drawable.btn_star_big_on), "Achievements") } }) }) { paddingValues ->-        LazyColumn(Modifier.fillMaxSize(), contentPadding = paddingValues + PaddingValues(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 0.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {-            daily?.let { item { DailyCard(it, onOpenDaily) } }-            itemsIndexed(packs) { index, pack -> Card(Modifier.clickable { onOpenPack(index) }, colors = CardDefaults.cardColors(MaterialTheme.colorScheme.surface)) { Row(Modifier.fillMaxWidth().padding(16.dp), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) { Column { Text(pack.name, style = MaterialTheme.typography.headlineMedium); Text(pack.shape.replaceFirstChar { it.uppercase() }, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)) }; Text("${pack.completed}/${pack.total}", style = MaterialTheme.typography.titleMedium) } } }-        }+    DetailLazyColumn(title = stringResource(R.string.pack_selector), actions = { IconButton(onClick = onOpenSettings) { IconSettings() }; IconButton(onClick = onOpenGameCenter) { Icon(painterResource(id = android.R.drawable.btn_star_big_on), "Achievements") } }) {+        daily?.let { item { DailyCard(it, onOpenDaily) } }+        itemsIndexed(packs) { index, pack -> Card(Modifier.clickable { onOpenPack(index) }, colors = CardDefaults.cardColors(MaterialTheme.colorScheme.surface)) { Row(Modifier.fillMaxWidth().padding(16.dp), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) { Column { Text(pack.name, style = MaterialTheme.typography.headlineMedium); Text(pack.shape.replaceFirstChar { it.uppercase() }, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)) }; Text("${pack.completed}/${pack.total}", style = MaterialTheme.typography.titleMedium) } } }     } }
games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/SettingsScreen.kt
diff --git a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/SettingsScreen.kt b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/SettingsScreen.ktindex aea91538fe..d570cc98f1 100644--- a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/SettingsScreen.kt+++ b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/SettingsScreen.kt@@ -3,7 +3,6 @@ package com.vayunmathur.games.pipes.ui import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable@@ -16,13 +15,11 @@ import androidx.compose.ui.unit.dp import com.vayunmathur.games.pipes.R import com.vayunmathur.games.pipes.Route import com.vayunmathur.games.pipes.platform.PipesViewModel+import com.vayunmathur.library.ui.DetailScaffold import com.vayunmathur.library.ui.ExperimentalMaterial3Api-import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Switch import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.ui.R as UiR @@ -30,12 +27,10 @@ import com.vayunmathur.library.ui.R as UiR @Composable fun SettingsScreen(backStack: NavBackStack<Route>, viewModel: PipesViewModel) {     val colorblind by viewModel.colorblind.collectAsState()-    Scaffold(topBar = { TopAppBar({ Text(stringResource(UiR.string.settings)) }, navigationIcon = { IconNavigation(backStack) }) }) { paddingValues ->-        Column(Modifier.fillMaxSize().padding(paddingValues).padding(16.dp)) {-            Row(Modifier.fillMaxWidth().padding(vertical = 8.dp), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) {-                Column(Modifier.weight(1f)) { Text(stringResource(R.string.colorblind_mode), style = MaterialTheme.typography.titleMedium); Text(stringResource(R.string.colorblind_mode_desc), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)) }-                Switch(checked = colorblind, onCheckedChange = { viewModel.setColorblind(it) })-            }+    DetailScaffold(title = stringResource(UiR.string.settings), backStack = backStack) {+        Row(Modifier.fillMaxWidth().padding(vertical = 8.dp), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) {+            Column(Modifier.weight(1f)) { Text(stringResource(R.string.colorblind_mode), style = MaterialTheme.typography.titleMedium); Text(stringResource(R.string.colorblind_mode_desc), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)) }+            Switch(checked = colorblind, onCheckedChange = { viewModel.setColorblind(it) })         }     } }