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

Make transfer feature module #1643

Merged
merged 1 commit into from
May 27, 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
@@ -0,0 +1,4 @@
package org.mifospay.common

const val PAYEE_EXTERNAL_ID_ARG = "payeeExternalId"
const val TRANSFER_AMOUNT_ARG = "transferAmount"
Original file line number Diff line number Diff line change
@@ -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
}
}
1 change: 1 addition & 0 deletions feature/make-transfer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
12 changes: 12 additions & 0 deletions feature/make-transfer/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 2 additions & 0 deletions feature/make-transfer/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 -> {
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mifospay.common.presenter
package org.mifospay.feature.make.transfer

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.mifospay.common.navigation
package org.mifospay.feature.make.transfer.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
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 +
Expand Down
23 changes: 23 additions & 0 deletions feature/make-transfer/src/main/res/drawable/transfer_failure.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="oval"
android:useLevel="false">

<solid android:color="@color/primaryDarkBlue"/>

</shape>

</item>

<item
android:bottom="10dp"
android:drawable="@drawable/ic_close" android:gravity="center"
android:left="10dp" android:right="10dp"
android:top="10dp"/>


</layer-list>
23 changes: 23 additions & 0 deletions feature/make-transfer/src/main/res/drawable/transfer_success.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="oval"
android:useLevel="false">

<solid android:color="@color/primaryDarkBlue"/>

</shape>

</item>

<item
android:bottom="10dp"
android:drawable="@drawable/ic_done" android:gravity="center"
android:left="10dp" android:right="10dp"
android:top="10dp"/>


</layer-list>
8 changes: 8 additions & 0 deletions feature/make-transfer/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<resources>
<string name="feature_make_transfer_loading">Loading</string>
<string name="feature_make_transfer_send_money">Send money</string>
<string name="feature_make_transfer_sending_to">Sending to</string>
<string name="feature_make_transfer_amount">Amount</string>
<string name="feature_make_transfer_transaction_success">Transaction successful</string>
<string name="feature_make_transfer_transaction_unable_to_process">Unable to process transfer</string>
</resources>
Original file line number Diff line number Diff line change
@@ -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)
}
}
1 change: 1 addition & 0 deletions mifospay/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {

implementation(projects.feature.auth)
implementation(projects.feature.passcode)
implementation(projects.feature.makeTransfer)

// Compose
implementation(libs.androidx.activity.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Loading