From b189d74f2bf9e6334a182a0233e97135b381b6b8 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Fri, 5 Jun 2026 15:07:59 +0200 Subject: [PATCH 1/2] add argument to home to open the bottom sheet --- .../hedvig/android/app/ui/HedvigAppState.kt | 2 +- .../app/ui/IsTopLevelGraphInHierarchy.kt | 2 +- .../home/home/navigation/HomeDestinations.kt | 6 +++++- .../feature/home/home/navigation/HomeGraph.kt | 19 +++++++++++++++++++ .../feature/home/home/ui/HomeDestination.kt | 18 ++++++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/app/app/src/main/kotlin/com/hedvig/android/app/ui/HedvigAppState.kt b/app/app/src/main/kotlin/com/hedvig/android/app/ui/HedvigAppState.kt index 390d3efddb..c82d569eda 100644 --- a/app/app/src/main/kotlin/com/hedvig/android/app/ui/HedvigAppState.kt +++ b/app/app/src/main/kotlin/com/hedvig/android/app/ui/HedvigAppState.kt @@ -355,7 +355,7 @@ private sealed interface TopLevelDestination { val destination: Destination object Home : TopLevelDestination { - override val destination: Destination = HomeDestination.Home + override val destination: Destination = HomeDestination.Home() } object Insurances : TopLevelDestination { diff --git a/app/app/src/main/kotlin/com/hedvig/android/app/ui/IsTopLevelGraphInHierarchy.kt b/app/app/src/main/kotlin/com/hedvig/android/app/ui/IsTopLevelGraphInHierarchy.kt index 7cbdb27fa5..ff8e482611 100644 --- a/app/app/src/main/kotlin/com/hedvig/android/app/ui/IsTopLevelGraphInHierarchy.kt +++ b/app/app/src/main/kotlin/com/hedvig/android/app/ui/IsTopLevelGraphInHierarchy.kt @@ -32,7 +32,7 @@ internal val TopLevelGraph.destination: Destination internal val TopLevelGraph.startDestination: Destination get() = when (this) { - TopLevelGraph.Home -> HomeDestination.Home + TopLevelGraph.Home -> HomeDestination.Home() TopLevelGraph.Insurances -> InsurancesDestination.Insurances TopLevelGraph.Forever -> ForeverDestination.Forever TopLevelGraph.Payments -> PaymentsDestination.Payments diff --git a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeDestinations.kt b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeDestinations.kt index feaf4ed484..4764cd0861 100644 --- a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeDestinations.kt +++ b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeDestinations.kt @@ -13,7 +13,11 @@ sealed interface HomeDestination { data object Graph : HomeDestination, Destination @Serializable - data object Home : HomeDestination, Destination + data class Home( + // When true, the home screen automatically opens the start-claim consent sheet on arrival. Defaults to false for + // regular home navigation; set to true when arriving via the `/submit-claim` deep link (see homeGraph). + val startClaimFlow: Boolean = false, + ) : HomeDestination, Destination @Serializable data class FirstVet(val sections: List) : HomeDestination, Destination { diff --git a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeGraph.kt b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeGraph.kt index bed682b0bb..2c2b75711d 100644 --- a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeGraph.kt +++ b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeGraph.kt @@ -1,6 +1,9 @@ package com.hedvig.android.feature.home.home.navigation +import android.content.Intent +import androidx.core.os.BundleCompat import androidx.lifecycle.compose.dropUnlessResumed +import androidx.navigation.NavBackStackEntry import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import coil3.ImageLoader @@ -45,8 +48,13 @@ fun NavGraphBuilder.homeGraph( exitTransition = { MotionDefaults.fadeThroughExit }, ) { val viewModel: HomeViewModel = koinViewModel() + // The `/submit-claim` deep link lands on Home but carries no route argument, so the typed `startClaimFlow` + // resolves to its default (false). Detect that entry point from the launching deep link intent instead, so the + // public URL stays clean while still auto-opening the start-claim consent sheet. + val startClaimFlow = startClaimFlow || it.wasLaunchedFromClaimDeepLink(hedvigDeepLinkContainer) HomeDestination( viewModel = viewModel, + startClaimFlow = startClaimFlow, onNavigateToInbox = dropUnlessResumed { onNavigateToInbox() }, onNavigateToNewConversation = dropUnlessResumed { onNavigateToNewConversation() }, navigateToClaimChat = dropUnlessResumed { navigateToClaimChat() }, @@ -84,3 +92,14 @@ fun NavGraphBuilder.homeGraph( nestedGraphs() } } + +/** + * Whether this back stack entry was opened by the claim flow deep link (`/submit-claim`). The deep link does not carry + * any route argument, so we inspect the launching intent's URI and match it against the known claim flow patterns. + */ +private fun NavBackStackEntry.wasLaunchedFromClaimDeepLink(hedvigDeepLinkContainer: HedvigDeepLinkContainer): Boolean { + val arguments = arguments ?: return false + val deepLinkIntent = BundleCompat.getParcelable(arguments, NavController.KEY_DEEP_LINK_INTENT, Intent::class.java) + val deepLinkUri = deepLinkIntent?.data?.toString() ?: return false + return hedvigDeepLinkContainer.claimFlow.any { claimFlowUri -> deepLinkUri.startsWith(claimFlowUri) } +} diff --git a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeDestination.kt b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeDestination.kt index 2ca5fc2c15..2235f40e6d 100644 --- a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeDestination.kt +++ b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/ui/HomeDestination.kt @@ -38,6 +38,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.produceState import androidx.compose.runtime.remember import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Alignment @@ -153,6 +154,7 @@ import org.jetbrains.compose.resources.stringResource @Composable internal fun HomeDestination( viewModel: HomeViewModel, + startClaimFlow: Boolean, onNavigateToInbox: () -> Unit, onNavigateToNewConversation: () -> Unit, navigateToClaimChat: () -> Unit, @@ -174,6 +176,7 @@ internal fun HomeDestination( val notificationPermissionState = rememberNotificationPermissionState() HomeScreen( uiState = uiState, + startClaimFlow = startClaimFlow, notificationPermissionState = notificationPermissionState, reload = { viewModel.emit(HomeEvent.RefreshData) }, onNavigateToInbox = onNavigateToInbox, @@ -203,6 +206,7 @@ internal fun HomeDestination( @Composable private fun HomeScreen( uiState: HomeUiState, + startClaimFlow: Boolean, notificationPermissionState: NotificationPermissionState, reload: () -> Unit, onNavigateToInbox: () -> Unit, @@ -247,6 +251,17 @@ private fun HomeScreen( navigateToClaimChatInDevMode = navigateToClaimChatInDevMode, isStagingEnvironment = (uiState as? Success)?.isProduction?.not() ?: false, ) + // Auto-open the start-claim consent sheet when arriving via the `/submit-claim` deep link, mirroring a tap on the + // "Start claim" button. Guarded so it only happens once per entry, surviving recompositions and configuration changes. + if (startClaimFlow) { + var hasOpenedStartClaimSheet by rememberSaveable { mutableStateOf(false) } + LaunchedEffect(Unit) { + if (!hasOpenedStartClaimSheet) { + hasOpenedStartClaimSheet = true + startClaimBottomSheetState.show() + } + } + } Box(Modifier.fillMaxSize()) { val toolbarHeight = 64.dp val transition = updateTransition(targetState = uiState, label = "home ui state") @@ -801,6 +816,7 @@ private fun PreviewHomeScreen( ), isProduction = true, ), + startClaimFlow = false, notificationPermissionState = rememberPreviewNotificationPermissionState(), reload = {}, onNavigateToInbox = {}, @@ -834,6 +850,7 @@ private fun PreviewHomeScreenWithError() { Surface(color = HedvigTheme.colorScheme.backgroundPrimary) { HomeScreen( uiState = HomeUiState.Error(null), + startClaimFlow = false, notificationPermissionState = rememberPreviewNotificationPermissionState(), reload = {}, onNavigateToInbox = {}, @@ -888,6 +905,7 @@ private fun PreviewHomeScreenAllHomeTextTypes( addonBannerInfo = null, isProduction = true, ), + startClaimFlow = false, notificationPermissionState = rememberPreviewNotificationPermissionState(), reload = {}, onNavigateToInbox = {}, From e8f6d0686083e55ce368fac07c73c6c2b1e02267 Mon Sep 17 00:00:00 2001 From: mariiapanasetskaia Date: Fri, 5 Jun 2026 15:47:53 +0200 Subject: [PATCH 2/2] remove comment --- .../hedvig/android/feature/home/home/navigation/HomeGraph.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeGraph.kt b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeGraph.kt index 2c2b75711d..49b0b3a6c4 100644 --- a/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeGraph.kt +++ b/app/feature/feature-home/src/main/kotlin/com/hedvig/android/feature/home/home/navigation/HomeGraph.kt @@ -48,9 +48,6 @@ fun NavGraphBuilder.homeGraph( exitTransition = { MotionDefaults.fadeThroughExit }, ) { val viewModel: HomeViewModel = koinViewModel() - // The `/submit-claim` deep link lands on Home but carries no route argument, so the typed `startClaimFlow` - // resolves to its default (false). Detect that entry point from the launching deep link intent instead, so the - // public URL stays clean while still auto-opening the start-claim consent sheet. val startClaimFlow = startClaimFlow || it.wasLaunchedFromClaimDeepLink(hedvigDeepLinkContainer) HomeDestination( viewModel = viewModel,