@@ -51,6 +51,8 @@ import androidx.compose.ui.focus.focusRequester
5151import androidx.compose.ui.graphics.Color
5252import androidx.compose.ui.input.pointer.PointerIcon
5353import androidx.compose.ui.input.pointer.pointerHoverIcon
54+ import androidx.compose.ui.semantics.contentDescription
55+ import androidx.compose.ui.semantics.semantics
5456import androidx.compose.ui.text.TextRange
5557import androidx.compose.ui.text.input.TextFieldValue
5658import androidx.compose.ui.text.style.TextOverflow
@@ -88,7 +90,7 @@ sealed class NavDestination {
8890}
8991
9092@Composable
91- fun App () {
93+ fun App (initialDeeplink : String? = null ) {
9294 val reviewHandler: ReviewHandler = koinInject()
9395 LaunchedEffect (Unit ) {
9496 reviewHandler.incrementAppStartCount()
@@ -106,7 +108,7 @@ fun App() {
106108 )
107109 // Main content
108110 Box (modifier = Modifier .weight(1f )) {
109- LinuxApp ()
111+ LinuxApp (initialDeeplink = initialDeeplink )
110112 }
111113 // Navigation bar area with white/surface color
112114 Spacer (
@@ -120,8 +122,11 @@ fun App() {
120122}
121123
122124@Composable
123- fun LinuxApp () {
124- var currentDestination by remember { mutableStateOf<NavDestination >(NavDestination .Basics ) }
125+ fun LinuxApp (initialDeeplink : String? = null) {
126+ val initialDestination = remember(initialDeeplink) {
127+ parseDeeplink(initialDeeplink) ? : NavDestination .Basics
128+ }
129+ var currentDestination by remember { mutableStateOf<NavDestination >(initialDestination) }
125130 val navigationStack = remember { mutableListOf<NavDestination >() }
126131 val searchTextValue = rememberSaveable(stateSaver = TextFieldValue .Saver ) {
127132 mutableStateOf(TextFieldValue (text = " " , selection = TextRange (0 )))
@@ -278,6 +283,25 @@ private fun parseRoute(route: String): NavDestination? = when {
278283 else -> null
279284}
280285
286+ private fun parseDeeplink (url : String? ): NavDestination ? {
287+ if (url == null ) return null
288+
289+ return when {
290+ url.endsWith(" /basics.html" ) || url.endsWith(" /basics" ) -> NavDestination .Basics
291+ url.endsWith(" /tips.html" ) || url.endsWith(" /tips" ) -> NavDestination .Tips
292+ url.contains(" /man/" ) -> {
293+ val commandName = url.substringAfterLast(" /man/" ).removeSuffix(" .html" )
294+ NavDestination .CommandDetail (commandName)
295+ }
296+ url.contains(" /basic/" ) -> {
297+ val categoryId = url.substringAfterLast(" /basic/" ).removeSuffix(" .html" )
298+ NavDestination .BasicGroups (categoryId)
299+ }
300+ url.endsWith(" /" ) || url.endsWith(" /index.html" ) -> NavDestination .Commands
301+ else -> null
302+ }
303+ }
304+
281305@Composable
282306private fun getTitleForDestination (dest : NavDestination ): String = when (dest) {
283307 NavDestination .Basics -> " Basics"
@@ -307,7 +331,12 @@ private fun GenericTopBar(
307331
308332 TopAppBar (
309333 title = {
310- Text (title, maxLines = 1 , overflow = TextOverflow .Ellipsis )
334+ Text (
335+ title,
336+ modifier = Modifier .semantics { contentDescription = " TopAppBarTitle" },
337+ maxLines = 1 ,
338+ overflow = TextOverflow .Ellipsis ,
339+ )
311340 },
312341 backgroundColor = MaterialTheme .colors.primary,
313342 contentColor = Color .White ,
@@ -361,7 +390,12 @@ private fun DetailTopBar(
361390
362391 TopAppBar (
363392 title = {
364- Text (commandName, maxLines = 1 , overflow = TextOverflow .Ellipsis )
393+ Text (
394+ commandName,
395+ modifier = Modifier .semantics { contentDescription = " TopAppBarTitle" },
396+ maxLines = 1 ,
397+ overflow = TextOverflow .Ellipsis ,
398+ )
365399 },
366400 backgroundColor = MaterialTheme .colors.primary,
367401 contentColor = Color .White ,
@@ -476,7 +510,10 @@ private fun SearchTopBar(
476510 } else {
477511 Text (
478512 title,
479- modifier = Modifier .weight(1f ).padding(start = 16 .dp),
513+ modifier = Modifier
514+ .weight(1f )
515+ .padding(start = 16 .dp)
516+ .semantics { contentDescription = " TopAppBarTitle" },
480517 style = MaterialTheme .typography.h6.copy(color = LocalContentColor .current),
481518 maxLines = 1 ,
482519 overflow = TextOverflow .Ellipsis ,
0 commit comments