Skip to content

Commit

Permalink
Fix icon positioning
Browse files Browse the repository at this point in the history
Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>
  • Loading branch information
ellykits committed Oct 29, 2024
1 parent 5eda671 commit e48a72d
Showing 1 changed file with 37 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,38 +173,12 @@ fun TopScreenSection(
SetupToolbarIcons(

Check warning on line 173 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L173

Added line #L173 was not covered by tests
menuIcons = topScreenSection?.menuIcons,
isFilterIconEnabled = isFilterIconEnabled,
filteredRecordsCount = filteredRecordsCount,
navController = navController,
modifier = modifier,
onClick = onClick,
decodeImage = decodeImage,

Check warning on line 180 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L175-L180

Added lines #L175 - L180 were not covered by tests
)
if (isFilterIconEnabled) {
BadgedBox(
modifier = Modifier.padding(end = 8.dp),
badge = {
if (filteredRecordsCount != null && filteredRecordsCount > -1) {
Badge {
Text(
text =
if (filteredRecordsCount > 99) "99+" else filteredRecordsCount.toString(),
overflow = TextOverflow.Clip,
maxLines = 1,
)
}
}
},
) {
Icon(
imageVector = Icons.Outlined.FilterAlt,
contentDescription = FILTER,
tint = Color.White,
modifier =
modifier
.clickable { onClick(ToolbarClickEvent.FilterData) }
.testTag(TOP_ROW_FILTER_ICON_TEST_TAG),
)
}
}
}
}
if (isSearchBarVisible) {
Expand Down Expand Up @@ -310,6 +284,7 @@ fun TopScreenSection(
fun SetupToolbarIcons(
menuIcons: List<ImageProperties>?,
isFilterIconEnabled: Boolean,
filteredRecordsCount: Long? = null,
navController: NavController,
modifier: Modifier,
onClick: (ToolbarClickEvent) -> Unit,
Expand All @@ -321,6 +296,8 @@ fun SetupToolbarIcons(
if (menuIcons.size <= iconsCount) {
RenderMenuIcon(
menuIcons = menuIcons.subList(0, min(iconsCount, menuIcons.size)),
isFilterIconEnabled = isFilterIconEnabled,
filteredRecordsCount = filteredRecordsCount,

Check warning on line 300 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L297-L300

Added lines #L297 - L300 were not covered by tests
navController = navController,
modifier = modifier,
onClick = onClick,
Expand All @@ -330,6 +307,8 @@ fun SetupToolbarIcons(
Row(verticalAlignment = Alignment.CenterVertically) {
RenderMenuIcon(
menuIcons = menuIcons.subList(0, iconsCount),
isFilterIconEnabled = false,
filteredRecordsCount = null,
navController = navController,
modifier = modifier,
onClick = onClick,
Expand Down Expand Up @@ -376,12 +355,43 @@ fun SetupToolbarIcons(
@Composable
private fun RenderMenuIcon(
menuIcons: List<ImageProperties>,
isFilterIconEnabled: Boolean,
filteredRecordsCount: Long? = null,
navController: NavController,
modifier: Modifier,
onClick: (ToolbarClickEvent) -> Unit,
decodeImage: ((String) -> Bitmap?)?,
) {
LazyRow(horizontalArrangement = Arrangement.spacedBy(14.dp)) {
item {

Check warning on line 366 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L366

Added line #L366 was not covered by tests
if (isFilterIconEnabled) {
BadgedBox(
modifier = Modifier.padding(end = 8.dp),
badge = {

Check warning on line 370 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L369-L370

Added lines #L369 - L370 were not covered by tests
if (filteredRecordsCount != null && filteredRecordsCount > -1) {
Badge {
Text(
text = if (filteredRecordsCount > 99) "99+" else filteredRecordsCount.toString(),
overflow = TextOverflow.Clip,
maxLines = 1,
)

Check warning on line 377 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L375-L377

Added lines #L375 - L377 were not covered by tests
}
}
},
) {

Check warning on line 381 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L380-L381

Added lines #L380 - L381 were not covered by tests
Icon(
imageVector = Icons.Outlined.FilterAlt,
contentDescription = FILTER,
tint = Color.White,

Check warning on line 385 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L383-L385

Added lines #L383 - L385 were not covered by tests
modifier =
modifier
.size(22.dp)
.clickable { onClick(ToolbarClickEvent.FilterData) }
.testTag(TOP_ROW_FILTER_ICON_TEST_TAG),
)

Check warning on line 391 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L387-L391

Added lines #L387 - L391 were not covered by tests
}
}
}
items(menuIcons) {
Image(
imageProperties = it,
Expand Down

0 comments on commit e48a72d

Please sign in to comment.