Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d0228fae0 | ||
|
|
f8631e9a63 |
+2
-2
@@ -13,8 +13,8 @@ android {
|
||||
applicationId "com.conta.app"
|
||||
minSdk 24
|
||||
targetSdk 34
|
||||
versionCode 1
|
||||
versionName "1.0.0"
|
||||
versionCode 3
|
||||
versionName "1.0.2"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.conta.app.data.network.Session
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
|
||||
@@ -82,6 +83,14 @@ class AppViewModel : ViewModel() {
|
||||
_message.value = msg
|
||||
}
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
val saved = ServiceLocator.settings.baseUrl.first()
|
||||
Session.baseUrl = saved
|
||||
if (saved.isNotBlank()) refreshAll()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun <T> runRequest(block: suspend () -> T): Boolean {
|
||||
return try {
|
||||
block()
|
||||
|
||||
@@ -20,7 +20,6 @@ import androidx.compose.material.icons.filled.AccountBalance
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.CreditCard
|
||||
import androidx.compose.material.icons.filled.Schedule
|
||||
import androidx.compose.material.icons.filled.Sync
|
||||
import androidx.compose.material.icons.filled.Warning
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
@@ -30,7 +29,6 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
@@ -68,16 +66,6 @@ fun AccountsScreen(viewModel: AppViewModel, navController: NavController) {
|
||||
val loading by viewModel.loading.collectAsStateWithLifecycle()
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text("Cuentas", fontWeight = FontWeight.Bold) },
|
||||
actions = {
|
||||
androidx.compose.material3.IconButton(onClick = { viewModel.refreshAccounts() }) {
|
||||
Icon(Icons.Filled.Sync, contentDescription = "Actualizar")
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
FloatingActionButton(onClick = { navController.navigate(Routes.accountForm()) }) {
|
||||
Icon(Icons.Filled.Add, contentDescription = "Nueva cuenta")
|
||||
|
||||
@@ -21,7 +21,6 @@ import androidx.compose.material.icons.filled.CheckCircle
|
||||
import androidx.compose.material.icons.filled.CreditCard
|
||||
import androidx.compose.material.icons.filled.Event
|
||||
import androidx.compose.material.icons.filled.NotificationsActive
|
||||
import androidx.compose.material.icons.filled.Sync
|
||||
import androidx.compose.material.icons.filled.Savings
|
||||
import androidx.compose.material.icons.filled.Schedule
|
||||
import androidx.compose.material3.Card
|
||||
@@ -33,7 +32,6 @@ import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
@@ -68,16 +66,6 @@ fun DashboardScreen(viewModel: AppViewModel, navController: NavController) {
|
||||
val loading by viewModel.loading.collectAsStateWithLifecycle()
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text("Conta", fontWeight = FontWeight.Bold) },
|
||||
actions = {
|
||||
IconButton(onClick = { viewModel.refreshDashboard() }) {
|
||||
Icon(Icons.Filled.Sync, contentDescription = "Actualizar")
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
FloatingActionButton(onClick = { navController.navigate(Routes.transactionForm(preset = "expense")) }) {
|
||||
Icon(Icons.Filled.Add, contentDescription = "Nueva transacción")
|
||||
@@ -95,11 +83,16 @@ fun DashboardScreen(viewModel: AppViewModel, navController: NavController) {
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
EmptyState("No conectado. Configura la URL del servidor en Ajustes.")
|
||||
androidx.compose.material3.Button(onClick = { navController.navigate(Routes.SETTINGS) }) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
androidx.compose.material3.Button(onClick = { viewModel.refreshAll() }) {
|
||||
Text("Reintentar")
|
||||
}
|
||||
androidx.compose.material3.OutlinedButton(onClick = { navController.navigate(Routes.SETTINGS) }) {
|
||||
Text("Ir a Ajustes")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> DashboardContent(
|
||||
summary = summary!!,
|
||||
notices = notices,
|
||||
|
||||
@@ -26,7 +26,6 @@ import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -62,13 +61,7 @@ fun SettingsScreen(viewModel: AppViewModel, navController: NavController) {
|
||||
|
||||
val summary by viewModel.summary.collectAsStateWithLifecycle()
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text("Ajustes", fontWeight = FontWeight.Bold) },
|
||||
)
|
||||
},
|
||||
) { padding ->
|
||||
Scaffold { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(padding)
|
||||
|
||||
@@ -10,18 +10,15 @@ import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Sync
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -56,16 +53,6 @@ fun TransactionsScreen(viewModel: AppViewModel, navController: NavController) {
|
||||
val totalExpense = filtered.filter { it.transactionType == "expense" }.sumOf { it.amount }
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text("Movimientos", fontWeight = FontWeight.Bold) },
|
||||
actions = {
|
||||
IconButton(onClick = { viewModel.refreshDashboard() }) {
|
||||
Icon(Icons.Filled.Sync, contentDescription = "Actualizar")
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
FloatingActionButton(onClick = { navController.navigate(Routes.transactionForm()) }) {
|
||||
Icon(Icons.Filled.Add, contentDescription = "Nueva transacción")
|
||||
|
||||
Reference in New Issue
Block a user