Showing a loading indicator
This commit is contained in:
parent
9c2653944d
commit
ce0cdd7d95
|
@ -1,10 +1,8 @@
|
|||
package net.codinux.banking.ui.screens
|
||||
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextButton
|
||||
import androidx.compose.runtime.*
|
||||
|
@ -12,6 +10,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -25,6 +24,8 @@ import net.codinux.banking.ui.service.BankDataImporterAndExporter
|
|||
fun ExportScreen(onClosed: () -> Unit) {
|
||||
var transactions: Collection<AccountTransactionEntity>
|
||||
|
||||
var isLoadingExportedData by remember { mutableStateOf(true) }
|
||||
|
||||
var exportedDataText by remember { mutableStateOf("") }
|
||||
|
||||
val importerExporter = BankDataImporterAndExporter()
|
||||
|
@ -34,10 +35,13 @@ fun ExportScreen(onClosed: () -> Unit) {
|
|||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
coroutineScope.launch(Dispatchers.IOorDefault) {
|
||||
transactions = DI.bankingService.getAllAccountTransactions() // a only very bit problematic: if in the meantime new transactions are retrieved, then this transactions property doesn't contain the newly retrieved transactions
|
||||
transactions = DI.bankingService.getAllAccountTransactions() // only a bit problematic: if in the meantime new transactions are retrieved, then this transactions property doesn't contain the newly retrieved transactions
|
||||
|
||||
val initiallyExportedData = importerExporter.exportTransactionsAsCsv(transactions, ',')
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
exportedDataText = importerExporter.exportTransactionsAsCsv(transactions, ',')
|
||||
exportedDataText = initiallyExportedData
|
||||
isLoadingExportedData = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,9 +55,17 @@ fun ExportScreen(onClosed: () -> Unit) {
|
|||
}
|
||||
}
|
||||
|
||||
Column(Modifier.verticalScroll(ScrollState(0), enabled = true).horizontalScroll(ScrollState(0), enabled = true)) {
|
||||
SelectionContainer {
|
||||
Text(exportedDataText, fontFamily = FontFamily.Monospace)
|
||||
Column(Modifier.fillMaxSize().verticalScroll(ScrollState(0), enabled = true).horizontalScroll(ScrollState(0), enabled = true)) {
|
||||
if (isLoadingExportedData == false) {
|
||||
SelectionContainer {
|
||||
Text(exportedDataText, fontFamily = FontFamily.Monospace)
|
||||
}
|
||||
} else {
|
||||
Spacer(Modifier.weight(1f))
|
||||
|
||||
Text("Daten werden geladen ...", Modifier.fillMaxWidth(), textAlign = TextAlign.Center) // centering text does not work, no matter what i tried
|
||||
|
||||
Spacer(Modifier.weight(1f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue