forked from openMF/android-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented compose navigation in group module (openMF#2187)
* feat: implemented groupNavGraph implemented group_nav_graph fixed error fixed topBar * compose navigation in group module
- Loading branch information
Showing
10 changed files
with
224 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
feature/groups/src/main/java/com/mifos/feature/groups/navigation/GroupListNavigation.kt
This file was deleted.
Oops, something went wrong.
157 changes: 157 additions & 0 deletions
157
feature/groups/src/main/java/com/mifos/feature/groups/navigation/GroupNavGraph.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
package com.mifos.feature.groups.navigation | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
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.objects.accounts.savings.DepositType | ||
import com.mifos.core.objects.client.Client | ||
import com.mifos.core.objects.group.Group | ||
import com.mifos.core.objects.response.SaveResponse | ||
import com.mifos.feature.groups.create_new_group.CreateNewGroupScreen | ||
import com.mifos.feature.groups.group_details.GroupDetailsScreen | ||
import com.mifos.feature.groups.group_list.GroupsListRoute | ||
import com.mifos.feature.groups.sync_group_payloads.SyncGroupPayloadsScreenRoute | ||
|
||
/** | ||
* Created by Pronay Sarker on 13/08/2024 | ||
*/ | ||
|
||
fun NavGraphBuilder.groupNavGraph( | ||
paddingValues: PaddingValues, | ||
navController: NavController, | ||
addGroupLoanAccount: (Int) -> Unit, | ||
addSavingsAccount: (Int) -> Unit, | ||
loadDocumentList: (Int) -> Unit, | ||
clientListFragment: (List<Client>) -> Unit, | ||
loadGroupDataTables: (Int) -> Unit, | ||
loadNotes: (Int) -> Unit, | ||
loadLoanAccountSummary: (Int) -> Unit, | ||
loadSavingsAccountSummary: (Int, DepositType) -> Unit, | ||
activateGroup: (Int) -> Unit | ||
) { | ||
navigation( | ||
startDestination = GroupScreen.GroupListScreen.route, | ||
route = "group_list_routes" | ||
) { | ||
groupListScreenRoute( | ||
paddingValues = paddingValues, | ||
onAddGroupClick = navController::navigateToCreateNewGroupScreen, | ||
onGroupClick = navController::navigateToGroupDetailsScreen, | ||
onSyncClick = { } | ||
) | ||
|
||
groupDetailsRoute( | ||
onBackPressed = navController::popBackStack, | ||
addGroupLoanAccount = addGroupLoanAccount, | ||
addSavingsAccount = addSavingsAccount, | ||
loadDocumentList = loadDocumentList, | ||
clientListFragment = clientListFragment, | ||
loadGroupDataTables = loadGroupDataTables, | ||
loadNotes = loadNotes, | ||
loadLoanAccountSummary = loadLoanAccountSummary, | ||
loadSavingsAccountSummary = loadSavingsAccountSummary, | ||
activateGroup = activateGroup | ||
) | ||
|
||
addNewGroupRoute( | ||
onGroupCreated = { } | ||
) | ||
|
||
syncGroupPayloadsRoute( | ||
onBackPressed = navController::popBackStack | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.groupListScreenRoute( | ||
paddingValues: PaddingValues, | ||
onAddGroupClick: () -> Unit, | ||
onGroupClick: (groupId: Int) -> Unit, | ||
onSyncClick: (List<Group>) -> Unit | ||
) { | ||
composable(route = GroupScreen.GroupListScreen.route) { | ||
GroupsListRoute( | ||
paddingValues = paddingValues, | ||
onAddGroupClick = onAddGroupClick, | ||
onGroupClick = onGroupClick, | ||
onSyncClick = onSyncClick | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.groupDetailsRoute( | ||
onBackPressed: () -> Unit, | ||
addGroupLoanAccount: (Int) -> Unit, | ||
addSavingsAccount: (Int) -> Unit, | ||
loadDocumentList: (Int) -> Unit, | ||
clientListFragment: (List<Client>) -> Unit, | ||
loadGroupDataTables: (Int) -> Unit, | ||
loadNotes: (Int) -> Unit, | ||
loadLoanAccountSummary: (Int) -> Unit, | ||
loadSavingsAccountSummary: (Int, DepositType) -> Unit, | ||
activateGroup: (Int) -> Unit | ||
) { | ||
composable( | ||
route = GroupScreen.GroupDetailsScreen.route, | ||
arguments = listOf( | ||
navArgument(name = Constants.GROUP_ID, builder = { type = NavType.IntType }) | ||
) | ||
) { | ||
GroupDetailsScreen( | ||
onBackPressed = onBackPressed, | ||
addLoanAccount = addGroupLoanAccount, | ||
addSavingsAccount = addSavingsAccount, | ||
documents = loadDocumentList, | ||
groupClients = clientListFragment, | ||
moreGroupInfo = loadGroupDataTables, | ||
notes = loadNotes, | ||
loanAccountSelected = loadLoanAccountSummary, | ||
savingsAccountSelected = loadSavingsAccountSummary, | ||
activateGroup = activateGroup | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.addNewGroupRoute( | ||
onGroupCreated: (group: SaveResponse?) -> Unit, | ||
) { | ||
composable(route = GroupScreen.CreateNewGroupScreen.route) { | ||
CreateNewGroupScreen( | ||
onGroupCreated = onGroupCreated | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.syncGroupPayloadsRoute( | ||
onBackPressed: () -> Unit | ||
) { | ||
composable(route = GroupScreen.SyncGroupPayloadScreen.route) { | ||
SyncGroupPayloadsScreenRoute( | ||
onBackPressed = onBackPressed | ||
) | ||
} | ||
} | ||
|
||
fun NavController.navigateToCreateNewGroupScreen() { | ||
navigate(GroupScreen.CreateNewGroupScreen.route) | ||
} | ||
|
||
fun NavController.navigateToGroupDetailsScreen(groupId: Int) { | ||
navigate(GroupScreen.GroupDetailsScreen.argument(groupId)) | ||
} | ||
|
||
fun NavController.navigateToSyncGroupPayloadScreen() { | ||
// TODO() | ||
navigate(GroupScreen.SyncGroupPayloadScreen.route) | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
20 changes: 20 additions & 0 deletions
20
feature/groups/src/main/java/com/mifos/feature/groups/navigation/GroupScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.mifos.feature.groups.navigation | ||
|
||
import com.mifos.core.common.utils.Constants | ||
|
||
/** | ||
* Created by Pronay Sarker on 13/08/2024 (10:39 AM) | ||
*/ | ||
sealed class GroupScreen(val route: String) { | ||
|
||
data object GroupListScreen : GroupScreen("group_list_screen") | ||
|
||
data object CreateNewGroupScreen : GroupScreen("create_new_group") | ||
|
||
data object GroupDetailsScreen : GroupScreen("group_details_screen/{${Constants.GROUP_ID}}"){ | ||
fun argument(groupId : Int) = "group_details_screen/${groupId}" | ||
} | ||
|
||
data object SyncGroupPayloadScreen : GroupScreen("sync_group_payload_screen") | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.