feat: replace text observation field with an interactive editable card in MaintenanceDashboardScreen and several improvements and bug corrections
This commit is contained in:
@@ -2,6 +2,8 @@ package com.example.ui.screens
|
|||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import com.example.R
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
@@ -515,17 +517,6 @@ fun MaintenanceDashboardScreen(
|
|||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
color = BrandBlack
|
color = BrandBlack
|
||||||
)
|
)
|
||||||
IconButton(
|
|
||||||
onClick = { isListExpanded = !isListExpanded },
|
|
||||||
modifier = Modifier.size(24.dp).testTag("toggle_expand_list_button")
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = if (isListExpanded) Icons.Default.FullscreenExit else Icons.Default.Fullscreen,
|
|
||||||
contentDescription = if (isListExpanded) "Recolher visualização" else "Expandir listagem",
|
|
||||||
tint = BrandGreen,
|
|
||||||
modifier = Modifier.size(20.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1309,7 +1300,40 @@ fun EditActivityBottomSheet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var progressValue by remember(activity) { mutableStateOf(activity.percentualExecucao.toFloat()) }
|
var progressValue by remember(activity) { mutableStateOf(activity.percentualExecucao.toFloat()) }
|
||||||
var observationText by remember { mutableStateOf("") }
|
var observationText by remember(activity) { mutableStateOf(activity.observacoes ?: findings.find { it.tipo == "OBS" }?.descricao ?: "") }
|
||||||
|
var showEditObsDialog by remember { mutableStateOf(false) }
|
||||||
|
var tempObsText by remember(observationText) { mutableStateOf(observationText) }
|
||||||
|
|
||||||
|
val draftAddedFindings = remember(activity) { mutableStateListOf<Pair<String, String>>() }
|
||||||
|
val draftUpdatedFindings = remember(activity) { mutableStateMapOf<String, String>() }
|
||||||
|
val draftDeletedFindingIds = remember(activity) { mutableStateListOf<String>() }
|
||||||
|
|
||||||
|
val displayFindings = remember(findings, draftAddedFindings.toList(), draftUpdatedFindings.toMap(), draftDeletedFindingIds.toList()) {
|
||||||
|
val list = findings
|
||||||
|
.filter { !draftDeletedFindingIds.contains(it.id) }
|
||||||
|
.map { f ->
|
||||||
|
if (draftUpdatedFindings.containsKey(f.id)) {
|
||||||
|
f.copy(descricao = draftUpdatedFindings[f.id]!!)
|
||||||
|
} else {
|
||||||
|
f
|
||||||
|
}
|
||||||
|
}.toMutableList()
|
||||||
|
|
||||||
|
draftAddedFindings.forEachIndexed { index, (tipo, desc) ->
|
||||||
|
list.add(
|
||||||
|
com.example.data.model.OSFinding(
|
||||||
|
id = "draft_new_$index",
|
||||||
|
numeroOs = activity.numeroOs,
|
||||||
|
tipo = tipo,
|
||||||
|
descricao = desc,
|
||||||
|
timestamp = System.currentTimeMillis(),
|
||||||
|
responsavel = currentUser?.displayName ?: "Encarregado Campo"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
list
|
||||||
|
}
|
||||||
|
|
||||||
val newPhotosList = remember { mutableStateListOf<String>() }
|
val newPhotosList = remember { mutableStateListOf<String>() }
|
||||||
var tempCameraPath by remember { mutableStateOf<String?>(null) }
|
var tempCameraPath by remember { mutableStateOf<String?>(null) }
|
||||||
var selectedPhotoForViewer by remember { mutableStateOf<String?>(null) }
|
var selectedPhotoForViewer by remember { mutableStateOf<String?>(null) }
|
||||||
@@ -1416,9 +1440,27 @@ fun EditActivityBottomSheet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Latest Observation Display Card (if present)
|
// Card Interativo de Observação da OS
|
||||||
val latestObsText = activity.observacoes ?: findings.find { it.tipo == "OBS" }?.descricao
|
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||||
if (!latestObsText.isNullOrBlank()) {
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
|
) {
|
||||||
|
Icon(Icons.Default.Comment, contentDescription = "Observação", tint = Color(0xFF6A1B9A), modifier = Modifier.size(18.dp))
|
||||||
|
Text(
|
||||||
|
text = "Observação da OS",
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
color = BrandBlack
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
colors = CardDefaults.cardColors(containerColor = Color(0xFFF3E5F5)),
|
colors = CardDefaults.cardColors(containerColor = Color(0xFFF3E5F5)),
|
||||||
border = BorderStroke(1.dp, Color(0xFFE1BEE7)),
|
border = BorderStroke(1.dp, Color(0xFFE1BEE7)),
|
||||||
@@ -1428,27 +1470,66 @@ fun EditActivityBottomSheet(
|
|||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(10.dp),
|
modifier = Modifier.padding(10.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
Icon(Icons.Default.Comment, contentDescription = "Última Observação", tint = Color(0xFF6A1B9A), modifier = Modifier.size(18.dp))
|
Text(
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
text = if (observationText.isBlank()) "Nenhuma observação registrada" else observationText,
|
||||||
Text(
|
fontSize = 12.sp,
|
||||||
text = "Última Observação da OS:",
|
fontWeight = if (observationText.isBlank()) FontWeight.Normal else FontWeight.Medium,
|
||||||
fontSize = 10.sp,
|
color = if (observationText.isBlank()) Color.Gray else BrandBlack,
|
||||||
fontWeight = FontWeight.Bold,
|
modifier = Modifier.weight(1f)
|
||||||
color = Color(0xFF6A1B9A)
|
)
|
||||||
)
|
if (currentUser != null) {
|
||||||
Text(
|
IconButton(
|
||||||
text = latestObsText,
|
onClick = {
|
||||||
fontSize = 12.sp,
|
tempObsText = observationText
|
||||||
fontWeight = FontWeight.Medium,
|
showEditObsDialog = true
|
||||||
color = BrandBlack
|
},
|
||||||
)
|
modifier = Modifier.size(28.dp)
|
||||||
|
) {
|
||||||
|
Icon(Icons.Default.Edit, contentDescription = "Editar Observação", tint = Color(0xFF6A1B9A), modifier = Modifier.size(16.dp))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showEditObsDialog) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = { showEditObsDialog = false },
|
||||||
|
title = {
|
||||||
|
Text("Editar Observação da OS", fontWeight = FontWeight.Bold, fontSize = 16.sp)
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = tempObsText,
|
||||||
|
onValueChange = { tempObsText = it },
|
||||||
|
placeholder = { Text("Digite a observação da OS...", fontSize = 13.sp) },
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.height(100.dp),
|
||||||
|
maxLines = 4
|
||||||
|
)
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
observationText = tempObsText.trim()
|
||||||
|
showEditObsDialog = false
|
||||||
|
},
|
||||||
|
colors = ButtonDefaults.buttonColors(containerColor = BrandGreen)
|
||||||
|
) {
|
||||||
|
Text("Confirmar")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = { showEditObsDialog = false }) {
|
||||||
|
Text("Cancelar")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Slider Progress Update Panel
|
// Slider Progress Update Panel
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
Row(
|
Row(
|
||||||
@@ -1517,28 +1598,6 @@ fun EditActivityBottomSheet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text Observation Entry
|
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
|
||||||
Text(
|
|
||||||
text = "Nova Observação de Campo",
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 14.sp,
|
|
||||||
color = BrandBlack
|
|
||||||
)
|
|
||||||
OutlinedTextField(
|
|
||||||
value = observationText,
|
|
||||||
onValueChange = { observationText = it },
|
|
||||||
placeholder = { Text("Descreva anomalias, materiais usados ou causas de atraso...", fontSize = 13.sp) },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(80.dp)
|
|
||||||
.testTag("os_notes_field"),
|
|
||||||
maxLines = 3,
|
|
||||||
shape = RoundedCornerShape(8.dp),
|
|
||||||
enabled = currentUser != null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 🛡️ Achados de Segurança Section
|
// 🛡️ Achados de Segurança Section
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
HorizontalDivider(color = Color(0xFFF1F1F1))
|
HorizontalDivider(color = Color(0xFFF1F1F1))
|
||||||
@@ -1553,7 +1612,7 @@ fun EditActivityBottomSheet(
|
|||||||
) {
|
) {
|
||||||
Icon(Icons.Default.Security, contentDescription = "Segurança", tint = Color(0xFFD84315), modifier = Modifier.size(18.dp))
|
Icon(Icons.Default.Security, contentDescription = "Segurança", tint = Color(0xFFD84315), modifier = Modifier.size(18.dp))
|
||||||
Text(
|
Text(
|
||||||
text = "Achados de Segurança (${findings.count { it.tipo == "SEGURANCA" }})",
|
text = "Achados de Segurança (${displayFindings.count { it.tipo == "SEGURANCA" }})",
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = BrandBlack
|
color = BrandBlack
|
||||||
@@ -1577,7 +1636,7 @@ fun EditActivityBottomSheet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val segurancaFindings = findings.filter { it.tipo == "SEGURANCA" }
|
val segurancaFindings = displayFindings.filter { it.tipo == "SEGURANCA" }
|
||||||
if (segurancaFindings.isEmpty()) {
|
if (segurancaFindings.isEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
text = "Nenhum achado de segurança registrado para esta OS.",
|
text = "Nenhum achado de segurança registrado para esta OS.",
|
||||||
@@ -1596,7 +1655,16 @@ fun EditActivityBottomSheet(
|
|||||||
findingText = finding.descricao
|
findingText = finding.descricao
|
||||||
showFindingDialog = true
|
showFindingDialog = true
|
||||||
},
|
},
|
||||||
onDelete = { onDeleteFinding(finding) }
|
onDelete = {
|
||||||
|
if (finding.id.startsWith("draft_new_")) {
|
||||||
|
val idx = finding.id.removePrefix("draft_new_").toIntOrNull()
|
||||||
|
if (idx != null && idx in draftAddedFindings.indices) {
|
||||||
|
draftAddedFindings.removeAt(idx)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
draftDeletedFindingIds.add(finding.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1617,7 +1685,7 @@ fun EditActivityBottomSheet(
|
|||||||
) {
|
) {
|
||||||
Icon(Icons.Default.Build, contentDescription = "Manutenção", tint = Color(0xFF0277BD), modifier = Modifier.size(18.dp))
|
Icon(Icons.Default.Build, contentDescription = "Manutenção", tint = Color(0xFF0277BD), modifier = Modifier.size(18.dp))
|
||||||
Text(
|
Text(
|
||||||
text = "Achados de Manutenção (${findings.count { it.tipo == "MANUTENCAO" }})",
|
text = "Achados de Manutenção (${displayFindings.count { it.tipo == "MANUTENCAO" }})",
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
color = BrandBlack
|
color = BrandBlack
|
||||||
@@ -1641,7 +1709,7 @@ fun EditActivityBottomSheet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val manutencaoFindings = findings.filter { it.tipo == "MANUTENCAO" }
|
val manutencaoFindings = displayFindings.filter { it.tipo == "MANUTENCAO" }
|
||||||
if (manutencaoFindings.isEmpty()) {
|
if (manutencaoFindings.isEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
text = "Nenhum achado de manutenção registrado para esta OS.",
|
text = "Nenhum achado de manutenção registrado para esta OS.",
|
||||||
@@ -1660,7 +1728,16 @@ fun EditActivityBottomSheet(
|
|||||||
findingText = finding.descricao
|
findingText = finding.descricao
|
||||||
showFindingDialog = true
|
showFindingDialog = true
|
||||||
},
|
},
|
||||||
onDelete = { onDeleteFinding(finding) }
|
onDelete = {
|
||||||
|
if (finding.id.startsWith("draft_new_")) {
|
||||||
|
val idx = finding.id.removePrefix("draft_new_").toIntOrNull()
|
||||||
|
if (idx != null && idx in draftAddedFindings.indices) {
|
||||||
|
draftAddedFindings.removeAt(idx)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
draftDeletedFindingIds.add(finding.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1922,6 +1999,21 @@ fun EditActivityBottomSheet(
|
|||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
isSubmitting = true
|
isSubmitting = true
|
||||||
|
// 1. Aplicar rascunhos de achados (adição, edição e exclusão)
|
||||||
|
draftAddedFindings.forEach { (tipo, desc) ->
|
||||||
|
onAddFinding(tipo, desc)
|
||||||
|
}
|
||||||
|
draftUpdatedFindings.forEach { (id, newDesc) ->
|
||||||
|
findings.find { it.id == id }?.let { original ->
|
||||||
|
onUpdateFinding(original.copy(descricao = newDesc))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
draftDeletedFindingIds.forEach { id ->
|
||||||
|
findings.find { it.id == id }?.let { original ->
|
||||||
|
onDeleteFinding(original)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 2. Salvar progresso, observação e fotos
|
||||||
val photoParam = if (newPhotosList.isNotEmpty()) newPhotosList.joinToString("|") else null
|
val photoParam = if (newPhotosList.isNotEmpty()) newPhotosList.joinToString("|") else null
|
||||||
onUpdateProgress(progressValue.toInt(), observationText, photoParam)
|
onUpdateProgress(progressValue.toInt(), observationText, photoParam)
|
||||||
onDismiss()
|
onDismiss()
|
||||||
@@ -1969,9 +2061,17 @@ fun EditActivityBottomSheet(
|
|||||||
onClick = {
|
onClick = {
|
||||||
if (findingText.isNotBlank()) {
|
if (findingText.isNotBlank()) {
|
||||||
if (activeFindingForDialog == null) {
|
if (activeFindingForDialog == null) {
|
||||||
onAddFinding(dialogTipo, findingText.trim())
|
draftAddedFindings.add(dialogTipo to findingText.trim())
|
||||||
} else {
|
} else {
|
||||||
onUpdateFinding(activeFindingForDialog!!.copy(descricao = findingText.trim()))
|
val target = activeFindingForDialog!!
|
||||||
|
if (target.id.startsWith("draft_new_")) {
|
||||||
|
val idx = target.id.removePrefix("draft_new_").toIntOrNull()
|
||||||
|
if (idx != null && idx in draftAddedFindings.indices) {
|
||||||
|
draftAddedFindings[idx] = target.tipo to findingText.trim()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
draftUpdatedFindings[target.id] = findingText.trim()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
showFindingDialog = false
|
showFindingDialog = false
|
||||||
}
|
}
|
||||||
@@ -2027,6 +2127,9 @@ fun EditActivityBottomSheet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Espaçamento inferior reforçado para evitar sobreposição por botões nativos do Android
|
||||||
|
Spacer(modifier = Modifier.height(32.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2317,10 +2420,10 @@ fun rememberScrollState() = androidx.compose.foundation.rememberScrollState()
|
|||||||
@Composable
|
@Composable
|
||||||
fun GoogleIcon(modifier: Modifier = Modifier) {
|
fun GoogleIcon(modifier: Modifier = Modifier) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.AccountCircle,
|
painter = painterResource(id = R.drawable.ic_google),
|
||||||
contentDescription = "Google",
|
contentDescription = "Google",
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
tint = Color.White
|
tint = Color.Unspecified
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,190 +152,7 @@ fun SettingsScreen(
|
|||||||
verticalArrangement = Arrangement.spacedBy(20.dp)
|
verticalArrangement = Arrangement.spacedBy(20.dp)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// Seção 2: Status da API Google Cloud
|
// Seção: Painel do Administrador
|
||||||
Column {
|
|
||||||
Text(
|
|
||||||
text = "Status da API Google Cloud",
|
|
||||||
fontSize = 20.sp,
|
|
||||||
fontWeight = FontWeight.Black,
|
|
||||||
color = Color(0xFF0F2644),
|
|
||||||
modifier = Modifier.padding(bottom = 8.dp)
|
|
||||||
)
|
|
||||||
|
|
||||||
Card(
|
|
||||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
|
||||||
shape = RoundedCornerShape(12.dp),
|
|
||||||
elevation = CardDefaults.cardElevation(defaultElevation = 1.dp)
|
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(16.dp)
|
|
||||||
) {
|
|
||||||
if (!connectionTested) {
|
|
||||||
// Erro ou Awaiting Connection State
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Warning,
|
|
||||||
contentDescription = "Alerta",
|
|
||||||
tint = Color(0xFFD32F2F),
|
|
||||||
modifier = Modifier.size(24.dp)
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = "Configure e teste a conexão para carregar as métricas da API Google Cloud em tempo real.",
|
|
||||||
color = Color(0xFFD32F2F),
|
|
||||||
fontSize = 14.sp,
|
|
||||||
fontWeight = FontWeight.Medium
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
|
||||||
) {
|
|
||||||
// Coluna Latência
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "Latência",
|
|
||||||
fontSize = 13.sp,
|
|
||||||
color = Color.Gray,
|
|
||||||
fontWeight = FontWeight.Medium
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = apiLatency ?: "0ms",
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = Color.Gray,
|
|
||||||
fontWeight = FontWeight.Bold
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(6.dp))
|
|
||||||
|
|
||||||
LinearProgressIndicator(
|
|
||||||
progress = { 0.8f },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(8.dp),
|
|
||||||
color = BrandGreen,
|
|
||||||
trackColor = Color(0xFFE0E0E0),
|
|
||||||
strokeCap = androidx.compose.ui.graphics.StrokeCap.Round
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(6.dp))
|
|
||||||
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = apiLatency ?: "0ms",
|
|
||||||
fontSize = 16.sp,
|
|
||||||
fontWeight = FontWeight.Black,
|
|
||||||
color = BrandBlack
|
|
||||||
)
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.DateRange,
|
|
||||||
contentDescription = "Online",
|
|
||||||
tint = BrandGreen,
|
|
||||||
modifier = Modifier.size(14.dp)
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = "Online",
|
|
||||||
fontSize = 14.sp,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = BrandGreen
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.width(24.dp))
|
|
||||||
|
|
||||||
// Coluna Cota
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "Cota de Uso",
|
|
||||||
fontSize = 13.sp,
|
|
||||||
color = Color.Gray,
|
|
||||||
fontWeight = FontWeight.Medium
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = apiQuota ?: "0%",
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = Color.Gray,
|
|
||||||
fontWeight = FontWeight.Bold
|
|
||||||
)
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Info,
|
|
||||||
contentDescription = "Cota",
|
|
||||||
tint = BrandGreen,
|
|
||||||
modifier = Modifier.size(14.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(6.dp))
|
|
||||||
|
|
||||||
val quotaFloat = (apiQuota?.replace("%", "")?.toFloatOrNull() ?: 0f) / 100f
|
|
||||||
LinearProgressIndicator(
|
|
||||||
progress = { quotaFloat.coerceIn(0f, 1f) },
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(8.dp),
|
|
||||||
color = BrandGreen,
|
|
||||||
trackColor = Color(0xFFE0E0E0),
|
|
||||||
strokeCap = androidx.compose.ui.graphics.StrokeCap.Round
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(6.dp))
|
|
||||||
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = apiQuota ?: "0%",
|
|
||||||
fontSize = 16.sp,
|
|
||||||
fontWeight = FontWeight.Black,
|
|
||||||
color = BrandBlack
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = "Bom",
|
|
||||||
fontSize = 14.sp,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = BrandGreen
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Seção: Simulação de Data
|
|
||||||
DateSimulationSection(
|
|
||||||
hasTotalAccess = hasTotalAccess,
|
|
||||||
simulationConfig = simulationConfig,
|
|
||||||
onActivateSimulation = { dateMillis, mode ->
|
|
||||||
viewModel.setDateSimulation(dateMillis, mode)
|
|
||||||
},
|
|
||||||
onClearSimulation = {
|
|
||||||
viewModel.clearDateSimulation()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Seção 3: Painel do Administrador
|
|
||||||
Column {
|
Column {
|
||||||
Text(
|
Text(
|
||||||
text = "Painel do Administrador",
|
text = "Painel do Administrador",
|
||||||
@@ -396,6 +213,18 @@ fun SettingsScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Seção: Simulação de Data (Posicionada no final da tela)
|
||||||
|
DateSimulationSection(
|
||||||
|
hasTotalAccess = hasTotalAccess,
|
||||||
|
simulationConfig = simulationConfig,
|
||||||
|
onActivateSimulation = { dateMillis, mode ->
|
||||||
|
viewModel.setDateSimulation(dateMillis, mode)
|
||||||
|
},
|
||||||
|
onClearSimulation = {
|
||||||
|
viewModel.clearDateSimulation()
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user