Skip to content

Commit

Permalink
chore: Update dependencies and target SDK
Browse files Browse the repository at this point in the history
ui: Improved animations between screens

Updated the target SDK to 35 and several dependencies, including

Also updated Gradle wrapper to 8.10.2.

Additionally, removed the `enableStrongSkippingMode` flag from Compose Compiler options and fixed the `windowInsets` parameter in `ModalBottomSheetLayout`.
  • Loading branch information
BobbyESP committed Nov 18, 2024
1 parent db639b3 commit be60ec6
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ val localProperties = Properties().apply {

android {
namespace = "com.bobbyesp.metadator"
compileSdk = 34
compileSdk = 35

defaultConfig {
applicationId = "com.bobbyesp.metadator"
Expand Down Expand Up @@ -106,7 +106,6 @@ android {
buildConfig = true
}
composeCompiler {
enableStrongSkippingMode = true
reportsDestination = layout.buildDirectory.dir("compose_compiler")
}
kotlin {
Expand Down
2 changes: 1 addition & 1 deletion app/mediaplayer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {

android {
namespace = "com.bobbyesp.mediaplayer"
compileSdk = 34
compileSdk = 35

defaultConfig {
minSdk = 24
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/bobbyesp/metadator/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class App : Application() {
lateinit var packageInfo: PackageInfo
var isPlayStoreBuild by Delegates.notNull<Boolean>()

val appVersion: String get() = packageInfo.versionName
val appVersion: String get() = packageInfo.versionName.toString()

const val APP_PACKAGE_NAME = "com.bobbyesp.metadator"
const val APP_FILE_PROVIDER = "$APP_PACKAGE_NAME.fileprovider"
Expand Down
3 changes: 1 addition & 2 deletions app/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

android {
namespace = "com.bobbyesp.ui"
compileSdk = 34
compileSdk = 35

defaultConfig {
minSdk = 24
Expand Down Expand Up @@ -42,7 +42,6 @@ android {
compose = true
}
composeCompiler {
enableStrongSkippingMode = true
reportsDestination = layout.buildDirectory.dir("compose_compiler")
}
packaging {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun BottomSheet(
onDismissRequest = { onDismiss() },
sheetState = state,
dragHandle = { BottomSheetDefaults.DragHandle() },
windowInsets = windowInsets,
contentWindowInsets = { windowInsets },
) {
content()
}
Expand Down
192 changes: 105 additions & 87 deletions app/ui/src/main/java/com/bobbyesp/ui/motion/AnimatedComposables.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.bobbyesp.ui.motion

import android.os.Build
import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.VisibilityThreshold
import androidx.compose.animation.core.spring
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.slideOutVertically
import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.IntOffset
Expand All @@ -15,106 +22,117 @@ import androidx.navigation.NavDeepLink
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import com.bobbyesp.ui.motion.MotionConstants.DURATION_ENTER
import com.bobbyesp.ui.motion.MotionConstants.DURATION_EXIT
import com.bobbyesp.ui.motion.MotionConstants.InitialOffset
import kotlin.reflect.KType

fun NavGraphBuilder.fadeThroughComposable(
route: String,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit
) = composable(
route = route,
arguments = arguments,
deepLinks = deepLinks,
enterTransition = {
fadeIn(animationSpec = tween(220, delayMillis = 90)) +
scaleIn(
initialScale = 0.92f,
animationSpec = tween(220, delayMillis = 90)
)
},
exitTransition = {
fadeOut(animationSpec = tween(90))
},
popEnterTransition = {
fadeIn(animationSpec = tween(220, delayMillis = 90)) +
scaleIn(
initialScale = 0.92f,
animationSpec = tween(220, delayMillis = 90)
)
},
popExitTransition = {
fadeOut(animationSpec = tween(90))
},
content = content
)
fun <T> enterTween() = tween<T>(durationMillis = DURATION_ENTER, easing = EmphasizedEasing)

fun <T> exitTween() = tween<T>(durationMillis = DURATION_ENTER, easing = EmphasizedEasing)

val enterTween = tweenEnter<IntOffset>()
val exitTween = tweenExit<IntOffset>()
val fadeTween = tween<Float>(durationMillis = DURATION_EXIT)
private val fadeSpring =
spring<Float>(dampingRatio = Spring.DampingRatioNoBouncy, stiffness = Spring.StiffnessMedium)

private val fadeTween = tween<Float>(durationMillis = DURATION_EXIT)
val fadeSpec = fadeTween

inline fun <reified T : Any> NavGraphBuilder.animatedComposable(
deepLinks: List<NavDeepLink> = emptyList(),
noinline content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit
) = composable<T>(
deepLinks = deepLinks,
enterTransition = {
materialSharedAxisXIn(initialOffsetX = { (it * InitialOffset).toInt() })
},
exitTransition = {
materialSharedAxisXOut(targetOffsetX = { -(it * InitialOffset).toInt() })
},
popEnterTransition = {
materialSharedAxisXIn(initialOffsetX = { -(it * InitialOffset).toInt() })
},
popExitTransition = {
materialSharedAxisXOut(targetOffsetX = { (it * InitialOffset).toInt() })
},
content = content
)
usePredictiveBack: Boolean = Build.VERSION.SDK_INT >= 34,
noinline content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit,
) {
if (usePredictiveBack) {
animatedComposablePredictiveBack<T>(deepLinks, content)
} else {
animatedComposableLegacy<T>(deepLinks, content)
}
}

inline fun <reified T : Any> NavGraphBuilder.animatedComposablePredictiveBack(
deepLinks: List<NavDeepLink> = emptyList(),
noinline content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit,
) =
composable<T>(
deepLinks = deepLinks,
enterTransition = { materialSharedAxisXIn(initialOffsetX = { (it * 0.15f).toInt() }) },
exitTransition = {
materialSharedAxisXOut(targetOffsetX = { -(it * InitialOffset).toInt() })
},
popEnterTransition = {
scaleIn(
animationSpec = tween(durationMillis = 350, easing = EmphasizedDecelerate),
initialScale = 0.9f,
) + materialSharedAxisXIn(initialOffsetX = { -(it * InitialOffset).toInt() })
},
popExitTransition = {
materialSharedAxisXOut(targetOffsetX = { (it * InitialOffset).toInt() }) +
scaleOut(
targetScale = 0.9f,
animationSpec = tween(durationMillis = 350, easing = EmphasizedAccelerate),
)
},
content = content,
)

inline fun <reified T : Any> NavGraphBuilder.animatedComposableLegacy(
deepLinks: List<NavDeepLink> = emptyList(),
noinline content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit,
) =
composable<T>(
deepLinks = deepLinks,
enterTransition = {
materialSharedAxisXIn(initialOffsetX = { (it * InitialOffset).toInt() })
},
exitTransition = {
materialSharedAxisXOut(targetOffsetX = { -(it * InitialOffset).toInt() })
},
popEnterTransition = {
materialSharedAxisXIn(initialOffsetX = { -(it * InitialOffset).toInt() })
},
popExitTransition = {
materialSharedAxisXOut(targetOffsetX = { (it * InitialOffset).toInt() })
},
content = content,
)

inline fun <reified T : Any> NavGraphBuilder.animatedComposableVariant(
deepLinks: List<NavDeepLink> = emptyList(),
noinline content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit
) = composable<T>(
deepLinks = deepLinks,
enterTransition = {
materialSharedAxisYIn(initialOffsetY = { (it * InitialOffset).toInt() })
},
exitTransition = {
materialSharedAxisYOut(targetOffsetY = { -(it * InitialOffset).toInt() })
},
popEnterTransition = {
materialSharedAxisYIn(initialOffsetY = { -(it * InitialOffset).toInt() })
},
popExitTransition = {
materialSharedAxisYOut(targetOffsetY = { (it * InitialOffset).toInt() })
},
content = content
)
noinline content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit,
) =
composable<T>(
deepLinks = deepLinks,
enterTransition = {
slideInHorizontally(enterTween(), initialOffsetX = { (it * InitialOffset).toInt() }) +
fadeIn(fadeSpec)
},
exitTransition = { fadeOut(fadeSpec) },
popEnterTransition = { fadeIn(fadeSpec) },
popExitTransition = {
slideOutHorizontally(exitTween(), targetOffsetX = { (it * InitialOffset).toInt() }) +
fadeOut(fadeSpec)
},
content = content,
)

val springSpec =
spring(stiffness = Spring.StiffnessMedium, visibilityThreshold = IntOffset.VisibilityThreshold)

inline fun <reified T : Any> NavGraphBuilder.slideInVerticallyComposable(
deepLinks: List<NavDeepLink> = emptyList(),
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
noinline content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit
) = composable<T>(
deepLinks = deepLinks,
enterTransition = {
slideInVertically(
initialOffsetY = { it }, animationSpec = enterTween
) + fadeIn()
},
typeMap = typeMap,
exitTransition = { slideOutVertically() },
popEnterTransition = { slideInVertically() },
popExitTransition = {
slideOutVertically(
targetOffsetY = { it },
animationSpec = enterTween
) + fadeOut()
},
content = content
)
noinline content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit,
) =
composable<T>(
deepLinks = deepLinks,
typeMap = typeMap,
enterTransition = {
slideInVertically(initialOffsetY = { it }, animationSpec = enterTween()) + fadeIn()
},
exitTransition = { slideOutVertically() },
popEnterTransition = { slideInVertically() },
popExitTransition = {
slideOutVertically(targetOffsetY = { it }, animationSpec = enterTween()) + fadeOut()
},
content = content,
)
3 changes: 1 addition & 2 deletions app/utilities/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {

android {
namespace = "com.bobbyesp.utilities"
compileSdk = 34
compileSdk = 35

defaultConfig {
minSdk = 24
Expand All @@ -35,7 +35,6 @@ android {
buildConfig = true
}
composeCompiler {
enableStrongSkippingMode = true
reportsDestination = layout.buildDirectory.dir("compose_compiler")
}
kotlinOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object Logging {
Build.VERSION.RELEASE
}

val appName = packageInfo.applicationInfo.name
val appName = packageInfo.applicationInfo?.name
return StringBuilder()
.append("App version: $appName $versionName ($versionCode)\n")
.append("Android version: Android $release (API ${Build.VERSION.SDK_INT})\n")
Expand Down
3 changes: 1 addition & 2 deletions crashhandler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

android {
namespace = "com.bobbyesp.crashhandler"
compileSdk = 34
compileSdk = 35

defaultConfig {
minSdk = 24
Expand All @@ -32,7 +32,6 @@ android {
compose = true
}
composeCompiler {
enableStrongSkippingMode = true
reportsDestination = layout.buildDirectory.dir("compose_compiler")
}
kotlinOptions {
Expand Down
Loading

0 comments on commit be60ec6

Please sign in to comment.