From 39c9006809704545e9d0bff7d15205872b41c8c6 Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 15 Oct 2024 11:17:46 +0200 Subject: [PATCH] Showing serverTransactionsRetentionDays and lastAccountUpdateTime to user --- .../kotlin/net/codinux/banking/ui/forms/LabelledValue.kt | 4 ++-- .../banking/ui/screens/BankAccountSettingsScreen.kt | 4 ++++ .../kotlin/net/codinux/banking/ui/service/FormatUtil.kt | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/LabelledValue.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/LabelledValue.kt index 33944be..c206fde 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/LabelledValue.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/LabelledValue.kt @@ -13,7 +13,7 @@ import androidx.compose.ui.unit.sp import net.codinux.banking.ui.config.Colors @Composable -fun LabelledValue(label: String, value: String?, valueTextColor: Color? = null) { +fun LabelledValue(label: String, value: String?, valueTextColor: Color? = null, labelMaxLines: Int = 1) { if (value != null) { Column(Modifier.fillMaxWidth()) { @@ -22,7 +22,7 @@ fun LabelledValue(label: String, value: String?, valueTextColor: Color? = null) modifier = Modifier.padding(top = 12.dp, bottom = 2.dp), fontSize = 15.sp, color = Colors.FormLabelTextColor, - maxLines = 1, + maxLines = labelMaxLines, overflow = TextOverflow.Ellipsis ) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankAccountSettingsScreen.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankAccountSettingsScreen.kt index c9c3815..43c95a9 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankAccountSettingsScreen.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankAccountSettingsScreen.kt @@ -77,6 +77,10 @@ fun BankAccountSettingsScreen(account: BankAccountEntity, onClosed: () -> Unit) LabelledValue("IBAN", account.iban ?: "") LabelledValue("Typ", Internationalization.translate(account.type)) + + LabelledValue("Anzahl Tage, für die Umsätze auf dem Server vorgehalten werden", account.serverTransactionsRetentionDays?.toString() ?: "", labelMaxLines = 2) + + LabelledValue("Umsätze zum letzten Mal abgerufen am", account.lastAccountUpdateTime?.let { DI.formatUtil.formatDateTime(it) } ?: "" ) } } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/FormatUtil.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/FormatUtil.kt index f9aa12d..fbea6e0 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/FormatUtil.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/FormatUtil.kt @@ -12,6 +12,15 @@ class FormatUtil { fun formatDate(date: LocalDate): String = // TODO: find a better way "${minDigits(date.dayOfMonth, 2)}.${minDigits(date.monthNumber, 2)}.${date.year.toString().substring(2)}" + fun formatDateTime(dateTime: Instant): String = + formatDateTime(dateTime.toLocalDateTime(TimeZone.currentSystemDefault())) + + fun formatDateTime(dateTime: LocalDateTime): String = + "${formatDate(dateTime.date)} ${formatTime(dateTime.time)}" + + fun formatTime(time: LocalTime): String = // TODO: find a better way + "${minDigits(time.hour, 2)}:${minDigits(time.minute, 2)}:${minDigits(time.second, 2)} Uhr" + fun formatGroupingDate(date: LocalDate, transactionsGrouping: TransactionsGrouping): String = when (transactionsGrouping) { TransactionsGrouping.Day -> formatDate(date) TransactionsGrouping.Week -> formatWeek(date)