Skip to content

Conversation

@amjiao
Copy link
Contributor

@amjiao amjiao commented Mar 22, 2025

Overview

ErrorState, LoadingState, and GameDetailsLoadingState UI.
Added onRefresh function to HomeViewModel for TryAgain button functionality in ErrorState.

Changes Made

ErrorState, LoadingState, GameDetailsLoadingState to be called wherever there are ApiResponse.Loading or ApiResponse.Error.
ErrorState needs to be called within another Column with a Spacer underneath because it needs to sit on top of the bottomNavBar
LoadingState can take custom header strings, so it should be used in both HomeScreen and PastGamesScreen.

Test Coverage

Already implemented in HomeScreen, works as expected.

Next Steps (delete if not applicable)

Should the ErrorState show up after a certain amount of time has passed in the LoadingState?

Screenshots

GameDetailsLoadingState Screenshot 2025-03-22 at 3 07 04 PM
ErrorState HomeError
LoadingState HomeLoading

@amjiao amjiao requested a review from zachseidner1 March 22, 2025 19:14
Copy link
Collaborator

@zachseidner1 zachseidner1 left a comment

Choose a reason for hiding this comment

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

Nice work Amy! There's some improvements to be made, and I'd love for you to implement the shimmer modifier extension function if you have time. But things look good!

verticalArrangement = Arrangement.SpaceBetween
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally
Copy link
Collaborator

Choose a reason for hiding this comment

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

Redundant parameter here

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 made a column for the feedback icon + text and nested that + the button within the main column, so i think both of these are necessary

import com.cornellappdev.score.theme.GrayStroke

@Composable
fun LoadingStateBox(cornerRoundness: Int, height: Dp) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also I think it's better to just expose a Modifier parameter here instead of 2 separate parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since the cornerRoundness is nested within Modifier.background and I'm passing in the same color parameter each time for Modifier.background, is it okay if i keep the cornerRoundness so I can pass it in and use a modifier parameter for the height/width?

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 also want to have the default width be the maxWidth and I don't have a default value for the height so maybe it would be better to leave height as it's own parameter too?

@amjiao amjiao requested a review from zachseidner1 April 7, 2025 16:34
Copy link
Collaborator

@zachseidner1 zachseidner1 left a comment

Choose a reason for hiding this comment

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

Please take a look at my comments, I'd like you to fix previews and establish a ScorePreview component for use down the line. I trust you to make these changes well so I am approving this now so you can merge after making those changes. Nice work!

@Preview
@Composable
private fun GameDetailsLoadingStatePreview() {
GameDetailsLoadingState()
Copy link
Collaborator

Choose a reason for hiding this comment

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

So because you used a Composition local provider, this breaks your previews since we didn't provide the value here. Could you make a custom preview function ScorePreview that is sort of like ResellPreview, and then provide the value through a custom ScoreTheme function? Sorry to have you just using the Resell code so much but I do think it's the best solution. I don't want you to just feel like you're copying and pasting code and not understanding why so please ask questions if you have them! Composition locals are a tricky topic.

Copy link
Collaborator

@zachseidner1 zachseidner1 left a comment

Choose a reason for hiding this comment

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

The animation makes this look so much better! There are some comments I left for you to address. Then I'll do a final pass over and we should be good.

@amjiao amjiao requested a review from zachseidner1 April 9, 2025 22:08
Copy link
Collaborator

@zachseidner1 zachseidner1 left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for addressing my other comments! I did a quick migration of the rest of the previews to use ScorePreview so it's obvious to future developers that they need to use this. Please merge it when you're ready 🥳

@amjiao amjiao merged commit b51b133 into main Apr 14, 2025
1 check passed
@amjiao amjiao deleted the Amy/error-loading-states branch April 14, 2025 14:45
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.

3 participants