Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes main content padding on various screens #2906

Merged
merged 11 commits into from
Dec 6, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.smartregister.fhircore.engine.R
import org.smartregister.fhircore.engine.configuration.navigation.NavigationMenuConfig
import org.smartregister.fhircore.engine.ui.theme.GreyTextColor
import org.smartregister.fhircore.engine.util.annotation.PreviewWithBackgroundExcludeGenerated

Expand All @@ -51,9 +52,19 @@ fun RegisterFooter(
previousButtonClickListener: () -> Unit,
nextButtonClickListener: () -> Unit,
modifier: Modifier = Modifier,
fabActions: List<NavigationMenuConfig>? = null,
) {
if (resultCount > 0) {
Row(modifier = modifier.fillMaxWidth().testTag(SEARCH_FOOTER_TAG).padding(bottom = 32.dp)) {
Row(
modifier =
modifier
.fillMaxWidth()
.testTag(SEARCH_FOOTER_TAG)
.padding(
bottom =
if (!fabActions.isNullOrEmpty() && fabActions.first().visible) 80.dp else 32.dp,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!fabActions.isNullOrEmpty() && fabActions.first().visible) 80.dp else 32.dp,
//Declared these constants in AndroidExtensions file
const val PADDING_BOTTOM_WITH_FAB = 80
const val PADDING_BOTTOM_WITHOUT_FAB = 32
if (!fabActions.isNullOrEmpty() && fabActions.first().visible) PADDING_BOTTOM_WITH_FAB.dp else PADDING_BOTTOM_WITHOUT_FAB.dp,

),
) {
Box(
modifier = modifier.weight(1f).padding(4.dp).wrapContentWidth(Alignment.Start),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.navigation.NavController
import androidx.navigation.testing.TestNavHostController
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.test.core.app.ApplicationProvider
import io.mockk.mockk
import org.junit.Rule
import org.junit.Test
Expand All @@ -34,7 +35,7 @@ import org.smartregister.fhircore.quest.ui.report.measure.screens.SHOW_PROGRESS_
class MeasureReportListScreenTest {

@get:Rule(order = 0) val composeTestRule = createComposeRule()
private val navController: NavController = mockk(relaxUnitFun = true)
private val navController = TestNavHostController(ApplicationProvider.getApplicationContext())
private val dataList =
Pager(PagingConfig(10)) {
MeasureReportPagingSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
LaunchedEffect(Unit) {
snackStateFlow.hookSnackBar(scaffoldState, profileUiState.resourceData, navController)
}

val fabActions = profileUiState.profileConfiguration?.fabActions
Scaffold(
scaffoldState = scaffoldState,
topBar = {
Expand All @@ -118,8 +118,6 @@
}
},
floatingActionButton = {
val fabActions = profileUiState.profileConfiguration?.fabActions

if (!fabActions.isNullOrEmpty() && fabActions.first().visible) {
ExtendedFab(
modifier = Modifier.testTag(FAB_BUTTON_TEST_TAG),
Expand Down Expand Up @@ -154,7 +152,14 @@
color = MaterialTheme.colors.primary,
)
}
LazyColumn(state = lazyListState) {
LazyColumn(
state = lazyListState,
modifier =
Modifier.padding(
bottom =
if (!fabActions.isNullOrEmpty() && fabActions.first().visible) 80.dp else 32.dp,
),
) {
item(key = profileUiState.resourceData?.baseResourceId) {
ViewRenderer(
viewProperties = profileUiState.profileConfiguration?.views ?: emptyList(),
Expand Down Expand Up @@ -320,15 +325,15 @@
DropdownMenuItem(
enabled = enabled,
onClick = {
showOverflowMenu = false
onEvent(
ProfileEvent.OverflowMenuClick(
navController = navController,
resourceData = profileUiState.resourceData,
overflowMenuItemConfig = overflowMenuItemConfig,

Check warning on line 333 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/profile/ProfileScreen.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/profile/ProfileScreen.kt#L328-L333

Added lines #L328 - L333 were not covered by tests
),
)
},

Check warning on line 336 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/profile/ProfileScreen.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/profile/ProfileScreen.kt#L336

Added line #L336 was not covered by tests
contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp),
modifier =
modifier
Expand All @@ -336,7 +341,7 @@
.background(
color =
if (overflowMenuItemConfig.confirmAction) {
overflowMenuItemConfig.backgroundColor.parseColor().copy(alpha = 0.1f)

Check warning on line 344 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/profile/ProfileScreen.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/profile/ProfileScreen.kt#L344

Added line #L344 was not covered by tests
} else {
Color.Transparent
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ fun RegisterCardList(
resultCount = pagingItems.itemCount,
currentPage = currentPage.value.plus(1),
pagesCount = registerUiState.pagesCount,
fabActions = registerUiState.registerConfiguration?.fabActions,
previousButtonClickListener = { onEvent(RegisterEvent.MoveToPreviousPage) },
nextButtonClickListener = { onEvent(RegisterEvent.MoveToNextPage) },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
showProgressIndicator: Boolean = false,
) {
val lazyReportItems = dataList.collectAsLazyPagingItems().itemSnapshotList.groupBy { it?.module }

Scaffold(
topBar = {
TopAppBar(
Expand Down Expand Up @@ -92,13 +91,15 @@
}
}
} else {
LazyColumn(modifier = modifier.background(Color.White).fillMaxSize()) {
LazyColumn(
modifier = modifier.background(Color.White).fillMaxSize().padding(bottom = 32.dp),
) {
lazyReportItems.keys.forEach { key ->
item {

Check warning on line 98 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/report/measure/screens/MeasureReportListScreen.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/report/measure/screens/MeasureReportListScreen.kt#L98

Added line #L98 was not covered by tests
key?.let { it1 ->
MeasureReportRow(
it1,
{ onReportMeasureClicked(lazyReportItems[key] as List<ReportConfiguration>) },

Check warning on line 102 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/report/measure/screens/MeasureReportListScreen.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/report/measure/screens/MeasureReportListScreen.kt#L100-L102

Added lines #L100 - L102 were not covered by tests
)
}
}
Expand Down
Loading