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

refactor: refactor run report fragment to compose #2113

Merged
merged 2 commits into from
Jun 23, 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
5 changes: 5 additions & 0 deletions core/data/src/main/java/com/mifos/core/data/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import com.mifos.core.data.repository.CheckerInboxTasksRepository
import com.mifos.core.data.repository.GroupDetailsRepository
import com.mifos.core.data.repository.GroupsListRepository
import com.mifos.core.data.repository.NewIndividualCollectionSheetRepository
import com.mifos.core.data.repository.ReportCategoryRepository
import com.mifos.core.data.repository_imp.CenterDetailsRepositoryImp
import com.mifos.core.data.repository_imp.CenterListRepositoryImp
import com.mifos.core.data.repository_imp.CheckerInboxRepositoryImp
import com.mifos.core.data.repository_imp.CheckerInboxTasksRepositoryImp
import com.mifos.core.data.repository_imp.GroupDetailsRepositoryImp
import com.mifos.core.data.repository_imp.GroupsListRepositoryImpl
import com.mifos.core.data.repository_imp.NewIndividualCollectionSheetRepositoryImp
import com.mifos.core.data.repository_imp.ReportCategoryRepositoryImp
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -45,4 +47,7 @@ abstract class DataModule {

@Binds
internal abstract fun bindCheckerInboxRepository(impl: CheckerInboxRepositoryImp): CheckerInboxRepository

@Binds
internal abstract fun bindReportCategoryRepository(impl: ReportCategoryRepositoryImp): ReportCategoryRepository
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.mifos.mifosxdroid.online.runreports.reportcategory
package com.mifos.core.data.repository

import com.mifos.core.objects.runreports.client.ClientReportTypeItem
import rx.Observable

/**
* Created by Aditya Gupta on 12/08/23.
*/
interface ReportCategoryRepository {

fun getReportCategories(
reportCategory: String?,
suspend fun getReportCategories(
reportCategory: String,
genericResultSet: Boolean,
parameterType: Boolean
): Observable<List<ClientReportTypeItem>>
): List<ClientReportTypeItem>

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mifos.mifosxdroid.online.runreports.reportcategory
package com.mifos.core.data.repository_imp

import com.mifos.core.data.repository.ReportCategoryRepository
import com.mifos.core.network.datamanager.DataManagerRunReport
import com.mifos.core.objects.runreports.client.ClientReportTypeItem
import rx.Observable
import javax.inject.Inject

/**
Expand All @@ -11,13 +11,11 @@ import javax.inject.Inject
class ReportCategoryRepositoryImp @Inject constructor(private val dataManager: DataManagerRunReport) :
ReportCategoryRepository {

override fun getReportCategories(
reportCategory: String?,
override suspend fun getReportCategories(
reportCategory: String,
genericResultSet: Boolean,
parameterType: Boolean
): Observable<List<ClientReportTypeItem>> {
): List<ClientReportTypeItem> {
return dataManager.getReportCategories(reportCategory, genericResultSet, parameterType)
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import androidx.compose.material.icons.rounded.Check
import androidx.compose.material.icons.rounded.Close
import androidx.compose.material.icons.rounded.Delete
import androidx.compose.material.icons.rounded.FilterList
import androidx.compose.material.icons.rounded.KeyboardArrowDown
import androidx.compose.material.icons.rounded.KeyboardArrowUp
import androidx.compose.material.icons.rounded.PersonOutline
import androidx.compose.material.icons.rounded.Search
import androidx.compose.material.icons.rounded.Sync
Expand All @@ -27,4 +29,6 @@ object MifosIcons {
val check = Icons.Rounded.Check
val close = Icons.Rounded.Close
val delete = Icons.Rounded.Delete
val arrowUp = Icons.Rounded.KeyboardArrowUp
val arrowDown = Icons.Rounded.KeyboardArrowDown
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mifos.core.domain.use_cases

import com.mifos.core.common.utils.Resource
import com.mifos.core.data.repository.ReportCategoryRepository
import com.mifos.core.objects.runreports.client.ClientReportTypeItem
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetReportCategoryUseCase @Inject constructor(private val repository: ReportCategoryRepository) {

suspend operator fun invoke(
reportCategory: String,
genericResultSet: Boolean,
parameterType: Boolean
): Flow<Resource<List<ClientReportTypeItem>>> = flow {
try {
emit(Resource.Loading())
val response =
repository.getReportCategories(reportCategory, genericResultSet, parameterType)
emit(Resource.Success(response))
} catch (exception: Exception) {
emit(Resource.Error(exception.message.toString()))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import javax.inject.Singleton
*/
@Singleton
class DataManagerRunReport @Inject constructor(val mBaseApiManager: BaseApiManager) {
fun getReportCategories(
suspend fun getReportCategories(
reportCategory: String?,
genericResultSet: Boolean,
parameterType: Boolean
): Observable<List<ClientReportTypeItem>> {
): List<ClientReportTypeItem> {
return mBaseApiManager.runReportsService.getReportCategories(
reportCategory,
genericResultSet, parameterType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ interface RunReportsService {
* @return List of ClientReportTypeItem
*/
@GET(APIEndPoint.RUN_REPORTS + "/reportCategoryList")
fun getReportCategories(
suspend fun getReportCategories(
@Query("R_reportCategory") category: String?,
@Query("genericResultSet") genericResultSet: Boolean,
@Query("parameterType") parameterType: Boolean
): Observable<List<ClientReportTypeItem>>
): List<ClientReportTypeItem>

/**
* Endpoint to fetch FullParameter list after fetching the categories.
Expand Down
1 change: 1 addition & 0 deletions feature/report/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
23 changes: 23 additions & 0 deletions feature/report/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
alias(libs.plugins.mifos.android.library.jacoco)
}

android {
namespace = "com.mifos.feature.report"
}

dependencies {

implementation(projects.core.domain)

//DBFlow dependencies
kapt(libs.dbflow.processor)
implementation(libs.dbflow)
kapt(libs.github.dbflow.processor)
testImplementation(libs.hilt.android.testing)
testImplementation(projects.core.testing)

androidTestImplementation(projects.core.testing)
}
Empty file.
21 changes: 21 additions & 0 deletions feature/report/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mifos.feature.report

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("com.mifos.feature.report.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions feature/report/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Loading
Loading