Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package com.mifos.feature.client.fixedDepositAccount

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import androidx.compose.ui.Modifier

// Import all your step destinations
import com.mifos.feature.client.fixedDepositAccount.details.DetailsStepRoute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

import com.mifos.feature.client.fixedDepositAccount.details.detailsStepDestination
import com.mifos.feature.client.fixedDepositAccount.details.navigateToDetailsStep
import com.mifos.feature.client.fixedDepositAccount.currency.currencyStepDestination
import com.mifos.feature.client.fixedDepositAccount.currency.navigateToCurrencyStep
import com.mifos.feature.client.fixedDepositAccount.terms.termsStepDestination
import com.mifos.feature.client.fixedDepositAccount.terms.navigateToTermsStep
import com.mifos.feature.client.fixedDepositAccount.settings.settingsStepDestination
import com.mifos.feature.client.fixedDepositAccount.settings.navigateToSettingsStep
import com.mifos.feature.client.fixedDepositAccount.charges.chargesStepDestination
import com.mifos.feature.client.fixedDepositAccount.charges.navigateToChargesStep
import com.mifos.feature.client.fixedDepositAccount.preview.previewStepDestination
import com.mifos.feature.client.fixedDepositAccount.preview.navigateToPreviewStep

@Composable
fun FixedDepositAccountFlowScreen(
clientId: Int,
navigateBack: () -> Unit,
onAccountCreated: (accountId: String) -> Unit,
modifier: Modifier = Modifier
) {
val navController = rememberNavController()

NavHost(
navController = navController,
startDestination = DetailsStepRoute(clientId),
modifier = modifier
) {
// Step 1: Details
detailsStepDestination(
navController = navController,
navigateBack = navigateBack,
onNext = { navController.navigateToCurrencyStep(clientId) }
)

// Step 2: Currency 👈 ADD HERE
currencyStepDestination(
navController = navController,
navigateBack = { navController.popBackStack() },
onNext = { navController.navigateToTermsStep(clientId) }
)

// Step 3: Terms
termsStepDestination(
navController = navController,
navigateBack = { navController.popBackStack() },
onNext = { navController.navigateToSettingsStep(clientId) }
)

// Step 4: Settings
settingsStepDestination(
navController = navController,
navigateBack = { navController.popBackStack() },
onNext = { navController.navigateToChargesStep(clientId) }
)

// Step 5: Charges
chargesStepDestination(
navController = navController,
navigateBack = { navController.popBackStack() },
onNext = { navController.navigateToPreviewStep(clientId) }
)

// Step 6: Preview
previewStepDestination(
navController = navController,
navigateBack = { navController.popBackStack() },
onSubmit = {
// Account created successfully
onAccountCreated("accountId")
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,33 @@ fun NavGraphBuilder.clientFixedDepositAccountDestination(
navigateBack = navigateBack,
onApproveAccount = onApproveAccount,
onViewAccount = onViewAccount,
onCreateNew = { clientId ->
// Navigate to the multi-step flow
navController.navigateToFixedDepositFlow(clientId)
)
}
}
// Add the multi-step flow route
composable<FixedDepositAccountFlowRoute> { backStackEntry ->
val route = backStackEntry.toRoute<FixedDepositAccountFlowRoute>()
FixedDepositAccountFlowScreen(
clientId = route.clientId,
navigateBack = { navController.popBackStack() },
onAccountCreated = { accountId ->
// Navigate back to listing or details
navController.popBackStack()
}
)
}
}
@Serializable
data class FixedDepositAccountFlowRoute(
val clientId: Int
)

fun NavController.navigateToFixedDepositFlow(clientId: Int) {
this.navigate(FixedDepositAccountFlowRoute(clientId = clientId))
}

fun NavController.navigateToFixedDepositAccountRoute(
clientId: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.mifos.feature.client.fixedDepositAccount.preview

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import kotlinx.serialization.Serializable

@Serializable
data class PreviewStepRoute(
val clientId: Int = -1
)

fun NavGraphBuilder.previewStepDestination(
navController: NavController,
navigateBack: () -> Unit,
onSubmit: () -> Unit
) {
composable<PreviewStepRoute> {
PreviewStepScreenContainer(
navigateBack = navigateBack,
onSubmit = onSubmit
)
}
}

fun NavController.navigateToPreviewStep(clientId: Int) {
this.navigate(PreviewStepRoute(clientId = clientId))
}
Loading