diff --git a/feature/payments/.gitignore b/feature/payments/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/feature/payments/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/payments/build.gradle.kts b/feature/payments/build.gradle.kts new file mode 100644 index 00000000..dd734d5b --- /dev/null +++ b/feature/payments/build.gradle.kts @@ -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")) +} \ No newline at end of file diff --git a/feature/payments/consumer-rules.pro b/feature/payments/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/feature/payments/proguard-rules.pro b/feature/payments/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/feature/payments/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/feature/payments/src/androidTest/java/org/mifospay/payments/ExampleInstrumentedTest.kt b/feature/payments/src/androidTest/java/org/mifospay/payments/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..ec5267db --- /dev/null +++ b/feature/payments/src/androidTest/java/org/mifospay/payments/ExampleInstrumentedTest.kt @@ -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) + } +} \ No newline at end of file diff --git a/feature/payments/src/main/AndroidManifest.xml b/feature/payments/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/feature/payments/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/feature/payments/src/main/kotlin/org/mifospay/feature/payments/PaymentNavigation.kt b/feature/payments/src/main/kotlin/org/mifospay/feature/payments/PaymentNavigation.kt new file mode 100644 index 00000000..5e2816c8 --- /dev/null +++ b/feature/payments/src/main/kotlin/org/mifospay/feature/payments/PaymentNavigation.kt @@ -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) -> Unit +) { + composable(route = PAYMENTS_ROUTE) { + PaymentsRoute( + showQr = showQr, + onNewSI = onNewSI, + onAccountClicked = onAccountClicked, + viewReceipt = viewReceipt + ) + } +} diff --git a/feature/payments/src/main/kotlin/org/mifospay/feature/payments/PaymentsScreen.kt b/feature/payments/src/main/kotlin/org/mifospay/feature/payments/PaymentsScreen.kt new file mode 100644 index 00000000..bdc62187 --- /dev/null +++ b/feature/payments/src/main/kotlin/org/mifospay/feature/payments/PaymentsScreen.kt @@ -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) -> 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) -> 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 = "", { _ -> }, {}, {},{ _, _ ->}) +} diff --git a/feature/payments/src/test/java/org/mifospay/payments/ExampleUnitTest.kt b/feature/payments/src/test/java/org/mifospay/payments/ExampleUnitTest.kt new file mode 100644 index 00000000..dbd15bfa --- /dev/null +++ b/feature/payments/src/test/java/org/mifospay/payments/ExampleUnitTest.kt @@ -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) + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 95c29764..a5d6c693 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -48,3 +48,4 @@ include(":feature:invoices") include(":feature:invoices") include(":feature:settings") include(":feature:profile") +include(":feature:payments")