Adding screen transitions. (#990)

- Fixes #989
This commit is contained in:
Dessalines 2024-07-26 16:02:38 -04:00 committed by GitHub
parent bc9199e3d2
commit d0aade6cd9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 1 deletions

1
.gitignore vendored
View File

@ -15,4 +15,5 @@ app/schemas
.project
.settings
.classpath
.kotlin
build.sh

View File

@ -89,7 +89,8 @@ dependencies {
implementation 'androidx.compose.runtime:runtime-livedata'
// Activities
implementation 'androidx.activity:activity-compose'
implementation 'androidx.activity:activity-compose:1.9.1'
implementation 'androidx.activity:activity-ktx:1.9.1'
// LiveData
implementation 'androidx.lifecycle:lifecycle-runtime-compose'

View File

@ -4,8 +4,11 @@ import android.app.Application
import android.os.Bundle
import android.provider.Settings
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.animation.AnimatedContentTransitionScope
import androidx.compose.animation.core.tween
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.mutableStateOf
@ -25,6 +28,7 @@ import com.dessalines.thumbkey.ui.components.settings.behavior.BehaviorActivity
import com.dessalines.thumbkey.ui.components.settings.lookandfeel.LookAndFeelActivity
import com.dessalines.thumbkey.ui.components.setup.SetupActivity
import com.dessalines.thumbkey.ui.theme.ThumbkeyTheme
import com.dessalines.thumbkey.utils.ANIMATION_SPEED
import com.dessalines.thumbkey.utils.getImeNames
import splitties.systemservices.inputMethodManager
@ -39,6 +43,7 @@ class MainActivity : AppCompatActivity() {
}
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContent {
@ -79,6 +84,30 @@ class MainActivity : AppCompatActivity() {
NavHost(
navController = navController,
startDestination = startDestination,
enterTransition = {
slideIntoContainer(
towards = AnimatedContentTransitionScope.SlideDirection.Left,
animationSpec = tween(ANIMATION_SPEED),
)
},
exitTransition = {
slideOutOfContainer(
towards = AnimatedContentTransitionScope.SlideDirection.Left,
animationSpec = tween(ANIMATION_SPEED),
)
},
popEnterTransition = {
slideIntoContainer(
towards = AnimatedContentTransitionScope.SlideDirection.Right,
animationSpec = tween(ANIMATION_SPEED),
)
},
popExitTransition = {
slideOutOfContainer(
towards = AnimatedContentTransitionScope.SlideDirection.Right,
animationSpec = tween(ANIMATION_SPEED),
)
},
) {
composable(
route = "setup",

View File

@ -5,6 +5,8 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.Chat
import androidx.compose.material.icons.outlined.AttachMoney
@ -55,6 +57,7 @@ fun AboutActivity(navController: NavController) {
val version = ctx.packageManager.getPackageInfo(ctx.packageName, 0).versionName
val snackbarHostState = remember { SnackbarHostState() }
val scrollState = rememberScrollState()
Scaffold(
snackbarHost = { SnackbarHost(snackbarHostState) },
@ -66,6 +69,7 @@ fun AboutActivity(navController: NavController) {
modifier =
Modifier
.padding(padding)
.verticalScroll(scrollState)
.background(color = MaterialTheme.colorScheme.surface),
) {
ProvidePreferenceTheme {

View File

@ -55,6 +55,7 @@ import kotlin.math.sqrt
const val TAG = "com.thumbkey"
const val IME_ACTION_CUSTOM_LABEL = EditorInfo.IME_MASK_ACTION + 1
const val ANIMATION_SPEED = 300
fun accelCurve(
offset: Float,