added the network check
This commit is contained in:
2
.idea/other.xml
generated
2
.idea/other.xml
generated
@@ -262,7 +262,7 @@
|
|||||||
<option name="codename" value="q6q" />
|
<option name="codename" value="q6q" />
|
||||||
<option name="id" value="q6q" />
|
<option name="id" value="q6q" />
|
||||||
<option name="manufacturer" value="Samsung" />
|
<option name="manufacturer" value="Samsung" />
|
||||||
<option name="name" value="SM-F956B" />
|
<option name="name" value="Galaxy Z Fold6" />
|
||||||
<option name="screenDensity" value="420" />
|
<option name="screenDensity" value="420" />
|
||||||
<option name="screenX" value="1856" />
|
<option name="screenX" value="1856" />
|
||||||
<option name="screenY" value="2160" />
|
<option name="screenY" value="2160" />
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ android {
|
|||||||
applicationId = "in.sminnovations.attendanceapp.user"
|
applicationId = "in.sminnovations.attendanceapp.user"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 3
|
versionCode = 4
|
||||||
|
|
||||||
versionName = "3.0.1"
|
versionName = "3.0.2"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
|
|||||||
@@ -0,0 +1,128 @@
|
|||||||
|
package `in`.sminnovations.attendanceapp.screens.home.ui.componets
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.OutlinedCard
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.text.SpanStyle
|
||||||
|
import androidx.compose.ui.text.buildAnnotatedString
|
||||||
|
import androidx.compose.ui.text.withStyle
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
internal fun ErrorContent(
|
||||||
|
errorMessage: String,
|
||||||
|
userName: String?,
|
||||||
|
checkedOutTime: String
|
||||||
|
) {
|
||||||
|
|
||||||
|
val errorExplanations = mapOf(
|
||||||
|
// Network and Data Access Errors
|
||||||
|
"Failed to fetch employee data" to "There was an issue retrieving your employee information. Please check your internet connection and try again.",
|
||||||
|
"Failed to fetch attendance data" to "Unable to retrieve attendance records. Please verify your internet connection and try again.",
|
||||||
|
|
||||||
|
// Employee Validation Errors
|
||||||
|
"Invalid employee ID" to "The scanned ID isn't recognized. Double-check the ID, and if the issue continues, contact your administrator.",
|
||||||
|
"Employee ID has expired" to "This ID is no longer active. Please contact HR to renew or reactivate your ID.",
|
||||||
|
|
||||||
|
// Attendance Process Errors
|
||||||
|
"Invalid attendance record" to "An unexpected issue occurred with your attendance record. Please contact support for assistance.",
|
||||||
|
"Already checked out for today." to "You've already completed your check-out for today. If you need to make corrections, please contact support.",
|
||||||
|
"Failed to check in" to "There was an issue recording your check-in. Please try again or contact support if the problem persists.",
|
||||||
|
"Failed to check out" to "There was an issue recording your check-out. Please try again or contact support if the problem persists.",
|
||||||
|
|
||||||
|
// Generic Error
|
||||||
|
"An error occurred" to "An unexpected error occurred. Please try again or contact support if the issue continues."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
val detailedExplanation = errorExplanations[errorMessage] ?: "An unexpected error occurred."
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(20.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
// Only show the "Error Message for" text if we have a valid userName
|
||||||
|
if (!userName.isNullOrEmpty()) {
|
||||||
|
OutlinedCard(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(bottom = 16.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = buildAnnotatedString {
|
||||||
|
append("Error Message for ")
|
||||||
|
withStyle(style = SpanStyle(color = Color.Green)) {
|
||||||
|
append(userName)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
modifier = Modifier.padding(16.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OutlinedCard(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(bottom = 16.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = errorMessage,
|
||||||
|
style = MaterialTheme.typography.titleLarge,
|
||||||
|
color = MaterialTheme.colorScheme.error,
|
||||||
|
modifier = Modifier.padding(16.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detailed explanation for the error
|
||||||
|
OutlinedCard(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(bottom = if (checkedOutTime.isNotEmpty()) 16.dp else 0.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
letterSpacing = 2.sp,
|
||||||
|
lineHeight = 40.sp,
|
||||||
|
text = detailedExplanation,
|
||||||
|
fontSize = 18.sp,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
|
modifier = Modifier.padding(16.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkedOutTime.isNotEmpty()) {
|
||||||
|
OutlinedCard(
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "Check Out Time",
|
||||||
|
style = MaterialTheme.typography.titleLarge
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
Text(
|
||||||
|
text = checkedOutTime,
|
||||||
|
style = MaterialTheme.typography.titleLarge,
|
||||||
|
color = Color.Green
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package `in`.sminnovations.attendanceapp.screens.home.ui.componets
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.google.accompanist.permissions.ExperimentalPermissionsApi
|
||||||
|
import com.google.accompanist.permissions.PermissionState
|
||||||
|
|
||||||
|
|
||||||
|
@OptIn(ExperimentalPermissionsApi::class)
|
||||||
|
@Composable
|
||||||
|
internal fun RequestPermissionsContent(cameraPermissionState: PermissionState) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(16.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "Camera Permission Required",
|
||||||
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
Button(onClick = { cameraPermissionState.launchPermissionRequest() }) {
|
||||||
|
Text("Request Permission")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user