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

Feat/implement UI for event filtering #224

Merged
merged 28 commits into from
Dec 18, 2024

Conversation

Simmanz
Copy link
Contributor

@Simmanz Simmanz commented Dec 12, 2024

Description

This PR aims to create a pop-up in which the user can set filters for the parks in the map.

Features

Park filters

  • By Rating => user specify the minimal rating in [1, 5] stars.
  • By event density (thresholds for number of events) => {LOW, MEDIUM, HIGH}

New components

  • class ParkFilter, which handle filtering using FilterSettings.
  • class FilterSettings, which store the value of each park filter setting.
  • @composable fun ParkFilterSettings, which is the content of the pop-up, an interactible UI for settings of the filter.

Big issues

I encountered MANY issues with the EventViewModel.

  1. Initialy called eventViewModel.getEvent(park) then uiState => but it was always uiState.Empty

  2. I implemented two new eventViewModel functions getEventsByParkList() which calls getEventsByEid(eid_list)
    Now that the new implementation is called, the eventList remains empty all the time !

  3. When going into ParkOverview(), exiting it will cause parks with events to have their event list loaded.
    Essentially, the filters worked only after going into ParkOverview() once, becacuse the event list would remain empty otherwise.

  4. I merged main with this branch, causing the ParkOverview() to no longer display the event list. Some calls are made which correctly load the event list, but the filters are only given empty lists. I am thinking of rolling back.

Not enough time remains to fix the eventViewModel bizarre behavior, nor the main branch breaking changes. Choose to remove the following filtering features :

  • By the status of the events => {CREATED, ONGOING, FINISHED}
  • If spots remains for the user (#participants < #max)

Tests

  • Implemented unit test for the FilterSettings / ParkFilter API
  • Implemented UI test for the filter settings user interface.

Testing the feature :

  1. New icon in the topAppBarActions in the Screen.MAP.
  2. It should open a pop-up, containing rating and event density parameters. As well as a reset button.
  3. Confirming should apply the filter settings.
  4. Clicking outside the pop-up should discard changes.
  5. Parks in the map should be filtered accordingly (they appear only if they match the filters)

@Simmanz Simmanz added the Enhancement ✨ New feature or request label Dec 12, 2024
@Simmanz Simmanz added this to the Milestone M3 milestone Dec 12, 2024
@Simmanz Simmanz self-assigned this Dec 12, 2024
@Simmanz Simmanz linked an issue Dec 12, 2024 that may be closed by this pull request
2 tasks
Copy link
Contributor

@misterM125 misterM125 left a comment

Choose a reason for hiding this comment

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

Great PR!

The filters are a welcome addition to better help users narrow down specific parks.

I do have a couple suggestion to help make your code cleaner and make your filters easier and clearer to use for users

/** The default filter settings. */
companion object {
val DEFAULT_RATING = 1
val DEFAULT_EVENT_DENSITY = listOf(EventDensity.LOW, EventDensity.MEDIUM, EventDensity.HIGH)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems as though as though all your filters start as selected, which means that they will all be applied without user input. I don't know if this is intentional but it feels a bit misleading as when you click on a filter for the first time, you would expect it to be selected and not the contrary, i would suggest for the eventDensity list to initally start as empty instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually the default filters are the following :

  • Minimum rating of 1 star (the minimum rating possible to give to a park)
  • By default all kinds of event densities are accepted, giving an empty list would mean no park to display.

The sole thing which could be problematic is if when a park is added, its rating is initialized outside the allowed range [1, 5]. But I do not know how it is defined.

Copy link
Contributor

Choose a reason for hiding this comment

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

What i meant is that i think it would be better to make it that your density filters all start as unselected and accept all park densities in such a default state, then if a user clicks on HIGH density for example, then it will show only the high density parks, the other way around which you are currently doing feels a bit confusing to me, this might just be a detail, if you feel the filters are fine as is i'll still approve the review

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 think that this is a bad idea, because if a user does not choose to select any density, then no park will be displayed.

The current implementation will display all of the parks if the user touches nothing. Then he can opt-out some parks.

Copy link
Contributor

@misterM125 misterM125 left a comment

Choose a reason for hiding this comment

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

Great changes!
Event filtering looks really good now

@Simmanz Simmanz merged commit af502e4 into main Dec 18, 2024
3 checks passed
@Simmanz Simmanz deleted the Feat/implement-ui-for-event-filtering branch December 18, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement UI for event filtering
2 participants