-
Notifications
You must be signed in to change notification settings - Fork 38
feat: expenses grid display #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: expenses grid display #156
Conversation
|
Thanks for the PR! |
| }, | ||
| actions = { | ||
| // only creates toggling button if navigation is at home | ||
| if (backStackEntry.value?.destination?.route == BottomNavigation.Home.route) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to have the toggle for both tabs Home and Upcoming. Probably also synchronizing the same option to use the same on both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure that sounds good. Can I do that as part of a seperate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes can also be done in a separate PR.
| modifier = modifier.fillMaxSize(), | ||
| color = MaterialTheme.colorScheme.background, | ||
| ) { | ||
| var isGridMode by remember { mutableStateOf(false) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now we'll switch back to the default layout on ever app start, right? What do you think about persisting this toggle making sure we do not need to change it again after each app start?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats a good point, so right now on my android 14 , unless i close the app with the "close all" option in the recent apps screen, the previous layout state is maintained(stays in either grid or row format at last scrolled location ). Maybe its version dependent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as you do not close the Activity completely but just put the app to the background the state is retained. But as soon as you close it or restart your device it will be lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this at least persistent for orientation changes. Saving this value in DataStore can be done as a follow up.
app/src/main/java/de/dbauer/expensetracker/ui/RecurringExpenseOverview.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/de/dbauer/expensetracker/ui/RecurringExpenseOverview.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/de/dbauer/expensetracker/ui/RecurringExpenseOverview.kt
Outdated
Show resolved
Hide resolved
| ), | ||
| ), | ||
| onItemClicked = {}, | ||
| isGridMode = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea: Add a boolean PreviewParameter which allows you to generate a preview for both the normal and your grid mode:
https://developer.android.com/jetpack/compose/tooling/previews#preview-data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementing previews to streamline testing and debugging is a great idea. If it can be done quickly for this PR I'm all for it. But if not, do you think we should maybe do it as part of another pull request? Maybe just get this one merged and running. Just trying to modularize ours PRs as best I can...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's quite easy to realize but also not a must for the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can achieve it by doing this:
private class GridLayoutParameterProvider : PreviewParameterProvider<Boolean> {
override val values = sequenceOf(false, true)
}
@Preview()
@Composable
private fun RecurringExpenseOverviewPreview(
@PreviewParameter(GridLayoutParameterProvider::class) isGridMode: Boolean
) {
...
RecurringExpenseOverview(
...
isGridMode = isGridMode
)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it out. It worked but the bottom of my screen was blocked out in white with a next button that didn't work. I'm getting by with just manually adding test items. Think I'll stick with that for now. But we should definetly implement something like this in the near future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the suggestion I mode above and it works fine for me.
app/src/main/java/de/dbauer/expensetracker/ui/RecurringExpenseOverview.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/de/dbauer/expensetracker/ui/RecurringExpenseOverview.kt
Outdated
Show resolved
Hide resolved
| onItemClicked = { | ||
| selectedRecurringExpense = it | ||
| }, | ||
| contentPadding = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the contentPadding it is important for the outside padding and to be able to scroll the cards at the bottom above the FloatingActionButton. Without the bottom padding of 88.dp the price of the last cards will be behind the plus button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this was an issued addressed in commit 2f34afb. I found that if i kept the padding there was stuttering when scrolling while display was filled or closed to filled with items. I can keep the padding intact( and have some stuttering when scrolling with an almost filled screen) or remove it but keep the last item coverd. Maybe there is another way to make sure the last item is not covered by the FAB. But stuttering stops once the number of items exceed
the display room. Here is a video with the padding intact.
Android.recording.-.26.Feb.2024.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can possible keep the padding now, and debug later it on. I observe it only occurs when the display is almost full or full.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might have found a solution. Just pushed it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check this on the weekend when I have a bit more time, there should be a solution for this scrolling issue.
|
Looks good so far. I'll look into the remaining issues you mentioned on the weekend. If the changes are ready from your side please squash your commits to remove the fix commits. |
Can raise the last expense item above FAB by either applying bottom padding or using a Spacer. Bottom padding leads to stuttering when scrolling. Here, Spacer is used without side effects.
445ee44 to
492f087
Compare
The scrolling issue seems to be resolved on my end. Commits have been squashed and rebased. Unless there is anything else you want to address for this PR I'm good to go. |
Because of the AnimatedContent in RecurringExpenseOverview the list is reset and scrolled back to the top. To make sure the scroll state matches that we need to reset it here. It make the TopAppBar use the surface color again. This is a workaround which can hopefully removed in the near future.
The size still works to get 2 column layout on a 4.6 inch phone.
Add night mode preview
141ce45 to
db8851c
Compare
|
Thanks for merging. I will work on adding a grid option to Upcoming Payments. |
This pull request makes the following changes:
Addresses issue #117
Adds feature where expenses can be viewed in a grid. Users can toggle between the default row format and grid format.