Skip to content

Conversation

@melissavelasquezz
Copy link
Contributor

Overview

Sourced and modified from Resell's falling confetti, ConfettiOverlay.
Added a confetti animation that bursts from the Check-In Pop-Up on a successful check-in, using a physic-based burst. The effect is anchored to the pop-up's bounds and is triggered by a ConfettiEvent.

Changes Made

UI

  • Added ConfettiBurst composable that emits particles from the full pop-up rectangle with initial velocity and gravity for a natural burst and then fall arc/effect.
  • Particles fade out as the animation completes
  • Calls onAnimationFinished() from ConfettiRepository to end burst and hide UI

Integration

  • wrapped CheckInPopUp with GloballyPositioned to capture its bounds via boundsInRoot() and passed that rectangle to ConfettiBurst
  • CheckInViewModel triggers the confetti burst after a successful check in.

Testing

Tested manually/visually on emulator

Related PRs or Issues

#99 and cuappdev/resell-android#86

Screenshots

Confetti Burst Demo
confettiBurstDemo.webm

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.

Amazing job with this! I have one small structural concern and a few nits, but the animation looks awesome.


val rect = originRectInRoot

var started by remember(uiState.showing) { mutableStateOf(false) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we really need this started variable or could we use uiState.showing?

Comment on lines +137 to +138
val g = 1750f
val t = progress * 1.2f
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: avoid one letter variable names

)

when (particle.shape) {
//draws circle
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: this comment is not needed

)
}

//draws rectangle
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: this comment is not needed

* Renders a confetti burst anchored to a given popup rectangle.(checkinpopup).
*
* Reads 'showing' from [ConfettiViewModel]. If false or rect is null, renders nothing.
* When shown, spawns particles inside the bounds of 'originRectInRoot'.
Copy link
Collaborator

Choose a reason for hiding this comment

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

if this is the case, would particleSpawningBounds be a better name?

val systemUiController: SystemUiController = rememberSystemUiController()

val checkInUiState = checkInViewModel.collectUiStateValue()
var confettiBounds by remember { mutableStateOf<Rect?>(null) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you think we could have the confettiBounds be stored as a part of the repository, so this way the UI doesn't necessarily have to be in this file so it can modify them?

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