Skip to content

Commit

Permalink
Merge pull request #531 from nimblehq/feature/define-deeplink-structure
Browse files Browse the repository at this point in the history
[#548] Prepare initial setup for deep-link
  • Loading branch information
ryan-conway authored Dec 7, 2023
2 parents ebb41f0 + 1974e18 commit 91c7ac8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
19 changes: 19 additions & 0 deletions sample-compose/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@

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

<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="https" />
<data android:host="android.nimblehq.co" />
</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="android" />
</intent-filter>
</activity>
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package co.nimblehq.sample.compose.ui

import androidx.compose.runtime.Composable
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavDeepLink
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navDeepLink
import co.nimblehq.sample.compose.ui.base.BaseDestination
import co.nimblehq.sample.compose.ui.screens.main.mainNavGraph

Expand All @@ -25,13 +25,16 @@ fun AppNavGraph(

fun NavGraphBuilder.composable(
destination: BaseDestination,
deepLinks: List<NavDeepLink> = emptyList(),
content: @Composable (NavBackStackEntry) -> Unit,
) {
composable(
route = destination.route,
arguments = destination.arguments,
deepLinks = deepLinks,
deepLinks = destination.deepLinks.map {
navDeepLink {
uriPattern = it
}
},
content = content
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ abstract class BaseDestination(val route: String = "") {

open val arguments: List<NamedNavArgument> = emptyList()

open val deepLinks: List<String> = listOf(
"https://android.nimblehq.co/$route",
"android://$route",
)

open var destination: String = route

open var parcelableArgument: Pair<String, Any?> = "" to null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package co.nimblehq.template.compose.ui

import androidx.compose.runtime.Composable
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavDeepLink
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navDeepLink
import co.nimblehq.template.compose.ui.base.BaseDestination
import co.nimblehq.template.compose.ui.screens.main.mainNavGraph

Expand All @@ -25,13 +25,16 @@ fun AppNavGraph(

fun NavGraphBuilder.composable(
destination: BaseDestination,
deepLinks: List<NavDeepLink> = emptyList(),
content: @Composable (NavBackStackEntry) -> Unit,
) {
composable(
route = destination.route,
arguments = destination.arguments,
deepLinks = deepLinks,
deepLinks = destination.deepLinks.map {
navDeepLink {
uriPattern = it
}
},
content = content
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ abstract class BaseDestination(val route: String = "") {

open val arguments: List<NamedNavArgument> = emptyList()

open val deepLinks: List<String> = emptyList()

open var destination: String = route

data class Up(val results: HashMap<String, Any> = hashMapOf()) : BaseDestination() {
Expand Down

0 comments on commit 91c7ac8

Please sign in to comment.