Skip to content

Commit

Permalink
Merge branch 'master' into nav_graph_checker_inbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-gupta99 authored Aug 21, 2024
2 parents 9cdcc3c + bd1948b commit a6f2e23
Show file tree
Hide file tree
Showing 59 changed files with 822 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ object Constants {
const val ACTIVATE_CENTER = "activate_center"
const val ACTIVATE_GROUP = "activate_group"
const val ACTIVATE_TYPE = "activation_type"
const val ACTIVATE_ID = "activation_id"
const val INTIAL_LOGIN = "initial_login"
const val INDIVIDUAL_SHEET = "collection_sheet"
const val DISBURSEMENT_DATE = "disbursement_date"
Expand Down Expand Up @@ -216,4 +217,5 @@ object Constants {
const val REPORT_TYPE_ITEM = "report_type_item"
const val REPORT_PARAMETER_RESPONSE = "report_parameter_response"
const val LOAN_WITH_ASSOCIATIONS = "loanWithAssociation"
const val PASSCODE_INITIAL_LOGIN = "passcode_initial_login"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ val LightGray = Color(0xFFD3D3D3)
val BluePrimary = Color(0xFF2D5BA8)
val BluePrimaryDark = Color(0xFF9BB1E3)
val BlueSecondary = Color(0xFFD7E2FC)
val LightGreen = Color(0xFF99CC00)
val LightGreen = Color(0xFF99CC00)
val SummerSky = Color(0xFF29B6F6)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mifos.feature.about.navigation

/**
* Created by Pronay Sarker on 18/08/2024 (2:42 PM)
*/
sealed class AboutScreens(val route: String) {
data object AboutScreen : AboutScreens(route = "about_screen_route")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import com.mifos.feature.about.AboutScreen
/**
* Created by Pronay Sarker on 10/08/2024 (7:56 AM)
*/
const val ABOUT_SCREEN_ROUTE = "about_screen_route"

fun NavController.navigateToAboutScreen() {
this.navigate(ABOUT_SCREEN_ROUTE)
}

fun NavGraphBuilder.aboutScreen(
onBackPressed: () -> Unit
) {
composable(ABOUT_SCREEN_ROUTE) {
composable(AboutScreens.AboutScreen.route) {
AboutScreen(
onBackPressed = onBackPressed
)
}
}
}

fun NavController.navigateToAboutScreen() {
navigate(AboutScreens.AboutScreen.route)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ import java.util.Locale

@Composable
fun ActivateScreen(
id: Int,
activateType: String,
onBackPressed: () -> Unit
) {

val viewModel: ActivateViewModel = hiltViewModel()
val state by viewModel.activateUiState.collectAsStateWithLifecycle()
val id by viewModel.id.collectAsStateWithLifecycle()
val activateType by viewModel.activateType.collectAsStateWithLifecycle()

ActivateScreen(
state = state,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.mifos.feature.activate

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.mifos.core.common.utils.Constants
import com.mifos.core.common.utils.Resource
import com.mifos.core.domain.use_cases.ActivateCenterUseCase
import com.mifos.core.domain.use_cases.ActivateClientUseCase
Expand All @@ -18,9 +20,13 @@ import javax.inject.Inject
class ActivateViewModel @Inject constructor(
private val activateClientUseCase: ActivateClientUseCase,
private val activateCenterUseCase: ActivateCenterUseCase,
private val activateGroupUseCase: ActivateGroupUseCase
private val activateGroupUseCase: ActivateGroupUseCase,
savedStateHandle: SavedStateHandle
) : ViewModel() {

val id = savedStateHandle.getStateFlow(key = Constants.ACTIVATE_ID, initialValue = 0)
val activateType = savedStateHandle.getStateFlow(key = Constants.ACTIVATE_TYPE, initialValue = "")

private val _activateUiState = MutableStateFlow<ActivateUiState>(ActivateUiState.Initial)
val activateUiState = _activateUiState.asStateFlow()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.mifos.feature.activate.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.mifos.core.common.utils.Constants
import com.mifos.feature.activate.ActivateScreen

/**
* Created by Pronay Sarker on 18/08/2024 (1:40 PM)
*/
fun NavGraphBuilder.activateScreen(
onBackPressed: () -> Unit
) {
composable(
route = ActivateScreens.ActivateScreen.route,
arguments = listOf(
navArgument(name = Constants.ACTIVATE_ID, builder = { NavType.IntType }),
navArgument(name = Constants.ACTIVATE_TYPE, builder = { NavType.StringType })
)
) {
ActivateScreen(
onBackPressed = onBackPressed
)
}
}

fun NavController.navigateToActivateScreen(id : Int, type : String){
navigate(ActivateScreens.ActivateScreen.argument(id, type))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mifos.feature.activate.navigation

import com.mifos.core.common.utils.Constants

/**
* Created by Pronay Sarker on 18/08/2024 (1:40 PM)
*/
sealed class ActivateScreens(val route: String) {
data object ActivateScreen : ActivateScreens("activate_screen/{${Constants.ACTIVATE_ID}}/{${Constants.ACTIVATE_TYPE}}") {
fun argument(id: Int, type: String) = "activate_screen/$id/$type"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.feature.auth.login.presentation
package com.mifos.feature.auth.login

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.feature.auth.login.presentation
package com.mifos.feature.auth.login

/**
* Created by Aditya Gupta on 06/08/23.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mifos.feature.auth.login.presentation
package com.mifos.feature.auth.login

import android.content.Context
import androidx.lifecycle.ViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.mifos.feature.auth.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import com.mifos.feature.auth.login.LoginScreen

fun NavGraphBuilder.authNavGraph(
navigateHome: () -> Unit,
navigatePasscode: () -> Unit,
updateServerConfig: () -> Unit
) {
navigation(
startDestination = AuthScreens.LoginScreen.route,
route = AuthScreens.LoginScreenRoute.route
) {
loginRoute(
navigatePasscode = navigatePasscode,
navigateHome = navigateHome,
updateServerConfig = updateServerConfig
)
}

}

fun NavGraphBuilder.loginRoute(
navigateHome: () -> Unit,
navigatePasscode: () -> Unit,
updateServerConfig: () -> Unit
) {
composable(
route = AuthScreens.LoginScreen.route
) {
LoginScreen(
homeIntent = navigateHome,
passcodeIntent = navigatePasscode,
onClickToUpdateServerConfig = updateServerConfig
)
}
}

fun NavController.navigateToLogin() {
navigate(AuthScreens.LoginScreen.route)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.mifos.feature.auth.navigation

sealed class AuthScreens(val route: String) {

data object LoginScreenRoute : AuthScreens("login_screen_route")

data object LoginScreen : AuthScreens("login_screen")

}
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ fun GenerateCollectionSheetScreen(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun GenerateCollectionSheetContent(
centerDetailsState: List<CenterDetail>?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ fun IndividualCollectionSheetScreen(
onBackPressed: () -> Unit,
onDetail: (String, IndividualCollectionSheet) -> Unit,
) {

val snackbarHostState = remember { SnackbarHostState() }

val pagerState = rememberPagerState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,16 @@ import com.mifos.feature.collection_sheet.R

@Composable
fun IndividualCollectionSheetDetailsScreen(
sheet: IndividualCollectionSheet,
onBackPressed: () -> Unit,
submit: (Int, IndividualCollectionSheetPayload, List<String>, LoanAndClientName, List<PaymentTypeOptions>, Int) -> Unit
) {

val viewModel: IndividualCollectionSheetDetailsViewModel = hiltViewModel()
val state by viewModel.individualCollectionSheetDetailsUiState.collectAsStateWithLifecycle()
val loansAndClientNames = viewModel.filterLoanAndClientNames(sheet.clients ?: emptyList())
val loansAndClientNames = viewModel.filterLoanAndClientNames(viewModel.sheet.clients ?: emptyList())

IndividualCollectionSheetDetailsScreen(
sheet = sheet,
sheet = viewModel.sheet,
loansAndClientNames = loansAndClientNames,
state = state,
onBackPressed = onBackPressed,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.gson.Gson
import com.mifos.core.common.utils.Constants
import com.mifos.core.common.utils.Resource
import com.mifos.core.domain.use_cases.SaveIndividualCollectionSheetUseCase
import com.mifos.core.network.model.IndividualCollectionSheetPayload
import com.mifos.core.objects.collectionsheet.ClientCollectionSheet
import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet
import com.mifos.core.objects.collectionsheet.LoanAndClientName
import com.mifos.feature.collection_sheet.R
import dagger.hilt.android.lifecycle.HiltViewModel
Expand All @@ -18,9 +22,13 @@ import javax.inject.Inject

@HiltViewModel
class IndividualCollectionSheetDetailsViewModel @Inject constructor(
private val saveIndividualCollectionSheetUseCase: SaveIndividualCollectionSheetUseCase
private val saveIndividualCollectionSheetUseCase: SaveIndividualCollectionSheetUseCase,
savedStateHandle: SavedStateHandle
) : ViewModel() {

private val arg = savedStateHandle.getStateFlow(key = Constants.INDIVIDUAL_SHEET, initialValue = "" )
val sheet : IndividualCollectionSheet = Gson().fromJson(arg.value, IndividualCollectionSheet::class.java)

private val _individualCollectionSheetDetailsUiState =
MutableStateFlow<IndividualCollectionSheetDetailsUiState>(
IndividualCollectionSheetDetailsUiState.Empty
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.mifos.feature.individual_collection_sheet.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import androidx.navigation.navigation
import com.mifos.core.common.utils.Constants
import com.mifos.core.network.model.IndividualCollectionSheetPayload
import com.mifos.core.objects.accounts.loan.PaymentTypeOptions
import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet
import com.mifos.core.objects.collectionsheet.LoanAndClientName
import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetScreen
import com.mifos.feature.individual_collection_sheet.individual_collection_sheet.ui.IndividualCollectionSheetScreen
import com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details.IndividualCollectionSheetDetailsScreen

/**
* Created by Pronay Sarker on 20/08/2024 (4:06 PM)
*/
fun NavGraphBuilder.individualCollectionSheetNavGraph(
navController: NavController,
onBackPressed: () -> Unit,
navigateToPaymentDetails: (Int, IndividualCollectionSheetPayload, List<String>, LoanAndClientName, List<PaymentTypeOptions>, Int) -> Unit
) {
navigation(
route = "generate_collection_sheet",
startDestination = CollectionSheetScreens.IndividualCollectionSheetScreen.route
) {
individualCollectionSheetScreen(
onBackPressed = onBackPressed,
onDetail = { _, sheet -> navController.navigateToIndividualCollectionSheetDetailScreen(sheet) }
)

individualCollectionSheetDetailScreen(
onBackPressed = onBackPressed,
submit = navigateToPaymentDetails
)
}
}

private fun NavGraphBuilder.individualCollectionSheetScreen(
onBackPressed: () -> Unit,
onDetail: (String, IndividualCollectionSheet) -> Unit
) {
composable(
route = CollectionSheetScreens.IndividualCollectionSheetScreen.route
) {
IndividualCollectionSheetScreen(
onBackPressed = onBackPressed,
onDetail = onDetail
)
}
}

private fun NavGraphBuilder.individualCollectionSheetDetailScreen(
onBackPressed: () -> Unit,
submit: (Int, IndividualCollectionSheetPayload, List<String>, LoanAndClientName, List<PaymentTypeOptions>, Int) -> Unit
) {
composable(
route = CollectionSheetScreens.IndividualCollectionSheetDetailScreen.route,
arguments = listOf(
navArgument(name = Constants.INDIVIDUAL_SHEET, builder = { NavType.StringType })
)
) {
IndividualCollectionSheetDetailsScreen(
onBackPressed = onBackPressed,
submit = submit
)
}
}

fun NavGraphBuilder.generateCollectionSheetScreen(
onBackPressed: () -> Unit
) {
composable(CollectionSheetScreens.GenerateCollectionSheetScreen.route) {
GenerateCollectionSheetScreen(
onBackPressed = onBackPressed
)
}
}

fun NavController.navigateToIndividualCollectionSheetDetailScreen(sheet: IndividualCollectionSheet) {
navigate(CollectionSheetScreens.IndividualCollectionSheetDetailScreen.argument(sheet))
}

fun NavController.navigateToIndividualCollectionSheet() {
navigate(CollectionSheetScreens.IndividualCollectionSheetScreen.route)
}
Loading

0 comments on commit a6f2e23

Please sign in to comment.