Compare commits
2 Commits
main
...
predictive
Author | SHA1 | Date | |
---|---|---|---|
|
2655cb5f43 | ||
|
c691a106d5 |
@ -31,7 +31,7 @@ android {
|
||||
defaultConfig {
|
||||
applicationId = "me.ash.reader"
|
||||
minSdk = 26
|
||||
targetSdk = 33
|
||||
targetSdk = 34
|
||||
versionCode = 26
|
||||
versionName = "0.11.0"
|
||||
|
||||
|
@ -4,8 +4,10 @@
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="28" />
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@ -19,6 +21,7 @@
|
||||
<application
|
||||
android:name=".infrastructure.android.AndroidApp"
|
||||
android:allowBackup="true"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/read_you"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
|
@ -8,19 +8,69 @@
|
||||
|
||||
package me.ash.reader.ui.ext
|
||||
|
||||
import android.os.Build
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.navigation.NamedNavArgument
|
||||
import androidx.navigation.NavBackStackEntry
|
||||
import androidx.navigation.NavDeepLink
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.compose.composable
|
||||
import me.ash.reader.ui.motion.EmphasizedAccelerate
|
||||
import me.ash.reader.ui.motion.EmphasizedDecelerate
|
||||
import me.ash.reader.ui.motion.materialSharedAxisXIn
|
||||
import me.ash.reader.ui.motion.materialSharedAxisXOut
|
||||
|
||||
private const val INITIAL_OFFSET_FACTOR = 0.10f
|
||||
private const val INITIAL_SCALE_FACTOR = 0.8f
|
||||
|
||||
|
||||
fun NavGraphBuilder.animatedComposable(
|
||||
route: String,
|
||||
arguments: List<NamedNavArgument> = emptyList(),
|
||||
deepLinks: List<NavDeepLink> = emptyList(),
|
||||
usePredictiveBack: Boolean = Build.VERSION.SDK_INT >= 34,
|
||||
content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit,
|
||||
) {
|
||||
if (usePredictiveBack) {
|
||||
animatedComposablePredictiveBack(route, arguments, deepLinks, content)
|
||||
} else {
|
||||
animatedComposableLegacy(route, arguments, deepLinks, content)
|
||||
}
|
||||
}
|
||||
|
||||
fun NavGraphBuilder.animatedComposablePredictiveBack(
|
||||
route: String,
|
||||
arguments: List<NamedNavArgument> = emptyList(),
|
||||
deepLinks: List<NavDeepLink> = emptyList(),
|
||||
content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit,
|
||||
) =
|
||||
composable(
|
||||
route = route,
|
||||
arguments = arguments,
|
||||
deepLinks = deepLinks,
|
||||
enterTransition = { materialSharedAxisXIn(initialOffsetX = { (it * INITIAL_OFFSET_FACTOR).toInt() }) },
|
||||
exitTransition = {
|
||||
materialSharedAxisXOut(targetOffsetX = { -(it * INITIAL_OFFSET_FACTOR).toInt() })
|
||||
},
|
||||
popEnterTransition = {
|
||||
scaleIn(
|
||||
animationSpec = tween(durationMillis = 350, easing = EmphasizedDecelerate),
|
||||
initialScale = INITIAL_SCALE_FACTOR,
|
||||
) + materialSharedAxisXIn(initialOffsetX = { -(it * INITIAL_OFFSET_FACTOR).toInt() })
|
||||
},
|
||||
popExitTransition = {
|
||||
materialSharedAxisXOut(targetOffsetX = { (it * INITIAL_OFFSET_FACTOR).toInt() }) +
|
||||
scaleOut(
|
||||
targetScale = INITIAL_SCALE_FACTOR,
|
||||
animationSpec = tween(durationMillis = 350, easing = EmphasizedAccelerate),
|
||||
)
|
||||
},
|
||||
content = content,
|
||||
)
|
||||
|
||||
fun NavGraphBuilder.animatedComposableLegacy(
|
||||
route: String,
|
||||
arguments: List<NamedNavArgument> = emptyList(),
|
||||
deepLinks: List<NavDeepLink> = emptyList(),
|
||||
|
@ -204,9 +204,6 @@ fun FeedsPage(
|
||||
}
|
||||
}
|
||||
|
||||
BackHandler(true) {
|
||||
context.findActivity()?.moveTaskToBack(false)
|
||||
}
|
||||
|
||||
RYScaffold(
|
||||
topBarTonalElevation = topBarTonalElevation.value.dp,
|
||||
|
@ -13,21 +13,21 @@ aboutLibsRelease = "11.1.1"
|
||||
accompanist = "0.34.0"
|
||||
|
||||
# AndroidX
|
||||
activityCompose = "1.9.0"
|
||||
activityCompose = "1.9.3"
|
||||
appcompat = "1.7.0"
|
||||
browser = "1.8.0"
|
||||
coreKtx = "1.13.1"
|
||||
datastore = "1.1.1"
|
||||
espresso = "3.5.1"
|
||||
lifecycle = "2.8.1"
|
||||
navigation = "2.7.7"
|
||||
navigation = "2.8.3"
|
||||
paging = "3.3.0"
|
||||
profileinstaller = "1.3.1"
|
||||
profileinstaller = "1.4.1"
|
||||
room = "2.6.1"
|
||||
work = "2.9.0"
|
||||
|
||||
# Compose
|
||||
composeBom = "2024.09.02"
|
||||
composeBom = "2024.10.01"
|
||||
composeCompiler = "1.5.8"
|
||||
composeHtml = "1.0.2"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user