diff --git a/core/common/src/main/kotlin/org/mifospay/common/NavArgsConstants.kt b/core/common/src/main/kotlin/org/mifospay/common/NavArgsConstants.kt new file mode 100644 index 000000000..45c53c100 --- /dev/null +++ b/core/common/src/main/kotlin/org/mifospay/common/NavArgsConstants.kt @@ -0,0 +1,4 @@ +package org.mifospay.common + +const val PAYEE_EXTERNAL_ID_ARG = "payeeExternalId" +const val TRANSFER_AMOUNT_ARG = "transferAmount" diff --git a/core/data/src/main/java/org/mifospay/core/data/repository/local/LocalRepository.kt b/core/data/src/main/java/org/mifospay/core/data/repository/local/LocalRepository.kt new file mode 100644 index 000000000..ae922af1f --- /dev/null +++ b/core/data/src/main/java/org/mifospay/core/data/repository/local/LocalRepository.kt @@ -0,0 +1,25 @@ +package org.mifospay.core.data.repository.local + +import org.mifospay.core.datastore.PreferencesHelper +import com.mifospay.core.model.domain.client.Client +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class LocalRepository @Inject constructor(val preferencesHelper: PreferencesHelper) { + + val clientDetails: Client + get() { + val details = Client() + details.name = preferencesHelper.fullName + details.clientId = preferencesHelper.clientId + details.externalId = preferencesHelper.clientVpa + return details + } + + fun saveClientData(client: Client) { + preferencesHelper.saveFullName(client.name) + preferencesHelper.clientId = client.clientId + preferencesHelper.clientVpa = client.externalId + } +} diff --git a/feature/make-transfer/.gitignore b/feature/make-transfer/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/feature/make-transfer/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/make-transfer/build.gradle.kts b/feature/make-transfer/build.gradle.kts new file mode 100644 index 000000000..74ea21ed4 --- /dev/null +++ b/feature/make-transfer/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + alias(libs.plugins.mifospay.android.feature) + alias(libs.plugins.mifospay.android.library.compose) +} + +android { + namespace = "org.mifospay.feature.make.transfer" +} + +dependencies { + implementation(projects.core.data) +} diff --git a/feature/make-transfer/src/androidTest/java/org/mifospay/feature/make/transfer/ExampleInstrumentedTest.kt b/feature/make-transfer/src/androidTest/java/org/mifospay/feature/make/transfer/ExampleInstrumentedTest.kt new file mode 100644 index 000000000..0d13a07f0 --- /dev/null +++ b/feature/make-transfer/src/androidTest/java/org/mifospay/feature/make/transfer/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package org.mifospay.feature.make.transfer + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("org.mifospay.feature.make.transfer", appContext.packageName) + } +} \ No newline at end of file diff --git a/feature/make-transfer/src/main/AndroidManifest.xml b/feature/make-transfer/src/main/AndroidManifest.xml new file mode 100644 index 000000000..8072ee00d --- /dev/null +++ b/feature/make-transfer/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/mifospay/src/main/java/org/mifospay/common/ui/MakeTransferScreen.kt b/feature/make-transfer/src/main/kotlin/org/mifospay/feature/make/transfer/MakeTransferScreen.kt similarity index 93% rename from mifospay/src/main/java/org/mifospay/common/ui/MakeTransferScreen.kt rename to feature/make-transfer/src/main/kotlin/org/mifospay/feature/make/transfer/MakeTransferScreen.kt index a222b5d05..b8fa36787 100644 --- a/mifospay/src/main/java/org/mifospay/common/ui/MakeTransferScreen.kt +++ b/feature/make-transfer/src/main/kotlin/org/mifospay/feature/make/transfer/MakeTransferScreen.kt @@ -1,4 +1,4 @@ -package org.mifospay.common.ui +package org.mifospay.feature.make.transfer import android.widget.Toast import androidx.compose.foundation.layout.Arrangement @@ -20,7 +20,6 @@ import androidx.compose.material3.SheetState import androidx.compose.material3.Text import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.rememberCoroutineScope @@ -40,11 +39,7 @@ import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import kotlinx.coroutines.launch -import org.mifospay.R import org.mifospay.common.Constants -import org.mifospay.common.presenter.MakeTransferState -import org.mifospay.common.presenter.MakeTransferViewModel -import org.mifospay.common.presenter.ShowTransactionStatus import org.mifospay.core.designsystem.component.MifosOverlayLoadingWheel @Composable @@ -76,7 +71,9 @@ fun MakeTransferScreen( val context = LocalContext.current when (uiState) { MakeTransferState.Loading -> { - MifosOverlayLoadingWheel(contentDesc = stringResource(R.string.loading)) + MifosOverlayLoadingWheel( + contentDesc = stringResource(R.string.feature_make_transfer_loading) + ) } is MakeTransferState.Error -> { @@ -170,7 +167,7 @@ fun MakeTransferContent( .fillMaxWidth() ) { Text( - text = stringResource(id = R.string.send_money), + text = stringResource(id = R.string.feature_make_transfer_send_money), style = TextStyle( fontSize = 24.sp, fontWeight = FontWeight.Bold, @@ -192,7 +189,7 @@ fun MakeTransferContent( .padding(20.dp) ) { Text( - text = stringResource(id = R.string.sending_to) + Constants.COLON, + text = stringResource(id = R.string.feature_make_transfer_sending_to) + Constants.COLON, style = TextStyle( Color.Black, MaterialTheme.typography.bodyMedium.fontSize @@ -222,7 +219,7 @@ fun MakeTransferContent( Spacer(modifier = Modifier.height(20.dp)) Text( - text = stringResource(id = R.string.amount) + Constants.COLON, + text = stringResource(id = R.string.feature_make_transfer_amount) + Constants.COLON, style = TextStyle( Color.Black, MaterialTheme.typography.bodyMedium.fontSize @@ -295,9 +292,9 @@ fun TransactionStatusContent(showTransactionStatus: ShowTransactionStatus) { ) { Text( text = if (showTransactionStatus.showSuccessStatus) { - stringResource(id = R.string.transaction_success) + stringResource(id = R.string.feature_make_transfer_transaction_success) } else { - stringResource(id = R.string.transaction_unable_to_process) + stringResource(id = R.string.feature_make_transfer_transaction_unable_to_process) }, style = TextStyle( fontSize = 24.sp, @@ -322,9 +319,9 @@ fun TransactionStatusContent(showTransactionStatus: ShowTransactionStatus) { painterResource(R.drawable.transfer_failure) }, contentDescription = if (showTransactionStatus.showSuccessStatus) { - stringResource(id = R.string.transaction_success) + stringResource(id = R.string.feature_make_transfer_transaction_success) } else { - stringResource(id = R.string.transaction_unable_to_process) + stringResource(id = R.string.feature_make_transfer_transaction_unable_to_process) }, modifier = Modifier .align(Alignment.Center) diff --git a/mifospay/src/main/java/org/mifospay/common/presenter/MakeTransferViewModel.kt b/feature/make-transfer/src/main/kotlin/org/mifospay/feature/make/transfer/MakeTransferViewModel.kt similarity index 95% rename from mifospay/src/main/java/org/mifospay/common/presenter/MakeTransferViewModel.kt rename to feature/make-transfer/src/main/kotlin/org/mifospay/feature/make/transfer/MakeTransferViewModel.kt index b44a8407d..39f95d6fa 100644 --- a/mifospay/src/main/java/org/mifospay/common/presenter/MakeTransferViewModel.kt +++ b/feature/make-transfer/src/main/kotlin/org/mifospay/feature/make/transfer/MakeTransferViewModel.kt @@ -1,4 +1,4 @@ -package org.mifospay.common.presenter +package org.mifospay.feature.make.transfer import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel @@ -11,13 +11,13 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn +import org.mifospay.common.PAYEE_EXTERNAL_ID_ARG +import org.mifospay.common.TRANSFER_AMOUNT_ARG import org.mifospay.core.data.base.UseCase import org.mifospay.core.data.base.UseCaseHandler import org.mifospay.core.data.domain.usecase.account.TransferFunds import org.mifospay.core.data.domain.usecase.client.SearchClient -import org.mifospay.data.local.LocalRepository -import org.mifospay.payments.send.navigation.PAYEE_EXTERNAL_ID_ARG -import org.mifospay.payments.send.navigation.TRANSFER_AMOUNT_ARG +import org.mifospay.core.data.repository.local.LocalRepository import javax.inject.Inject @HiltViewModel diff --git a/mifospay/src/main/java/org/mifospay/common/navigation/MakeTransferNavigation.kt b/feature/make-transfer/src/main/kotlin/org/mifospay/feature/make/transfer/navigation/MakeTransferNavigation.kt similarity index 86% rename from mifospay/src/main/java/org/mifospay/common/navigation/MakeTransferNavigation.kt rename to feature/make-transfer/src/main/kotlin/org/mifospay/feature/make/transfer/navigation/MakeTransferNavigation.kt index 47ec0d62e..2e3ff2392 100644 --- a/mifospay/src/main/java/org/mifospay/common/navigation/MakeTransferNavigation.kt +++ b/feature/make-transfer/src/main/kotlin/org/mifospay/feature/make/transfer/navigation/MakeTransferNavigation.kt @@ -1,4 +1,4 @@ -package org.mifospay.common.navigation +package org.mifospay.feature.make.transfer.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder @@ -6,9 +6,9 @@ import androidx.navigation.NavOptions import androidx.navigation.NavType import androidx.navigation.compose.composable import androidx.navigation.navArgument -import org.mifospay.common.ui.MakeTransferScreenRoute -import org.mifospay.payments.send.navigation.PAYEE_EXTERNAL_ID_ARG -import org.mifospay.payments.send.navigation.TRANSFER_AMOUNT_ARG +import org.mifospay.common.PAYEE_EXTERNAL_ID_ARG +import org.mifospay.common.TRANSFER_AMOUNT_ARG +import org.mifospay.feature.make.transfer.MakeTransferScreenRoute const val MAKE_TRANSFER_ROUTE_BASE = "make_transfer_route" const val MAKE_TRANSFER_ROUTE = MAKE_TRANSFER_ROUTE_BASE + diff --git a/feature/make-transfer/src/main/res/drawable/transfer_failure.xml b/feature/make-transfer/src/main/res/drawable/transfer_failure.xml new file mode 100644 index 000000000..0d548e884 --- /dev/null +++ b/feature/make-transfer/src/main/res/drawable/transfer_failure.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/feature/make-transfer/src/main/res/drawable/transfer_success.xml b/feature/make-transfer/src/main/res/drawable/transfer_success.xml new file mode 100644 index 000000000..63e3c60c8 --- /dev/null +++ b/feature/make-transfer/src/main/res/drawable/transfer_success.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/feature/make-transfer/src/main/res/values/strings.xml b/feature/make-transfer/src/main/res/values/strings.xml new file mode 100644 index 000000000..0a9915d59 --- /dev/null +++ b/feature/make-transfer/src/main/res/values/strings.xml @@ -0,0 +1,8 @@ + + Loading + Send money + Sending to + Amount + Transaction successful + Unable to process transfer + diff --git a/feature/make-transfer/src/test/java/org/mifospay/feature/make/transfer/ExampleUnitTest.kt b/feature/make-transfer/src/test/java/org/mifospay/feature/make/transfer/ExampleUnitTest.kt new file mode 100644 index 000000000..3a3b0cf4d --- /dev/null +++ b/feature/make-transfer/src/test/java/org/mifospay/feature/make/transfer/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package org.mifospay.feature.make.transfer + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/mifospay/build.gradle.kts b/mifospay/build.gradle.kts index 52e58611a..e6ee648a9 100644 --- a/mifospay/build.gradle.kts +++ b/mifospay/build.gradle.kts @@ -72,6 +72,7 @@ dependencies { implementation(projects.feature.auth) implementation(projects.feature.passcode) + implementation(projects.feature.makeTransfer) // Compose implementation(libs.androidx.activity.compose) diff --git a/mifospay/src/main/java/org/mifospay/navigation/MifosNavHost.kt b/mifospay/src/main/java/org/mifospay/navigation/MifosNavHost.kt index 25d7b2aa4..ec3e87018 100644 --- a/mifospay/src/main/java/org/mifospay/navigation/MifosNavHost.kt +++ b/mifospay/src/main/java/org/mifospay/navigation/MifosNavHost.kt @@ -9,9 +9,9 @@ import androidx.compose.ui.platform.LocalContext import androidx.navigation.compose.NavHost import com.mifospay.core.model.domain.Transaction import org.mifospay.common.Constants -import org.mifospay.common.navigation.makeTransferScreen -import org.mifospay.common.navigation.navigateToMakeTransferScreen import org.mifospay.editprofile.ui.EditProfileActivity +import org.mifospay.feature.make.transfer.navigation.makeTransferScreen +import org.mifospay.feature.make.transfer.navigation.navigateToMakeTransferScreen import org.mifospay.history.specific_transactions.ui.SpecificTransactionsActivity import org.mifospay.home.navigation.HOME_ROUTE import org.mifospay.home.navigation.financeScreen diff --git a/mifospay/src/main/java/org/mifospay/payments/send/SendScreenRoute.kt b/mifospay/src/main/java/org/mifospay/payments/send/SendScreenRoute.kt index 3d4697eb6..81421fc37 100644 --- a/mifospay/src/main/java/org/mifospay/payments/send/SendScreenRoute.kt +++ b/mifospay/src/main/java/org/mifospay/payments/send/SendScreenRoute.kt @@ -52,7 +52,6 @@ import com.togitech.ccp.component.TogiCountryCodePicker import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.mifospay.R -import org.mifospay.common.presenter.MakeTransferViewModel import org.mifospay.core.designsystem.component.MfOutlinedTextField import org.mifospay.core.designsystem.component.MfOverlayLoadingWheel import org.mifospay.core.designsystem.component.MifosButton diff --git a/settings.gradle.kts b/settings.gradle.kts index 53d8ba4c8..822ce0cba 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,7 +21,7 @@ rootProject.name = "mobile-wallet" enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") include(":mifospay") -include(":feature:auth") + include(":core:data") include(":core:datastore") include(":core:designsystem") @@ -31,5 +31,8 @@ include(":core:network") include(":core:network") include(":core:model") include(":core:datastore-proto") -include(":feature:passcode") include(":core:analytics") + +include(":feature:passcode") +include(":feature:auth") +include(":feature:make-transfer")