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: navigation components center module
- Loading branch information
1 parent
a33c278
commit fc08922
Showing
14 changed files
with
209 additions
and
100 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
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
32 changes: 0 additions & 32 deletions
32
feature/center/src/main/java/com/mifos/feature/center/navigation/CenterListNavigation.kt
This file was deleted.
Oops, something went wrong.
148 changes: 148 additions & 0 deletions
148
feature/center/src/main/java/com/mifos/feature/center/navigation/CenterNavigation.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,148 @@ | ||
package com.mifos.feature.center.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.client.Client | ||
import com.mifos.core.objects.group.Center | ||
import com.mifos.feature.center.center_details.CenterDetailsScreen | ||
import com.mifos.feature.center.center_group_list.GroupListScreen | ||
import com.mifos.feature.center.center_list.ui.CenterListScreen | ||
import com.mifos.feature.center.create_center.CreateNewCenterScreen | ||
import com.mifos.feature.center.sync_center_payloads.SyncCenterPayloadsScreenRoute | ||
|
||
fun NavGraphBuilder.centerNavGraph( | ||
navController: NavController, | ||
paddingValues: PaddingValues, | ||
onActivateCenter: (Int,String) -> Unit, | ||
addSavingsAccount: (Int) -> Unit | ||
) { | ||
navigation( | ||
startDestination = CenterScreens.CenterListScreen.route, | ||
route = "center_screen_route" | ||
) { | ||
centerListScreenRoute( | ||
paddingValues = paddingValues, | ||
createNewCenter = navController::navigateCreateCenterScreenRoute, | ||
syncClicked = { }, // TODO open sync dialog inside center list screen | ||
onCenterSelect = navController::navigateCenterDetailsScreenRoute | ||
) | ||
centerDetailScreenRoute( | ||
onBackPressed = navController::popBackStack, | ||
onActivateCenter = onActivateCenter, | ||
addSavingsAccount = addSavingsAccount, | ||
groupList = navController::navigateCenterGroupListScreenRoute | ||
) | ||
centerGroupListScreenRoute( | ||
onBackPressed = navController::popBackStack, | ||
loadClientsOfGroup = { } | ||
) | ||
createCenterScreenRoute( | ||
onCreateSuccess = navController::popBackStack | ||
) | ||
syncCenterPayloadsScreenRoute( | ||
onBackPressed = navController::popBackStack | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.centerListScreenRoute( | ||
paddingValues: PaddingValues, | ||
createNewCenter: () -> Unit, | ||
syncClicked: (List<Center>) -> Unit, | ||
onCenterSelect: (Int) -> Unit | ||
) { | ||
composable( | ||
route = CenterScreens.CenterListScreen.route | ||
) { | ||
CenterListScreen( | ||
paddingValues = paddingValues, | ||
createNewCenter = createNewCenter, | ||
syncClicked = syncClicked, | ||
onCenterSelect = onCenterSelect | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.centerDetailScreenRoute( | ||
onBackPressed: () -> Unit, | ||
onActivateCenter: (Int,String) -> Unit, | ||
addSavingsAccount: (Int) -> Unit, | ||
groupList: (Int) -> Unit | ||
) { | ||
composable( | ||
route = CenterScreens.CenterDetailScreen.route, | ||
arguments = listOf(navArgument(Constants.CENTER_ID, builder = { type = NavType.IntType })) | ||
) { | ||
CenterDetailsScreen( | ||
onBackPressed = onBackPressed, | ||
onActivateCenter = {onActivateCenter(it,Constants.ACTIVATE_CENTER)}, | ||
addSavingsAccount = addSavingsAccount, | ||
groupList = groupList | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.centerGroupListScreenRoute( | ||
onBackPressed: () -> Unit, | ||
loadClientsOfGroup: (List<Client>) -> Unit | ||
) { | ||
composable( | ||
route = CenterScreens.CenterGroupListScreen.route, | ||
arguments = listOf(navArgument(Constants.CENTER_ID, builder = { type = NavType.IntType })) | ||
) { | ||
GroupListScreen( | ||
onBackPressed = onBackPressed, | ||
loadClientsOfGroup = loadClientsOfGroup | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.createCenterScreenRoute( | ||
onCreateSuccess: () -> Unit | ||
) { | ||
composable( | ||
route = CenterScreens.CreateCenterScreen.route | ||
) { | ||
CreateNewCenterScreen( | ||
onCreateSuccess = onCreateSuccess | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.syncCenterPayloadsScreenRoute( | ||
onBackPressed: () -> Unit | ||
) { | ||
composable( | ||
route = CenterScreens.SyncCenterPayloadsScreen.route | ||
) { | ||
SyncCenterPayloadsScreenRoute( | ||
onBackPressed = onBackPressed | ||
) | ||
} | ||
} | ||
|
||
fun NavController.navigateCenterListScreenRoute() { | ||
navigate(CenterScreens.CenterListScreen.route) | ||
} | ||
|
||
fun NavController.navigateCenterDetailsScreenRoute(centerId: Int) { | ||
navigate(CenterScreens.CenterDetailScreen.argument(centerId)) | ||
} | ||
|
||
fun NavController.navigateCreateCenterScreenRoute() { | ||
navigate(CenterScreens.CreateCenterScreen.route) | ||
} | ||
|
||
fun NavController.navigateCenterGroupListScreenRoute(centerId: Int) { | ||
navigate(CenterScreens.CenterGroupListScreen.arguments(centerId)) | ||
} | ||
|
||
fun NavController.navigateCenterSyncPayloadsScreenRoute() { | ||
navigate(CenterScreens.SyncCenterPayloadsScreen.route) | ||
} |
20 changes: 20 additions & 0 deletions
20
feature/center/src/main/java/com/mifos/feature/center/navigation/CenterScreens.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.center.navigation | ||
|
||
import com.mifos.core.common.utils.Constants | ||
|
||
sealed class CenterScreens(val route: String) { | ||
|
||
data object CenterListScreen : CenterScreens("center_list_screen") | ||
|
||
data object CenterDetailScreen : CenterScreens("center_detail_screen/{${Constants.CENTER_ID}}") { | ||
fun argument(centerId: Int) = "center_detail_screen/${centerId}" | ||
} | ||
|
||
data object CenterGroupListScreen : CenterScreens("center_group_list_screen/{${Constants.CENTER_ID}}") { | ||
fun arguments(centerId: Int) = "center_group_list_screen/${centerId}" | ||
} | ||
|
||
data object CreateCenterScreen : CenterScreens("create_center_screen/{${Constants.CENTER_ID}}") | ||
|
||
data object SyncCenterPayloadsScreen : CenterScreens("sync_center_payloads_screen") | ||
} |
33 changes: 0 additions & 33 deletions
33
feature/client/src/main/java/com/mifos/feature/client/navigation/ClientListNavigation.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.