mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 04:25:27 +00:00
Added animations for toolbar transitions
This commit is contained in:
parent
b910db322b
commit
44f7c9a545
@ -1,7 +1,11 @@
|
||||
package com.topjohnwu.magisk.extensions
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
||||
import androidx.transition.AutoTransition
|
||||
import androidx.transition.TransitionManager
|
||||
|
||||
fun View.setOnViewReadyListener(callback: () -> Unit) = addOnGlobalLayoutListener(true, callback)
|
||||
|
||||
@ -12,3 +16,8 @@ fun View.addOnGlobalLayoutListener(oneShot: Boolean = false, callback: () -> Uni
|
||||
callback()
|
||||
}
|
||||
})
|
||||
|
||||
fun ViewGroup.startAnimations() {
|
||||
val transition = AutoTransition().setInterpolator(FastOutSlowInInterpolator())
|
||||
TransitionManager.beginDelayedTransition(this, transition)
|
||||
}
|
@ -16,6 +16,7 @@ import com.ncapdevi.fragnav.FragNavController
|
||||
import com.topjohnwu.magisk.Const
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.databinding.ActivityMainMd2Binding
|
||||
import com.topjohnwu.magisk.extensions.startAnimations
|
||||
import com.topjohnwu.magisk.model.navigation.Navigation
|
||||
import com.topjohnwu.magisk.redesign.compat.CompatActivity
|
||||
import com.topjohnwu.magisk.redesign.compat.CompatNavigationDelegate
|
||||
@ -136,7 +137,8 @@ open class MainActivity : CompatActivity<MainViewModel, ActivityMainMd2Binding>(
|
||||
viewModel.insets.value = insets
|
||||
}
|
||||
|
||||
fun setDisplayHomeAsUpEnabled(isEnabled: Boolean) {
|
||||
private fun setDisplayHomeAsUpEnabled(isEnabled: Boolean) {
|
||||
binding.mainToolbar.startAnimations()
|
||||
when {
|
||||
isEnabled -> binding.mainToolbar.setNavigationIcon(R.drawable.ic_back_md2)
|
||||
else -> binding.mainToolbar.navigationIcon = null
|
||||
|
Loading…
Reference in New Issue
Block a user