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

Add achivement click animation #1235 #1265

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Aniokrait
Copy link
Contributor

Issue

Overview (Required)

  • add animation on click for acquired achivements.
  • refactor and make a component for achivement animation.
  • It looked more natural with the background slightly transparent, so I made the background translucent.

Movie (Optional)

achievement_animation.mp4

@Aniokrait Aniokrait requested a review from a team as a code owner September 17, 2023 04:33
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 17, 2023 04:52 Inactive
@github-actions
Copy link

github-actions bot commented Sep 17, 2023

Test Results

221 tests   221 ✔️  6m 41s ⏱️
  11 suites      0 💤
  11 files        0

Results for commit 220c85d.

♻️ This comment has been updated with latest results.

)

sealed interface ClickedAchievementState {
Copy link
Member

Choose a reason for hiding this comment

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

How about naming this AchievementAnimationState and AchievementAnimationState.Animating AchievementAnimationState.NotAnimating?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The namings look better. I will rename them.

@github-actions github-actions bot temporarily deployed to deploygate-distribution September 17, 2023 05:46 Inactive
Copy link
Member

@takahirom takahirom left a comment

Choose a reason for hiding this comment

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

I would like to have a screenshot for this ideally. Could you see it? Maybe we can add a archivement by injecting the datastore in the test. 👀

Comment on lines 93 to 94
showAnimation = { achievement -> viewModel.onClickAchievement(achievement) },
finishAnimation = viewModel::onFinishAnimation,
Copy link
Member

Choose a reason for hiding this comment

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

We would like to promote the best practice that a StateHolder should be notified events.
So how about naming this onAchivementClicked and judge if we run a animation in ViewModel for showAnimation?
And use "onAnimationFinished" as a name for finishAnimation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed showAnimation to onAchivementClick and finishAnimation to onAnimationFinish.

@@ -120,13 +121,17 @@ class AchievementsScreenViewModel @Inject constructor(
)
}

private val clickedAchievement = MutableStateFlow<AchievementAnimationState>(AchievementAnimationState.NotAnimating)
Copy link
Member

Choose a reason for hiding this comment

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

Could you change this name as we change the state? 🙇

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for overlooking. I renamed clickedAchievement to achievementAnimationState.

@Aniokrait
Copy link
Contributor Author

I would like to have a screenshot for this ideally. Could you see it? Maybe we can add a archivement by injecting the datastore in the test. 👀

I've tried to add the screenshot tests. It seems to work fine.

@github-actions github-actions bot temporarily deployed to deploygate-distribution September 17, 2023 11:02 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 19, 2023 11:18 Inactive
@@ -30,6 +38,11 @@ class AchievementsScreenTest {
@Inject
lateinit var achievementsScreenRobot: AchievementsScreenRobot

@Before
fun setup() {
LottieTask.EXECUTOR = Executor(Runnable::run)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you should restore the executor after test to isolate the tests 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@takahirom
I've checked if this setup affects other test classes.
To invesigate that, I created AchievementsScreenTest2 copying original one except setUp function. As a result, all the test cases in AchievementsScreenTest2 didn't capture achivement highlight correctly because LottieTask.EXECUTOR was not set up for tests.
So, I assume changing LottieTask.EXECUTOR is confined in its test class and tearDown isn't really necessary.
However, if you are concerned about other test cases in the same test class, which doesn't need to set up LottieTask.EXECUTOR, I'd make setup in each test cases like below. But I feel it's kind of hacky.

fun checkHighlightImageA() {
    achievementsScreenRobot {
        LottieTask.EXECUTOR = Executor(Runnable::run)
        setupSavedAchievement(ArcticFox)
        setupScreenContent()
        clickAchievementImageA()
        checkScreenCapture()
        LottieTask.EXECUTOR = Executors.newCachedThreadPool()
    }
}

Copy link
Member

Choose a reason for hiding this comment

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

As far as I know static variable is used across the tests. We have some options to do it.
How about adding it 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.

@takahirom
I wasn't aware of that system.
I added LottieTestRule.

@github-actions github-actions bot temporarily deployed to deploygate-distribution September 30, 2023 01:07 Inactive
@github-actions github-actions bot temporarily deployed to deploygate-distribution September 30, 2023 03:00 Inactive
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.

Allow Replay of Achievement Animations Only for Achievements Already Acquired
2 participants