Moved payments to feature module (#1672)

This commit is contained in:
Aditya Kumdale 2024-06-20 20:39:50 +05:30 committed by GitHub
parent f1e9e74464
commit 7b8876306e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 206 additions and 0 deletions

1
feature/payments/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View 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"))
}

View File

21
feature/payments/proguard-rules.pro vendored Normal file
View 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

View File

@ -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)
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View File

@ -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
)
}
}

View File

@ -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 = "", { _ -> }, {}, {},{ _, _ ->})
}

View File

@ -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)
}
}

View File

@ -48,3 +48,4 @@ include(":feature:invoices")
include(":feature:invoices")
include(":feature:settings")
include(":feature:profile")
include(":feature:payments")