Skip to content

Commit

Permalink
No Internet dialog Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Vimalraj-Vijay committed Jan 12, 2025
1 parent 7da371e commit 1fbc853
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
},
)
}
}
2 changes: 2 additions & 0 deletions coremodule/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
<string name="are_you_sure_to_delete_all">Are you sure to delete all ?</string>
<string name="delete_all_desc">All the tasks will be deleted once you click confirm. Click Confirm to delete or Dismiss.</string>
<string name="something_went_wrong_try_again_later">Something went wrong. Try again later.</string>
<string name="ok">OK</string>
<string name="no_internet_message">No Internet. Please check your connection.</string>
</resources>

0 comments on commit 1fbc853

Please sign in to comment.