Compare commits
2 Commits
2024-04-13
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
30ab8e2fe9 | ||
|
cf9e8b483c |
@ -1,12 +1,18 @@
|
|||||||
package it.edu.cassandroferminervi.flowschool.screens
|
package it.edu.cassandroferminervi.flowschool.screens
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.CardDefaults
|
||||||
|
import androidx.compose.material3.ElevatedCard
|
||||||
|
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.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
@ -24,18 +30,79 @@ fun HomeScreen(navigator: DestinationsNavigator, token: String) {
|
|||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(horizontal = 50.dp)
|
|
||||||
) {
|
) {
|
||||||
Button(onClick = {
|
ElevatedCard(
|
||||||
|
elevation = CardDefaults.cardElevation(
|
||||||
|
defaultElevation = 6.dp
|
||||||
|
),
|
||||||
|
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxHeight(0.5F)
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(25.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
"Scannerizza codice QR",
|
||||||
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
"Scannerizzando il codice QR generato dinamicamente dal dispositivo situato nella scuola ti permette di segnare la presenza in modo efficiente.",
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp)
|
||||||
|
)
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
) {
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
navigator.navigate(PermissionScreenDestination(token))
|
navigator.navigate(PermissionScreenDestination(token))
|
||||||
}, modifier = Modifier.align(Alignment.CenterHorizontally)) {
|
}, modifier = Modifier
|
||||||
Text("Scannerizza codice QR")
|
.align(Alignment.BottomEnd)
|
||||||
|
.padding(16.dp)
|
||||||
|
) {
|
||||||
|
Text("Prosegui")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
Button(onClick = {
|
ElevatedCard(
|
||||||
|
elevation = CardDefaults.cardElevation(
|
||||||
|
defaultElevation = 6.dp
|
||||||
|
),
|
||||||
|
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxHeight()
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(25.dp)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
"Cerca professore",
|
||||||
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
"Cerca il professore sul quale vuoi ottenere informazioni come l'orario di entrata, l'orario di uscita e la classe in cui presiede attualmente.",
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp)
|
||||||
|
)
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
) {
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
navigator.navigate(SearchingScreenDestination(token))
|
navigator.navigate(SearchingScreenDestination(token))
|
||||||
}, modifier = Modifier.align(Alignment.CenterHorizontally)) {
|
}, modifier = Modifier
|
||||||
Text("Cerca professore")
|
.align(Alignment.BottomEnd)
|
||||||
|
.padding(16.dp)
|
||||||
|
) {
|
||||||
|
Text("Prosegui")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,6 @@ package it.edu.cassandroferminervi.flowschool.util
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.camera.core.ImageAnalysis
|
import androidx.camera.core.ImageAnalysis
|
||||||
import androidx.camera.core.ImageProxy
|
import androidx.camera.core.ImageProxy
|
||||||
@ -17,7 +16,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class QrAnalyzer(private val context: Context, val navigator: DestinationsNavigator, val token: String) : ImageAnalysis.Analyzer {
|
class QrAnalyzer(private val context: Context, private val navigator: DestinationsNavigator, val token: String) : ImageAnalysis.Analyzer {
|
||||||
private val options = BarcodeScannerOptions.Builder()
|
private val options = BarcodeScannerOptions.Builder()
|
||||||
.setBarcodeFormats(Barcode.FORMAT_QR_CODE)
|
.setBarcodeFormats(Barcode.FORMAT_QR_CODE)
|
||||||
.build()
|
.build()
|
||||||
@ -37,7 +36,6 @@ class QrAnalyzer(private val context: Context, val navigator: DestinationsNaviga
|
|||||||
?.mapNotNull { it.rawValue }
|
?.mapNotNull { it.rawValue }
|
||||||
?.joinToString(",")
|
?.joinToString(",")
|
||||||
?.let {
|
?.let {
|
||||||
Toast.makeText(context, it, Toast.LENGTH_SHORT).show()
|
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
val response = RetrofitInstance.api.postPresence(token, it)
|
val response = RetrofitInstance.api.postPresence(token, it)
|
||||||
val resBody = response.body()
|
val resBody = response.body()
|
||||||
|
Loading…
Reference in New Issue
Block a user