Skip to content

Commit 9f34cf9

Browse files
committed
🌟 add keyboard shortcut : escape -> navigate back
1 parent e882378 commit 9f34cf9

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

β€Žsrc/main/kotlin/com/theapache64/stackzy/ui/feature/MainActivity.ktβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import androidx.compose.material.MaterialTheme
77
import androidx.compose.material.Text
88
import androidx.compose.ui.Alignment
99
import androidx.compose.ui.Modifier
10+
import androidx.compose.ui.input.key.Key
11+
import androidx.compose.ui.input.key.KeyEventType
12+
import androidx.compose.ui.input.key.key
13+
import androidx.compose.ui.input.key.type
1014
import androidx.compose.ui.res.painterResource
1115
import androidx.compose.ui.unit.dp
1216
import androidx.compose.ui.window.Window
@@ -70,6 +74,14 @@ class MainActivity : Activity() {
7074
width = (screenSize.width * 0.9).dp,
7175
height = (screenSize.height * 0.8).dp
7276
),
77+
onKeyEvent = {
78+
if (it.type == KeyEventType.KeyUp && it.key.keyCode == Key.Escape.keyCode) {
79+
root.onEscapePressed()
80+
true
81+
} else {
82+
false
83+
}
84+
}
7385
) {
7486

7587
if (OsCheck.operatingSystemType == OSType.MacOS) {

β€Žsrc/main/kotlin/com/theapache64/stackzy/ui/feature/liblist/LibraryListScreen.ktβ€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import com.theapache64.stackzy.ui.common.Selectable
2424
import com.theapache64.stackzy.ui.common.loading.LoadingAnimation
2525
import com.theapache64.stackzy.util.R
2626

27-
2827
@Composable
2928
fun LibraryListScreen(
3029
viewModel: LibraryListViewModel,
@@ -87,7 +86,7 @@ fun LibraryListScreen(
8786

8887
if (libraries.isNotEmpty()) {
8988
LazyVerticalGrid(
90-
cells = GridCells.Fixed(4)
89+
cells = GridCells.Fixed(4),
9190
) {
9291
items(libraries) { library ->
9392
Column {

β€Žsrc/main/kotlin/com/theapache64/stackzy/ui/navigation/NavHostComponent.ktβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ class NavHostComponent(
138138
router.push(Config.LibraryDetail(libraryWrapper))
139139
}
140140

141+
fun onEscapePressed() {
142+
if (router.state.value.backStack.isNotEmpty()) {
143+
router.pop()
144+
}
145+
}
141146

142147
@OptIn(ExperimentalDecomposeApi::class)
143148
@Composable
@@ -244,6 +249,11 @@ class NavHostComponent(
244249
androidApp = androidAppWrapper
245250
)
246251
)*/
252+
253+
// Temp
254+
val playStoreUrl =
255+
URI("https://play.google.com/store/apps/details?id=${androidAppWrapper.androidApp.appPackage.name}")
256+
Desktop.getDesktop().browse(playStoreUrl)
247257
}
248258

249259
/**

0 commit comments

Comments
Β (0)