Skip to content

Conversation

@gurnoorpannu
Copy link

Fixes #320

Changes Made

  • Added dateAdded field to ExpirationDate entity with automatic timestamp
  • Created database migration (v3 → v4) with backward compatibility for existing items
  • Updated UI to display "Added on [date]" in food cards (subtle, small text)
  • Added read-only "Date Added" field in edit screen for existing items
  • Updated CSV export/import to handle new field with backward compatibility
  • Updated preview data and string resources

Copy link
Owner

@lorenzovngl lorenzovngl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I think it’s a great implementation. I requested a few changes, and I’d also like to suggest making this feature optional, allowing users to choose whether to display the added date for items, as shown in the image below.

Image

Here's a starting code:

        SettingsItem(
            label = "Show added date",
            description = "Display the date when each item was added to your list."
        ) {
            Row(
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(start = 11.dp)
            ) {
                Switch(
                    modifier = Modifier.padding(start = 4.dp),
                    checked = isAddedDateEnabled,
                    onCheckedChange = { enabled ->
                        // Logic
                    }
                )
            }
        }

Comment on lines +194 to +197
colors = TextFieldDefaults.colors(
disabledTextColor = MaterialTheme.colorScheme.onSurface,
disabledLabelColor = MaterialTheme.colorScheme.onSurfaceVariant,
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to remove these lines, otherwise the appearance of the textfield doesn't clearly tell to the user that it's disabled.

AppDatabase::class.java,
"database.db"
).fallbackToDestructiveMigration()
).addMigrations(MIGRATION_3_4)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add some unit tests for this migration here?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

View the date an item was added

2 participants