Skip to content

Collection Sheet Enhancement #2406

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

Open
wants to merge 19 commits into
base: kmp-impl
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions feature/collectionSheet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ kotlin {
implementation(compose.ui)
implementation(projects.core.domain)
implementation(libs.kotlinx.serialization.json)
implementation(compose.components.uiToolingPreview)
Copy link
Member

Choose a reason for hiding this comment

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

Remove this as u already defined in dependencies {} block

Copy link
Member

Choose a reason for hiding this comment

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

i mentioned remove it from commonMain but keep the dependencies{}:

  • cause when we create a project from KMP wizard this way it is done by default maybe they have sth in mind where in future the previews will work for all platform if we have it here
dependencies {
    debugImplementation(compose.uiTooling)
}


implementation(libs.coil.core)
implementation(libs.coil.kt)
implementation(libs.coil.kt.compose)

}
}
}

dependencies {
debugImplementation(compose.uiTooling)
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,4 @@
<string name="feature_collection_sheet_productive_collection_sheet">Productive Collection Sheet</string>
<string name="feature_collection_sheet_productive_sheet_submitted">Productive Sheet Submitted Successfully</string>
<string name="feature_collection_sheet_collection_sheet_submitted">Collection Sheet Submitted Successfully</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import androidx.compose.ui.Modifier
import com.mifos.core.designsystem.component.MifosScaffold
import com.mifos.core.designsystem.component.MifosTabRow
import com.mifos.core.designsystem.utility.TabContent
import com.mifos.core.ui.util.DevicePreview
import com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet.NewIndividualCollectionSheetScreen
import com.mifos.feature.individualCollectionSheet.savedIndividualCollectionSheet.SavedIndividualCollectionSheetCompose
import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview

@Composable
internal fun IndividualCollectionSheetScreen(
onBackPressed: () -> Unit,
onDetail: (String, IndividualCollectionSheet) -> Unit,
onDetail: (IndividualCollectionSheet) -> Unit,
) {
val snackbarHostState = remember { SnackbarHostState() }

Expand Down Expand Up @@ -69,8 +69,8 @@ enum class IndividualCollectionSheetScreenContents {
SAVED,
}

@DevicePreview
@Preview
@Composable
private fun IndividualCollectionSheetScreenPreview() {
IndividualCollectionSheetScreen(onBackPressed = {}, onDetail = { _, _ -> })
IndividualCollectionSheetScreen(onBackPressed = {}, onDetail = { _ -> })
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
Expand Down Expand Up @@ -58,14 +59,15 @@ import com.mifos.core.designsystem.component.MifosSweetError
import com.mifos.core.designsystem.icon.MifosIcons
import com.mifos.core.model.objects.account.loan.PaymentTypeOptions
import com.mifos.core.model.objects.collectionsheets.LoanAndClientName
import com.mifos.core.model.objects.collectionsheets.LoanCollectionSheet
import com.mifos.core.network.model.IndividualCollectionSheetPayload
import com.mifos.core.ui.util.DevicePreview
import com.mifos.room.entities.collectionsheet.ClientCollectionSheet
import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet
import com.mifos.room.entities.noncore.BulkRepaymentTransactions
import kotlinx.coroutines.launch
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.koin.compose.viewmodel.koinViewModel

@Composable
Expand Down Expand Up @@ -178,17 +180,17 @@ internal fun IndividualCollectionSheetDetailsScreen(
} else {
LazyColumn {
Copy link
Member

Choose a reason for hiding this comment

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

whenever u use LazyColumn use key for better performance

sheet.clients?.toList()?.let {
itemsIndexed(it) { index, client ->
itemsIndexed(it.zip(loansAndClientNames)) { index,(client, loanAndClientName) ->
IndividualCollectionSheetItem(
client = client,
index = index,
loan = loanAndClientName.loan,
onClick = {
sheet.paymentTypeOptions?.let { paymentTypeOptions ->
submit(
index,
payload,
paymentTypeOptions.map { paymentTypeOption -> paymentTypeOption.name.toString() },
loansAndClientNames[index],
paymentTypeOptions.map { it.name.toString() },
loanAndClientName,
paymentTypeOptions.toList(),
client.clientId,
)
Expand All @@ -206,10 +208,11 @@ internal fun IndividualCollectionSheetDetailsScreen(
@Composable
private fun IndividualCollectionSheetItem(
client: ClientCollectionSheet,
index: Int,
loan: LoanCollectionSheet?,
modifier: Modifier = Modifier,
onClick: () -> Unit,
) {

OutlinedCard(
modifier = modifier
.padding(6.dp)
Expand Down Expand Up @@ -246,18 +249,16 @@ private fun IndividualCollectionSheetItem(
Text(
text = it,
style = MaterialTheme.typography.bodyLarge,

)
}
Row {
Text(
text = stringResource(Res.string.feature_collection_sheet_total_due),
style = MaterialTheme.typography.bodyMedium,

)
Spacer(modifier = Modifier.width(16.dp))
Text(
text = client.loans?.get(index)?.totalDue.toString(),
text = (loan?.totalDue ?: 0.0).toString(),
style = MaterialTheme.typography.bodyMedium,
)
}
Expand All @@ -268,18 +269,16 @@ private fun IndividualCollectionSheetItem(
)
Spacer(modifier = Modifier.width(16.dp))
Text(
text = client.loans?.get(index)?.chargesDue.toString(),
text = (loan?.chargesDue ?: 0.0).toString(),
style = MaterialTheme.typography.bodyMedium,
)
}
if (loan?.productShortName != null) {
Text(
text = "${loan.productShortName} (#${loan.productShortName})",
style = MaterialTheme.typography.bodyMedium,
)
}
Text(
text = "${client.loans?.get(index)?.productShortName} (#${
client.loans?.get(
index,
)?.productShortName
})",
style = MaterialTheme.typography.bodyMedium,
)
}
Icon(
imageVector = MifosIcons.ArrowForward,
Expand All @@ -289,7 +288,7 @@ private fun IndividualCollectionSheetItem(
}
}

@DevicePreview
@Preview
@Composable
private fun IndividualCollectionSheetDetailsScreenEmptyPreview() {
IndividualCollectionSheetDetailsScreen(
Expand All @@ -303,7 +302,7 @@ private fun IndividualCollectionSheetDetailsScreenEmptyPreview() {
)
}

@DevicePreview
@Preview
@Composable
private fun IndividualCollectionSheetDetailsScreenErrorPreview() {
IndividualCollectionSheetDetailsScreen(
Expand All @@ -317,7 +316,7 @@ private fun IndividualCollectionSheetDetailsScreenErrorPreview() {
)
}

@DevicePreview
@Preview
@Composable
private fun IndividualCollectionSheetDetailsScreenLoadingPreview() {
IndividualCollectionSheetDetailsScreen(
Expand All @@ -331,7 +330,7 @@ private fun IndividualCollectionSheetDetailsScreenLoadingPreview() {
)
}

@DevicePreview
@Preview
@Composable
private fun IndividualCollectionSheetDetailsScreenSuccessPreview() {
IndividualCollectionSheetDetailsScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidclient.feature.collectionsheet.generated.resources.feature_collect
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import co.touchlab.kermit.Logger
import com.mifos.core.common.utils.Constants
import com.mifos.core.common.utils.DataState
import com.mifos.core.domain.useCases.SaveIndividualCollectionSheetUseCase
Expand All @@ -40,6 +41,12 @@ class IndividualCollectionSheetDetailsViewModel(
IndividualCollectionSheet()
}

init {
Logger.e("Revanth"){
sheet.toString()
}
}

@Suppress("ktlint:standard:property-naming")
private val uiStateInternal = MutableStateFlow<IndividualCollectionSheetDetailsUiState>(
IndividualCollectionSheetDetailsUiState.Empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDeta
import com.mifos.feature.individualCollectionSheet.paymentDetails.PaymentDetailsScreenRoute
import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json

fun NavGraphBuilder.individualCollectionSheetNavGraph(
Expand All @@ -38,7 +37,7 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph(
) {
individualCollectionSheetScreen(
onBackPressed = onBackPressed,
onDetail = { _, sheet ->
onDetail = { sheet ->
navController.navigateToIndividualCollectionSheetDetailScreen(sheet)
},

Expand All @@ -55,7 +54,7 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph(

private fun NavGraphBuilder.individualCollectionSheetScreen(
onBackPressed: () -> Unit,
onDetail: (String, IndividualCollectionSheet) -> Unit,
onDetail: (IndividualCollectionSheet) -> Unit,
) {
composable(
route = CollectionSheetScreens.IndividualCollectionSheetScreen.route,
Expand Down
Loading
Loading