alchemist: add clear icon #216 + fix all_discovered achievement #223
- Commit
daa7b5851511e6611e810f2f1ad44cd0593459e8- Author
- Vayun Mathur <[email protected]>
- When
- 2026-06-14 23:23 UTC (5 months ago)
- Parents
7e6c35d
Diff
games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.kt
diff --git a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.kt b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.ktindex e08905b816..195e10a8d5 100644--- a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.kt+++ b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.kt@@ -114,14 +114,18 @@ fun HomeScreen( Scaffold( topBar = { TopAppBar(title = { Text(stringResource(R.string.app_name)) }, actions = {+ if (activeItems.isNotEmpty()) {+ IconButton(onClick = { viewModel.clearElements() }) {+ Icon(+ painterResource(id = android.R.drawable.ic_menu_close_clear_cancel), "Clear"+ )+ }+ } IconButton(onClick = onOpenGameCenter) { Icon( painterResource(id = android.R.drawable.btn_star_big_on), "Achievements" ) }- com.vayunmathur.library.ui.BackupButtons(- datastoreNames = listOf("datastore_default")- ) }) }) { paddingValues -> Box(
games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistViewModel.kt
diff --git a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistViewModel.kt b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistViewModel.ktindex b5992d70fd..cda4b70238 100644--- a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistViewModel.kt+++ b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistViewModel.kt@@ -130,6 +130,10 @@ class AlchemistViewModel(application: Application) : AndroidViewModel(applicatio _placedElements.update { it + duplicatedItem } } + fun clearElements() {+ _placedElements.update { emptyList() }+ }+ /** * Test the moved element against the other placed elements for a recipe match. * If found, removes the two inputs, adds the outputs at the target's position,@@ -181,6 +185,7 @@ class AlchemistViewModel(application: Application) : AndroidViewModel(applicatio if (items.size > 4) achievementsManager.onAchievementUnlocked("first_creation") achievementsManager.onProgressUpdated("collector_50", items.size) achievementsManager.onProgressUpdated("collector_100", items.size)+ achievementsManager.onProgressUpdated("all_discovered", items.size) val all = _allItems.value if (items.size >= all.size && all.isNotEmpty()) {