Skip to content

Commit

Permalink
empty section information
Browse files Browse the repository at this point in the history
  • Loading branch information
chathil committed Jun 6, 2021
1 parent 9f8ff1b commit 9a7fcd5
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 35 deletions.
95 changes: 60 additions & 35 deletions app/src/main/java/com/example/dieter/ui/screen/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
Expand Down Expand Up @@ -73,6 +74,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.focus.FocusState
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
Expand Down Expand Up @@ -387,14 +389,27 @@ fun HomeScreen(
Spacer(Modifier.size(12.dp))
}
} else {
Text("Nothing for now")
Image(
painter = painterResource(id = R.drawable.healthy_food),
contentDescription = "eat",
modifier = Modifier
.fillMaxWidth()
.height(212.dp)
)
Text(
"Tap the middle button of the floating bar to start",
style = MaterialTheme.typography.body1,
modifier = Modifier.padding(horizontal = 16.dp)
)
}

IconButton(onClick = { expand = !expand }) {
Icon(
imageVector = if (expand) Icons.Filled.ExpandLess else Icons.Filled.ExpandMore,
contentDescription = "expand"
)
if (nutrients.isNotEmpty()) {
IconButton(onClick = { expand = !expand }) {
Icon(
imageVector = if (expand) Icons.Filled.ExpandLess else Icons.Filled.ExpandMore,
contentDescription = "expand"
)
}
}
}

Expand All @@ -416,7 +431,7 @@ fun HomeScreen(
modifier = Modifier.fillMaxWidth(.25f)
) {
Icon(
if (showWeightEntry) Icons.Filled.ExpandLess else Icons.Filled.ExpandMore,
if (showWeightEntry or bodyWeightEntries.isEmpty()) Icons.Filled.ExpandLess else Icons.Filled.ExpandMore,
contentDescription = "new entry"
)
}
Expand All @@ -425,7 +440,7 @@ fun HomeScreen(
Modifier
.padding(bottom = 12.dp)
)
if (showWeightEntry) {
if (showWeightEntry or bodyWeightEntries.isEmpty()) {
Row(Modifier.fillMaxWidth()) {
BodyWeight(bodyWeightState = bodyWeightState)
Spacer(Modifier.size(8.dp))
Expand Down Expand Up @@ -453,38 +468,48 @@ fun HomeScreen(
}
}

Row(
modifier = Modifier
.horizontalScroll(rememberScrollState())
.height(232.dp)
) {
Spacer(Modifier.size(16.dp))
bodyWeightEntries.forEach {
BodyWeightBar(
weightModelSet = it,
if (bodyWeightEntries.isNotEmpty()) {
Row(
modifier = Modifier
.horizontalScroll(rememberScrollState())
.height(232.dp)
) {
Spacer(Modifier.size(16.dp))
bodyWeightEntries.forEach {
BodyWeightBar(
weightModelSet = it,
onDelete = {
homeViewModel.deleteBodyWeight(it)
}
)
Spacer(Modifier.size(8.dp))
}
Spacer(Modifier.size(16.dp))
}
} else {
Text(
"Nothings here, start by adding it.",
style = MaterialTheme.typography.body1,
modifier = Modifier.padding(horizontal = 16.dp)
)
}
Spacer(Modifier.size(12.dp))
if (todaysFoods.isNotEmpty()) {
HomeSection(
title = "Food eaten today",
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
)
todaysFoods.forEach {
FoodCard(
foodModel = it, deletable = true,
onDelete = {
homeViewModel.deleteBodyWeight(it)
homeViewModel.deleteTodaysFood(it)
}
)
Spacer(Modifier.size(8.dp))
}
Spacer(Modifier.size(16.dp))
}
Spacer(Modifier.size(12.dp))
HomeSection(
title = "Food eaten today",
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
)
todaysFoods.forEach {
FoodCard(
foodModel = it, deletable = true,
onDelete = {
homeViewModel.deleteTodaysFood(it)
}
)
Spacer(Modifier.size(8.dp))
}
Spacer(Modifier.size(216.dp))
}
Expand Down
Binary file added app/src/main/res/drawable/healthy_food.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9a7fcd5

Please sign in to comment.