refactor: remove Google Sheets ID connection UI from SettingsScreen
This commit is contained in:
@@ -57,7 +57,6 @@ fun SettingsScreen(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
// Observe state from ViewModel
|
// Observe state from ViewModel
|
||||||
val activeSpreadsheetId by viewModel.activeSpreadsheetId.collectAsStateWithLifecycle()
|
|
||||||
val apiLatency by viewModel.apiLatency.collectAsStateWithLifecycle()
|
val apiLatency by viewModel.apiLatency.collectAsStateWithLifecycle()
|
||||||
val apiQuota by viewModel.apiQuota.collectAsStateWithLifecycle()
|
val apiQuota by viewModel.apiQuota.collectAsStateWithLifecycle()
|
||||||
val apiStatusLoading by viewModel.apiStatusLoading.collectAsStateWithLifecycle()
|
val apiStatusLoading by viewModel.apiStatusLoading.collectAsStateWithLifecycle()
|
||||||
@@ -65,7 +64,6 @@ fun SettingsScreen(
|
|||||||
val isSyncing by viewModel.isSyncing.collectAsStateWithLifecycle()
|
val isSyncing by viewModel.isSyncing.collectAsStateWithLifecycle()
|
||||||
val conflictLogs by viewModel.conflictLogs.collectAsStateWithLifecycle()
|
val conflictLogs by viewModel.conflictLogs.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
var tempSpreadsheetId by remember(activeSpreadsheetId) { mutableStateOf(activeSpreadsheetId) }
|
|
||||||
var showClearCacheDialog by remember { mutableStateOf(false) }
|
var showClearCacheDialog by remember { mutableStateOf(false) }
|
||||||
var showConflictsDialog by remember { mutableStateOf(false) }
|
var showConflictsDialog by remember { mutableStateOf(false) }
|
||||||
var activeTestModal by remember { mutableStateOf<Int?>(null) }
|
var activeTestModal by remember { mutableStateOf<Int?>(null) }
|
||||||
@@ -143,105 +141,6 @@ fun SettingsScreen(
|
|||||||
.padding(16.dp),
|
.padding(16.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(20.dp)
|
verticalArrangement = Arrangement.spacedBy(20.dp)
|
||||||
) {
|
) {
|
||||||
// Seção 1: Conexão de Dados
|
|
||||||
Column {
|
|
||||||
Text(
|
|
||||||
text = "Conexão de Dados",
|
|
||||||
fontSize = 20.sp,
|
|
||||||
fontWeight = FontWeight.Black,
|
|
||||||
color = Color(0xFF0F2644), // Azul escuro da imagem
|
|
||||||
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)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "Google Sheets ID",
|
|
||||||
fontSize = 14.sp,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = CargillBlack,
|
|
||||||
modifier = Modifier.padding(bottom = 6.dp)
|
|
||||||
)
|
|
||||||
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
|
||||||
) {
|
|
||||||
OutlinedTextField(
|
|
||||||
value = tempSpreadsheetId,
|
|
||||||
onValueChange = { tempSpreadsheetId = it },
|
|
||||||
placeholder = { Text("Insira o ID da Planilha") },
|
|
||||||
singleLine = true,
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
shape = RoundedCornerShape(8.dp),
|
|
||||||
colors = OutlinedTextFieldDefaults.colors(
|
|
||||||
focusedBorderColor = CargillGreen,
|
|
||||||
unfocusedBorderColor = Color(0xFFCCCCCC)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
if (tempSpreadsheetId.isBlank()) {
|
|
||||||
Toast.makeText(context, "Insira um ID de planilha válido.", Toast.LENGTH_SHORT).show()
|
|
||||||
} else {
|
|
||||||
viewModel.testConnection(
|
|
||||||
tempSpreadsheetId,
|
|
||||||
onSuccess = {
|
|
||||||
Toast.makeText(context, "Conexão com Google Sheets bem-sucedida!", Toast.LENGTH_SHORT).show()
|
|
||||||
},
|
|
||||||
onFailure = { error ->
|
|
||||||
Toast.makeText(context, "Falha na conexão: $error", Toast.LENGTH_LONG).show()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
shape = RoundedCornerShape(12.dp),
|
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = Color.White),
|
|
||||||
border = BorderStroke(1.dp, Color(0xFFCCCCCC)),
|
|
||||||
contentPadding = PaddingValues(horizontal = 14.dp, vertical = 12.dp),
|
|
||||||
modifier = Modifier.shadow(1.dp, shape = RoundedCornerShape(12.dp))
|
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = "Testar Conexão",
|
|
||||||
color = CargillBlack,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 14.sp
|
|
||||||
)
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.CheckCircle,
|
|
||||||
contentDescription = "Test Connection",
|
|
||||||
tint = CargillGreen,
|
|
||||||
modifier = Modifier.size(16.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (apiStatusLoading) {
|
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
|
||||||
LinearProgressIndicator(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
color = CargillGreen,
|
|
||||||
trackColor = Color(0xFFE8F5E9)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Seção 2: Status da API Google Cloud
|
// Seção 2: Status da API Google Cloud
|
||||||
Column {
|
Column {
|
||||||
|
|||||||
Reference in New Issue
Block a user