Updated policy items design

This commit is contained in:
Viktor De Pasquale 2019-10-19 21:07:06 +02:00
parent b66b82a6e9
commit 7c6d85221d
3 changed files with 12 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import com.topjohnwu.magisk.model.events.PolicyEnableEvent
import com.topjohnwu.magisk.model.events.PolicyUpdateEvent import com.topjohnwu.magisk.model.events.PolicyUpdateEvent
import com.topjohnwu.magisk.utils.KObservableField import com.topjohnwu.magisk.utils.KObservableField
import com.topjohnwu.magisk.utils.RxBus import com.topjohnwu.magisk.utils.RxBus
import com.topjohnwu.magisk.utils.rotationTo
import com.topjohnwu.magisk.utils.setRevealed import com.topjohnwu.magisk.utils.setRevealed
class PolicyRvItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvItem<PolicyRvItem>() { class PolicyRvItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvItem<PolicyRvItem>() {
@ -41,6 +42,7 @@ class PolicyRvItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvIte
fun toggle(view: View) { fun toggle(view: View) {
toggle() toggle()
view.rotationTo(if (isExpanded.value) 225 else 180)
(view.parent as ViewGroup) (view.parent as ViewGroup)
.findViewById<View>(R.id.expand_layout) .findViewById<View>(R.id.expand_layout)
.setRevealed(isExpanded.value) .setRevealed(isExpanded.value)

View File

@ -369,4 +369,12 @@ fun RecyclerView.setDividers(dividerVertical: Drawable?, dividerHorizontal: Draw
setDrawable(dividerVertical) setDrawable(dividerVertical)
}.let { addItemDecoration(it) } }.let { addItemDecoration(it) }
} }
}
@BindingAdapter("rotationAnimated")
fun View.rotationTo(value: Int) {
animate()
.rotation(value.toFloat())
.setInterpolator(FastOutSlowInInterpolator())
.start()
} }

View File

@ -16,7 +16,7 @@
</data> </data>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
style="?styleCardNormal" style="?styleCardVariant"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
@ -82,7 +82,7 @@
revealFix="@{item.isExpanded()}" revealFix="@{item.isExpanded()}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?colorSurface" android:background="?colorSurfaceVariant"
android:visibility="invisible" android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"