Added the Auto Update Check Feature
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package `in`.sminnovations.attendanceapp.screens.home.ui
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -18,6 +20,11 @@ import `in`.sminnovations.attendanceapp.screens.home.ui.componets.NetworkErrorDi
|
||||
import `in`.sminnovations.attendanceapp.screens.home.ui.componets.UpdateDialog
|
||||
import `in`.sminnovations.attendanceapp.screens.home.viewModel.HomeViewModel
|
||||
import `in`.sminnovations.attendanceapp.screens.settings.ui.SettingsScreenDialogue
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalPermissionsApi::class)
|
||||
@Composable
|
||||
@@ -32,12 +39,24 @@ fun HomeScreen(
|
||||
|
||||
val downloadProgress by viewModel.downloadProgress.collectAsState()
|
||||
val context = LocalContext.current
|
||||
Box (modifier = Modifier.fillMaxSize()){
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
|
||||
SettingsScreenDialogue(
|
||||
showDialogue = showSettingDialog.value,
|
||||
onDismissDialogue = { showSettingDialog.value = false }
|
||||
)
|
||||
fun checkForUpdateToast(context: Context ,value : Boolean){
|
||||
val scope = CoroutineScope(Dispatchers.IO)
|
||||
scope.launch {
|
||||
delay(1000)
|
||||
}
|
||||
if (value) {
|
||||
Toast.makeText(context, "App is Upto Date", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
}
|
||||
SettingsScreenDialogue(showDialogue = showSettingDialog.value,
|
||||
onDismissDialogue = { showSettingDialog.value = false },
|
||||
onCheckForUpdate = {
|
||||
viewModel.checkForUpdates(context)
|
||||
checkForUpdateToast(context,!isUpdateDialogVisible)
|
||||
})
|
||||
|
||||
|
||||
if (uiState.isConnected) {
|
||||
@@ -49,20 +68,24 @@ fun HomeScreen(
|
||||
onDismiss = { viewModel.dismissUpdate() },
|
||||
onInstall = { url -> viewModel.installUpdate(url) })
|
||||
}
|
||||
AttendanceScreenContent(
|
||||
uiState = uiState,
|
||||
AttendanceScreenContent(uiState = uiState,
|
||||
cameraPermissionState = cameraPermissionState,
|
||||
onScannerToggle = { if (uiState.isScanning) viewModel.stopScanning() else viewModel.startScanning() },
|
||||
onQrCodeScanned = viewModel::setQRCodeValue,
|
||||
onClickSettings = { showSettingDialog.value = true }
|
||||
)
|
||||
onClickSettings = { showSettingDialog.value = true })
|
||||
|
||||
} else {
|
||||
NetworkErrorDialog(showDialog = true, onRetry = {
|
||||
viewModel.reStartMonitoring()
|
||||
},
|
||||
)
|
||||
}, onCheckForUpdate = {
|
||||
viewModel.checkForUpdates(context)
|
||||
checkForUpdateToast(context,!isUpdateDialogVisible)
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user