From 1fbc853860343a87e4fa562ef2aa78f9a83f5a42 Mon Sep 17 00:00:00 2001 From: Vimalraj Date: Sun, 12 Jan 2025 20:24:12 +0530 Subject: [PATCH] No Internet dialog Handling --- .../coremodule/common/utils/ViewUtils.kt | 35 +++++++++++++++++++ coremodule/src/main/res/values/strings.xml | 2 ++ 2 files changed, 37 insertions(+) diff --git a/coremodule/src/main/java/com/vimalraj/coremodule/common/utils/ViewUtils.kt b/coremodule/src/main/java/com/vimalraj/coremodule/common/utils/ViewUtils.kt index 23b13cd..505bde9 100644 --- a/coremodule/src/main/java/com/vimalraj/coremodule/common/utils/ViewUtils.kt +++ b/coremodule/src/main/java/com/vimalraj/coremodule/common/utils/ViewUtils.kt @@ -4,9 +4,11 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.AlertDialog import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.Icon @@ -26,6 +28,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.compose.ui.window.DialogProperties import com.vimalraj.coremodule.R @Composable @@ -120,4 +123,36 @@ fun GenericAlertDialog( } } ) +} + + +@Composable +fun NoInternetAlertDialog( + onDismissRequest: () -> Unit, +) { + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + AlertDialog( + modifier = Modifier.fillMaxWidth(0.9f), + properties = DialogProperties( + usePlatformDefaultWidth = false, + decorFitsSystemWindows = true, + dismissOnClickOutside = true, + dismissOnBackPress = true + ), + shape = RoundedCornerShape(8.dp), + onDismissRequest = { + onDismissRequest() + }, + confirmButton = { + TextButton(onClick = { + onDismissRequest() + }) { + Text(text = stringResource(R.string.ok)) + } + }, + title = { + Text(text = stringResource(R.string.no_internet_message), fontSize = 16.sp) + }, + ) + } } \ No newline at end of file diff --git a/coremodule/src/main/res/values/strings.xml b/coremodule/src/main/res/values/strings.xml index 9071664..d43537d 100644 --- a/coremodule/src/main/res/values/strings.xml +++ b/coremodule/src/main/res/values/strings.xml @@ -5,4 +5,6 @@ Are you sure to delete all ? All the tasks will be deleted once you click confirm. Click Confirm to delete or Dismiss. Something went wrong. Try again later. + OK + No Internet. Please check your connection. \ No newline at end of file