Skip to content

Commit

Permalink
Add category, category icon and repeat to EntryOverviewView
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Heckner committed Jun 24, 2022
1 parent 3daae54 commit a65f9a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) {
Expand All @@ -40,6 +43,7 @@ fun EntryOverviewView(
H1(attrs = { classes(AppStylesheet.h1) }) { Text(" Entry") }
EntryOverview(
entry,
categoryList,
deleteDialog,
onEditButton,
onDeleteButton,
Expand All @@ -52,6 +56,7 @@ fun EntryOverviewView(
@Composable
fun EntryOverview(
entry: Entry,
categoryList: List<Category>,
deleteDialog: Boolean,
onEditButton: () -> Unit,
onDeleteButton: () -> Unit,
Expand All @@ -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") }
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion budget-binder-multiplatform-app/src/jsMain/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ fun App() = withDI(di) {
}
)
}

FeedbackSnackbar(snackBarText.value, snackBarHidden.value) {
snackBarHidden.value = true
}
Expand Down

0 comments on commit a65f9a2

Please sign in to comment.