mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-12 12:08:56 +01:00
Implement predictive back animation (#10273)
For home screen tabs, Navigator screens and most dialogs
This commit is contained in:
@@ -4,9 +4,11 @@ package eu.kanade.tachiyomi.util.view
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Rect
|
||||
import android.os.Build
|
||||
import android.view.Gravity
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.RoundedCorner
|
||||
import android.view.View
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
@@ -95,3 +97,22 @@ fun View?.isVisibleOnScreen(): Boolean {
|
||||
Rect(0, 0, Resources.getSystem().displayMetrics.widthPixels, Resources.getSystem().displayMetrics.heightPixels)
|
||||
return actualPosition.intersect(screen)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns window radius (in pixel) applied to this view
|
||||
*/
|
||||
fun View.getWindowRadius(): Int {
|
||||
val rad = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val windowInsets = rootWindowInsets
|
||||
listOfNotNull(
|
||||
windowInsets.getRoundedCorner(RoundedCorner.POSITION_TOP_LEFT),
|
||||
windowInsets.getRoundedCorner(RoundedCorner.POSITION_TOP_RIGHT),
|
||||
windowInsets.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_LEFT),
|
||||
windowInsets.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_RIGHT),
|
||||
)
|
||||
.minOfOrNull { it.radius }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
return rad ?: 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user