@@ -3,26 +3,47 @@ package zed.rainxch.githubstore
33import androidx.compose.foundation.isSystemInDarkTheme
44import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
55import androidx.compose.runtime.Composable
6+ import androidx.compose.runtime.LaunchedEffect
67import androidx.compose.runtime.getValue
78import androidx.lifecycle.compose.collectAsStateWithLifecycle
89import androidx.navigation.compose.rememberNavController
910import org.jetbrains.compose.ui.tooling.preview.Preview
1011import org.koin.compose.viewmodel.koinViewModel
1112import zed.rainxch.core.presentation.theme.GithubStoreTheme
1213import zed.rainxch.core.presentation.utils.ApplyAndroidSystemBars
14+ import zed.rainxch.githubstore.app.deeplink.DeepLinkDestination
15+ import zed.rainxch.githubstore.app.deeplink.DeepLinkParser
1316import zed.rainxch.githubstore.app.navigation.AppNavigation
1417import zed.rainxch.githubstore.app.navigation.GithubStoreGraph
1518import zed.rainxch.githubstore.app.components.RateLimitDialog
1619
1720@OptIn(ExperimentalMaterial3ExpressiveApi ::class )
1821@Composable
1922@Preview
20- fun App () {
23+ fun App (deepLinkUri : String? = null ) {
2124 val viewModel: MainViewModel = koinViewModel()
2225 val state by viewModel.state.collectAsStateWithLifecycle()
2326
2427 val navBackStack = rememberNavController()
2528
29+ LaunchedEffect (deepLinkUri) {
30+ deepLinkUri?.let { uri ->
31+ when (val destination = DeepLinkParser .parse(uri)) {
32+ is DeepLinkDestination .Repository -> {
33+ navBackStack.navigate(
34+ GithubStoreGraph .DetailsScreen (
35+ owner = destination.owner,
36+ repo = destination.repo
37+ )
38+ )
39+ }
40+
41+ DeepLinkDestination .None -> { /* ignore unrecognized deep links */
42+ }
43+ }
44+ }
45+ }
46+
2647 GithubStoreTheme (
2748 fontTheme = state.currentFontTheme,
2849 appTheme = state.currentColorTheme,
@@ -31,19 +52,21 @@ fun App() {
3152 ) {
3253 ApplyAndroidSystemBars (state.isDarkTheme)
3354
34- if (state.showRateLimitDialog && state.rateLimitInfo != null ) {
35- RateLimitDialog (
36- rateLimitInfo = state.rateLimitInfo,
37- isAuthenticated = state.isLoggedIn,
38- onDismiss = {
39- viewModel.onAction(MainAction .DismissRateLimitDialog )
40- },
41- onSignIn = {
42- viewModel.onAction(MainAction .DismissRateLimitDialog )
43-
44- navBackStack.navigate(GithubStoreGraph .AuthenticationScreen )
45- }
46- )
55+ if (state.showRateLimitDialog) {
56+ state.rateLimitInfo?.let {
57+ RateLimitDialog (
58+ rateLimitInfo = it,
59+ isAuthenticated = state.isLoggedIn,
60+ onDismiss = {
61+ viewModel.onAction(MainAction .DismissRateLimitDialog )
62+ },
63+ onSignIn = {
64+ viewModel.onAction(MainAction .DismissRateLimitDialog )
65+
66+ navBackStack.navigate(GithubStoreGraph .AuthenticationScreen )
67+ }
68+ )
69+ }
4770 }
4871
4972 AppNavigation (
0 commit comments