Skip to content

Commit

Permalink
Refactor- [:feature:guarantor] Apply & Fix Detekt, Ktlint Rules (#2680)
Browse files Browse the repository at this point in the history
  • Loading branch information
niyajali authored Sep 1, 2024
1 parent e355ae8 commit 7c5217c
Show file tree
Hide file tree
Showing 14 changed files with 417 additions and 283 deletions.
9 changes: 0 additions & 9 deletions feature/client-charge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,5 @@ android {
}

dependencies {
implementation(projects.core.ui)
implementation(projects.core.common)
implementation(projects.core.model)
implementation(projects.core.data)
implementation(libs.dbflow)
kapt(libs.dbflow.processor)
implementation(libs.dbflow.core)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.espresso.core)
}
20 changes: 10 additions & 10 deletions feature/guarantor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
Expand All @@ -7,13 +16,4 @@ android {
namespace = "org.mifos.mobile.feature.guarantor"
}

dependencies {
implementation(projects.core.ui)
implementation(projects.core.common)
implementation(projects.core.model)
implementation(projects.core.data)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.espresso.core)
}
dependencies { }
9 changes: 9 additions & 0 deletions feature/guarantor/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Mifos Initiative
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
package org.mifos.mobile.feature.guarantor.navigation

import androidx.navigation.NavController
Expand All @@ -9,10 +18,9 @@ import androidx.navigation.compose.navigation
import androidx.navigation.navArgument
import org.mifos.mobile.core.common.Constants.INDEX
import org.mifos.mobile.core.common.Constants.LOAN_ID
import org.mifos.mobile.feature.guarantor.screens.guarantor_add.AddGuarantorScreen
import org.mifos.mobile.feature.guarantor.screens.guarantor_details.GuarantorDetailScreen
import org.mifos.mobile.feature.guarantor.screens.guarantor_list.GuarantorListScreen

import org.mifos.mobile.feature.guarantor.screens.guarantorAdd.AddGuarantorScreen
import org.mifos.mobile.feature.guarantor.screens.guarantorDetails.GuarantorDetailScreen
import org.mifos.mobile.feature.guarantor.screens.guarantorList.GuarantorListScreen

fun NavController.navigateToGuarantorScreen(loanId: Long) {
navigate(GuarantorNavigation.GuarantorScreenBase.passArguments(loanId = loanId.toString()))
Expand All @@ -39,18 +47,18 @@ fun NavGraphBuilder.guarantorNavGraph(
navController.navigate(
GuarantorNavigation.GuarantorAdd.passArguments(
index = -1,
loanId = loanId
)
loanId = loanId,
),
)
},
onGuarantorClicked = { index, loanId ->
navController.navigate(
GuarantorNavigation.GuarantorDetails.passArguments(
index = index,
loanId = loanId
)
loanId = loanId,
),
)
}
},
)

detailGuarantorRoute(
Expand All @@ -59,64 +67,66 @@ fun NavGraphBuilder.guarantorNavGraph(
navController.navigate(
GuarantorNavigation.GuarantorAdd.passArguments(
index = index,
loanId = loanId
)
loanId = loanId,
),
)
}
},
)
}
}

fun NavGraphBuilder.listGuarantorRoute(
navigateBack: () -> Unit,
addGuarantor: (Long) -> Unit,
onGuarantorClicked: (Int, Long) -> Unit
onGuarantorClicked: (Int, Long) -> Unit,
) {
composable(
route = GuarantorNavigation.GuarantorList.route,
arguments = listOf(
navArgument(name = LOAN_ID) { type = NavType.StringType }
)
navArgument(name = LOAN_ID) { type = NavType.StringType },
),
) {
GuarantorListScreen(
navigateBack = navigateBack,
addGuarantor = addGuarantor,
onGuarantorClicked = onGuarantorClicked
onGuarantorClicked = onGuarantorClicked,
)
}
}

fun NavGraphBuilder.detailGuarantorRoute(
navigateBack: () -> Unit,
updateGuarantor: (index: Int, loanId: Long) -> Unit
updateGuarantor: (index: Int, loanId: Long) -> Unit,
) {
composable(
route = GuarantorNavigation.GuarantorDetails.route,
arguments = listOf(
navArgument(name = INDEX) { type = NavType.IntType },
navArgument(name = LOAN_ID) { type = NavType.LongType }
)
navArgument(name = LOAN_ID) { type = NavType.LongType },
),
) {
GuarantorDetailScreen(
navigateBack = navigateBack,
updateGuarantor = updateGuarantor
updateGuarantor = updateGuarantor,
)
}
}

fun NavGraphBuilder.addGuarantorRoute(
navigateBack: () -> Unit
navigateBack: () -> Unit,
) {
composable(
route = GuarantorNavigation.GuarantorAdd.route,
arguments = listOf(
navArgument(name = INDEX) { type = NavType.IntType; defaultValue = -1 },
navArgument(name = LOAN_ID) { type = NavType.LongType }
)
navArgument(name = INDEX) {
type = NavType.IntType
defaultValue = -1
},
navArgument(name = LOAN_ID) { type = NavType.LongType },
),
) {
AddGuarantorScreen(
navigateBack = navigateBack,
)
}
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
*/
package org.mifos.mobile.feature.guarantor.navigation

import org.mifos.mobile.core.common.Constants.INDEX
Expand All @@ -10,25 +19,25 @@ import org.mifos.mobile.feature.guarantor.navigation.GuarantorRoute.GUARANTOR_NA
sealed class GuarantorNavigation(val route: String) {

data object GuarantorScreenBase : GuarantorNavigation(
route = "$GUARANTOR_NAVIGATION_ROUTE_BASE/{$LOAN_ID}"
){
route = "$GUARANTOR_NAVIGATION_ROUTE_BASE/{$LOAN_ID}",
) {
fun passArguments(loanId: String) = "$GUARANTOR_NAVIGATION_ROUTE_BASE/$loanId"
}

data object GuarantorList : GuarantorNavigation(
route = "$GUARANTOR_LIST_SCREEN_ROUTE/{$LOAN_ID}"
){
route = "$GUARANTOR_LIST_SCREEN_ROUTE/{$LOAN_ID}",
) {
fun passArguments(loanId: String) = "$GUARANTOR_LIST_SCREEN_ROUTE/$loanId"
}

data object GuarantorDetails : GuarantorNavigation(
route = "$GUARANTOR_DETAIL_SCREEN_ROUTE/{$LOAN_ID}/{$INDEX}"
route = "$GUARANTOR_DETAIL_SCREEN_ROUTE/{$LOAN_ID}/{$INDEX}",
) {
fun passArguments(index: Int, loanId: Long) = "$GUARANTOR_DETAIL_SCREEN_ROUTE/$loanId/$index"
}

data object GuarantorAdd : GuarantorNavigation(
route = "$GUARANTOR_ADD_SCREEN_ROUTE/{$LOAN_ID}/{$INDEX}"
route = "$GUARANTOR_ADD_SCREEN_ROUTE/{$LOAN_ID}/{$INDEX}",
) {
fun passArguments(index: Int, loanId: Long) = "$GUARANTOR_ADD_SCREEN_ROUTE/$loanId/$index"
}
Expand All @@ -39,4 +48,4 @@ object GuarantorRoute {
const val GUARANTOR_LIST_SCREEN_ROUTE = "guarantor_list_screen_route"
const val GUARANTOR_DETAIL_SCREEN_ROUTE = "guarantor_detail_screen_route"
const val GUARANTOR_ADD_SCREEN_ROUTE = "guarantor_add_screen_route"
}
}
Loading

0 comments on commit 7c5217c

Please sign in to comment.