NetworkErrorDialog
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package `in`.sminnovations.attendanceapp.screens.home.ui.componets
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import `in`.sminnovations.attendanceapp.screens.settings.ui.components.subSetting.AboutSettings
|
||||
|
||||
|
||||
@Composable
|
||||
fun NetworkErrorDialog(
|
||||
showDialog: Boolean,
|
||||
onRetry: () -> Unit,
|
||||
onSettings: () -> Unit,
|
||||
) {
|
||||
if (showDialog) {
|
||||
val showSettingDialog = remember { mutableStateOf(false) }
|
||||
val context = LocalContext.current
|
||||
AlertDialog(onDismissRequest = { /* Do nothing to prevent dismissal by tapping outside */ },
|
||||
title = {
|
||||
if (!showSettingDialog.value) {
|
||||
Text(text = "Network Error")
|
||||
} else {
|
||||
Text(text = "Settings")
|
||||
}
|
||||
},
|
||||
text = {
|
||||
if (!showSettingDialog.value) {
|
||||
Text(text = "Network is not connected. Please check your Wi-Fi or mobile data.\n\nIf Wi-Fi is just connected wait for some time and press retry again")
|
||||
} else {
|
||||
AboutSettings(context = context)
|
||||
}
|
||||
|
||||
},
|
||||
confirmButton = {
|
||||
if (!showSettingDialog.value) {
|
||||
Button(onClick = {
|
||||
onRetry()
|
||||
}) {
|
||||
Text("Retry")
|
||||
}
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
if (!showSettingDialog.value) {
|
||||
Button(onClick = { showSettingDialog.value = true }) {
|
||||
Text("Settings")
|
||||
}
|
||||
} else {
|
||||
Button(onClick = { showSettingDialog.value = false }) {
|
||||
Text("Network")
|
||||
}
|
||||
}
|
||||
},
|
||||
modifier = Modifier.padding(16.dp)
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user