@@ -40,6 +40,8 @@ import androidx.compose.runtime.collectAsState
4040import androidx.compose.runtime.getValue
4141import androidx.compose.runtime.mutableStateOf
4242import androidx.compose.runtime.remember
43+ import androidx.compose.runtime.saveable.rememberSaveable
44+ import androidx.compose.runtime.setValue
4345import androidx.compose.ui.Alignment
4446import androidx.compose.ui.Modifier
4547import androidx.compose.ui.graphics.Color
@@ -58,6 +60,7 @@ import org.koin.androidx.viewmodel.ext.android.viewModel
5860import org.openedx.core.presentation.ListItemPosition
5961import org.openedx.core.ui.HandleUIMessage
6062import org.openedx.core.ui.MainScreenTitle
63+ import org.openedx.core.ui.OfflineModeDialog
6164import org.openedx.core.ui.displayCutoutForLandscape
6265import org.openedx.core.ui.statusBarsInset
6366import org.openedx.core.ui.theme.OpenEdXTheme
@@ -90,6 +93,7 @@ class DatesFragment : Fragment() {
9093 DatesScreen (
9194 uiState = uiState,
9295 uiMessage = uiMessage,
96+ hasInternetConnection = viewModel.hasInternetConnection,
9397 onAction = { action ->
9498 when (action) {
9599 DatesViewActions .OpenSettings -> {
@@ -117,6 +121,7 @@ class DatesFragment : Fragment() {
117121private fun DatesScreen (
118122 uiState : DatesUIState ,
119123 uiMessage : UIMessage ? ,
124+ hasInternetConnection : Boolean ,
120125 onAction : (DatesViewActions ) -> Unit ,
121126) {
122127 val scaffoldState = rememberScaffoldState()
@@ -133,6 +138,9 @@ private fun DatesScreen(
133138 refreshing = uiState.isRefreshing,
134139 onRefresh = { onAction(DatesViewActions .SwipeRefresh ) }
135140 )
141+ var isInternetConnectionShown by rememberSaveable {
142+ mutableStateOf(false )
143+ }
136144
137145 Scaffold (
138146 scaffoldState = scaffoldState,
@@ -216,6 +224,21 @@ private fun DatesScreen(
216224 pullRefreshState,
217225 Modifier .align(Alignment .TopCenter )
218226 )
227+
228+ if (! isInternetConnectionShown && ! hasInternetConnection) {
229+ OfflineModeDialog (
230+ Modifier
231+ .fillMaxWidth()
232+ .align(Alignment .BottomCenter ),
233+ onDismissCLick = {
234+ isInternetConnectionShown = true
235+ },
236+ onReloadClick = {
237+ isInternetConnectionShown = true
238+ onAction(DatesViewActions .SwipeRefresh )
239+ }
240+ )
241+ }
219242 }
220243 }
221244 )
@@ -372,6 +395,7 @@ private fun DatesScreenPreview() {
372395 DatesScreen (
373396 uiState = DatesUIState (isLoading = false ),
374397 uiMessage = null ,
398+ hasInternetConnection = true ,
375399 onAction = {}
376400 )
377401 }
0 commit comments