From a65f9a201687cba3a8d9df8d3fbb3e8298419095 Mon Sep 17 00:00:00 2001 From: Dominik Heckner Date: Fri, 24 Jun 2022 14:41:38 +0200 Subject: [PATCH] Add category, category icon and repeat to EntryOverviewView --- .../screens/entry/EntryOverviewView.kt | 30 +++++++++++++++++-- .../src/jsMain/kotlin/main.kt | 1 - 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/budget-binder-multiplatform-app/src/jsMain/kotlin/de/hsfl/budgetBinder/screens/entry/EntryOverviewView.kt b/budget-binder-multiplatform-app/src/jsMain/kotlin/de/hsfl/budgetBinder/screens/entry/EntryOverviewView.kt index 364d605d..0bc7fffc 100644 --- a/budget-binder-multiplatform-app/src/jsMain/kotlin/de/hsfl/budgetBinder/screens/entry/EntryOverviewView.kt +++ b/budget-binder-multiplatform-app/src/jsMain/kotlin/de/hsfl/budgetBinder/screens/entry/EntryOverviewView.kt @@ -1,9 +1,11 @@ package de.hsfl.budgetBinder.screens.entry import androidx.compose.runtime.* +import de.hsfl.budgetBinder.common.Category import de.hsfl.budgetBinder.common.Entry import de.hsfl.budgetBinder.compose.DeleteDialog import de.hsfl.budgetBinder.compose.theme.AppStylesheet +import de.hsfl.budgetBinder.presentation.CategoryImageToIcon import de.hsfl.budgetBinder.presentation.event.LifecycleEvent import de.hsfl.budgetBinder.presentation.viewmodel.entry.EntryEvent import de.hsfl.budgetBinder.presentation.viewmodel.entry.EntryViewModel @@ -25,6 +27,7 @@ fun EntryOverviewView( //Data val entry by viewModel.selectedEntryState.collectAsState() val deleteDialog by viewModel.dialogState.collectAsState() + val categoryList by viewModel.categoryListState.collectAsState() //LifeCycle LaunchedEffect(Unit) { @@ -40,6 +43,7 @@ fun EntryOverviewView( H1(attrs = { classes(AppStylesheet.h1) }) { Text(" Entry") } EntryOverview( entry, + categoryList, deleteDialog, onEditButton, onDeleteButton, @@ -52,6 +56,7 @@ fun EntryOverviewView( @Composable fun EntryOverview( entry: Entry, + categoryList: List, deleteDialog: Boolean, onEditButton: () -> Unit, onDeleteButton: () -> Unit, @@ -74,9 +79,28 @@ fun EntryOverview( Div(attrs = { classes("mdc-typography--headline4", AppStylesheet.text) }) { Text(entry.name) } - Div(attrs = { - classes("mdc-typography--headline6", AppStylesheet.text) - }) { Text("Amount: ${entry.amount}€") } + Div(attrs = { classes(AppStylesheet.flexContainer) }) { + Div(attrs = { + classes("mdc-typography--headline6", AppStylesheet.text, AppStylesheet.buttonOverview) + }) { + var categoryName = "No Category" + var categoryIcon = Category.Image.DEFAULT + for (category in categoryList) { + if (entry.category_id == category.id) { + categoryName = category.name + categoryIcon = category.image + } + } + Text("Category: $categoryName") + CategoryImageToIcon(categoryIcon) + } + Div(attrs = { + classes("mdc-typography--headline6", AppStylesheet.text, AppStylesheet.buttonOverview) + }) { Text("Amount: ${entry.amount}€") } + Div(attrs = { + classes("mdc-typography--headline6", AppStylesheet.text, AppStylesheet.buttonOverview) + }) { Text("Repeat: " + if (entry.repeat) "Yes" else "No") } + } } } } diff --git a/budget-binder-multiplatform-app/src/jsMain/kotlin/main.kt b/budget-binder-multiplatform-app/src/jsMain/kotlin/main.kt index 6f034c21..c6b10d59 100644 --- a/budget-binder-multiplatform-app/src/jsMain/kotlin/main.kt +++ b/budget-binder-multiplatform-app/src/jsMain/kotlin/main.kt @@ -54,7 +54,6 @@ fun App() = withDI(di) { } ) } - FeedbackSnackbar(snackBarText.value, snackBarHidden.value) { snackBarHidden.value = true }