mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
animate negative snackbar
This commit is contained in:
parent
a27661edca
commit
843a0f7f16
3 changed files with 15 additions and 2 deletions
6
Habitica/res/drawable/snackbar_background_black.xml
Normal file
6
Habitica/res/drawable/snackbar_background_black.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="@color/black" />
|
||||
<corners android:radius="100dp" />
|
||||
<stroke android:width="1dp" android:color="@color/black_20_alpha" />
|
||||
</shape>
|
||||
|
|
@ -15,6 +15,7 @@ import androidx.core.view.ViewCompat
|
|||
import com.google.android.material.snackbar.BaseTransientBottomBar
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.common.habitica.helpers.Animations
|
||||
import com.plattysoft.leonids.ParticleSystem
|
||||
|
||||
class HabiticaSnackbar
|
||||
|
|
@ -111,7 +112,7 @@ private constructor(parent: ViewGroup, content: View, callback: ContentViewCallb
|
|||
}
|
||||
|
||||
enum class SnackbarDisplayType {
|
||||
NORMAL, FAILURE, FAILURE_BLUE, DROP, SUCCESS, BLUE
|
||||
NORMAL, FAILURE, FAILURE_BLUE, DROP, SUCCESS, BLUE, BLACK
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
@ -247,6 +248,7 @@ private constructor(parent: ViewGroup, content: View, callback: ContentViewCallb
|
|||
|
||||
when (displayType) {
|
||||
SnackbarDisplayType.FAILURE -> snackbar.setBackgroundResource(R.drawable.snackbar_background_red)
|
||||
SnackbarDisplayType.BLACK -> snackbar.setBackgroundResource(R.drawable.snackbar_background_black)
|
||||
SnackbarDisplayType.FAILURE_BLUE, SnackbarDisplayType.BLUE -> snackbar.setBackgroundResource(
|
||||
R.drawable.snackbar_background_blue
|
||||
)
|
||||
|
|
@ -265,6 +267,11 @@ private constructor(parent: ViewGroup, content: View, callback: ContentViewCallb
|
|||
}
|
||||
|
||||
snackbar.show()
|
||||
if (displayType == SnackbarDisplayType.FAILURE || displayType == SnackbarDisplayType.FAILURE_BLUE) {
|
||||
container.postDelayed({
|
||||
snackbar.getView().startAnimation(Animations.negativeShakeAnimation())
|
||||
}, 600L)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSubscriberBenefitAnimation(container: ViewGroup, snackbar: HabiticaSnackbar) {
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.3
|
||||
CODE=6441
|
||||
CODE=6461
|
||||
Loading…
Reference in a new issue