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 search module
- Loading branch information
1 parent
68f2813
commit 0fe0c09
Showing
8 changed files
with
169 additions
and
78 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
51 changes: 0 additions & 51 deletions
51
feature/search/src/main/java/com/mifos/feature/search/Navigation/SearchNavigation.kt
This file was deleted.
Oops, something went wrong.
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
92 changes: 92 additions & 0 deletions
92
feature/search/src/main/java/com/mifos/feature/search/navigation/SearchNavigation.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,92 @@ | ||
package com.mifos.feature.search.navigation | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.ui.Modifier | ||
import androidx.navigation.NavController | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.navigation | ||
import com.mifos.core.common.utils.Constants | ||
import com.mifos.core.objects.SearchedEntity | ||
import com.mifos.core.ui.components.FabType | ||
import com.mifos.feature.search.SearchScreenRoute | ||
|
||
fun NavGraphBuilder.searchNavGraph( | ||
paddingValues: PaddingValues, | ||
onCreateClient: () -> Unit, | ||
onCreateCenter: () -> Unit, | ||
onCreateGroup: () -> Unit, | ||
onClient: (Int) -> Unit, | ||
onCenter: (Int) -> Unit, | ||
onGroup: (Int) -> Unit, | ||
onSavings: (Int) -> Unit, | ||
onLoan: (Int) -> Unit | ||
) { | ||
navigation( | ||
startDestination = SearchScreens.SearchScreen.route, | ||
route = SearchScreens.SearchScreenRoute.route | ||
) { | ||
searchRoute( | ||
modifier = Modifier.padding(paddingValues), | ||
onFabClick = { | ||
when (it) { | ||
FabType.CLIENT -> { | ||
onCreateClient() | ||
} | ||
|
||
FabType.CENTER -> { | ||
onCreateCenter() | ||
} | ||
|
||
FabType.GROUP -> { | ||
onCreateGroup() | ||
} | ||
} | ||
}, | ||
onSearchOptionClick = { searchedEntity -> | ||
when (searchedEntity.entityType) { | ||
Constants.SEARCH_ENTITY_LOAN -> { | ||
onLoan(searchedEntity.entityId) | ||
} | ||
|
||
Constants.SEARCH_ENTITY_CLIENT -> { | ||
onClient(searchedEntity.entityId) | ||
} | ||
|
||
Constants.SEARCH_ENTITY_GROUP -> { | ||
onGroup(searchedEntity.entityId) | ||
} | ||
|
||
Constants.SEARCH_ENTITY_SAVING -> { | ||
onSavings(searchedEntity.entityId) | ||
} | ||
|
||
Constants.SEARCH_ENTITY_CENTER -> { | ||
onCenter(searchedEntity.entityId) | ||
} | ||
} | ||
} | ||
) | ||
} | ||
} | ||
|
||
fun NavGraphBuilder.searchRoute( | ||
modifier: Modifier, | ||
onFabClick: (FabType) -> Unit, | ||
onSearchOptionClick: (SearchedEntity) -> Unit | ||
) { | ||
composable( | ||
route = SearchScreens.SearchScreen.route | ||
) { | ||
SearchScreenRoute( | ||
modifier = modifier, | ||
onFabClick = onFabClick, | ||
onSearchOptionClick = onSearchOptionClick | ||
) | ||
} | ||
} | ||
|
||
fun NavController.navigateSearchScreen() { | ||
navigate(SearchScreens.SearchScreen.route) | ||
} |
7 changes: 7 additions & 0 deletions
7
feature/search/src/main/java/com/mifos/feature/search/navigation/SearchScreens.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,7 @@ | ||
package com.mifos.feature.search.navigation | ||
|
||
sealed class SearchScreens(val route: String) { | ||
data object SearchScreenRoute : SearchScreens("search_screen_route") | ||
|
||
data object SearchScreen : SearchScreens("search_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
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