Skip to content

Conversation

@armouldr
Copy link
Collaborator

@armouldr armouldr commented Oct 29, 2024

Implemented the UI of Event Details screen according to the Figma. Note that it is not linked to Firebase as this will be a separate task.

Also added EventDetailsTest to test said screen's UI and wrote a method to allow us to get an event by its id, as this will be useful when linking the screen to the backend

@armouldr armouldr linked an issue Oct 29, 2024 that may be closed by this pull request
Added a savedEvents parameter to keep track of which events the user follows.
Fixed the errors in text files due to the previous refactoring
Added all the composables required by the figma design.
Improved the event details UI to adhere to the figma.
Wrote some UI tests for the Event Screen
Added a test for findEventById method.
@armouldr armouldr marked this pull request as ready for review November 1, 2024 00:43
Copy link
Collaborator

@oskar-codes oskar-codes left a comment

Choose a reason for hiding this comment

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

This pull request is an overall good addition to the project, well done!

class HydrationAndSerializationTest {
private val user =

val user =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider leaving these values private.

fun EventScreen(
navigationAction: NavigationAction,
eventId: String,
eventListViewModel: EventListViewModel,
Copy link
Collaborator

@oskar-codes oskar-codes Nov 3, 2024

Choose a reason for hiding this comment

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

Here you should only use a single EventViewModel instead of both the eventListViewModel and eventId. This will make the function declaration more succinct. The instanciation of this EventViewModel could then be placed in MainActivity right before passing it as a parameter to the EventDetails.

By the way, the EventViewModel doesn't exist on your branch, you should pull it from main.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh the EventViewModel class didn't exist when I frist wrote my code but that's indeed better suited.

private var scope: CoroutineScope? = null

@OptIn(ExperimentalMaterial3Api::class)
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should remove this UnusedMaterial3ScaffoldPaddingParameter suppression, and actually use the padding parameter provided by the Scaffold. This will ensure the content is well within the bounds of the scaffold.

content = { padding ->
// Mock image before linking to backend
Column(
modifier = Modifier.testTag("eventDetailsPage").verticalScroll(rememberScrollState())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentionned in the previous comment, simply add the .padding(padding) modifier 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.

You are right I added the modifier.

Column(
modifier =
Modifier.testTag("eventDetailsInformationCard")
.background(primaryLight)
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Avoid using explicit theme-independent colors for text and background. This will set the color to a constant value that stays even when changing theme, which removes the purpose of having a theme alltogether. Use instead the associated value: MaterialTheme.colorScheme.primary.

Make sure to also add the appropriate changes to lines 182, 211, 219, 223, 231, 251, and 272. Also for some of these, do you need to specify the color ? Often the default color is good enough.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I hadn't understood how our theme worked ! Should be good now thank you

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this file existed before this pull request, but we should consider renaming it to EventListViewModelTest, to avoid confusion with the EventViewModel because this file tests an EventListViewModel, not an EventViewModel.

}

@Test
fun testFindAssociationById() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe the name of this test has nothing to do with its contents, it might be better to rename it to something else.

* @param id The ID of the event to find.
* @return The event with the given ID, or null if no such event exists.
*/
fun findEventById(id: String): Event? {
Copy link
Collaborator

@oskar-codes oskar-codes Nov 3, 2024

Choose a reason for hiding this comment

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

This is a good function to have, but as mentionned in a previous comment, consider using the EventViewModel for your pull request. It should contains a single Event, just like the UserViewModel, and should be instanciated when you navigate to an event's details page.
Note that the current EventViewModel is only partially implemented as it is unused, and will require changes before you can use it. Maybe that's something you can do when you link the event details to the backend.

class EventDetailsTest {
private lateinit var navHostController: NavHostController
private lateinit var navigationAction: NavigationAction
@Mock private lateinit var collectionReference: CollectionReference
Copy link
Collaborator

Choose a reason for hiding this comment

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

It appears that several of these mocked variables such as db or collectionReference are not used in this test. Consider removing them if they are not necessary.

assertDisplayComponentInScroll(composeTestRule.onNodeWithTag("signUpButton"))
}

private fun assertDisplayComponentInScroll(compose: SemanticsNodeInteraction) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great use of helper functions 🚀

Fix EventCardTest that couldn't find some elements because the elements are in merged tree
@armouldr armouldr requested a review from oskar-codes November 5, 2024 23:47
Copy link
Collaborator

@oskar-codes oskar-codes left a comment

Choose a reason for hiding this comment

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

Well done addressing the changes I requested, this will prove itself considerably useful for the application.

uid?.let {
EventScreen(
navigationAction = navigationActions,
eventViewModel = EventViewModel(eventRepository, userRepository),
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should extract the instanciation of the EventViewModel at the top of the composable, and wrap it in a remember { ... }

In MainActivity, moved EventViewModel out of the composable.
In Serialization, simplified a statement
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 7, 2024

@armouldr armouldr merged commit 4a0609c into main Nov 7, 2024
2 checks passed
@armouldr armouldr deleted the feat/event-details-ui branch November 7, 2024 10:04
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.

Implement event screen

3 participants