mirror of
https://github.com/openMF/mobile-wallet.git
synced 2026-02-06 11:36:57 +00:00
Moved payments to feature module (#1672)
This commit is contained in:
parent
f1e9e74464
commit
7b8876306e
1
feature/payments/.gitignore
vendored
Normal file
1
feature/payments/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
||||
18
feature/payments/build.gradle.kts
Normal file
18
feature/payments/build.gradle.kts
Normal file
@ -0,0 +1,18 @@
|
||||
plugins {
|
||||
alias(libs.plugins.mifospay.android.feature)
|
||||
alias(libs.plugins.mifospay.android.library.compose)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "org.mifospay.feature.payments"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.core.data)
|
||||
implementation(projects.feature.history)
|
||||
implementation(projects.feature.invoices)
|
||||
implementation(projects.feature.sendMoney)
|
||||
|
||||
//Todo:Remove after moving required packages to feature module
|
||||
implementation(project(":mifospay"))
|
||||
}
|
||||
0
feature/payments/consumer-rules.pro
Normal file
0
feature/payments/consumer-rules.pro
Normal file
21
feature/payments/proguard-rules.pro
vendored
Normal file
21
feature/payments/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@ -0,0 +1,24 @@
|
||||
package org.mifospay.payments
|
||||
|
||||
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.payments.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
4
feature/payments/src/main/AndroidManifest.xml
Normal file
4
feature/payments/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@ -0,0 +1,27 @@
|
||||
package org.mifospay.feature.payments
|
||||
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.compose.composable
|
||||
import com.mifospay.core.model.domain.Transaction
|
||||
|
||||
const val PAYMENTS_ROUTE = "payments_route"
|
||||
|
||||
fun NavController.navigateToPayments(navOptions: NavOptions) = navigate(PAYMENTS_ROUTE, navOptions)
|
||||
|
||||
fun NavGraphBuilder.paymentsScreen(
|
||||
showQr: (String) -> Unit,
|
||||
onNewSI: () -> Unit,
|
||||
viewReceipt: (String) -> Unit,
|
||||
onAccountClicked: (String, ArrayList<Transaction>) -> Unit
|
||||
) {
|
||||
composable(route = PAYMENTS_ROUTE) {
|
||||
PaymentsRoute(
|
||||
showQr = showQr,
|
||||
onNewSI = onNewSI,
|
||||
onAccountClicked = onAccountClicked,
|
||||
viewReceipt = viewReceipt
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
package org.mifospay.feature.payments
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.mifospay.core.model.domain.Transaction
|
||||
import org.mifospay.core.ui.MifosScrollableTabRow
|
||||
import org.mifospay.core.ui.utility.TabContent
|
||||
import org.mifospay.feature.history.HistoryScreen
|
||||
import org.mifospay.feature.invoices.InvoiceScreen
|
||||
import org.mifospay.feature.send.money.SendScreenRoute
|
||||
import org.mifospay.payments.TransferViewModel
|
||||
import org.mifospay.payments.ui.RequestScreen
|
||||
import org.mifospay.standinginstruction.ui.StandingInstructionsScreen
|
||||
|
||||
@Composable
|
||||
fun PaymentsRoute(
|
||||
viewModel: TransferViewModel = hiltViewModel(),
|
||||
showQr: (String) -> Unit,
|
||||
onNewSI: () -> Unit,
|
||||
viewReceipt: (String) -> Unit,
|
||||
onAccountClicked: (String, ArrayList<Transaction>) -> Unit
|
||||
) {
|
||||
val vpa by viewModel.vpa.collectAsStateWithLifecycle()
|
||||
PaymentScreenContent(vpa = vpa, showQr = showQr, onNewSI = onNewSI, onAccountClicked = onAccountClicked, viewReceipt = viewReceipt)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun PaymentScreenContent(
|
||||
vpa: String,
|
||||
showQr: (String) -> Unit,
|
||||
onNewSI: () -> Unit,
|
||||
viewReceipt: (String) -> Unit,
|
||||
onAccountClicked: (String, ArrayList<Transaction>) -> Unit
|
||||
) {
|
||||
|
||||
val pagerState = rememberPagerState(
|
||||
pageCount = { PaymentsScreenContents.entries.size }
|
||||
)
|
||||
|
||||
val tabContents = listOf(
|
||||
TabContent(PaymentsScreenContents.SEND.name) {
|
||||
SendScreenRoute(
|
||||
onBackClick = {},
|
||||
showToolBar = false,
|
||||
proceedWithMakeTransferFlow = { externalId, transferAmount ->
|
||||
|
||||
}
|
||||
)
|
||||
},
|
||||
TabContent(PaymentsScreenContents.REQUEST.name) {
|
||||
RequestScreen(showQr = { showQr.invoke(vpa) })
|
||||
},
|
||||
TabContent(PaymentsScreenContents.HISTORY.name) {
|
||||
HistoryScreen(
|
||||
accountClicked = onAccountClicked,
|
||||
viewReceipt = viewReceipt
|
||||
)
|
||||
},
|
||||
TabContent(PaymentsScreenContents.SI.name) {
|
||||
StandingInstructionsScreen(onNewSI = { onNewSI.invoke() })
|
||||
},
|
||||
TabContent(PaymentsScreenContents.INVOICES.name) {
|
||||
InvoiceScreen()
|
||||
}
|
||||
)
|
||||
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
MifosScrollableTabRow(tabContents = tabContents, pagerState = pagerState)
|
||||
}
|
||||
}
|
||||
|
||||
enum class PaymentsScreenContents {
|
||||
SEND,
|
||||
REQUEST,
|
||||
HISTORY,
|
||||
SI,
|
||||
INVOICES
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun PaymentsScreenPreview() {
|
||||
PaymentScreenContent(vpa = "", { _ -> }, {}, {},{ _, _ ->})
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package org.mifospay.payments
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -48,3 +48,4 @@ include(":feature:invoices")
|
||||
include(":feature:invoices")
|
||||
include(":feature:settings")
|
||||
include(":feature:profile")
|
||||
include(":feature:payments")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user