Skip to content

Commit

Permalink
refactor: refactor run report fragment to compose
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-gupta99 committed Jun 17, 2024
1 parent 8fa9130 commit 865ecb6
Show file tree
Hide file tree
Showing 27 changed files with 617 additions and 212 deletions.
9 changes: 7 additions & 2 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 @@ -5,11 +5,13 @@ 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.CenterListRepositoryImp
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 All @@ -31,8 +33,11 @@ abstract class DataModule {
): GroupsListRepository

@Binds
internal abstract fun provideGroupDetailsRepository(impl : GroupDetailsRepositoryImp) : GroupDetailsRepository
internal abstract fun provideGroupDetailsRepository(impl: GroupDetailsRepositoryImp): GroupDetailsRepository

@Binds
internal abstract fun bindCenterListRepository(impl: CenterListRepositoryImp): CenterListRepository

@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 @@ -2,7 +2,13 @@ package com.mifos.core.designsystem.icon

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Add
import androidx.compose.material.icons.rounded.ArrowBackIosNew
import androidx.compose.material.icons.rounded.KeyboardArrowDown
import androidx.compose.material.icons.rounded.KeyboardArrowUp

object MifosIcons {
val Add = Icons.Rounded.Add
val arrowUp = Icons.Rounded.KeyboardArrowUp
val arrowDown = Icons.Rounded.KeyboardArrowDown
val arrowBack = Icons.Rounded.ArrowBackIosNew
}
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

0 comments on commit 865ecb6

Please sign in to comment.