Skip to content

Commit

Permalink
improve settings color transition
Browse files Browse the repository at this point in the history
  • Loading branch information
qimiko committed Jan 15, 2024
1 parent 2dfdf7e commit f938b64
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions app/src/main/java/com/geode/launcher/SettingsActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.geode.launcher

import android.app.UiModeManager
import android.content.ActivityNotFoundException
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
Expand All @@ -12,6 +13,9 @@ import androidx.activity.ComponentActivity
import androidx.activity.OnBackPressedDispatcher
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
Expand Down Expand Up @@ -111,7 +115,14 @@ fun onOpenFileManager(context: Context) {
type = "vnd.android.document/directory"
}

context.startActivity(intent)
try {
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(
context,
context.getText(R.string.no_activity_found), Toast.LENGTH_SHORT
).show()
}
}

@Composable
Expand Down Expand Up @@ -223,14 +234,21 @@ fun SettingsScreen(
}
}

// fix theme transition by giving it the exact same animation as the top bar
val containerColor by animateColorAsState(
targetValue = MaterialTheme.colorScheme.background,
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
label = "background color"
)

val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
containerColor = containerColor,
snackbarHost = {
SnackbarHost(hostState = snackbarHostState)
},
topBar = {
// todo: the TopAppBar makes theme transitions look bad. why is that
TopAppBar(
navigationIcon = {
IconButton(onClick = { onBackPressedDispatcher?.onBackPressed() }) {
Expand Down

0 comments on commit f938b64

Please sign in to comment.