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.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_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 @@
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

Check warning on line 68 in android/engine/src/main/java/org/smartregister/fhircore/engine/ui/components/register/RegisterFooter.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/ui/components/register/RegisterFooter.kt#L68

Added line #L68 was not covered by tests
} 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 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 @@
LaunchedEffect(Unit) {
snackStateFlow.hookSnackBar(scaffoldState, profileUiState.resourceData, navController)
}

val fabActions = profileUiState.profileConfiguration?.fabActions
Scaffold(
scaffoldState = scaffoldState,
topBar = {
Expand All @@ -118,8 +120,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 +154,16 @@
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 Expand Up @@ -320,15 +329,15 @@
DropdownMenuItem(
enabled = enabled,
onClick = {
showOverflowMenu = false
onEvent(
ProfileEvent.OverflowMenuClick(
navController = navController,
resourceData = profileUiState.resourceData,
overflowMenuItemConfig = overflowMenuItemConfig,

Check warning on line 337 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#L332-L337

Added lines #L332 - L337 were not covered by tests
),
)
},

Check warning on line 340 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#L340

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

Check warning on line 348 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#L348

Added line #L348 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