Animate the attachment open/close button

This commit is contained in:
Benoit Marty 2021-12-30 16:52:58 +01:00
parent 464ac3bce2
commit 5eebc995ff
3 changed files with 20 additions and 17 deletions

View File

@ -84,7 +84,21 @@ class AttachmentTypeSelectorView(context: Context,
}
}
private fun animateOpen() {
views.attachmentCloseButton.animate()
.setDuration(200)
.rotation(135f)
}
private fun animateClose() {
views.attachmentCloseButton.animate()
.setDuration(200)
.rotation(0f)
}
fun show(anchor: View) {
animateOpen()
this.anchor = anchor
val anchorCoordinates = IntArray(2)
anchor.getLocationOnScreen(anchorCoordinates)
@ -96,6 +110,8 @@ class AttachmentTypeSelectorView(context: Context,
}
override fun dismiss() {
animateClose()
val capturedAnchor = anchor
if (capturedAnchor != null) {
animateWindowOutCircular(capturedAnchor, contentView)

View File

@ -1,15 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="36"
android:viewportHeight="36">
<path
android:pathData="M18,18m-0,-18a18,18 0,1 1,-0 36a18,18 0,1 1,-0 -36"
android:fillColor="?vctr_content_quinary"/>
<path
android:pathData="M13.521,23.4807L23.067,13.9348M13.521,13.9348L23.067,23.4807"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="?vctr_content_secondary"
android:strokeLineCap="round"/>
</vector>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/composer_min_height"
android:background="?android:colorBackground">
@ -12,10 +13,11 @@
android:layout_margin="@dimen/composer_attachment_margin"
android:background="@null"
android:contentDescription="@string/action_close"
android:src="@drawable/ic_attachment_close"
android:src="@drawable/ic_attachment"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:rotation="135" />
<HorizontalScrollView
android:layout_width="0dp"