Skip to content

Conversation

@abGit9
Copy link
Contributor

@abGit9 abGit9 commented Feb 25, 2024

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.

@abGit9 abGit9 changed the title Feat: expenses grid display feat: expenses grid display Feb 25, 2024
@DennisBauer
Copy link
Owner

Thanks for the PR!

},
actions = {
// only creates toggling button if navigation is at home
if (backStackEntry.value?.destination?.route == BottomNavigation.Home.route) {
Copy link
Owner

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.

Copy link
Contributor Author

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?

Copy link
Owner

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) }
Copy link
Owner

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?

Copy link
Contributor Author

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?

Copy link
Owner

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.

Copy link
Owner

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.

),
),
onItemClicked = {},
isGridMode = false,
Copy link
Owner

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

Copy link
Contributor Author

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...

Copy link
Owner

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.

Copy link
Owner

@DennisBauer DennisBauer Feb 26, 2024

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
    )
}

Copy link
Contributor Author

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.

Copy link
Owner

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.

@DennisBauer DennisBauer added the feature New feature or request label Feb 25, 2024
onItemClicked = {
selectedRecurringExpense = it
},
contentPadding =
Copy link
Owner

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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...

Copy link
Owner

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.

@DennisBauer
Copy link
Owner

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.

@abGit9 abGit9 force-pushed the feature_expenses_grid_display branch from 445ee44 to 492f087 Compare March 2, 2024 00:14
@abGit9
Copy link
Contributor Author

abGit9 commented Mar 2, 2024

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.

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
@DennisBauer DennisBauer force-pushed the feature_expenses_grid_display branch from 141ce45 to db8851c Compare March 2, 2024 19:24
@DennisBauer DennisBauer merged commit 19e07f2 into DennisBauer:main Mar 2, 2024
@abGit9
Copy link
Contributor Author

abGit9 commented Mar 2, 2024

Thanks for merging. I will work on adding a grid option to Upcoming Payments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants