mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 08:09:12 +01:00
Update MediaPreviewV2 design values.
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
package org.thoughtcrime.securesms.animation;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
/**
|
||||
* Based on https://developer.android.com/training/animation/screen-slide#depth-page
|
||||
*/
|
||||
public final class DepthPageTransformer implements ViewPager.PageTransformer {
|
||||
private static final float MIN_SCALE = 0.75f;
|
||||
|
||||
public void transformPage(@NonNull View view, float position) {
|
||||
final int pageWidth = view.getWidth();
|
||||
|
||||
if (position < -1f) {
|
||||
view.setAlpha(0f);
|
||||
|
||||
} else if (position <= 0f) {
|
||||
view.setAlpha(1f);
|
||||
view.setTranslationX(0f);
|
||||
view.setScaleX(1f);
|
||||
view.setScaleY(1f);
|
||||
|
||||
} else if (position <= 1f) {
|
||||
view.setAlpha(1f - position);
|
||||
|
||||
view.setTranslationX(pageWidth * -position);
|
||||
|
||||
final float scaleFactor = MIN_SCALE + (1f - MIN_SCALE) * (1f - Math.abs(position));
|
||||
|
||||
view.setScaleX(scaleFactor);
|
||||
view.setScaleY(scaleFactor);
|
||||
|
||||
} else {
|
||||
view.setAlpha(0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package org.thoughtcrime.securesms.animation
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
|
||||
private const val MIN_SCALE = 0.75f
|
||||
|
||||
/**
|
||||
* Lifted from https://developer.android.com/develop/ui/views/animations/screen-slide-2#depth-page
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
class DepthPageTransformer2 : ViewPager2.PageTransformer {
|
||||
|
||||
override fun transformPage(view: View, position: Float) {
|
||||
view.apply {
|
||||
val pageWidth = width
|
||||
when {
|
||||
position < -1 -> alpha = 0f
|
||||
position <= 0 -> {
|
||||
alpha = 1f
|
||||
translationX = 0f
|
||||
translationZ = 0f
|
||||
scaleX = 1f
|
||||
scaleY = 1f
|
||||
}
|
||||
position <= 1 -> {
|
||||
alpha = 1 - position
|
||||
|
||||
translationX = pageWidth * -position
|
||||
translationZ = -1f
|
||||
|
||||
val scaleFactor = (MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)))
|
||||
scaleX = scaleFactor
|
||||
scaleY = scaleFactor
|
||||
}
|
||||
else -> alpha = 0f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user