mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 02:56:01 +00:00
@@ -44,6 +44,10 @@ android {
|
||||
debug {
|
||||
signingConfig = signingConfigs.getByName("defaultSignature")
|
||||
}
|
||||
create("fastDebug") {
|
||||
initWith(getByName("debug"))
|
||||
isDebuggable = false
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
|
||||
@@ -228,7 +228,7 @@ import com.bintianqi.owndroid.dpm.WorkModesScreen
|
||||
import com.bintianqi.owndroid.dpm.WorkProfile
|
||||
import com.bintianqi.owndroid.dpm.WorkProfileScreen
|
||||
import com.bintianqi.owndroid.dpm.dhizukuErrorStatus
|
||||
import com.bintianqi.owndroid.ui.Animations
|
||||
import com.bintianqi.owndroid.ui.NavTransition
|
||||
import com.bintianqi.owndroid.ui.theme.OwnDroidTheme
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.util.Locale
|
||||
@@ -275,7 +275,11 @@ fun Home(vm: MyViewModel, onLock: () -> Unit) {
|
||||
val focusMgr = LocalFocusManager.current
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
fun navigateUp() { navController.navigateUp() }
|
||||
fun navigate(destination: Any) { navController.navigate(destination) }
|
||||
fun navigate(destination: Any) {
|
||||
navController.navigate(destination) {
|
||||
launchSingleTop = true
|
||||
}
|
||||
}
|
||||
fun choosePackage() {
|
||||
navController.navigate(ApplicationsList(false))
|
||||
}
|
||||
@@ -293,10 +297,10 @@ fun Home(vm: MyViewModel, onLock: () -> Unit) {
|
||||
.fillMaxSize()
|
||||
.background(colorScheme.background)
|
||||
.pointerInput(Unit) { detectTapGestures(onTap = { focusMgr.clearFocus() }) },
|
||||
enterTransition = Animations.navHostEnterTransition,
|
||||
exitTransition = Animations.navHostExitTransition,
|
||||
popEnterTransition = Animations.navHostPopEnterTransition,
|
||||
popExitTransition = Animations.navHostPopExitTransition
|
||||
enterTransition = { NavTransition.enterTransition },
|
||||
exitTransition = { NavTransition.exitTransition },
|
||||
popEnterTransition = { NavTransition.popEnterTransition },
|
||||
popExitTransition = { NavTransition.popExitTransition }
|
||||
) {
|
||||
composable<Home> { HomeScreen(::navigate) }
|
||||
composable<WorkModes> {
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.bintianqi.owndroid.ui
|
||||
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.*
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.navigation.NavBackStackEntry
|
||||
|
||||
object Animations {
|
||||
private const val INITIAL_OFFSET_VALUE = 96
|
||||
private const val TARGET_OFFSET_VALUE = 96
|
||||
|
||||
private val bezier = CubicBezierEasing(0.20f, 0.85f, 0.0f, 1f)
|
||||
|
||||
private val tween: FiniteAnimationSpec<IntOffset> = tween(durationMillis = 550, easing = bezier, delayMillis = 50)
|
||||
|
||||
val navHostEnterTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition = {
|
||||
fadeIn(tween(100, easing = LinearEasing)) +
|
||||
slideIntoContainer(
|
||||
animationSpec = tween,
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.End,
|
||||
initialOffset = { INITIAL_OFFSET_VALUE }
|
||||
)
|
||||
}
|
||||
|
||||
val navHostExitTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition = {
|
||||
fadeOut(tween(100, easing = LinearEasing)) +
|
||||
slideOutOfContainer(
|
||||
animationSpec = tween,
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.Start,
|
||||
targetOffset = { -TARGET_OFFSET_VALUE }
|
||||
)
|
||||
}
|
||||
|
||||
val navHostPopEnterTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition = {
|
||||
fadeIn(tween(100, easing = LinearEasing)) +
|
||||
slideIntoContainer(
|
||||
animationSpec = tween,
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.End,
|
||||
initialOffset = { -INITIAL_OFFSET_VALUE }
|
||||
)
|
||||
}
|
||||
|
||||
val navHostPopExitTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition = {
|
||||
fadeOut(tween(100, easing = LinearEasing)) +
|
||||
slideOutOfContainer(
|
||||
animationSpec = tween,
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.Start,
|
||||
targetOffset = { TARGET_OFFSET_VALUE }
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
45
app/src/main/java/com/bintianqi/owndroid/ui/NavTransition.kt
Normal file
45
app/src/main/java/com/bintianqi/owndroid/ui/NavTransition.kt
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.bintianqi.owndroid.ui
|
||||
|
||||
import androidx.compose.animation.EnterTransition
|
||||
import androidx.compose.animation.ExitTransition
|
||||
import androidx.compose.animation.core.CubicBezierEasing
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.LinearEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
|
||||
/**
|
||||
* Learned from AOSP's Activity animation
|
||||
* `frameworks/base/core/res/res/anim/activity_xxx_xxx.xml`
|
||||
*/
|
||||
object NavTransition {
|
||||
val StandardAccelerateEasing = CubicBezierEasing(0.3F, 0F, 1F, 1F)
|
||||
|
||||
val enterTransition: EnterTransition = slideInHorizontally(
|
||||
tween(450, easing = FastOutSlowInEasing),
|
||||
{ 96 }
|
||||
) + fadeIn(
|
||||
tween(83, 50, LinearEasing)
|
||||
)
|
||||
|
||||
val exitTransition: ExitTransition = slideOutHorizontally(
|
||||
tween(450, easing = StandardAccelerateEasing),
|
||||
{ -96 }
|
||||
) + fadeOut(tween(100, 200, LinearEasing))
|
||||
|
||||
val popEnterTransition: EnterTransition = slideInHorizontally(
|
||||
tween(450, easing = FastOutSlowInEasing),
|
||||
{ -96 }
|
||||
)
|
||||
|
||||
val popExitTransition: ExitTransition =
|
||||
slideOutHorizontally(
|
||||
tween(450, easing = FastOutSlowInEasing),
|
||||
{ 96 }
|
||||
) + fadeOut(
|
||||
tween(83, 35, LinearEasing)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user