Modern Apps git

← Modern-Apps.git

alchemist: adopt TopAppBarOverlay (title-less overlay bars)

Commit
65de0be0e843c0fa743adeb13aabc447bc3c8024
Author
vayun-mathur <[email protected]>
When
2026-08-15 20:21 UTC (3 months ago)
Parents
7eb5641

Diff

games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/CollectionScreen.kt
diff --git a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/CollectionScreen.kt b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/CollectionScreen.ktindex b95b80acd3..130a1e9213 100644--- a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/CollectionScreen.kt+++ b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/CollectionScreen.kt@@ -2,20 +2,21 @@ package com.vayunmathur.games.alchemist.ui  import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar+import com.vayunmathur.library.ui.TopAppBarOverlay import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue@@ -31,7 +32,6 @@ import com.vayunmathur.games.alchemist.Route import com.vayunmathur.games.alchemist.platform.AlchemistViewModel import com.vayunmathur.games.alchemist.platform.CollectionUiState import com.vayunmathur.games.alchemist.ui.components.DynamicAlchemyIcon-import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.library.util.NavBackStack  /** Binds [AlchemistViewModel] to the stateless [CollectionScreen]. */@@ -64,16 +64,11 @@ fun CollectionScreen(     onBack: () -> Unit,     onOpenItemDetails: (Long) -> Unit ) {-    Scaffold(topBar = {-        TopAppBar(-            title = { Text(stringResource(R.string.collection)) },-            navigationIcon = { IconNavigation(onBack) }-        )-    }) { paddingValues ->+    Box(Modifier.fillMaxSize()) {         Column(             Modifier                 .fillMaxSize()-                .padding(paddingValues)+                .statusBarsPadding()         ) {             Text(                 text = stringResource(R.string.discovered_counter, state.discoveredItems.size, state.totalCount),@@ -111,5 +106,10 @@ fun CollectionScreen(                 }             }         }++        TopAppBarOverlay(+            modifier = Modifier.align(Alignment.TopCenter),+            onNavigateBack = onBack,+        )     } }
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 4d7182f299..b1ecbbad06 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@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState@@ -28,14 +29,13 @@ import com.vayunmathur.library.ui.DropdownMenu import com.vayunmathur.library.ui.DropdownMenuItem import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.Icon-import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconCheck import com.vayunmathur.library.ui.IconMoreVert import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold+import com.vayunmathur.library.ui.OverlayAction import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar+import com.vayunmathur.library.ui.TopAppBarOverlay import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState@@ -132,48 +132,9 @@ fun HomeScreen(      val lazyList = rememberLazyListState() -    Scaffold(-        topBar = {-            TopAppBar(title = { Text(stringResource(R.string.app_name)) }, actions = {-                if (activeItems.isNotEmpty()) {-                    IconButton(onClick = { actions.clearElements() }) {-                        Icon(-                            painterResource(id = android.R.drawable.ic_menu_close_clear_cancel), "Clear"-                        )-                    }-                }-                IconButton(onClick = onOpenCollection) {-                    Icon(-                        painterResource(id = android.R.drawable.ic_menu_sort_by_size), "Collection"-                    )-                }-                IconButton(onClick = onOpenGameCenter) {-                    Icon(-                        painterResource(id = android.R.drawable.btn_star_big_on), "Achievements"-                    )-                }-                IconButton(onClick = { overflowExpanded = true }) {-                    IconMoreVert()-                }-                DropdownMenu(-                    expanded = overflowExpanded,-                    onDismissRequest = { overflowExpanded = false }-                ) {-                    DropdownMenuItem(-                        text = { Text(stringResource(R.string.hide_maxed_elements)) },-                        trailingIcon = { if (state.hideExhausted) IconCheck() },-                        onClick = {-                            actions.setHideExhausted(!state.hideExhausted)-                            overflowExpanded = false-                        }-                    )-                }-            })-        }) { paddingValues ->+    Box(Modifier.fillMaxSize()) {         Box(-            Modifier-                .fillMaxSize()-                .padding(paddingValues)+            Modifier.fillMaxSize()         ) {             // 1. PLAY AREA (Full Screen)             Box(@@ -384,6 +345,62 @@ fun HomeScreen(             }         } +        TopAppBarOverlay(+            modifier = Modifier.align(Alignment.TopCenter),+            actions = buildList {+                if (activeItems.isNotEmpty()) {+                    add(+                        OverlayAction(+                            icon = { Icon(painterResource(id = android.R.drawable.ic_menu_close_clear_cancel), "Clear") },+                            contentDescription = "Clear",+                            onClick = { actions.clearElements() },+                        )+                    )+                }+                add(+                    OverlayAction(+                        icon = { Icon(painterResource(id = android.R.drawable.ic_menu_sort_by_size), "Collection") },+                        contentDescription = "Collection",+                        onClick = onOpenCollection,+                    )+                )+                add(+                    OverlayAction(+                        icon = { Icon(painterResource(id = android.R.drawable.btn_star_big_on), "Achievements") },+                        contentDescription = "Achievements",+                        onClick = onOpenGameCenter,+                    )+                )+                add(+                    OverlayAction(+                        icon = { IconMoreVert() },+                        contentDescription = "More",+                        onClick = { overflowExpanded = true },+                    )+                )+            }+        )++        Box(+            Modifier+                .align(Alignment.TopEnd)+                .statusBarsPadding()+        ) {+            DropdownMenu(+                expanded = overflowExpanded,+                onDismissRequest = { overflowExpanded = false }+            ) {+                DropdownMenuItem(+                    text = { Text(stringResource(R.string.hide_maxed_elements)) },+                    trailingIcon = { if (state.hideExhausted) IconCheck() },+                    onClick = {+                        actions.setHideExhausted(!state.hideExhausted)+                        overflowExpanded = false+                    }+                )+            }+        }+         if (contextMenuExpanded) {             DropdownMenu(                 expanded = contextMenuExpanded,
games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/ItemDetails.kt
diff --git a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/ItemDetails.kt b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/ItemDetails.ktindex 4b07d40be7..c024d6db91 100644--- a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/ItemDetails.kt+++ b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/ItemDetails.kt@@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape@@ -19,9 +20,8 @@ import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.ExperimentalMaterial3Api import com.vayunmathur.library.ui.MaterialTheme-import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text-import com.vayunmathur.library.ui.TopAppBar+import com.vayunmathur.library.ui.TopAppBarOverlay import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue@@ -37,7 +37,6 @@ import com.vayunmathur.games.alchemist.data.AlchemyRecipe import com.vayunmathur.games.alchemist.platform.AlchemistViewModel import com.vayunmathur.games.alchemist.platform.ItemDetailsUiState import com.vayunmathur.games.alchemist.ui.components.DynamicAlchemyIcon-import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.library.util.NavBackStack  /** Binds [AlchemistViewModel] to the stateless [ItemDetailsScreen]. */@@ -73,24 +72,13 @@ fun ItemDetailsScreen(     val recipes = state.recipes     val itemsIds = state.discoveredIds -    Scaffold(topBar = {-        TopAppBar(-            { Text(stringResource(R.string.item_details)) },-            navigationIcon = { IconNavigation(onBack) }-        )-    }) { paddingValues ->-        if (item == null) {-            // Catalog not yet loaded or item id unknown — render an empty surface-            // rather than crashing.-            Column(Modifier.padding(paddingValues)) {}-            return@Scaffold-        }--        Column(-            Modifier-                .padding(paddingValues)-                .padding(8.dp)-        ) {+    Box(Modifier.fillMaxSize()) {+        if (item != null) {+            Column(+                Modifier+                    .statusBarsPadding()+                    .padding(8.dp)+            ) {             Card(                 modifier = Modifier.fillMaxSize(),                 shape = RoundedCornerShape(16.dp),@@ -170,6 +158,12 @@ fun ItemDetailsScreen(                 }             }         }+        }++        TopAppBarOverlay(+            modifier = Modifier.align(Alignment.TopCenter),+            onNavigateBack = onBack,+        )     } }