feat(android): navigate to a specific comments page via intent

This commit is contained in:
Harsh Shandilya 2023-09-23 01:15:02 +05:30
parent 0d1f69d36e
commit 23366e4536
2 changed files with 15 additions and 0 deletions

View file

@ -63,4 +63,8 @@ class MainActivity : ComponentActivity() {
}
}
}
companion object {
const val NAVIGATION_KEY = "postId"
}
}

View file

@ -32,6 +32,7 @@ import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
@ -52,6 +53,7 @@ import androidx.navigation.navArgument
import androidx.navigation.navDeepLink
import androidx.paging.compose.collectAsLazyPagingItems
import com.deliveryhero.whetstone.compose.injectedViewModel
import dev.msfjarvis.claw.android.MainActivity
import dev.msfjarvis.claw.android.R
import dev.msfjarvis.claw.android.ui.datatransfer.DataTransferScreen
import dev.msfjarvis.claw.android.ui.decorations.ClawAppBar
@ -101,6 +103,15 @@ fun LobstersApp(
val navigationType = ClawNavigationType.fromSize(windowSizeClass.widthSizeClass)
val postIdOverride = context.getActivity()?.intent?.extras?.getString(MainActivity.NAVIGATION_KEY)
LaunchedEffect(false) {
if (postIdOverride != null) {
navController.navigate(
Destinations.Comments.route.replace(Destinations.Comments.placeholder, postIdOverride)
)
}
}
val navItems =
persistentListOf(
NavigationItem(