diff --git a/feature/search/build.gradle.kts b/feature/search/build.gradle.kts
index caa71924d21..a6465380725 100644
--- a/feature/search/build.gradle.kts
+++ b/feature/search/build.gradle.kts
@@ -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/android-client/blob/master/LICENSE.md
+ */
plugins {
alias(libs.plugins.mifos.android.feature)
alias(libs.plugins.mifos.android.library.compose)
diff --git a/feature/search/src/androidTest/java/com/mifos/feature/search/ExampleInstrumentedTest.kt b/feature/search/src/androidTest/java/com/mifos/feature/search/ExampleInstrumentedTest.kt
index d672723c875..95ff57e3be3 100644
--- a/feature/search/src/androidTest/java/com/mifos/feature/search/ExampleInstrumentedTest.kt
+++ b/feature/search/src/androidTest/java/com/mifos/feature/search/ExampleInstrumentedTest.kt
@@ -1,13 +1,20 @@
+/*
+ * 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/android-client/blob/master/LICENSE.md
+ */
package com.mifos.feature.search
-import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
-
+import androidx.test.platform.app.InstrumentationRegistry
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
-import org.junit.Assert.*
-
/**
* Instrumented test, which will execute on an Android device.
*
@@ -21,4 +28,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.mifos.feature.search.test", appContext.packageName)
}
-}
\ No newline at end of file
+}
diff --git a/feature/search/src/main/AndroidManifest.xml b/feature/search/src/main/AndroidManifest.xml
index a5918e68abc..1dc76da0f7e 100644
--- a/feature/search/src/main/AndroidManifest.xml
+++ b/feature/search/src/main/AndroidManifest.xml
@@ -1,4 +1,13 @@
+
\ No newline at end of file
diff --git a/feature/search/src/main/java/com/mifos/feature/search/SearchScreen.kt b/feature/search/src/main/java/com/mifos/feature/search/SearchScreen.kt
index 5125f5b9cf8..560edecc227 100644
--- a/feature/search/src/main/java/com/mifos/feature/search/SearchScreen.kt
+++ b/feature/search/src/main/java/com/mifos/feature/search/SearchScreen.kt
@@ -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/android-client/blob/master/LICENSE.md
+ */
package com.mifos.feature.search
import androidx.annotation.VisibleForTesting
@@ -29,9 +38,9 @@ import com.mifos.feature.search.components.SearchScreenResult
@Composable
fun SearchScreenRoute(
- modifier: Modifier = Modifier,
onFabClick: (FabType) -> Unit,
onSearchOptionClick: (SearchedEntity) -> Unit,
+ modifier: Modifier = Modifier,
viewModel: SearchViewModel = hiltViewModel(),
) {
val state by viewModel.state
@@ -50,12 +59,12 @@ fun SearchScreenRoute(
@VisibleForTesting
@Composable
internal fun SearchScreenContent(
- modifier: Modifier = Modifier,
state: SearchScreenState,
searchResultState: SearchResultState,
onEvent: (SearchScreenEvent) -> Unit,
onFabClick: (FabType) -> Unit,
- onResultItemClick: (SearchedEntity) -> Unit
+ onResultItemClick: (SearchedEntity) -> Unit,
+ modifier: Modifier = Modifier,
) {
val snackbarHostState = remember { SnackbarHostState() }
var fabButtonState by remember { mutableStateOf(FabButtonState.Collapsed) }
@@ -67,25 +76,25 @@ internal fun SearchScreenContent(
fabButtons = listOf(
FabButton(
fabType = FabType.CLIENT,
- iconRes = com.mifos.core.ui.R.drawable.core_ui_ic_person_black_24dp
+ iconRes = com.mifos.core.ui.R.drawable.core_ui_ic_person_black_24dp,
),
FabButton(
fabType = FabType.CENTER,
- iconRes = com.mifos.core.ui.R.drawable.core_ui_ic_centers_24dp
+ iconRes = com.mifos.core.ui.R.drawable.core_ui_ic_centers_24dp,
),
FabButton(
fabType = FabType.GROUP,
- iconRes = com.mifos.core.ui.R.drawable.core_ui_ic_group_black_24dp
- )
+ iconRes = com.mifos.core.ui.R.drawable.core_ui_ic_group_black_24dp,
+ ),
),
fabButtonState = fabButtonState,
onFabButtonStateChange = {
fabButtonState = it
},
- onFabClick = onFabClick
+ onFabClick = onFabClick,
)
},
- snackbarHostState = snackbarHostState
+ snackbarHostState = snackbarHostState,
) {
Column(
modifier = Modifier
@@ -97,13 +106,13 @@ internal fun SearchScreenContent(
modifier = Modifier
.padding(horizontal = 16.dp),
state = state,
- onEvent = onEvent
+ onEvent = onEvent,
)
SearchScreenResult(
modifier = Modifier.weight(2f),
searchResultState = searchResultState,
- onResultItemClick = onResultItemClick
+ onResultItemClick = onResultItemClick,
)
}
}
@@ -119,7 +128,7 @@ private fun SearchScreenContentEmptyStateAndLoadingPreview() {
searchResultState = SearchResultState.Loading,
onEvent = {},
onFabClick = {},
- onResultItemClick = {}
+ onResultItemClick = {},
)
}
@@ -132,7 +141,7 @@ private fun SearchScreenContentInitialEmptyStatePreview() {
searchResultState = SearchResultState.Empty(),
onEvent = {},
onFabClick = {},
- onResultItemClick = {}
+ onResultItemClick = {},
)
}
@@ -143,12 +152,12 @@ private fun SearchScreenContentEmptyResultPreview() {
modifier = Modifier,
state = SearchScreenState(
searchText = "yyy",
- selectedFilter = FilterOption.Groups
+ selectedFilter = FilterOption.Groups,
),
searchResultState = SearchResultState.Empty(false),
onEvent = {},
onFabClick = {},
- onResultItemClick = {}
+ onResultItemClick = {},
)
}
@@ -161,7 +170,7 @@ private fun SearchScreenContentErrorPreview() {
searchResultState = SearchResultState.Error("Something went wrong!"),
onEvent = {},
onFabClick = {},
- onResultItemClick = {}
+ onResultItemClick = {},
)
}
@@ -169,7 +178,7 @@ private fun SearchScreenContentErrorPreview() {
@Composable
private fun SearchScreenContentSuccessPreview(
@PreviewParameter(SearchResultPreviewParameter::class)
- results: List
+ results: List,
) {
SearchScreenContent(
modifier = Modifier,
@@ -179,6 +188,6 @@ private fun SearchScreenContentSuccessPreview(
searchResultState = SearchResultState.Success(results),
onEvent = {},
onFabClick = {},
- onResultItemClick = {}
+ onResultItemClick = {},
)
-}
\ No newline at end of file
+}
diff --git a/feature/search/src/main/java/com/mifos/feature/search/SearchUiState.kt b/feature/search/src/main/java/com/mifos/feature/search/SearchUiState.kt
index 7a33f1e5564..2b5cb89c1df 100644
--- a/feature/search/src/main/java/com/mifos/feature/search/SearchUiState.kt
+++ b/feature/search/src/main/java/com/mifos/feature/search/SearchUiState.kt
@@ -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/android-client/blob/master/LICENSE.md
+ */
package com.mifos.feature.search
import com.mifos.core.objects.SearchedEntity
@@ -5,5 +14,5 @@ import com.mifos.core.objects.SearchedEntity
data class SearchUiState(
val isLoading: Boolean = false,
val error: String? = null,
- val searchedEntities: List = emptyList()
-)
\ No newline at end of file
+ val searchedEntities: List = emptyList(),
+)
diff --git a/feature/search/src/main/java/com/mifos/feature/search/SearchViewModel.kt b/feature/search/src/main/java/com/mifos/feature/search/SearchViewModel.kt
index d444583a06e..4c9037eef35 100644
--- a/feature/search/src/main/java/com/mifos/feature/search/SearchViewModel.kt
+++ b/feature/search/src/main/java/com/mifos/feature/search/SearchViewModel.kt
@@ -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/android-client/blob/master/LICENSE.md
+ */
package com.mifos.feature.search
import androidx.compose.runtime.mutableStateOf
@@ -25,8 +34,8 @@ class SearchViewModel @Inject constructor(
var state = mutableStateOf(SearchScreenState())
private set
- private val _searchResultState = MutableStateFlow(SearchResultState.Empty())
- val searchResult = _searchResultState.asStateFlow()
+ private val searchResultState = MutableStateFlow(SearchResultState.Empty())
+ val searchResult = searchResultState.asStateFlow()
private var searchJob: Job? = null
@@ -35,7 +44,7 @@ class SearchViewModel @Inject constructor(
is SearchScreenEvent.UpdateSearchText -> {
viewModelScope.launch {
state.value = state.value.copy(
- searchText = event.searchText
+ searchText = event.searchText,
)
}
}
@@ -43,17 +52,17 @@ class SearchViewModel @Inject constructor(
is SearchScreenEvent.ClearSearchText -> {
viewModelScope.launch {
state.value = state.value.copy(
- searchText = ""
+ searchText = "",
)
- _searchResultState.update { SearchResultState.Empty() }
+ searchResultState.update { SearchResultState.Empty() }
}
}
is SearchScreenEvent.UpdateSelectedFilter -> {
viewModelScope.launch {
state.value = state.value.copy(
- selectedFilter = event.filter
+ selectedFilter = event.filter,
)
getSearchResult()
@@ -63,8 +72,11 @@ class SearchViewModel @Inject constructor(
is SearchScreenEvent.UpdateExactMatch -> {
viewModelScope.launch {
state.value = state.value.copy(
- exactMatch = if (state.value.exactMatch == null) true
- else !state.value.exactMatch!!
+ exactMatch = if (state.value.exactMatch == null) {
+ true
+ } else {
+ !state.value.exactMatch!!
+ },
)
getSearchResult()
@@ -76,7 +88,6 @@ class SearchViewModel @Inject constructor(
getSearchResult()
}
}
-
}
}
@@ -87,16 +98,16 @@ class SearchViewModel @Inject constructor(
searchJob = searchRepository.searchResources(
query = state.value.searchText,
resources = state.value.selectedFilter?.value,
- exactMatch = state.value.exactMatch
+ exactMatch = state.value.exactMatch,
).onStart {
- _searchResultState.update { SearchResultState.Loading }
+ searchResultState.update { SearchResultState.Loading }
}.catch { throwable ->
- _searchResultState.update { SearchResultState.Error(throwable.message.toString()) }
+ searchResultState.update { SearchResultState.Error(throwable.message.toString()) }
}.onEach { results ->
if (results.isEmpty()) {
- _searchResultState.update { SearchResultState.Empty(false) }
+ searchResultState.update { SearchResultState.Empty(false) }
} else {
- _searchResultState.update { SearchResultState.Success(results) }
+ searchResultState.update { SearchResultState.Success(results) }
}
}.launchIn(viewModelScope)
}
@@ -113,7 +124,7 @@ sealed interface SearchResultState {
data class SearchScreenState(
val searchText: String = "",
val selectedFilter: FilterOption? = null,
- val exactMatch: Boolean? = null
+ val exactMatch: Boolean? = null,
)
sealed interface SearchScreenEvent {
@@ -121,7 +132,7 @@ sealed interface SearchScreenEvent {
data class UpdateSelectedFilter(val filter: FilterOption? = null) : SearchScreenEvent
- data object ClearSearchText: SearchScreenEvent
+ data object ClearSearchText : SearchScreenEvent
data object UpdateExactMatch : SearchScreenEvent
@@ -142,4 +153,4 @@ sealed class FilterOption(val label: String, val value: String) {
companion object {
val values = listOf(Clients, Groups, LoanAccounts, SavingsAccounts)
}
-}
\ No newline at end of file
+}
diff --git a/feature/search/src/main/java/com/mifos/feature/search/components/FilterDialog.kt b/feature/search/src/main/java/com/mifos/feature/search/components/FilterDialog.kt
index c7d9bfc7cb1..a621d10f465 100644
--- a/feature/search/src/main/java/com/mifos/feature/search/components/FilterDialog.kt
+++ b/feature/search/src/main/java/com/mifos/feature/search/components/FilterDialog.kt
@@ -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/android-client/blob/master/LICENSE.md
+ */
package com.mifos.feature.search.components
import androidx.compose.foundation.clickable
@@ -27,10 +36,10 @@ import com.mifos.feature.search.SearchScreenEvent
@Composable
internal fun FilterDialog(
- modifier: Modifier = Modifier,
selected: FilterOption?,
onEvent: (SearchScreenEvent.UpdateSelectedFilter) -> Unit,
onDismiss: () -> Unit,
+ modifier: Modifier = Modifier,
) {
val configuration = LocalConfiguration.current
@@ -45,7 +54,7 @@ internal fun FilterDialog(
HorizontalDivider()
Column(
modifier = Modifier
- .verticalScroll(rememberScrollState())
+ .verticalScroll(rememberScrollState()),
) {
FilterOption(
text = "All",
@@ -53,7 +62,7 @@ internal fun FilterDialog(
onSelected = {
onEvent(SearchScreenEvent.UpdateSelectedFilter(null))
onDismiss()
- }
+ },
)
HorizontalDivider()
@@ -65,7 +74,7 @@ internal fun FilterDialog(
onSelected = {
onEvent(SearchScreenEvent.UpdateSelectedFilter(option))
onDismiss()
- }
+ },
)
if (index != FilterOption.values.size - 1) {
@@ -74,16 +83,16 @@ internal fun FilterDialog(
}
}
},
- confirmButton = {}
+ confirmButton = {},
)
}
@Composable
internal fun FilterOption(
- modifier: Modifier = Modifier,
text: String,
selected: Boolean,
- onSelected: () -> Unit
+ onSelected: () -> Unit,
+ modifier: Modifier = Modifier,
) {
Row(
modifier = modifier
@@ -97,11 +106,11 @@ internal fun FilterOption(
selected = selected,
onClick = {
onSelected()
- }
+ },
)
Text(
text = text,
- fontSize = 16.sp
+ fontSize = 16.sp,
)
}
}
@@ -109,27 +118,27 @@ internal fun FilterOption(
@DevicePreviews
@Composable
private fun FilterDialogPreview(
- modifier: Modifier = Modifier
+ modifier: Modifier = Modifier,
) {
FilterDialog(
modifier = modifier,
selected = null,
onEvent = {},
- onDismiss = {}
+ onDismiss = {},
)
}
@DevicePreviews
@Composable
private fun FilterOptionPreview(
- modifier: Modifier = Modifier
+ modifier: Modifier = Modifier,
) {
MaterialTheme {
FilterOption(
modifier = modifier,
text = "Search Option",
selected = true,
- onSelected = {}
+ onSelected = {},
)
}
-}
\ No newline at end of file
+}
diff --git a/feature/search/src/main/java/com/mifos/feature/search/components/SearchBox.kt b/feature/search/src/main/java/com/mifos/feature/search/components/SearchBox.kt
index e472f3d0934..4e199d65729 100644
--- a/feature/search/src/main/java/com/mifos/feature/search/components/SearchBox.kt
+++ b/feature/search/src/main/java/com/mifos/feature/search/components/SearchBox.kt
@@ -1,6 +1,14 @@
+/*
+ * 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/android-client/blob/master/LICENSE.md
+ */
package com.mifos.feature.search.components
-
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -45,29 +53,29 @@ import com.mifos.feature.search.SearchScreenState
@Composable
internal fun SearchBox(
- modifier: Modifier = Modifier,
state: SearchScreenState,
onEvent: (SearchScreenEvent) -> Unit,
+ modifier: Modifier = Modifier,
) {
val interactionSource = remember { MutableInteractionSource() }
var showDialog by remember { mutableStateOf(false) }
Box(
- modifier = modifier.fillMaxWidth()
+ modifier = modifier.fillMaxWidth(),
) {
Column(
modifier = Modifier.fillMaxWidth(),
- verticalArrangement = Arrangement.spacedBy(8.dp)
+ verticalArrangement = Arrangement.spacedBy(8.dp),
) {
// Title And Filter Icon
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
- verticalAlignment = Alignment.CenterVertically
+ verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = stringResource(id = R.string.feature_search_title),
- fontSize = 24.sp
+ fontSize = 24.sp,
)
AssistChip(
@@ -77,24 +85,24 @@ internal fun SearchBox(
label = {
Text(
text = state.selectedFilter?.label ?: "All",
- fontSize = 16.sp
+ fontSize = 16.sp,
)
},
leadingIcon = {
Icon(
imageVector = Icons.Default.FilterList,
- contentDescription = "filterIcon"
+ contentDescription = "filterIcon",
)
},
trailingIcon = {
Icon(
imageVector = Icons.Default.KeyboardArrowDown,
- contentDescription = "changeFilter"
+ contentDescription = "changeFilter",
)
},
colors = AssistChipDefaults.assistChipColors().copy(
- leadingIconContentColor = MaterialTheme.colorScheme.tertiary
- )
+ leadingIconContentColor = MaterialTheme.colorScheme.tertiary,
+ ),
)
}
@@ -124,12 +132,12 @@ internal fun SearchBox(
) {
Icon(
imageVector = Icons.Outlined.Search,
- contentDescription = "searchIcon"
+ contentDescription = "searchIcon",
)
Text(
text = stringResource(id = R.string.feature_search_title),
- fontSize = 16.sp
+ fontSize = 16.sp,
)
}
@@ -138,13 +146,13 @@ internal fun SearchBox(
modifier = Modifier
.clickable(
interactionSource = interactionSource,
- indication = null
+ indication = null,
) {
onEvent(SearchScreenEvent.UpdateExactMatch)
}
.padding(vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically,
- horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.Start)
+ horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.Start),
) {
Checkbox(
checked = state.exactMatch ?: false,
@@ -152,42 +160,40 @@ internal fun SearchBox(
onEvent(SearchScreenEvent.UpdateExactMatch)
},
modifier = Modifier
- .size(20.dp)
+ .size(20.dp),
)
Text(
text = stringResource(id = R.string.feature_search_exact_match),
- fontSize = 16.sp
+ fontSize = 16.sp,
)
}
}
}
AnimatedVisibility(
- visible = showDialog
+ visible = showDialog,
) {
FilterDialog(
selected = state.selectedFilter,
onEvent = onEvent,
onDismiss = {
showDialog = false
- }
+ },
)
}
}
-
@DevicePreviews
@Composable
private fun SearchBoxPreview() {
SearchBox(
modifier = Modifier.background(Color.White),
state = SearchScreenState(),
- onEvent = {}
+ onEvent = {},
)
}
-
@DevicePreviews
@Composable
private fun SearchBoxWithValuesPreview() {
@@ -196,8 +202,8 @@ private fun SearchBoxWithValuesPreview() {
state = SearchScreenState(
searchText = "search text",
selectedFilter = FilterOption.Groups,
- exactMatch = true
+ exactMatch = true,
),
- onEvent = {}
+ onEvent = {},
)
-}
\ No newline at end of file
+}
diff --git a/feature/search/src/main/java/com/mifos/feature/search/components/SearchScreenResult.kt b/feature/search/src/main/java/com/mifos/feature/search/components/SearchScreenResult.kt
index 524ea002d5b..9a455ec9b69 100644
--- a/feature/search/src/main/java/com/mifos/feature/search/components/SearchScreenResult.kt
+++ b/feature/search/src/main/java/com/mifos/feature/search/components/SearchScreenResult.kt
@@ -1,6 +1,14 @@
+/*
+ * 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/android-client/blob/master/LICENSE.md
+ */
package com.mifos.feature.search.components
-
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
@@ -36,9 +44,9 @@ import com.mifos.feature.search.SearchResultState
@Composable
internal fun SearchScreenResult(
- modifier: Modifier = Modifier,
searchResultState: SearchResultState,
onResultItemClick: (SearchedEntity) -> Unit,
+ modifier: Modifier = Modifier,
) {
Box(
modifier = modifier
@@ -46,7 +54,7 @@ internal fun SearchScreenResult(
) {
Crossfade(
targetState = searchResultState,
- label = "SearchResult"
+ label = "SearchResult",
) { state ->
when (state) {
is SearchResultState.Loading -> {
@@ -56,7 +64,7 @@ internal fun SearchScreenResult(
is SearchResultState.Empty -> {
if (!state.initial) {
MifosEmptyUi(
- text = stringResource(R.string.feature_search_no_search_result_found)
+ text = stringResource(R.string.feature_search_no_search_result_found),
)
}
}
@@ -64,7 +72,7 @@ internal fun SearchScreenResult(
is SearchResultState.Error -> {
MifosEmptyUi(
text = state.message,
- modifier = Modifier.align(Alignment.Center)
+ modifier = Modifier.align(Alignment.Center),
)
}
@@ -73,17 +81,17 @@ internal fun SearchScreenResult(
modifier = Modifier
.fillMaxSize(),
contentPadding = PaddingValues(vertical = 8.dp),
- verticalArrangement = Arrangement.spacedBy(8.dp)
+ verticalArrangement = Arrangement.spacedBy(8.dp),
) {
items(
items = state.results,
key = {
"${it.entityType}-${it.entityId}-${it.parentId}"
- }
+ },
) { searchedEntity ->
SearchResult(
searchedEntity = searchedEntity,
- onSearchOptionClick = onResultItemClick
+ onSearchOptionClick = onResultItemClick,
)
}
}
@@ -95,9 +103,9 @@ internal fun SearchScreenResult(
@Composable
internal fun SearchResult(
- modifier: Modifier = Modifier,
searchedEntity: SearchedEntity,
- onSearchOptionClick: (SearchedEntity) -> Unit
+ onSearchOptionClick: (SearchedEntity) -> Unit,
+ modifier: Modifier = Modifier,
) {
val color = ColorGenerator.MATERIAL.getColor(searchedEntity.entityType)
val drawable =
@@ -117,7 +125,7 @@ internal fun SearchResult(
)
},
colors = ListItemDefaults.colors(
- containerColor = MaterialTheme.colorScheme.surfaceContainerLowest
+ containerColor = MaterialTheme.colorScheme.surfaceContainerLowest,
),
modifier = modifier
.fillMaxWidth()
@@ -127,13 +135,12 @@ internal fun SearchResult(
)
}
-
@DevicePreviews
@Composable
private fun SearchScreenResultLoadingPreview() {
SearchScreenResult(
searchResultState = SearchResultState.Loading,
- onResultItemClick = {}
+ onResultItemClick = {},
)
}
@@ -142,7 +149,7 @@ private fun SearchScreenResultLoadingPreview() {
private fun SearchScreenResultInitialEmptyPreview() {
SearchScreenResult(
searchResultState = SearchResultState.Empty(),
- onResultItemClick = {}
+ onResultItemClick = {},
)
}
@@ -151,7 +158,7 @@ private fun SearchScreenResultInitialEmptyPreview() {
private fun SearchScreenResultEmptyPreview() {
SearchScreenResult(
searchResultState = SearchResultState.Empty(true),
- onResultItemClick = {}
+ onResultItemClick = {},
)
}
@@ -160,7 +167,7 @@ private fun SearchScreenResultEmptyPreview() {
private fun SearchScreenResultErrorPreview() {
SearchScreenResult(
searchResultState = SearchResultState.Error("Unable to fetch data from server"),
- onResultItemClick = {}
+ onResultItemClick = {},
)
}
@@ -168,11 +175,11 @@ private fun SearchScreenResultErrorPreview() {
@Composable
private fun SearchScreenResultSuccessPreview(
@PreviewParameter(SearchResultPreviewParameter::class)
- results: List
+ results: List,
) {
SearchScreenResult(
searchResultState = SearchResultState.Success(results),
- onResultItemClick = {}
+ onResultItemClick = {},
)
}
@@ -187,8 +194,8 @@ private fun SearchResultPreview() {
entityType = "center",
parentId = 3296,
parentName = "center",
- entityStatus = null
+ entityStatus = null,
),
- onSearchOptionClick = {}
+ onSearchOptionClick = {},
)
-}
\ No newline at end of file
+}
diff --git a/feature/search/src/main/java/com/mifos/feature/search/navigation/SearchNavigation.kt b/feature/search/src/main/java/com/mifos/feature/search/navigation/SearchNavigation.kt
index e5270c920a5..c36b008dcdb 100644
--- a/feature/search/src/main/java/com/mifos/feature/search/navigation/SearchNavigation.kt
+++ b/feature/search/src/main/java/com/mifos/feature/search/navigation/SearchNavigation.kt
@@ -1,9 +1,17 @@
+/*
+ * 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/android-client/blob/master/LICENSE.md
+ */
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
@@ -21,11 +29,11 @@ fun NavGraphBuilder.searchNavGraph(
onCenter: (Int) -> Unit,
onGroup: (Int) -> Unit,
onSavings: (Int) -> Unit,
- onLoan: (Int) -> Unit
+ onLoan: (Int) -> Unit,
) {
navigation(
startDestination = SearchScreens.SearchScreen.route,
- route = SearchScreens.SearchScreenRoute.route
+ route = SearchScreens.SearchScreenRoute.route,
) {
searchRoute(
modifier = Modifier.padding(paddingValues),
@@ -66,7 +74,7 @@ fun NavGraphBuilder.searchNavGraph(
onCenter(searchedEntity.entityId)
}
}
- }
+ },
)
}
}
@@ -74,15 +82,15 @@ fun NavGraphBuilder.searchNavGraph(
fun NavGraphBuilder.searchRoute(
modifier: Modifier,
onFabClick: (FabType) -> Unit,
- onSearchOptionClick: (SearchedEntity) -> Unit
+ onSearchOptionClick: (SearchedEntity) -> Unit,
) {
composable(
- route = SearchScreens.SearchScreen.route
+ route = SearchScreens.SearchScreen.route,
) {
SearchScreenRoute(
modifier = modifier,
onFabClick = onFabClick,
- onSearchOptionClick = onSearchOptionClick
+ onSearchOptionClick = onSearchOptionClick,
)
}
}
diff --git a/feature/search/src/main/java/com/mifos/feature/search/navigation/SearchScreens.kt b/feature/search/src/main/java/com/mifos/feature/search/navigation/SearchScreens.kt
index 27ff0d1b021..c73aa4950c0 100644
--- a/feature/search/src/main/java/com/mifos/feature/search/navigation/SearchScreens.kt
+++ b/feature/search/src/main/java/com/mifos/feature/search/navigation/SearchScreens.kt
@@ -1,7 +1,16 @@
+/*
+ * 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/android-client/blob/master/LICENSE.md
+ */
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")
-}
\ No newline at end of file
+}
diff --git a/feature/search/src/main/res/values/feature_search_strings.xml b/feature/search/src/main/res/values/feature_search_strings.xml
index fb93139eb8d..a545ab7a61b 100644
--- a/feature/search/src/main/res/values/feature_search_strings.xml
+++ b/feature/search/src/main/res/values/feature_search_strings.xml
@@ -1,4 +1,13 @@
+
Search
Filter Search
diff --git a/feature/search/src/test/java/com/mifos/feature/search/SearchViewModelTest.kt b/feature/search/src/test/java/com/mifos/feature/search/SearchViewModelTest.kt
index 772d6bf6b58..9c16f9dc2b1 100644
--- a/feature/search/src/test/java/com/mifos/feature/search/SearchViewModelTest.kt
+++ b/feature/search/src/test/java/com/mifos/feature/search/SearchViewModelTest.kt
@@ -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/android-client/blob/master/LICENSE.md
+ */
package com.mifos.feature.search
import com.mifos.core.testing.repository.TestSearchRepository
@@ -11,7 +20,6 @@ import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.test.assertIsNot
-
class SearchViewModelTest {
@get:Rule
@@ -31,7 +39,7 @@ class SearchViewModelTest {
}
@Test
- fun performSearchAndReturnEmptyResult() = runTest{
+ fun performSearchAndReturnEmptyResult() = runTest {
repository.addSampleResults(SearchResultPreviewData.searchResults)
viewModel.onEvent(SearchScreenEvent.UpdateSearchText("kkk"))
@@ -123,4 +131,4 @@ class SearchViewModelTest {
assertIsNot(viewModel.searchResult.value)
assertIs(viewModel.searchResult.value)
}
-}
\ No newline at end of file
+}