diff --git a/build-logic/convention/src/main/kotlin/CMPFeatureConventionPlugin.kt b/build-logic/convention/src/main/kotlin/CMPFeatureConventionPlugin.kt index f5f1eb5c95..8290974152 100644 --- a/build-logic/convention/src/main/kotlin/CMPFeatureConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/CMPFeatureConventionPlugin.kt @@ -17,8 +17,8 @@ class CMPFeatureConventionPlugin : Plugin { dependencies { add("commonMainImplementation", project(":core:ui")) add("commonMainImplementation", project(":core:designsystem")) - add("commonMainImplementation", project(":core:testing")) - add("commonMainImplementation", project(":core:data")) + //add("commonMainImplementation", project(":core:testing")) + //add("commonMainImplementation", project(":core:data")) add("commonMainImplementation", libs.findLibrary("koin.compose").get()) add("commonMainImplementation", libs.findLibrary("koin.compose.viewmodel").get()) diff --git a/feature/report/build.gradle.kts b/feature/report/build.gradle.kts index b3b81db17b..7a62ccc760 100644 --- a/feature/report/build.gradle.kts +++ b/feature/report/build.gradle.kts @@ -8,24 +8,23 @@ * See https://github.com/openMF/android-client/blob/master/LICENSE.md */ plugins { - alias(libs.plugins.mifos.android.feature) - alias(libs.plugins.mifos.android.library.compose) - alias(libs.plugins.mifos.android.library.jacoco) + alias(libs.plugins.mifos.cmp.feature) } android { namespace = "com.mifos.feature.report" } -dependencies { +kotlin { + sourceSets { + commonMain.dependencies { + implementation(compose.material3) + implementation(compose.components.resources) + implementation(compose.ui) + api(projects.core.common) + api(projects.core.model) - implementation(projects.core.domain) - - //DBFlow dependencies - testImplementation(libs.hilt.android.testing) - testImplementation(projects.core.testing) - - implementation(libs.kotlinx.serialization.json) + } + } +} - androidTestImplementation(projects.core.testing) -} \ No newline at end of file diff --git a/feature/report/src/main/java/com/mifos/feature/report/di/ReportModule.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/di/ReportModule.kt similarity index 100% rename from feature/report/src/main/java/com/mifos/feature/report/di/ReportModule.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/di/ReportModule.kt diff --git a/feature/report/src/main/java/com/mifos/feature/report/navigation/ReportNavigation.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/navigation/ReportNavigation.kt similarity index 100% rename from feature/report/src/main/java/com/mifos/feature/report/navigation/ReportNavigation.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/navigation/ReportNavigation.kt diff --git a/feature/report/src/main/java/com/mifos/feature/report/navigation/ReportScreens.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/navigation/ReportScreens.kt similarity index 100% rename from feature/report/src/main/java/com/mifos/feature/report/navigation/ReportScreens.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/navigation/ReportScreens.kt diff --git a/feature/report/src/main/java/com/mifos/feature/report/report/ReportScreen.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/report/ReportScreen.kt similarity index 83% rename from feature/report/src/main/java/com/mifos/feature/report/report/ReportScreen.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/report/ReportScreen.kt index 4531cc85b8..2754b33cdf 100644 --- a/feature/report/src/main/java/com/mifos/feature/report/report/ReportScreen.kt +++ b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/report/ReportScreen.kt @@ -9,10 +9,6 @@ */ package com.mifos.feature.report.report -import android.Manifest -import android.os.Build -import android.os.Environment -import android.widget.Toast import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyRow @@ -34,11 +30,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color.Companion.Black import androidx.compose.ui.graphics.Color.Companion.White import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.unit.dp import androidx.core.content.ContextCompat.getString @@ -46,9 +39,10 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.mifos.core.designsystem.component.MifosScaffold import com.mifos.core.designsystem.component.PermissionBox import com.mifos.core.model.objects.runreport.FullParameterListResponse -import com.mifos.feature.report.R +import core.designsystem.generated.resources.Res import kotlinx.coroutines.launch -import org.koin.androidx.compose.koinViewModel +import org.jetbrains.compose.resources.stringResource +import org.koin.compose.viewmodel.koinViewModel @Composable internal fun ReportScreen( @@ -66,7 +60,7 @@ internal fun ReportScreen( exportReport = { val reportDirectoryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) - .toString() + getString(context, R.string.feature_report_export_csv_directory) + .toString() + getString(context, Res.string.feature_report_export_csv_directory) viewModel.exportCsv( report = report, reportDirectoryPath = reportDirectoryPath, @@ -91,7 +85,7 @@ internal fun ReportScreen( when (state) { is ReportUiState.Initial -> Unit is ReportUiState.Message -> { - Toast.makeText(context, stringResource(id = state.message), Toast.LENGTH_SHORT).show() + Toast.makeText(context, stringResource(state.message), Toast.LENGTH_SHORT).show() } } @@ -105,10 +99,10 @@ internal fun ReportScreen( Manifest.permission.WRITE_EXTERNAL_STORAGE, ) }, - title = stringResource(R.string.feature_report_permission_required), - description = stringResource(R.string.feature_report_external_approve_permission_description), - confirmButtonText = stringResource(R.string.feature_report_proceed), - dismissButtonText = stringResource(R.string.feature_report_dismiss), + title = stringResource(Res.string.feature_report_permission_required), + description = stringResource(Res.string.feature_report_external_approve_permission_description), + confirmButtonText = stringResource(Res.string.feature_report_proceed), + dismissButtonText = stringResource(Res.string.feature_report_dismiss), onGranted = { LaunchedEffect(key1 = Unit) { scope.launch { @@ -121,7 +115,7 @@ internal fun ReportScreen( MifosScaffold( modifier = modifier, - title = stringResource(R.string.feature_report_title), + title = stringResource(Res.string.feature_report_title), onBackPressed = onBackPressed, actions = { TextButton( @@ -130,7 +124,7 @@ internal fun ReportScreen( }, colors = ButtonDefaults.textButtonColors(White), ) { - Text(text = stringResource(id = R.string.feature_report_export_csv), color = Black) + Text(text = stringResource(Res.string.feature_report_export_csv), color = Black) } }, snackbarHostState = snackbarHostState, @@ -166,7 +160,7 @@ private class ReportUiStateProvider : PreviewParameterProvider { override val values: Sequence get() = sequenceOf( ReportUiState.Initial, - ReportUiState.Message(R.string.feature_report_export_csv), + ReportUiState.Message(Res.string.feature_report_export_csv), ) } @@ -182,3 +176,6 @@ private fun ReportScreenPreview( exportReport = { }, ) } + + + diff --git a/feature/report/src/main/java/com/mifos/feature/report/report/ReportUiState.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/report/ReportUiState.kt similarity index 100% rename from feature/report/src/main/java/com/mifos/feature/report/report/ReportUiState.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/report/ReportUiState.kt diff --git a/feature/report/src/main/java/com/mifos/feature/report/report/ReportViewModel.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/report/ReportViewModel.kt similarity index 87% rename from feature/report/src/main/java/com/mifos/feature/report/report/ReportViewModel.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/report/ReportViewModel.kt index 087a7f3093..7316e3d3c8 100644 --- a/feature/report/src/main/java/com/mifos/feature/report/report/ReportViewModel.kt +++ b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/report/ReportViewModel.kt @@ -14,7 +14,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.mifos.core.common.utils.Constants import com.mifos.core.model.objects.runreport.FullParameterListResponse -import com.mifos.feature.report.R +import core.designsystem.generated.resources.Res import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow @@ -37,7 +37,7 @@ class ReportViewModel( fun exportCsv(report: FullParameterListResponse, reportDirectoryPath: String) = viewModelScope.launch(Dispatchers.IO) { - _reportUiState.value = ReportUiState.Message(R.string.feature_report_export_started) + _reportUiState.value = ReportUiState.Message(Res.string.feature_report_export_started) val timestamp = System.currentTimeMillis() val reportPath = "$reportDirectoryPath$timestamp.csv" val reportDirectory = File(reportDirectoryPath) @@ -46,7 +46,7 @@ class ReportViewModel( val makeRequiredDirectories = reportDirectory.mkdirs() if (!makeRequiredDirectories) { _reportUiState.value = - ReportUiState.Message(R.string.feature_report_unable_to_create_directory) + ReportUiState.Message(Res.string.feature_report_unable_to_create_directory) } } @@ -75,9 +75,9 @@ class ReportViewModel( fileWriter.close() } catch (e: Exception) { _reportUiState.value = - ReportUiState.Message(R.string.feature_report_unable_to_export) + ReportUiState.Message(Res.string.feature_report_unable_to_export) } _reportUiState.value = - ReportUiState.Message(R.string.feature_report_exported_successfully) + ReportUiState.Message(Res.string.feature_report_exported_successfully) } } diff --git a/feature/report/src/main/java/com/mifos/feature/report/reportDetail/ReportDetailScreen.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/reportDetail/ReportDetailScreen.kt similarity index 90% rename from feature/report/src/main/java/com/mifos/feature/report/reportDetail/ReportDetailScreen.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/reportDetail/ReportDetailScreen.kt index 3c75ba22fe..5227a78ea5 100644 --- a/feature/report/src/main/java/com/mifos/feature/report/reportDetail/ReportDetailScreen.kt +++ b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/reportDetail/ReportDetailScreen.kt @@ -46,14 +46,9 @@ import androidx.compose.ui.graphics.Color.Companion.Black import androidx.compose.ui.graphics.Color.Companion.Blue import androidx.compose.ui.graphics.Color.Companion.Gray import androidx.compose.ui.graphics.Color.Companion.White -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.tooling.preview.PreviewParameter -import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -65,8 +60,9 @@ import com.mifos.core.designsystem.component.MifosTextFieldDropdown import com.mifos.core.model.objects.runreport.DataRow import com.mifos.core.model.objects.runreport.FullParameterListResponse import com.mifos.core.model.objects.runreport.client.ClientReportTypeItem -import com.mifos.feature.report.R -import org.koin.androidx.compose.koinViewModel +import core.designsystem.generated.resources.Res +import org.jetbrains.compose.resources.stringResource +import org.koin.compose.viewmodel.koinViewModel @Composable internal fun ReportDetailScreen( @@ -210,21 +206,21 @@ internal fun ReportDetailScreen( MifosScaffold( modifier = modifier, - title = stringResource(id = R.string.feature_report_details), + title = stringResource(Res.string.feature_report_details), onBackPressed = onBackPressed, actions = { TextButton( onClick = { runReport(runReportDetail) }, colors = ButtonDefaults.textButtonColors(White), ) { - Text(text = stringResource(id = R.string.feature_report_run_report), color = Black) + Text(text = stringResource(Res.string.feature_report_run_report), color = Black) } }, snackbarHostState = snackbarHostState, ) { paddingValues -> Box(modifier = Modifier.padding(paddingValues)) { when (state) { - is ReportDetailUiState.Error -> MifosSweetError(message = stringResource(id = state.message)) { + is ReportDetailUiState.Error -> MifosSweetError(message = stringResource(state.message)) { onRetry() } @@ -368,7 +364,7 @@ private fun RunReportContent( .background(Blue, CircleShape), ) { Icon( - painter = painterResource(id = R.drawable.feature_report_ic_report_item), + painter = painterResource(Res.drawable.feature_report_ic_report_item), contentDescription = null, tint = Black, ) @@ -430,7 +426,7 @@ private fun RunReportContent( selectedOffice = value selectedOfficeId = officeList[index].row.first() }, - label = R.string.feature_report_office, + label = Res.string.feature_report_office, options = officeList.map { it.row[1] }, readOnly = true, ) @@ -447,7 +443,7 @@ private fun RunReportContent( selectedLoanPurpose = value selectedLoanPurposeId = loanPurposeList[index].row.first() }, - label = R.string.feature_report_loan_purpose, + label = Res.string.feature_report_loan_purpose, options = loanPurposeList.map { it.row[1] }, readOnly = true, ) @@ -464,7 +460,7 @@ private fun RunReportContent( selectedLoanOfficer = value selectedLoanOfficerId = reportOffices[index].row.first() }, - label = R.string.feature_report_loan_officer, + label = Res.string.feature_report_loan_officer, options = reportOffices.map { it.row[1] }, readOnly = true, ) @@ -481,7 +477,7 @@ private fun RunReportContent( selectedProducts = value selectedProductsId = reportProducts[index].row.first() }, - label = R.string.feature_report_product, + label = Res.string.feature_report_product, options = reportProducts.map { it.row[1] }, readOnly = true, ) @@ -498,7 +494,7 @@ private fun RunReportContent( selectedFund = value selectedFundId = fundList[index].row.first() }, - label = R.string.feature_report_fund, + label = Res.string.feature_report_fund, options = fundList.map { it.row[1] }, readOnly = true, ) @@ -515,7 +511,7 @@ private fun RunReportContent( selectedCurrency = value selectedCurrencyId = currencyList[index].row.first() }, - label = R.string.feature_report_currency, + label = Res.string.feature_report_currency, options = currencyList.map { it.row[1] }, readOnly = true, ) @@ -532,7 +528,7 @@ private fun RunReportContent( selectedParCalculator = value selectedParCalculatorId = parCalculatorList[index].row.first() }, - label = R.string.feature_report_par_type, + label = Res.string.feature_report_par_type, options = parCalculatorList.map { it.row[1] }, readOnly = true, ) @@ -549,7 +545,7 @@ private fun RunReportContent( selectedSavingsAccountDeposit = value selectedSavingsAccountDepositId = savingsAccountDepositList[index].row.first() }, - label = R.string.feature_report_saving_account, + label = Res.string.feature_report_saving_account, options = savingsAccountDepositList.map { it.row[1] }, readOnly = true, ) @@ -566,7 +562,7 @@ private fun RunReportContent( selectedGlAccount = value selectedGlAccountId = glAccountList[index].row.first() }, - label = R.string.feature_report_gl_account, + label = Res.string.feature_report_gl_account, options = glAccountList.map { it.row[1] }, readOnly = true, ) @@ -583,7 +579,7 @@ private fun RunReportContent( selectedObligationDate = value selectedObligationDateId = obligationDateList[index].row.first() }, - label = R.string.feature_report_obligation_date, + label = Res.string.feature_report_obligation_date, options = obligationDateList.map { it.row[1] }, readOnly = true, ) @@ -592,36 +588,4 @@ private fun RunReportContent( } } -private class ReportDetailUiStateProvider : PreviewParameterProvider { - override val values: Sequence - get() = sequenceOf( - ReportDetailUiState.Error(R.string.feature_report_failed_to_load_report_details), - ReportDetailUiState.Loading, - ReportDetailUiState.ParameterDetailsSuccess, - ) -} - -@Preview(showBackground = true) -@Composable -private fun ReportDetailScreenPreview( - @PreviewParameter(ReportDetailUiStateProvider::class) state: ReportDetailUiState, -) { - ReportDetailScreen( - reportItem = ClientReportTypeItem(), - state = state, - onBackPressed = {}, - onRetry = {}, - officeList = emptyList(), - loanPurposeList = emptyList(), - fundList = emptyList(), - currencyList = emptyList(), - parCalculatorList = emptyList(), - savingsAccountDepositList = emptyList(), - glAccountList = emptyList(), - obligationDateList = emptyList(), - reportOffices = emptyList(), - reportProducts = emptyList(), - runReport = {}, - ) -} diff --git a/feature/report/src/main/java/com/mifos/feature/report/reportDetail/ReportDetailUiState.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/reportDetail/ReportDetailUiState.kt similarity index 100% rename from feature/report/src/main/java/com/mifos/feature/report/reportDetail/ReportDetailUiState.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/reportDetail/ReportDetailUiState.kt diff --git a/feature/report/src/main/java/com/mifos/feature/report/reportDetail/ReportDetailViewModel.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/reportDetail/ReportDetailViewModel.kt similarity index 88% rename from feature/report/src/main/java/com/mifos/feature/report/reportDetail/ReportDetailViewModel.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/reportDetail/ReportDetailViewModel.kt index 01c872738c..76d4429db1 100644 --- a/feature/report/src/main/java/com/mifos/feature/report/reportDetail/ReportDetailViewModel.kt +++ b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/reportDetail/ReportDetailViewModel.kt @@ -12,6 +12,7 @@ package com.mifos.feature.report.reportDetail import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.mifos.core.common.network.MifosDispatchers import com.mifos.core.common.utils.Constants import com.mifos.core.common.utils.Resource import com.mifos.core.domain.useCases.GetReportFullParameterListUseCase @@ -22,7 +23,7 @@ import com.mifos.core.domain.useCases.GetRunReportWithQueryUseCase import com.mifos.core.model.objects.runreport.DataRow import com.mifos.core.model.objects.runreport.FullParameterListResponse import com.mifos.core.model.objects.runreport.client.ClientReportTypeItem -import com.mifos.feature.report.R +import core.designsystem.generated.resources.Res import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow @@ -68,7 +69,7 @@ class ReportDetailViewModel( when (result) { is Resource.Error -> _reportDetailUiState.value = - ReportDetailUiState.Error(R.string.feature_report_failed_to_load_report_details) + ReportDetailUiState.Error(Res.string.feature_report_failed_to_load_report_details) is Resource.Loading -> _reportDetailUiState.value = ReportDetailUiState.Loading @@ -80,7 +81,7 @@ class ReportDetailViewModel( } fun fetchParameterDetails(parameterName: String, parameterType: Boolean) = - viewModelScope.launch(Dispatchers.IO) { + viewModelScope.launch(MifosDispatchers.IO) { getReportParameterDetailsUseCase(parameterName, parameterType).collect { result -> when (result) { is Resource.Error -> Unit @@ -96,12 +97,12 @@ class ReportDetailViewModel( } fun fetchOffices(parameterName: String, officeId: Int, parameterType: Boolean) = - viewModelScope.launch(Dispatchers.IO) { + viewModelScope.launch(MifosDispatchers.IO) { getRunReportOfficesUseCase(parameterName, officeId, parameterType).collect { result -> when (result) { is Resource.Error -> _reportDetailUiState.value = - ReportDetailUiState.Error(R.string.feature_report_failed_to_load_report_details) + ReportDetailUiState.Error(Res.string.feature_report_failed_to_load_report_details) is Resource.Loading -> Unit @@ -114,12 +115,12 @@ class ReportDetailViewModel( } fun fetchProduct(parameterName: String, currencyId: String, parameterType: Boolean) = - viewModelScope.launch(Dispatchers.IO) { + viewModelScope.launch(MifosDispatchers.IO) { getRunReportProductUseCase(parameterName, currencyId, parameterType).collect { result -> when (result) { is Resource.Error -> _reportDetailUiState.value = - ReportDetailUiState.Error(R.string.feature_report_failed_to_load_report_details) + ReportDetailUiState.Error(Res.string.feature_report_failed_to_load_report_details) is Resource.Loading -> Unit @@ -132,12 +133,12 @@ class ReportDetailViewModel( } fun fetchRunReportWithQuery(reportName: String, options: MutableMap) = - viewModelScope.launch(Dispatchers.IO) { + viewModelScope.launch(MifosDispatchers.IO) { getRunReportWithQueryUseCase(reportName, options).collect { result -> when (result) { is Resource.Error -> _reportDetailUiState.value = - ReportDetailUiState.Error(R.string.feature_report_failed_to_load_report_details) + ReportDetailUiState.Error(Res.string.feature_report_failed_to_load_report_details) is Resource.Loading -> _reportDetailUiState.value = ReportDetailUiState.Loading diff --git a/feature/report/src/main/java/com/mifos/feature/report/runReport/RunReportScreen.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/runReport/RunReportScreen.kt similarity index 91% rename from feature/report/src/main/java/com/mifos/feature/report/runReport/RunReportScreen.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/runReport/RunReportScreen.kt index cf154d86c2..93b2804425 100644 --- a/feature/report/src/main/java/com/mifos/feature/report/runReport/RunReportScreen.kt +++ b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/runReport/RunReportScreen.kt @@ -11,6 +11,7 @@ package com.mifos.feature.report.runReport +import androidx.camera.core.Preview import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -49,15 +50,10 @@ import androidx.compose.ui.graphics.Color.Companion.Black import androidx.compose.ui.graphics.Color.Companion.Blue import androidx.compose.ui.graphics.Color.Companion.DarkGray import androidx.compose.ui.graphics.Color.Companion.White -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.tooling.preview.PreviewParameter -import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -66,8 +62,10 @@ import com.mifos.core.designsystem.component.MifosMenuDropDownItem import com.mifos.core.designsystem.component.MifosSweetError import com.mifos.core.designsystem.icon.MifosIcons import com.mifos.core.model.objects.runreport.client.ClientReportTypeItem -import com.mifos.feature.report.R -import org.koin.androidx.compose.koinViewModel +import core.designsystem.generated.resources.Res +import org.jetbrains.compose.resources.painterResource +import org.jetbrains.compose.resources.stringResource +import org.koin.compose.viewmodel.koinViewModel @Composable internal fun RunReportScreen( @@ -164,7 +162,7 @@ internal fun RunReportScreen( onDismissRequest = { showMenu = false }, ) { MifosMenuDropDownItem( - option = stringResource(id = R.string.feature_report_client), + option = stringResource(Res.string.feature_report_client), onClick = { onMenuClick(MenuItems.Client) menuTitle = MenuItems.Client.name @@ -172,7 +170,7 @@ internal fun RunReportScreen( }, ) MifosMenuDropDownItem( - option = stringResource(id = R.string.feature_report_loan), + option = stringResource(Res.string.feature_report_loan), onClick = { onMenuClick(MenuItems.Loan) menuTitle = MenuItems.Loan.name @@ -180,7 +178,7 @@ internal fun RunReportScreen( }, ) MifosMenuDropDownItem( - option = stringResource(id = R.string.feature_report_savings), + option = stringResource(Res.string.feature_report_savings), onClick = { onMenuClick(MenuItems.Savings) menuTitle = MenuItems.Savings.name @@ -188,7 +186,7 @@ internal fun RunReportScreen( }, ) MifosMenuDropDownItem( - option = stringResource(id = R.string.feature_report_fund), + option = stringResource(Res.string.feature_report_fund), onClick = { onMenuClick(MenuItems.Fund) menuTitle = MenuItems.Fund.name @@ -196,7 +194,7 @@ internal fun RunReportScreen( }, ) MifosMenuDropDownItem( - option = stringResource(id = R.string.feature_report_accounting), + option = stringResource(Res.string.feature_report_accounting), onClick = { onMenuClick(MenuItems.Accounting) menuTitle = MenuItems.Accounting.name @@ -204,7 +202,7 @@ internal fun RunReportScreen( }, ) MifosMenuDropDownItem( - option = stringResource(id = R.string.feature_report_xbrl), + option = stringResource(Res.string.feature_report_xbrl), onClick = { onMenuClick(MenuItems.XBRL) menuTitle = MenuItems.XBRL.name @@ -212,7 +210,7 @@ internal fun RunReportScreen( }, ) MifosMenuDropDownItem( - option = stringResource(id = R.string.feature_report_all), + option = stringResource(Res.string.feature_report_all), onClick = { onMenuClick(MenuItems.All) menuTitle = MenuItems.All.name @@ -229,7 +227,7 @@ internal fun RunReportScreen( ) { paddingValues -> Column(modifier = Modifier.padding(paddingValues)) { when (state) { - is RunReportUiState.Error -> MifosSweetError(message = stringResource(id = state.message)) { + is RunReportUiState.Error -> MifosSweetError(message = stringResource(state.message)) { onRetry() } @@ -287,7 +285,7 @@ private fun RunReportCardItem( .background(Blue, CircleShape), ) { Icon( - painter = painterResource(id = R.drawable.feature_report_ic_report_item), + painter = painterResource(Res.drawable.feature_report_ic_report_item), contentDescription = null, tint = Black, ) @@ -353,7 +351,7 @@ class RunReportUiStateProvider : PreviewParameterProvider { override val values: Sequence get() = sequenceOf( RunReportUiState.Loading, - RunReportUiState.Error(R.string.feature_report_failed_to_fetch_reports), + RunReportUiState.Error(Res.string.feature_report_failed_to_fetch_reports), RunReportUiState.RunReports(sampleRunReports), ) } @@ -379,3 +377,5 @@ val sampleRunReports = List(10) { reportCategory = "Category $it", ) } + + diff --git a/feature/report/src/main/java/com/mifos/feature/report/runReport/RunReportUiState.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/runReport/RunReportUiState.kt similarity index 100% rename from feature/report/src/main/java/com/mifos/feature/report/runReport/RunReportUiState.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/runReport/RunReportUiState.kt diff --git a/feature/report/src/main/java/com/mifos/feature/report/runReport/RunReportViewModel.kt b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/runReport/RunReportViewModel.kt similarity index 83% rename from feature/report/src/main/java/com/mifos/feature/report/runReport/RunReportViewModel.kt rename to feature/report/src/commonMain/kotlin/com/mifos/feature/report/runReport/RunReportViewModel.kt index 57e3192013..e7a7cc3604 100644 --- a/feature/report/src/main/java/com/mifos/feature/report/runReport/RunReportViewModel.kt +++ b/feature/report/src/commonMain/kotlin/com/mifos/feature/report/runReport/RunReportViewModel.kt @@ -11,10 +11,10 @@ package com.mifos.feature.report.runReport import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.mifos.core.common.network.MifosDispatchers import com.mifos.core.common.utils.Resource import com.mifos.core.domain.useCases.GetReportCategoryUseCase -import com.mifos.feature.report.R -import kotlinx.coroutines.Dispatchers +import core.designsystem.generated.resources.Res import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch @@ -30,7 +30,7 @@ class RunReportViewModel( reportCategory: String, genericResultSet: Boolean, parameterType: Boolean, - ) = viewModelScope.launch(Dispatchers.IO) { + ) = viewModelScope.launch(MifosDispatchers.IO) { getReportCategoryUseCase( reportCategory, genericResultSet, @@ -39,7 +39,7 @@ class RunReportViewModel( when (result) { is Resource.Error -> _runReportUiState.value = - RunReportUiState.Error(R.string.feature_report_failed_to_fetch_reports) + RunReportUiState.Error(Res.string.feature_report_failed_to_fetch_reports) is Resource.Loading -> _runReportUiState.value = RunReportUiState.Loading @@ -49,7 +49,7 @@ class RunReportViewModel( _runReportUiState.value = RunReportUiState.RunReports(reports) } else { _runReportUiState.value = - RunReportUiState.Error(R.string.feature_report_no_reports_found) + RunReportUiState.Error(Res.string.feature_report_no_reports_found) } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b12926d162..d5ed689681 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -181,6 +181,8 @@ packageName = "AndroidClient" packageNamespace = "org.mifos.client.desktop" packageVersion = "1.0.0" material3Android = "1.3.1" +uiToolingPreviewAndroid = "1.8.1" +cameraCore = "1.4.2" [libraries] @@ -542,6 +544,8 @@ moko-permission-compose = { group = "dev.icerock.moko", name = "permissions-comp window-size = { group = "dev.chrisbanes.material3", name = "material3-window-size-class-multiplatform", version.ref = "windowsSizeClass" } androidx-material3-android = { group = "androidx.compose.material3", name = "material3-android", version.ref = "material3Android" } +androidx-ui-tooling-preview-android = { group = "androidx.compose.ui", name = "ui-tooling-preview-android", version.ref = "uiToolingPreviewAndroid" } +androidx-camera-core = { group = "androidx.camera", name = "camera-core", version.ref = "cameraCore" } [plugins]