Skip to content

Commit

Permalink
Fixes main content padding on various screens (#2906)
Browse files Browse the repository at this point in the history
* adds padding to the profile lazy column

* setting padding on Register footer row ,on measure report list screen.

* fixes MeasureReport List Screen

* runs profile screen test

* runs engine test

* runs spotless

* edits the constant paddings on profile screen and register footer

* edits the constant paddings on profile screen and register footer

* runs quest spotless

* runs engine spotless
  • Loading branch information
brandyodhiambo authored Dec 6, 2023
1 parent c10cf7b commit 3cbb77b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
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 @@ -42,6 +43,8 @@ const val SEARCH_FOOTER_TAG = "searchFooterTag"
const val SEARCH_FOOTER_PREVIOUS_BUTTON_TAG = "searchFooterPreviousButtonTag"
const val SEARCH_FOOTER_NEXT_BUTTON_TAG = "searchFooterNextButtonTag"
const val SEARCH_FOOTER_PAGINATION_TAG = "searchFooterPaginationTag"
const val PADDING_BOTTOM_WITH_FAB = 80
const val PADDING_BOTTOM_WITHOUT_FAB = 32

@Composable
fun RegisterFooter(
Expand All @@ -51,9 +54,21 @@ 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) {
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 @@ -79,6 +79,8 @@ const val DROPDOWN_MENU_TEST_TAG = "dropDownMenuTestTag"
const val FAB_BUTTON_TEST_TAG = "fabButtonTestTag"
const val PROFILE_TOP_BAR_TEST_TAG = "profileTopBarTestTag"
const val PROFILE_TOP_BAR_ICON_TEST_TAG = "profileTopBarIconTestTag"
const val PADDING_BOTTOM_WITH_FAB = 80
const val PADDING_BOTTOM_WITHOUT_FAB = 32

@Composable
fun ProfileScreen(
Expand All @@ -94,7 +96,7 @@ fun ProfileScreen(
LaunchedEffect(Unit) {
snackStateFlow.hookSnackBar(scaffoldState, profileUiState.resourceData, navController)
}

val fabActions = profileUiState.profileConfiguration?.fabActions
Scaffold(
scaffoldState = scaffoldState,
topBar = {
Expand All @@ -118,8 +120,6 @@ fun ProfileScreen(
}
},
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 +154,16 @@ fun ProfileScreen(
color = MaterialTheme.colors.primary,
)
}
LazyColumn(state = lazyListState) {
LazyColumn(
state = lazyListState,
modifier =
Modifier.padding(
bottom =
if (!fabActions.isNullOrEmpty() && fabActions.first().visible) {
PADDING_BOTTOM_WITH_FAB.dp
} else PADDING_BOTTOM_WITHOUT_FAB.dp,
),
) {
item(key = profileUiState.resourceData?.baseResourceId) {
ViewRenderer(
viewProperties = profileUiState.profileConfiguration?.views ?: emptyList(),
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 @@ fun MeasureReportListScreen(
showProgressIndicator: Boolean = false,
) {
val lazyReportItems = dataList.collectAsLazyPagingItems().itemSnapshotList.groupBy { it?.module }

Scaffold(
topBar = {
TopAppBar(
Expand Down Expand Up @@ -92,7 +91,9 @@ fun MeasureReportListScreen(
}
}
} else {
LazyColumn(modifier = modifier.background(Color.White).fillMaxSize()) {
LazyColumn(
modifier = modifier.background(Color.White).fillMaxSize().padding(bottom = 32.dp),
) {
lazyReportItems.keys.forEach { key ->
item {
key?.let { it1 ->
Expand Down

0 comments on commit 3cbb77b

Please sign in to comment.