@@ -3,6 +3,7 @@ package org.openedx.dates.presentation.dates
33import android.os.Bundle
44import android.view.LayoutInflater
55import android.view.ViewGroup
6+ import androidx.compose.foundation.layout.Arrangement
67import androidx.compose.foundation.layout.Box
78import androidx.compose.foundation.layout.Column
89import androidx.compose.foundation.layout.PaddingValues
@@ -17,6 +18,7 @@ import androidx.compose.foundation.lazy.LazyColumn
1718import androidx.compose.foundation.lazy.rememberLazyListState
1819import androidx.compose.foundation.rememberScrollState
1920import androidx.compose.foundation.verticalScroll
21+ import androidx.compose.material.Card
2022import androidx.compose.material.CircularProgressIndicator
2123import androidx.compose.material.ExperimentalMaterialApi
2224import androidx.compose.material.Icon
@@ -48,15 +50,18 @@ import androidx.compose.ui.unit.Dp
4850import androidx.compose.ui.unit.dp
4951import androidx.fragment.app.Fragment
5052import org.koin.androidx.viewmodel.ext.android.viewModel
53+ import org.openedx.core.domain.model.DatesSection
5154import org.openedx.core.presentation.dates.CourseDateBlockSection
5255import org.openedx.core.ui.HandleUIMessage
5356import org.openedx.core.ui.MainScreenTitle
5457import org.openedx.core.ui.OfflineModeDialog
58+ import org.openedx.core.ui.OpenEdXButton
5559import org.openedx.core.ui.displayCutoutForLandscape
5660import org.openedx.core.ui.shouldLoadMore
5761import org.openedx.core.ui.statusBarsInset
5862import org.openedx.core.ui.theme.OpenEdXTheme
5963import org.openedx.core.ui.theme.appColors
64+ import org.openedx.core.ui.theme.appShapes
6065import org.openedx.core.ui.theme.appTypography
6166import org.openedx.dates.R
6267import org.openedx.dates.presentation.dates.DatesFragment.Companion.LOAD_MORE_THRESHOLD
@@ -103,6 +108,10 @@ class DatesFragment : Fragment() {
103108 viewModel.fetchMore()
104109 }
105110
111+ DatesViewActions .ShiftDueDate -> {
112+ viewModel.shiftDueDate()
113+ }
114+
106115 is DatesViewActions .OpenEvent -> {
107116 viewModel.navigateToCourseOutline(
108117 requireActivity().supportFragmentManager,
@@ -197,11 +206,23 @@ private fun DatesScreen(
197206 LazyColumn (
198207 modifier = contentWidth.fillMaxSize(),
199208 state = scrollState,
200- contentPadding = PaddingValues (bottom = 20 .dp)
209+ contentPadding = PaddingValues (bottom = 48 .dp)
201210 ) {
202211 uiState.dates.keys.forEach { sectionKey ->
203- val dates = uiState.dates[sectionKey] ? : emptyList ()
212+ val dates = uiState.dates[sectionKey].orEmpty ()
204213 dates.isNotEmptyThenLet { sectionDates ->
214+ val isHavePastRelatedDates =
215+ sectionKey == DatesSection .PAST_DUE && dates.any { it.relative }
216+ if (isHavePastRelatedDates) {
217+ item {
218+ ShiftDueDatesCard (
219+ modifier = Modifier .padding(top = 12 .dp),
220+ onClick = {
221+ onAction(DatesViewActions .ShiftDueDate )
222+ }
223+ )
224+ }
225+ }
205226 item {
206227 CourseDateBlockSection (
207228 sectionKey = sectionKey,
@@ -261,6 +282,44 @@ private fun DatesScreen(
261282 )
262283}
263284
285+ @Composable
286+ private fun ShiftDueDatesCard (
287+ modifier : Modifier = Modifier ,
288+ onClick : () -> Unit
289+ ) {
290+ Card (
291+ modifier = modifier
292+ .fillMaxWidth(),
293+ backgroundColor = MaterialTheme .appColors.cardViewBackground,
294+ shape = MaterialTheme .appShapes.cardShape,
295+ ) {
296+ Column (
297+ modifier = Modifier
298+ .fillMaxSize()
299+ .padding(12 .dp),
300+ horizontalAlignment = Alignment .CenterHorizontally ,
301+ verticalArrangement = Arrangement .spacedBy(12 .dp)
302+ ) {
303+ Text (
304+ modifier = Modifier .fillMaxWidth(),
305+ text = stringResource(id = R .string.dates_shift_due_date_card_title),
306+ color = MaterialTheme .appColors.textDark,
307+ style = MaterialTheme .appTypography.titleMedium,
308+ )
309+ Text (
310+ modifier = Modifier .fillMaxWidth(),
311+ text = stringResource(id = R .string.dates_shift_due_date_card_description),
312+ color = MaterialTheme .appColors.textDark,
313+ style = MaterialTheme .appTypography.labelLarge,
314+ )
315+ OpenEdXButton (
316+ text = stringResource(id = R .string.dates_shift_due_date),
317+ onClick = onClick
318+ )
319+ }
320+ }
321+ }
322+
264323@Composable
265324private fun EmptyState (
266325 modifier : Modifier = Modifier
@@ -317,3 +376,13 @@ private fun DatesScreenPreview() {
317376 )
318377 }
319378}
379+
380+ @Preview
381+ @Composable
382+ private fun ShiftDueDatesCardPreview () {
383+ OpenEdXTheme {
384+ ShiftDueDatesCard (
385+ onClick = {}
386+ )
387+ }
388+ }
0 commit comments