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

GS attempt at Bumble Challenge #1

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

Conversation

GPRSBirkbeck
Copy link

It was great to meet you all at DroidCon London - I'd love to know how to solve (if at all needed) TODO 4 on Challenge 2.
I also changed the padding of PeekInsideBackStack to 10dp as this provided a smoother experience on Pixel 3a.

Have a great week and thanks for sharing this great library.

@@ -10,14 +10,20 @@ import kotlinx.parcelize.Parcelize
class ToggleFreeze<T : Any> : CustomBackStackOperation<T> {

override fun isApplicable(elements: NavElements<T, CustomBackStack.State>): Boolean =
elements.any { TODO("(1) Define applicability logic") }
elements.any {
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case we'd like to be able to apply the ToggleFreeze operation when an element is Active or Frozen.
elements.any { it.targetState is Active || it.targetState is Frozen }

is State.Frozen -> active.copy() //I honestly have no idea how this should be implemented, as createModifier already seems to cover this..
//is State.Frozen -> createModifier(Modifier.blur(15.dp))
//is State.Frozen -> active.copy(specDp(15.dp))
//is State.Frozen -> TODO("(4) Frozen state should have blur of 15.dp. Note that blur only works Android 12+")
Copy link
Collaborator

@vladcipariu91 vladcipariu91 Nov 1, 2022

Choose a reason for hiding this comment

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

In order to fix this you'd need to add a new property to Props called val blur: Dp = 0.dp.

Then define a field frozen, similar to created, active etc
private val frozen = active.copy(blur = 15.dp)

You'll return the frozen value from the toProps function when the State is Frozen

Then similarly to how we animate the other props, you'd add something like this inside createModifier

val blur by transition.animateDp(
            transitionSpec = specDp,
            targetValueByState = { it.toProps(height).blur },
            label = ""
        )

then apply this to your modifier:

this
            .offset {
                IntOffset(
                    x = (offset.x * density).roundToInt(),
                    y = (offset.y * density).roundToInt()
                )
            }
            .scale(scale)
            .graphicsLayer { rotationX = rotation }
            .drawBehind {
                drawRoundRect(
                    color = Color.Black,
                    cornerRadius = CornerRadius(x = 10f * density, y = 10f * density)
                )
            }
            .alpha(alpha)
            .blur(
                blur, edgeTreatment = BlurredEdgeTreatment(
                    // TODO this is in %, above it's defined in pixels
                    RoundedCornerShape(2)
                )
            )
            .zIndex(zIndex)

@vladcipariu91
Copy link
Collaborator

@GPRSBirkbeck thanks for taking our challenges. I left some comments, hopefully that will clarify. Feel free to drop us more questions and checkout the Appyx repo

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.

2 participants