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 planet selection screen #298

Merged
merged 24 commits into from
Dec 19, 2024

Conversation

Kenzoud
Copy link
Contributor

@Kenzoud Kenzoud commented Dec 18, 2024

This pull request introduces the Planet Selection Screen to the application, providing users with an intuitive interface to browse and select planets for viewing in 3D.

Planet Selection Screen:

  • Added a dedicated screen for planet selection, implemented using Jetpack Compose.
  • Displays a horizontal row of planet buttons, each representing a unique planet.
  • Users can select a planet, which updates the displayed planet name and renders a 3D view of the selected planet.

New Components:

  • PlanetButton: A reusable composable button that displays a planet's icon and handles user interaction.
  • PlanetSelectionRow: A composable that arranges the planet buttons in a horizontal scrolling row.

3D Planet Rendering:

  • Integrated PlanetSurfaceView to render the selected planet in 3D using OpenGL.
  • Dynamically updates the planet view when a new planet is selected.

Navigation:

  • Added a new route and screen entry to the navigation system for the Planet Selection Screen.
  • Includes a back button for easy navigation to the menu.

Planet Data Enhancements:

  • Updated the PlanetData model to include an iconRes property for associating drawable resources with each planet.

ViewModel:

  • Introduced PlanetSelectionViewModel to manage the list of planets and track the currently selected planet using StateFlow.

Rendering:

  • Refactored PlanetRenderer to support dynamic updates for rendering planets in the selection screen.

Note on Testing PlanetSelectionScreen:

Testing the PlanetSelectionScreen composable proved to be particularly challenging due to its dependency on the PlanetSelectionViewModel, which relies on the PlanetsRepository. Mocking the PlanetsRepository to create a mock PlanetSelectionViewModel for testing the composable's behavior requires has been proven to be really complex (I have spent hours on it in vain).

That said, I have written tests for all the new classes introduced in this PR. If I have time before the deadline, I plan to revisit testing the PlanetSelectionScreen in a future PR.

These missing tests have been implemented in PR #305

Kenzoud and others added 15 commits December 18, 2024 18:36
- Implement PlanetRenderer to render planets in the Planet Selection Screen.
- Add support for updating planet textures and applying transformation matrices.
- Integrate with Camera for view rendering and scaling adjustments.
- Implement PlanetSurfaceView to integrate PlanetRenderer with AndroidView in Jetpack Compose.
- Enable seamless rendering of planets in the Planet Selection Screen.
- Add functionality to update the displayed planet dynamically.
- Introduce `iconRes` field in the PlanetData class to reference planet icons for the Planet Selection Screen.
- Enhance UI by enabling planet-specific button visuals in the horizontal selection row.
- Implement PlanetSelectionRow to display a horizontally scrollable row of planet buttons.
- Each button represents a planet and allows users to select a planet.
- Enables intuitive planet selection functionality in the PlanetSelectionScreen.
- Implement PlanetButton composable to represent a clickable button for each planet.
- Displays the planet's icon and handles user interactions for planet selection.
- Enhances usability and visual appeal in the PlanetSelectionRow composable.
…ng planets

- Implement PlanetSelectionScreen composable to display a list of planets and render the selected planet.
- Integrate a horizontally scrollable PlanetSelectionRow for selecting planets.
- Display the selected planet's name and a 3D rendered view using OpenGL.
- Improve navigation by adding a back button to return to the menu screen.
- Implement PlanetSelectionViewModel to handle the list of planets and the selected planet state.
- Provide functionality to update the selected planet.
- Expose planets and selectedPlanet as observable state for use in the PlanetSelectionScreen.
- Add a factory method for creating the ViewModel with necessary dependencies.
- Add `updateTexture` method to allow dynamic texture updates for planets.
- Modify `draw` method to support custom transformation matrices for flexible rendering.
- Improve adaptability of the Planet class for dynamic use cases such as planet selection screens.
@Kenzoud Kenzoud linked an issue Dec 18, 2024 that may be closed by this pull request
@Kenzoud Kenzoud self-assigned this Dec 18, 2024
Copy link

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@raniabbrk raniabbrk self-requested a review December 19, 2024 07:27
Copy link
Contributor

@raniabbrk raniabbrk left a comment

Choose a reason for hiding this comment

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

Great work on this PR! It is a really good addition to the app! I think it provides a perfectly intuitive interface for users to view planets in 3D and brings another interactive element to the application which is really cool. I tested the functionality, and everything works as expected. The horizontal scrolling row of planet buttons is seamless, and the back navigation is really smooth! It would have been ideal to have more tests but I completely understand that it's hard to mock the PlanetsRepository and to create a usable PlanetSelectionViewModel. Revisiting this in a future PR if we have time sounds like a good plan. I also wanted to point out how cleanly the new components are implemented, they make the codebase more modular and reusable. Good job:)

@Kenzoud Kenzoud merged commit a2bebf4 into main Dec 19, 2024
2 of 3 checks passed
@rihabbelmekki rihabbelmekki deleted the feature/implement-planet-selection-screen branch December 20, 2024 04:44
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 Planet selection screen
2 participants