NetworkErrorDialog
This commit is contained in:
@@ -1,14 +1,19 @@
|
|||||||
package `in`.sminnovations.attendanceapp.screens.home.ui.componets
|
package `in`.sminnovations.attendanceapp.screens.home.ui.componets
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import `in`.sminnovations.attendanceapp.screens.settings.ui.components.subSetting.AboutSettings
|
import `in`.sminnovations.attendanceapp.screens.settings.ui.components.subSetting.AboutSettings
|
||||||
|
|
||||||
@@ -18,50 +23,45 @@ fun NetworkErrorDialog(
|
|||||||
showDialog: Boolean,
|
showDialog: Boolean,
|
||||||
onRetry: () -> Unit,
|
onRetry: () -> Unit,
|
||||||
) {
|
) {
|
||||||
if (showDialog) {
|
if (!showDialog) return
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
var showSettingDialog by remember { mutableStateOf(false) }
|
||||||
confirmButton = {
|
val context = LocalContext.current
|
||||||
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)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
AlertDialog(
|
||||||
}
|
onDismissRequest = { /* Prevent dismissing by tapping outside */ },
|
||||||
|
title = {
|
||||||
|
Text(
|
||||||
|
text = if (showSettingDialog) "Settings" else "Network Error",
|
||||||
|
style = MaterialTheme.typography.headlineSmall,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
if (showSettingDialog) {
|
||||||
|
AboutSettings(context = context)
|
||||||
|
} else {
|
||||||
|
Text(
|
||||||
|
text = "Network is not connected. Please check your Wi-Fi or mobile data.\n\nIf Wi-Fi is just connected, wait for a while and then press retry.",
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.padding(vertical = 8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
if (!showSettingDialog) {
|
||||||
|
Button(onClick = onRetry) {
|
||||||
|
Text("Retry")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
Button(onClick = { showSettingDialog = !showSettingDialog }) {
|
||||||
|
Text(text = if (showSettingDialog) "Network" else "Settings")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modifier = Modifier.padding(16.dp)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user