Skip to content

Commit

Permalink
#8 - Enable deep link support
Browse files Browse the repository at this point in the history
  • Loading branch information
jhg3410 committed Feb 24, 2023
1 parent 4fee6f8 commit b40e93d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion NavigationCodelab/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="rally" android:host="single_account"/>
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navDeepLink
import com.example.compose.rally.ui.accounts.AccountsScreen
import com.example.compose.rally.ui.accounts.SingleAccountScreen
import com.example.compose.rally.ui.bills.BillsScreen
Expand Down Expand Up @@ -101,7 +102,8 @@ fun RallyApp() {
}
composable(
route = SingleAccount.routeWithArgs,
arguments = SingleAccount.arguments
arguments = SingleAccount.arguments,
deepLinks = SingleAccount.deepLinks
) { navBackStackEntry ->
val accountType =
navBackStackEntry.arguments?.getString(SingleAccount.accountTypeArg)
Expand All @@ -124,6 +126,6 @@ fun NavHostController.navigateSingleTopTo(route: String) =
restoreState = true
}

fun NavHostController.navigateToSingAccount(accountType:String) {
fun NavHostController.navigateToSingAccount(accountType: String) {
this.navigateSingleTopTo("${SingleAccount.route}/$accountType")
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.material.icons.filled.PieChart
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.navigation.NavType
import androidx.navigation.navArgument
import androidx.navigation.navDeepLink

/**
* Contract for information needed on every Rally navigation destination
Expand Down Expand Up @@ -61,6 +62,9 @@ object SingleAccount : RallyDestination {
val arguments = listOf(
navArgument(accountTypeArg) { type = NavType.StringType }
)
val deepLinks = listOf(navDeepLink {
uriPattern = "rally://$route/{$accountTypeArg}"
})
}

// Screens to be displayed in the top RallyTabRow
Expand Down

0 comments on commit b40e93d

Please sign in to comment.