Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Migrated payment details to compose, moved to module, implemented compose navigation #2204

Merged
merged 1 commit into from
Aug 31, 2024
Merged
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
Expand Up @@ -6,36 +6,44 @@ import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import androidx.navigation.navigation
import com.google.gson.Gson
import com.mifos.core.common.utils.Constants
import com.mifos.core.network.model.IndividualCollectionSheetPayload
import com.mifos.core.objects.accounts.loan.PaymentTypeOptions
import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet
import com.mifos.core.objects.collectionsheet.LoanAndClientName
import com.mifos.core.objects.collectionsheet.LoanCollectionSheet
import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetScreen
import com.mifos.feature.individual_collection_sheet.individual_collection_sheet.ui.IndividualCollectionSheetScreen
import com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details.IndividualCollectionSheetDetailsScreen
import com.mifos.feature.individual_collection_sheet.payment_details.PaymentDetailsScreenContent
import com.mifos.feature.individual_collection_sheet.payment_details.PaymentDetailsScreenRoute

/**
* Created by Pronay Sarker on 20/08/2024 (4:06 PM)
*/
fun NavGraphBuilder.individualCollectionSheetNavGraph(
navController: NavController,
onBackPressed: () -> Unit,
navigateToPaymentDetails: (Int, IndividualCollectionSheetPayload, List<String>, LoanAndClientName, List<PaymentTypeOptions>, Int) -> Unit
) {
navigation(
route = "generate_collection_sheet",
startDestination = CollectionSheetScreens.IndividualCollectionSheetScreen.route
) {
individualCollectionSheetScreen(
onBackPressed = onBackPressed,
onDetail = { _, sheet -> navController.navigateToIndividualCollectionSheetDetailScreen(sheet) }
onDetail = { _, sheet ->
navController.navigateToIndividualCollectionSheetDetailScreen(sheet)
}

)

individualCollectionSheetDetailScreen(
onBackPressed = onBackPressed,
submit = navigateToPaymentDetails
submit = navController::navigateToPaymentDetailsScreen
)

paymentDetailsScreen()
}
}

Expand Down Expand Up @@ -80,10 +88,47 @@ fun NavGraphBuilder.generateCollectionSheetScreen(
}
}

fun NavGraphBuilder.paymentDetailsScreen() {
composable(
route = CollectionSheetScreens.PaymentDetailsScreen.route,
arguments = listOf(
navArgument(name = Constants.ADAPTER_POSITION, builder = { NavType.IntType }),
navArgument(name = Constants.CLIENT_ID, builder = { NavType.IntType }),
navArgument(name = Constants.PAYLOAD, builder = { NavType.StringType }),
navArgument(name = Constants.PAYMENT_LIST, builder = { NavType.StringType }),
navArgument(name = Constants.LOAN_AND_CLIENT, builder = { NavType.StringType }),
navArgument(name = Constants.PAYMENT_OPTIONS, builder = { NavType.StringType }),
)
) {
PaymentDetailsScreenRoute()
}
}

fun NavController.navigateToIndividualCollectionSheetDetailScreen(sheet: IndividualCollectionSheet) {
navigate(CollectionSheetScreens.IndividualCollectionSheetDetailScreen.argument(sheet))
}

fun NavController.navigateToIndividualCollectionSheet() {
navigate(CollectionSheetScreens.IndividualCollectionSheetScreen.route)
}
fun NavController.navigateToPaymentDetailsScreen(
position: Int,
payload: IndividualCollectionSheetPayload,
paymentTypeOptionsName: List<String>,
loansAndClientName: LoanAndClientName,
paymentTypeOptions: List<PaymentTypeOptions>,
clientId: Int
) {
val payloadInGsonString = Gson().toJson(payload)
val paymentTypeOptionNameInGsonString = Gson().toJson(paymentTypeOptionsName)
val loansAndClientNameInGsonString = Gson().toJson(loansAndClientName)
val paymentTypeOptionsInGsonString = Gson().toJson(paymentTypeOptions)

navigate(
CollectionSheetScreens.PaymentDetailsScreen.argument(
position,
payloadInGsonString,
paymentTypeOptionNameInGsonString,
loansAndClientNameInGsonString,
paymentTypeOptionsInGsonString,
clientId
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.mifos.feature.individual_collection_sheet.navigation

import com.google.gson.Gson
import com.mifos.core.common.utils.Constants
import com.mifos.core.objects.accounts.loan.PaymentTypeOptions
import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet
import com.mifos.core.objects.collectionsheet.LoanAndClientName
import com.mifos.core.objects.db.CollectionSheet
import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetUiState

Expand All @@ -11,11 +13,28 @@ import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.G
*/
sealed class CollectionSheetScreens(val route: String) {

data object GenerateCollectionSheetScreen : CollectionSheetScreens("generate_collection_sheet_route")
data object GenerateCollectionSheetScreen :
CollectionSheetScreens("generate_collection_sheet_route")

data object IndividualCollectionSheetScreen : CollectionSheetScreens("individual_collection_sheet_route")
data object IndividualCollectionSheetScreen :
CollectionSheetScreens("individual_collection_sheet_route")

data object IndividualCollectionSheetDetailScreen : CollectionSheetScreens("individual_collection_sheet_detail/{${Constants.INDIVIDUAL_SHEET}}") {
data object PaymentDetailsScreen :
CollectionSheetScreens("payment_details_route/{${Constants.ADAPTER_POSITION}}/{${Constants.PAYLOAD}}/{${Constants.PAYMENT_LIST}}/{${Constants.LOAN_AND_CLIENT}}/{${Constants.PAYMENT_OPTIONS}}/{${Constants.CLIENT_ID}}") {
fun argument(
position: Int,
payload: String,
paymentTypeOptionsName: String,
loansAndClientName: String,
paymentTypeOptions: String,
clientId: Int
): String {
return "payment_details_route/$position/$payload/$paymentTypeOptionsName/$loansAndClientName/$paymentTypeOptions/$clientId"
}
}

data object IndividualCollectionSheetDetailScreen :
CollectionSheetScreens("individual_collection_sheet_detail/{${Constants.INDIVIDUAL_SHEET}}") {
fun argument(sheet: IndividualCollectionSheet): String {
val gson = Gson()
val sheetInGsonString = gson.toJson(sheet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ fun NewIndividualCollectionSheetScreen(
.weight(1f)
.padding(16.dp),
contentPadding = PaddingValues(),
enabled = selectedStaff != "" && selectedOffice != "",
// enabled = selectedOffice != "",
colors = ButtonDefaults.buttonColors(
containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary
)
Expand Down
Loading
Loading