Skip to content
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

Feature: Allow users to delete and like event pictures #315

Merged
merged 40 commits into from
Dec 20, 2024

Conversation

armouldr
Copy link
Collaborator

@armouldr armouldr commented Dec 17, 2024

From another PR of mine, you can now click on user pictures from the EventDetails. But this menu still lacks responsivity and feels very static. That's why I am adding the possibility to like and delete a picture :)

When you click on a picture, you can see:
-> Icon to like/dislike a picture
-> Counter of likes
-> the author's icon and name
-> a delete button

change likes attribute to be a ReferenceList<User> instead of an Int
@armouldr armouldr linked an issue Dec 17, 2024 that may be closed by this pull request
@armouldr armouldr marked this pull request as ready for review December 20, 2024 04:38
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
77.56% Line Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@Aurelien9Code Aurelien9Code left a comment

Choose a reason for hiding this comment

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

Very good PR ! Looks good to me !
If you don't have time to do the changes, I think it's okay as they are all minors

}
},
lazy = true)
if (updateAssociation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Very good idea to put the boolean, it allows you not to update all the association as you don't need to here

uid,
{
event.eventPictures.remove(uid)
updateEventWithoutImage(
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing this - that will in firebase for every field to change, you could have just override the image field to "" to avoid unnecessary server computing time

Comment on lines +503 to +504
eventPictures.forEach { pic -> pic.author.fetch(lazy = true) }
pagerState.scrollToPage(index)
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a bit too much a fetching right here, but as this is not a big amount of data this is really fine


if (event == null) {
Log.e("PictureOverlay", "Event is null")
Toast.makeText(LocalContext.current, "An error occurred.", Toast.LENGTH_SHORT).show()
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider putting the good error in the Toast if you have it, here : "Event is null"

Icon(
Icons.AutoMirrored.Filled.ArrowBack,
context.getString(R.string.event_details_content_description_arrow_left),
modifier = Modifier.size(iconSize))
modifier = Modifier.size(arrowSize))
}

IconButton(
Copy link
Contributor

Choose a reason for hiding this comment

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

you could remove the arrow right if we are on the lastPage and remove the arrow left if we are on the first page, this should be done very easily with the pageState like if pagerState.currentPageOffsetFraction == -0.5 for example

Modifier.testTag(EventDetailsTestTags.EVENT_PICTURES_LIKE_BUTTON),
colors =
IconButtonDefaults.iconButtonColors(
contentColor = MaterialTheme.colorScheme.onPrimary)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider hardcoding the colors because as you said, it seems better when being in light mode

Copy link
Contributor

Choose a reason for hiding this comment

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

So much valuable insights !

Copy link
Contributor

Choose a reason for hiding this comment

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

As I looked a bit the changes you made all the day and your explanations, I don't think there's anything to change here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for your review !

@armouldr armouldr merged commit 7edf610 into main Dec 20, 2024
2 of 3 checks passed
@armouldr armouldr deleted the feature/delete-and-like-pictures branch December 20, 2024 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants