Skip to content

Commit

Permalink
Add chat filter pill fade out on slide close.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal authored and greyson-signal committed Jan 4, 2023
1 parent 7b3d8d0 commit f387785
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class ConversationListFilterPullView @JvmOverloads constructor(
} else {
binding.filterText.translationY = 0f
}

if (state == FilterPullState.CLOSE_APEX) {
binding.filterText.alpha = FilterLerp.getPillCloseApexAlphaLerp(progress)
}
}

fun onUserDragFinished() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.conversationlist.chatfilter
import android.animation.FloatEvaluator
import androidx.annotation.FloatRange
import org.signal.core.util.dp
import org.thoughtcrime.securesms.util.Util

/**
* Centralized location for filter view linear interpolations.
Expand Down Expand Up @@ -37,6 +38,11 @@ object FilterLerp {
Point(1f, FILTER_APEX * 0.55f)
)

private val PILL_CLOSE_APEX_ALPHA_LERP = getFn(
Point(0.35f * FILTER_APEX / 100, 0f),
Point(0.7f * FILTER_APEX / 100, 1f)
)

private fun helpTextAlphaLerp(@FloatRange(from = 0.0, to = 1.0) startFraction: Float) = getFn(
Point(startFraction, 0f),
Point(1f, 1f)
Expand All @@ -46,6 +52,10 @@ object FilterLerp {
return getLerp(fraction, helpTextAlphaLerp(startFraction))
}

fun getPillCloseApexAlphaLerp(fraction: Float): Float {
return Util.clamp(getLerp(fraction, PILL_CLOSE_APEX_ALPHA_LERP), 0f, 1f)
}

/**
* Get the LERP for the "Filter enabled" pill.
*/
Expand Down

0 comments on commit f387785

Please sign in to comment.