diff --git a/app/src/main/java/illyan/jay/ui/about/About.kt b/app/src/main/java/illyan/jay/ui/about/About.kt index 2d2b0c8..afaab4c 100644 --- a/app/src/main/java/illyan/jay/ui/about/About.kt +++ b/app/src/main/java/illyan/jay/ui/about/About.kt @@ -79,7 +79,6 @@ import illyan.jay.ui.profile.ProfileNavGraph import illyan.jay.ui.settings.user.BooleanSetting import illyan.jay.ui.theme.JayTheme import illyan.jay.ui.theme.signaturePink -import illyan.jay.ui.theme.statefulColorScheme import illyan.jay.util.TestAdUnitIds @ProfileNavGraph @@ -240,7 +239,7 @@ fun AboutButtons() { Text( text = "${BuildConfig.VERSION_NAME} v${BuildConfig.VERSION_CODE}", style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } Button( @@ -277,7 +276,7 @@ fun AboutAdSetting( Card( modifier = Modifier.padding(bottom = 8.dp), colors = CardDefaults.cardColors( - containerColor = MaterialTheme.statefulColorScheme.tertiaryContainer + containerColor = MaterialTheme.colorScheme.tertiaryContainer ) ) { Row( diff --git a/app/src/main/java/illyan/jay/ui/components/Breadcrumb.kt b/app/src/main/java/illyan/jay/ui/components/Breadcrumb.kt index 7b81c0d..4508937 100644 --- a/app/src/main/java/illyan/jay/ui/components/Breadcrumb.kt +++ b/app/src/main/java/illyan/jay/ui/components/Breadcrumb.kt @@ -18,8 +18,12 @@ package illyan.jay.ui.components -import androidx.compose.animation.* +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.ExperimentalAnimationApi +import androidx.compose.animation.animateContentSize import androidx.compose.animation.core.MutableTransitionState +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.height diff --git a/app/src/main/java/illyan/jay/ui/components/JayDialogContent.kt b/app/src/main/java/illyan/jay/ui/components/JayDialogContent.kt index 99080bb..899b428 100644 --- a/app/src/main/java/illyan/jay/ui/components/JayDialogContent.kt +++ b/app/src/main/java/illyan/jay/ui/components/JayDialogContent.kt @@ -40,7 +40,6 @@ import androidx.compose.ui.graphics.Shape import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import illyan.jay.ui.theme.statefulColorScheme /** * Custom dialog content styling used (based on Material 3 AlertDialogContent) @@ -63,7 +62,7 @@ fun JayDialogContent( titleContentColor: Color = AlertDialogDefaults.titleContentColor, textContentColor: Color = AlertDialogDefaults.textContentColor, tonalElevation: Dp = AlertDialogDefaults.TonalElevation, - buttonContentColor: Color = MaterialTheme.statefulColorScheme.primary, + buttonContentColor: Color = MaterialTheme.colorScheme.primary, ) { JayDialogContent( modifier = modifier, diff --git a/app/src/main/java/illyan/jay/ui/components/Licenses.kt b/app/src/main/java/illyan/jay/ui/components/Licenses.kt index 4b32c18..6204246 100644 --- a/app/src/main/java/illyan/jay/ui/components/Licenses.kt +++ b/app/src/main/java/illyan/jay/ui/components/Licenses.kt @@ -28,6 +28,7 @@ import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -46,8 +47,6 @@ import androidx.compose.ui.unit.dp import illyan.compose.scrollbar.drawVerticalScrollbar import illyan.jay.R import illyan.jay.domain.model.libraries.LicenseType -import illyan.jay.ui.theme.statefulColorScheme -import illyan.jay.ui.theme.surfaceColorAtElevation import illyan.jay.util.findUrlIntervals import kotlin.math.hypot @@ -69,7 +68,7 @@ fun JayTextCard( modifier = modifier .drawVerticalScrollbar(lazyListState) .clip(RoundedCornerShape(cornerRadius)) - .background(MaterialTheme.statefulColorScheme.surfaceColorAtElevation(2.dp)), + .background(MaterialTheme.colorScheme.surfaceColorAtElevation(2.dp)), state = lazyListState, contentPadding = contentPadding, ) { @@ -208,7 +207,7 @@ fun ApacheV2License( } ClickableText( - style = TextStyle(color = MaterialTheme.statefulColorScheme.onSurface), + style = TextStyle(color = MaterialTheme.colorScheme.onSurface), onClick = { offset -> val urlAnnotations = annotatedString.getUrlAnnotations(offset, offset) urlAnnotations.firstOrNull()?.let { @@ -251,7 +250,7 @@ fun FreeBSDLicense( } Text( - style = TextStyle(color = MaterialTheme.statefulColorScheme.onSurface), + style = TextStyle(color = MaterialTheme.colorScheme.onSurface), text = annotatedString ) } @@ -277,7 +276,7 @@ fun EclipsePublicLicense() { } Text( - style = TextStyle(color = MaterialTheme.statefulColorScheme.onSurface), + style = TextStyle(color = MaterialTheme.colorScheme.onSurface), text = annotatedString ) } @@ -314,7 +313,7 @@ fun GPLV2License( } Text( - style = TextStyle(color = MaterialTheme.statefulColorScheme.onSurface), + style = TextStyle(color = MaterialTheme.colorScheme.onSurface), text = annotatedString ) } @@ -372,7 +371,7 @@ fun GPLV3License( } ClickableText( - style = TextStyle(color = MaterialTheme.statefulColorScheme.onSurface), + style = TextStyle(color = MaterialTheme.colorScheme.onSurface), onClick = { offset -> val urlAnnotations = annotatedString.getUrlAnnotations(offset, offset) urlAnnotations.firstOrNull()?.let { @@ -436,7 +435,7 @@ fun JayGPLV3License( Column { ClickableText( - style = TextStyle(color = MaterialTheme.statefulColorScheme.onSurface), + style = TextStyle(color = MaterialTheme.colorScheme.onSurface), onClick = { offset -> val urlAnnotations = annotatedString.getUrlAnnotations(offset, offset) urlAnnotations.firstOrNull()?.let { diff --git a/app/src/main/java/illyan/jay/ui/components/Tooltip.kt b/app/src/main/java/illyan/jay/ui/components/Tooltip.kt index 0d2bfff..3c6f74f 100644 --- a/app/src/main/java/illyan/jay/ui/components/Tooltip.kt +++ b/app/src/main/java/illyan/jay/ui/components/Tooltip.kt @@ -53,7 +53,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import illyan.jay.R -import illyan.jay.ui.theme.statefulColorScheme import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -160,10 +159,10 @@ fun TooltipButton( } ), shape = ButtonDefaults.shape, - color = MaterialTheme.statefulColorScheme.primary + color = MaterialTheme.colorScheme.primary ) { CompositionLocalProvider( - LocalContentColor provides MaterialTheme.statefulColorScheme.onPrimary, + LocalContentColor provides MaterialTheme.colorScheme.onPrimary, LocalTextStyle provides MaterialTheme.typography.labelLarge ) { Row( @@ -202,8 +201,8 @@ fun ContentWithTooltip( } PlainTooltipBox( modifier = modifier, - containerColor = MaterialTheme.statefulColorScheme.surfaceVariant, - contentColor = MaterialTheme.statefulColorScheme.onSurfaceVariant, + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant, tooltip = currentTooltip, tooltipState = tooltipState, ) { @@ -220,7 +219,7 @@ fun CopiedToKeyboardTooltip() { Icon( imageVector = Icons.Rounded.Done, contentDescription = "", - tint = MaterialTheme.statefulColorScheme.primary + tint = MaterialTheme.colorScheme.primary ) Text(text = stringResource(R.string.copied_to_clipboard)) } diff --git a/app/src/main/java/illyan/jay/ui/freedrive/FreeDrive.kt b/app/src/main/java/illyan/jay/ui/freedrive/FreeDrive.kt index a5b5383..3a4747e 100644 --- a/app/src/main/java/illyan/jay/ui/freedrive/FreeDrive.kt +++ b/app/src/main/java/illyan/jay/ui/freedrive/FreeDrive.kt @@ -66,7 +66,6 @@ import illyan.jay.ui.menu.MenuNavGraph import illyan.jay.ui.menu.SheetScreenBackPressHandler import illyan.jay.ui.settings.user.BooleanSetting import illyan.jay.ui.theme.JayTheme -import illyan.jay.ui.theme.statefulColorScheme import illyan.jay.util.plus private const val PaddingRatio = 0.25f @@ -209,12 +208,12 @@ fun FreeDriveScreenWithoutPermission( Text( text = stringResource(R.string.location_permission_denied_title), style = MaterialTheme.typography.titleLarge, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) Text( text = stringResource(R.string.location_permission_denied_description), style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) Column( modifier = Modifier.fillMaxWidth(), diff --git a/app/src/main/java/illyan/jay/ui/home/Home.kt b/app/src/main/java/illyan/jay/ui/home/Home.kt index 4617276..ed66f55 100644 --- a/app/src/main/java/illyan/jay/ui/home/Home.kt +++ b/app/src/main/java/illyan/jay/ui/home/Home.kt @@ -87,6 +87,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextField import androidx.compose.material3.TextFieldDefaults +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -166,8 +167,6 @@ import illyan.jay.ui.search.SearchViewModel import illyan.jay.ui.search.SearchViewModel.Companion.KeySearchQuery import illyan.jay.ui.theme.JayTheme import illyan.jay.ui.theme.mapStyleUrl -import illyan.jay.ui.theme.statefulColorScheme -import illyan.jay.ui.theme.surfaceColorAtElevation import illyan.jay.util.extraOptions import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay @@ -598,7 +597,7 @@ fun HomeScreen( Column( modifier = Modifier .fillMaxSize() - .background(MaterialTheme.statefulColorScheme.background) + .background(MaterialTheme.colorScheme.background) .padding(bottom = SearchBarHeight - RoundedCornerRadius / 4f) ) { val initialLocationLoaded by viewModel.initialLocationLoaded.collectAsStateWithLifecycle() @@ -682,7 +681,7 @@ fun HomeScreen( Box( modifier = Modifier .fillMaxSize() - .background(MaterialTheme.statefulColorScheme.background) + .background(MaterialTheme.colorScheme.background) ) } val styleUrl by mapStyleUrl.collectAsStateWithLifecycle() @@ -789,8 +788,8 @@ fun BottomSearchBar( pressedElevation = elevation ) val cardColors = CardDefaults.elevatedCardColors( - containerColor = MaterialTheme.statefulColorScheme.surfaceColorAtElevation(2.dp), - contentColor = MaterialTheme.statefulColorScheme.onSurface + containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(2.dp), + contentColor = MaterialTheme.colorScheme.onSurface ) val focusRequester = remember { FocusRequester() } val focusManager = LocalFocusManager.current @@ -936,7 +935,7 @@ fun BottomSheetScreen( ) { ConstraintLayout( modifier = modifier - .background(MaterialTheme.statefulColorScheme.surfaceColorAtElevation(0.dp)) + .background(MaterialTheme.colorScheme.surfaceColorAtElevation(0.dp)) .layout { measurable, constraints -> val placeable = measurable.measure(constraints) _sheetContentHeight.update { (placeable.height / density).dp } @@ -961,7 +960,7 @@ fun BottomSheetScreen( modifier = Modifier .width(24.dp) .height(4.dp), - color = MaterialTheme.statefulColorScheme.surfaceVariant, + color = MaterialTheme.colorScheme.surfaceVariant, shape = RoundedCornerShape(4.dp) ) {} } diff --git a/app/src/main/java/illyan/jay/ui/libraries/Libraries.kt b/app/src/main/java/illyan/jay/ui/libraries/Libraries.kt index e65401f..ec00431 100644 --- a/app/src/main/java/illyan/jay/ui/libraries/Libraries.kt +++ b/app/src/main/java/illyan/jay/ui/libraries/Libraries.kt @@ -39,6 +39,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier @@ -63,8 +64,6 @@ import illyan.jay.ui.destinations.LibraryDialogScreenDestination import illyan.jay.ui.libraries.model.UiLibrary import illyan.jay.ui.profile.ProfileNavGraph import illyan.jay.ui.theme.JayTheme -import illyan.jay.ui.theme.statefulColorScheme -import illyan.jay.ui.theme.surfaceColorAtElevation @ProfileNavGraph @Destination @@ -126,7 +125,7 @@ fun LibrariesScreen( itemsIndexed(libraries) { index, item -> val cardColors = if (index.mod(2) == 0) { CardDefaults.cardColors( - containerColor = MaterialTheme.statefulColorScheme.surfaceColorAtElevation(3.dp) + containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(3.dp) ) } else { CardDefaults.cardColors( diff --git a/app/src/main/java/illyan/jay/ui/menu/Menu.kt b/app/src/main/java/illyan/jay/ui/menu/Menu.kt index f566ea1..4d33d41 100644 --- a/app/src/main/java/illyan/jay/ui/menu/Menu.kt +++ b/app/src/main/java/illyan/jay/ui/menu/Menu.kt @@ -54,6 +54,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue @@ -85,8 +86,6 @@ import illyan.jay.ui.home.isSearching import illyan.jay.ui.home.sheetState import illyan.jay.ui.theme.JayTheme import illyan.jay.ui.theme.LocalTheme -import illyan.jay.ui.theme.statefulColorScheme -import illyan.jay.ui.theme.surfaceColorAtElevation import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import timber.log.Timber @@ -215,8 +214,8 @@ fun MenuItemCard( icon: ImageVector? = null, cardColors: CardColors = (@Composable { CardDefaults.cardColors( - containerColor = MaterialTheme.statefulColorScheme.surfaceColorAtElevation(1.dp), - contentColor = MaterialTheme.statefulColorScheme.onSurface + containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp), + contentColor = MaterialTheme.colorScheme.onSurface ) })(), onClick: () -> Unit = {}, diff --git a/app/src/main/java/illyan/jay/ui/poi/Poi.kt b/app/src/main/java/illyan/jay/ui/poi/Poi.kt index f397ef4..21d30ef 100644 --- a/app/src/main/java/illyan/jay/ui/poi/Poi.kt +++ b/app/src/main/java/illyan/jay/ui/poi/Poi.kt @@ -71,7 +71,6 @@ import illyan.jay.ui.poi.model.PlaceMetadata import illyan.jay.ui.sheet.SheetNavGraph import illyan.jay.ui.theme.JayTheme import illyan.jay.ui.theme.mapMarkers -import illyan.jay.ui.theme.statefulColorScheme import illyan.jay.util.largeTextPlaceholder import illyan.jay.util.plus import illyan.jay.util.textPlaceholder @@ -213,7 +212,7 @@ fun PoiScreen( .largeTextPlaceholder(place == null), text = place?.name ?: stringResource(R.string.unknown), style = MaterialTheme.typography.headlineMedium, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) AnimatedVisibility( modifier = Modifier @@ -223,7 +222,7 @@ fun PoiScreen( ) { Text( text = placeMetadata?.address ?: stringResource(R.string.unknown), - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } AnimatedVisibility(visible = !placeMetadata?.categories.isNullOrEmpty()) { @@ -236,7 +235,7 @@ fun PoiScreen( Box( modifier = Modifier .clip(RoundedCornerShape(8.dp)) - .background(MaterialTheme.statefulColorScheme.primaryContainer) + .background(MaterialTheme.colorScheme.primaryContainer) ) { Text( modifier = Modifier.padding( @@ -247,7 +246,7 @@ fun PoiScreen( ), text = it.replaceFirstChar { it.uppercase() }, style = MaterialTheme.typography.labelMedium, - color = MaterialTheme.statefulColorScheme.onPrimaryContainer, + color = MaterialTheme.colorScheme.onPrimaryContainer, ) } } @@ -269,7 +268,7 @@ fun PoiScreen( .toString() } ?: stringResource(R.string.unknown), style = MaterialTheme.typography.bodySmall, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } } diff --git a/app/src/main/java/illyan/jay/ui/profile/Profile.kt b/app/src/main/java/illyan/jay/ui/profile/Profile.kt index 63afdb9..6b15df1 100644 --- a/app/src/main/java/illyan/jay/ui/profile/Profile.kt +++ b/app/src/main/java/illyan/jay/ui/profile/Profile.kt @@ -102,7 +102,6 @@ import illyan.jay.ui.destinations.LoginDialogScreenDestination import illyan.jay.ui.destinations.UserSettingsDialogScreenDestination import illyan.jay.ui.home.RoundedCornerRadius import illyan.jay.ui.theme.JayTheme -import illyan.jay.ui.theme.statefulColorScheme import java.util.UUID @RootNavGraph @@ -377,7 +376,7 @@ fun ProfileTitleScreen( Icon( imageVector = Icons.Rounded.Lock, contentDescription = "", - tint = MaterialTheme.statefulColorScheme.error + tint = MaterialTheme.colorScheme.error ) Text( text = stringResource(R.string.locked), diff --git a/app/src/main/java/illyan/jay/ui/search/Search.kt b/app/src/main/java/illyan/jay/ui/search/Search.kt index 5390d81..2a6a1de 100644 --- a/app/src/main/java/illyan/jay/ui/search/Search.kt +++ b/app/src/main/java/illyan/jay/ui/search/Search.kt @@ -50,6 +50,7 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue @@ -75,8 +76,6 @@ import illyan.jay.ui.home.RoundedCornerRadius import illyan.jay.ui.search.model.UiRecord import illyan.jay.ui.theme.JayTheme import illyan.jay.ui.theme.signaturePink -import illyan.jay.ui.theme.statefulColorScheme -import illyan.jay.ui.theme.surfaceColorAtElevation import java.util.UUID @RootNavGraph @@ -159,7 +158,7 @@ fun SearchList( modifier = Modifier.padding(SearchPadding), text = stringResource(R.string.suggestions), style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } } @@ -174,7 +173,7 @@ fun SearchList( modifier = Modifier.padding(SearchPadding), text = stringResource(R.string.favorites), style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } favoriteItems( @@ -187,7 +186,7 @@ fun SearchList( modifier = Modifier.padding(SearchPadding), text = stringResource(R.string.history), style = MaterialTheme.typography.titleMedium, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } historyItems( @@ -336,7 +335,7 @@ fun LazyListScope.searchItems( itemsIndexed(list) { index, item -> if (index > 0) { Surface( - color = MaterialTheme.statefulColorScheme.surfaceColorAtElevation(1.dp) + color = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp) ) { Divider( modifier = Modifier @@ -348,7 +347,7 @@ fun LazyListScope.searchItems( ) ), thickness = DividerThickness, - color = MaterialTheme.statefulColorScheme.surfaceColorAtElevation(0.dp) + color = MaterialTheme.colorScheme.surfaceColorAtElevation(0.dp) ) } } @@ -404,7 +403,7 @@ fun FavoriteButton( tint = if (it) { MaterialTheme.signaturePink } else { - MaterialTheme.statefulColorScheme.onSurface + MaterialTheme.colorScheme.onSurface }, contentDescription = "Favorite icon" ) @@ -503,8 +502,8 @@ fun SearchCard( modifier: Modifier = Modifier, onClick: () -> Unit = {}, cardColors: CardColors = CardDefaults.cardColors( - containerColor = MaterialTheme.statefulColorScheme.surfaceColorAtElevation(1.dp), - contentColor = MaterialTheme.statefulColorScheme.onSurface, + containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp), + contentColor = MaterialTheme.colorScheme.onSurface, ), prefixContent: @Composable () -> Unit = { IconButton( @@ -514,7 +513,7 @@ fun SearchCard( Icon( modifier = Modifier.size(32.dp), imageVector = Icons.Rounded.Search, - tint = MaterialTheme.statefulColorScheme.onSurface, + tint = MaterialTheme.colorScheme.onSurface, contentDescription = "Search Item Icon" ) } @@ -555,7 +554,7 @@ fun SearchCard( title: String = "Title", description: String = "Description", icon: ImageVector = Icons.Rounded.Search, - tint: Color = MaterialTheme.statefulColorScheme.onSurface, + tint: Color = MaterialTheme.colorScheme.onSurface, shape: Shape = CardDefaults.shape, onClick: () -> Unit = {}, prefixContent: @Composable () -> Unit = { diff --git a/app/src/main/java/illyan/jay/ui/session/Session.kt b/app/src/main/java/illyan/jay/ui/session/Session.kt index 636ba77..adbfe6a 100644 --- a/app/src/main/java/illyan/jay/ui/session/Session.kt +++ b/app/src/main/java/illyan/jay/ui/session/Session.kt @@ -102,7 +102,6 @@ import illyan.jay.ui.theme.JayTheme import illyan.jay.ui.theme.mapMarkers import illyan.jay.ui.theme.signatureBlue import illyan.jay.ui.theme.signaturePink -import illyan.jay.ui.theme.statefulColorScheme import illyan.jay.util.format import kotlinx.coroutines.delay import timber.log.Timber @@ -391,12 +390,12 @@ fun SessionDetailsScreen( Text( text = it ?: stringResource(R.string.unknown), style = MaterialTheme.typography.titleLarge, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } Icon( imageVector = Icons.Rounded.ArrowRightAlt, contentDescription = "", - tint = MaterialTheme.statefulColorScheme.onSurface, + tint = MaterialTheme.colorScheme.onSurface, ) Crossfade( modifier = Modifier.animateContentSize(), @@ -406,13 +405,13 @@ fun SessionDetailsScreen( if (it.first) { Icon( imageVector = Icons.Rounded.MoreHoriz, contentDescription = "", - tint = MaterialTheme.statefulColorScheme.onSurface, + tint = MaterialTheme.colorScheme.onSurface, ) } else { Text( text = it.second ?: stringResource(R.string.unknown), style = MaterialTheme.typography.titleLarge, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } } @@ -554,12 +553,12 @@ fun SessionDetailsList( ) { Text( text = it.first, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, fontWeight = FontWeight.Medium, ) Text( text = it.second ?: stringResource(R.string.unknown), - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } } diff --git a/app/src/main/java/illyan/jay/ui/sessions/Sessions.kt b/app/src/main/java/illyan/jay/ui/sessions/Sessions.kt index 2182b9f..d220825 100644 --- a/app/src/main/java/illyan/jay/ui/sessions/Sessions.kt +++ b/app/src/main/java/illyan/jay/ui/sessions/Sessions.kt @@ -60,6 +60,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -99,8 +100,6 @@ import illyan.jay.ui.menu.SheetScreenBackPressHandler import illyan.jay.ui.sessions.model.UiSession import illyan.jay.ui.theme.JayTheme import illyan.jay.ui.theme.signatureBlue -import illyan.jay.ui.theme.statefulColorScheme -import illyan.jay.ui.theme.surfaceColorAtElevation import illyan.jay.util.cardPlaceholder import illyan.jay.util.format import illyan.jay.util.plus @@ -532,11 +531,11 @@ fun NoSessionPrompt( Icon( imageVector = Icons.Rounded.Info, contentDescription = "", - tint = MaterialTheme.statefulColorScheme.onSurface + tint = MaterialTheme.colorScheme.onSurface ) Text( text = stringResource(R.string.no_sessions_to_show), - color = MaterialTheme.statefulColorScheme.onSurface + color = MaterialTheme.colorScheme.onSurface ) } } @@ -581,7 +580,7 @@ fun SessionLoadingIndicator( SmallCircularProgressIndicator() Text( text = text, - color = MaterialTheme.statefulColorScheme.onSurface + color = MaterialTheme.colorScheme.onSurface ) } } @@ -610,14 +609,14 @@ fun SessionCard( val deleteFromCloudAction = sessionSwipeAction( icon = Icons.Rounded.CloudOff, enabled = isDeleteFromCloudEnabled, - enabledBackgroundColor = MaterialTheme.statefulColorScheme.tertiary, + enabledBackgroundColor = MaterialTheme.colorScheme.tertiary, onSwipe = onDeleteFromCloud ) val isDeleteEnabled = session?.canDelete == true && session.isNotOngoing val deleteAction = sessionSwipeAction( icon = Icons.Rounded.Delete, enabled = isDeleteEnabled, - enabledBackgroundColor = MaterialTheme.statefulColorScheme.error, + enabledBackgroundColor = MaterialTheme.colorScheme.error, onSwipe = onDelete ) val isSyncEnabled = session?.isSynced == false && session.isNotOngoing @@ -627,10 +626,10 @@ fun SessionCard( enabledBackgroundColor = MaterialTheme.signatureBlue, onSwipe = onSync ) - val containerColor = MaterialTheme.statefulColorScheme.surfaceColorAtElevation(1.dp) + val containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp) val cardColors = CardDefaults.cardColors( containerColor = containerColor, - contentColor = MaterialTheme.statefulColorScheme.onSurface + contentColor = MaterialTheme.colorScheme.onSurface ) Card( modifier = modifier, @@ -683,12 +682,12 @@ fun SessionCard( Text( text = it ?: stringResource(R.string.unknown), style = MaterialTheme.typography.titleLarge, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } Icon( imageVector = Icons.Rounded.ArrowRightAlt, contentDescription = "", - tint = MaterialTheme.statefulColorScheme.onSurface, + tint = MaterialTheme.colorScheme.onSurface, ) Crossfade( modifier = Modifier.animateContentSize(), @@ -699,13 +698,13 @@ fun SessionCard( Icon( imageVector = Icons.Rounded.MoreHoriz, contentDescription = "", - tint = MaterialTheme.statefulColorScheme.onSurface, + tint = MaterialTheme.colorScheme.onSurface, ) } else { Text( text = it.second ?: stringResource(R.string.unknown), style = MaterialTheme.typography.titleLarge, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } } @@ -782,11 +781,11 @@ fun SessionCard( fun sessionSwipeAction( modifier: Modifier = Modifier, icon: ImageVector, - tint: Color = MaterialTheme.statefulColorScheme.onSurface, + tint: Color = MaterialTheme.colorScheme.onSurface, enabled: Boolean = true, onSwipe: () -> Unit = {}, enabledBackgroundColor: Color = Color.Transparent, - disabledBackgroundColor: Color = MaterialTheme.statefulColorScheme.surface + disabledBackgroundColor: Color = MaterialTheme.colorScheme.surface ): SwipeAction { return SwipeAction( icon = { @@ -815,12 +814,12 @@ fun SessionDetailsList( ) { Text( text = it.first, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, fontWeight = FontWeight.Medium, ) Text( text = it.second, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) } } diff --git a/app/src/main/java/illyan/jay/ui/settings/data/DataSettings.kt b/app/src/main/java/illyan/jay/ui/settings/data/DataSettings.kt index d3ba6bb..16e6d5a 100644 --- a/app/src/main/java/illyan/jay/ui/settings/data/DataSettings.kt +++ b/app/src/main/java/illyan/jay/ui/settings/data/DataSettings.kt @@ -42,6 +42,7 @@ import androidx.compose.material3.IconToggleButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -69,8 +70,6 @@ import illyan.jay.ui.home.RoundedCornerRadius import illyan.jay.ui.profile.MenuButton import illyan.jay.ui.profile.ProfileNavGraph import illyan.jay.ui.theme.JayTheme -import illyan.jay.ui.theme.statefulColorScheme -import illyan.jay.ui.theme.surfaceColorAtElevation @ProfileNavGraph @Destination @@ -192,12 +191,12 @@ fun DataSettingsButtons( Text( text = it.toString(), style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, ) Text( text = byteString, style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.statefulColorScheme.onSurface, + color = MaterialTheme.colorScheme.onSurface, fontWeight = FontWeight.SemiBold ) } @@ -306,8 +305,8 @@ fun DescriptionCard( style: TextStyle = MaterialTheme.typography.labelLarge, fontWeight: FontWeight = FontWeight.Normal, showDescription: Boolean = false, - textColor: Color = MaterialTheme.statefulColorScheme.onSurface, - color: Color = MaterialTheme.statefulColorScheme.surfaceColorAtElevation(1.dp), + textColor: Color = MaterialTheme.colorScheme.onSurface, + color: Color = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp), content: @Composable () -> Unit = {}, ) { Card( diff --git a/app/src/main/java/illyan/jay/ui/settings/user/UserSettings.kt b/app/src/main/java/illyan/jay/ui/settings/user/UserSettings.kt index 7c8700e..c476133 100644 --- a/app/src/main/java/illyan/jay/ui/settings/user/UserSettings.kt +++ b/app/src/main/java/illyan/jay/ui/settings/user/UserSettings.kt @@ -59,6 +59,7 @@ import androidx.compose.material3.MenuDefaults import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.material3.TextButton +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.derivedStateOf @@ -98,8 +99,6 @@ import illyan.jay.ui.profile.MenuButton import illyan.jay.ui.profile.ProfileNavGraph import illyan.jay.ui.settings.user.model.UiPreferences import illyan.jay.ui.theme.JayTheme -import illyan.jay.ui.theme.statefulColorScheme -import illyan.jay.ui.theme.surfaceColorAtElevation import java.time.ZoneId import java.time.ZonedDateTime import java.time.format.DateTimeFormatter @@ -320,7 +319,7 @@ private fun SyncPreferencesLabel( Icon( imageVector = Icons.Rounded.Done, contentDescription = "", - tint = MaterialTheme.statefulColorScheme.primary + tint = MaterialTheme.colorScheme.primary ) Text( text = stringResource(R.string.synced), @@ -330,7 +329,7 @@ private fun SyncPreferencesLabel( Icon( imageVector = Icons.Rounded.Close, contentDescription = "", - tint = MaterialTheme.statefulColorScheme.error + tint = MaterialTheme.colorScheme.error ) Text( text = stringResource(R.string.not_synced), @@ -377,7 +376,7 @@ private fun SyncPreferencesButton( colors = CardDefaults.cardColors( containerColor = Color.Transparent, disabledContainerColor = Color.Transparent, - disabledContentColor = MaterialTheme.statefulColorScheme.onSurfaceVariant + disabledContentColor = MaterialTheme.colorScheme.onSurfaceVariant ), enabled = canSyncPreferences, onClick = { onShouldSyncChanged(!shouldSyncPreferences) } @@ -638,7 +637,7 @@ fun BooleanSetting( Text( text = if (enabled) enabledText else disabledText, style = textStyle, - color = MaterialTheme.statefulColorScheme.onSurface + color = MaterialTheme.colorScheme.onSurface ) } Switch( @@ -684,7 +683,7 @@ fun DropdownSetting( Text( text = getValueName(it), style = textStyle, - color = MaterialTheme.statefulColorScheme.onSurface + color = MaterialTheme.colorScheme.onSurface ) } } @@ -730,7 +729,7 @@ fun DropdownSetting( } DropdownMenuItem( modifier = if (value == selectedValue) { - Modifier.background(MaterialTheme.statefulColorScheme.surfaceColorAtElevation(elevation = 1.dp)) + Modifier.background(MaterialTheme.colorScheme.surfaceColorAtElevation(elevation = 1.dp)) } else { Modifier }, @@ -740,9 +739,9 @@ fun DropdownSetting( onClick = { selectValue(value); isDropdownOpen = false }, colors = if (value == selectedValue) { MenuDefaults.itemColors( - textColor = MaterialTheme.statefulColorScheme.primary, - leadingIconColor = MaterialTheme.statefulColorScheme.primary, - trailingIconColor = MaterialTheme.statefulColorScheme.primary, + textColor = MaterialTheme.colorScheme.primary, + leadingIconColor = MaterialTheme.colorScheme.primary, + trailingIconColor = MaterialTheme.colorScheme.primary, ) } else { MenuDefaults.itemColors() @@ -784,7 +783,7 @@ fun SettingItem( text = name, style = textStyle, fontWeight = fontWeight, - color = MaterialTheme.statefulColorScheme.onSurface + color = MaterialTheme.colorScheme.onSurface ) Row { content() } } diff --git a/app/src/main/java/illyan/jay/ui/theme/StatefulColorScheme.kt b/app/src/main/java/illyan/jay/ui/theme/StatefulColorScheme.kt index d721282..3dac627 100644 --- a/app/src/main/java/illyan/jay/ui/theme/StatefulColorScheme.kt +++ b/app/src/main/java/illyan/jay/ui/theme/StatefulColorScheme.kt @@ -58,83 +58,14 @@ class StatefulColorScheme( outlineState: State, outlineVariantState: State, scrimState: State, - surfaceBrightState: State, - surfaceDimState: State, - surfaceContainerState: State, - surfaceContainerHighState: State, - surfaceContainerHighestState: State, - surfaceContainerLowState: State, - surfaceContainerLowestState: State, + surfaceBrightState: State = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), + surfaceDimState: State = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), + surfaceContainerState: State = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), + surfaceContainerHighState: State = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), + surfaceContainerHighestState: State = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), + surfaceContainerLowState: State = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), + surfaceContainerLowestState: State = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), ) { - constructor( - primaryState: State, - onPrimaryState: State, - primaryContainerState: State, - onPrimaryContainerState: State, - inversePrimaryState: State, - secondaryState: State, - onSecondaryState: State, - secondaryContainerState: State, - onSecondaryContainerState: State, - tertiaryState: State, - onTertiaryState: State, - tertiaryContainerState: State, - onTertiaryContainerState: State, - backgroundState: State, - onBackgroundState: State, - surfaceState: State, - onSurfaceState: State, - surfaceVariantState: State, - onSurfaceVariantState: State, - surfaceTintState: State, - inverseSurfaceState: State, - inverseOnSurfaceState: State, - errorState: State, - onErrorState: State, - errorContainerState: State, - onErrorContainerState: State, - outlineState: State, - outlineVariantState: State, - scrimState: State, - ) : this( - primaryState = primaryState, - onPrimaryState = onPrimaryState, - primaryContainerState = primaryContainerState, - onPrimaryContainerState = onPrimaryContainerState, - inversePrimaryState = inversePrimaryState, - secondaryState = secondaryState, - onSecondaryState = onSecondaryState, - secondaryContainerState = secondaryContainerState, - onSecondaryContainerState = onSecondaryContainerState, - tertiaryState = tertiaryState, - onTertiaryState = onTertiaryState, - tertiaryContainerState = tertiaryContainerState, - onTertiaryContainerState = onTertiaryContainerState, - backgroundState = backgroundState, - onBackgroundState = onBackgroundState, - surfaceState = surfaceState, - onSurfaceState = onSurfaceState, - surfaceVariantState = surfaceVariantState, - onSurfaceVariantState = onSurfaceVariantState, - surfaceTintState = surfaceTintState, - inverseSurfaceState = inverseSurfaceState, - inverseOnSurfaceState = inverseOnSurfaceState, - errorState = errorState, - onErrorState = onErrorState, - errorContainerState = errorContainerState, - onErrorContainerState = onErrorContainerState, - outlineState = outlineState, - outlineVariantState = outlineVariantState, - scrimState = scrimState, - surfaceBrightState = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), - surfaceDimState = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), - surfaceContainerState = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), - surfaceContainerHighState = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), - surfaceContainerHighestState = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), - surfaceContainerLowState = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), - surfaceContainerLowestState = mutableStateOf(Color.Unspecified, structuralEqualityPolicy()), - ) - constructor( colorScheme: ColorScheme, ) : this( @@ -471,4 +402,36 @@ class StatefulColorScheme( "surfaceContainerLowestState=$surfaceContainerLowestState" + ")" } + + fun toColorScheme() = ColorScheme( + primary = primary, + onPrimary = onPrimary, + primaryContainer = primaryContainer, + onPrimaryContainer = onPrimaryContainer, + inversePrimary = inversePrimary, + secondary = secondary, + onSecondary = onSecondary, + secondaryContainer = secondaryContainer, + onSecondaryContainer = onSecondaryContainer, + tertiary = tertiary, + onTertiary = onTertiary, + tertiaryContainer = tertiaryContainer, + onTertiaryContainer = onTertiaryContainer, + background = background, + onBackground = onBackground, + surface = surface, + onSurface = onSurface, + surfaceVariant = surfaceVariant, + onSurfaceVariant = onSurfaceVariant, + surfaceTint = surfaceTint, + inverseSurface = inverseSurface, + inverseOnSurface = inverseOnSurface, + error = error, + onError = onError, + errorContainer = errorContainer, + onErrorContainer = onErrorContainer, + outline = outline, + outlineVariant = outlineVariant, + scrim = scrim, + ) } diff --git a/app/src/main/java/illyan/jay/ui/theme/Theme.kt b/app/src/main/java/illyan/jay/ui/theme/Theme.kt index a7b0412..3c4da9a 100644 --- a/app/src/main/java/illyan/jay/ui/theme/Theme.kt +++ b/app/src/main/java/illyan/jay/ui/theme/Theme.kt @@ -21,6 +21,7 @@ package illyan.jay.ui.theme import android.app.Activity import androidx.compose.animation.animateColorAsState import androidx.compose.animation.core.AnimationSpec +import androidx.compose.animation.core.Spring import androidx.compose.animation.core.spring import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.ColorScheme @@ -36,13 +37,10 @@ import androidx.compose.runtime.compositionLocalOf import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.remember -import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.compositeOver import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalView -import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.core.view.WindowCompat import androidx.hilt.navigation.compose.hiltViewModel @@ -53,7 +51,6 @@ import illyan.jay.domain.model.Theme import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update -import kotlin.math.ln import kotlin.math.roundToInt private val LightColors = lightColorScheme( @@ -215,7 +212,6 @@ private lateinit var lightMapMarkers: MapMarkers private val _mapMarkers = MutableStateFlow(null) val mapMarkers = _mapMarkers.asStateFlow() -internal val LocalStatefulColorScheme = staticCompositionLocalOf { null } val LocalTheme = compositionLocalOf { null } @Composable @@ -257,7 +253,7 @@ fun JayTheme( } } val systemUiController = rememberSystemUiController() - val colorSchemeState = animateColorScheme(colorScheme, spring()) + val colorSchemeState = animateColorScheme(colorScheme, spring(stiffness = Spring.StiffnessLow)) val view = LocalView.current val density = LocalDensity.current.density val markerHeight = (36.dp * density).value.roundToInt() @@ -295,11 +291,10 @@ fun JayTheme( } CompositionLocalProvider( - LocalStatefulColorScheme provides colorSchemeState, LocalTheme provides theme, ) { MaterialTheme( - colorScheme = colorScheme, + colorScheme = colorSchemeState.toColorScheme(), typography = Typography, content = content ) @@ -311,24 +306,3 @@ val MaterialTheme.signatureBlue: Color val MaterialTheme.signaturePink: Color get() = Color(0xFFFF63A0) - -val MaterialTheme.statefulColorScheme: StatefulColorScheme - @Composable - get() = LocalStatefulColorScheme.current ?: StatefulColorScheme(colorScheme = this.colorScheme) - -@Composable -fun StatefulColorScheme.surfaceColorAtElevation( - elevation: Dp, -): Color { - val color by remember { - derivedStateOf { - if (elevation == 0.dp) { - surface - } else { - val alpha = ((4.5f * ln(elevation.value + 1)) + 2f) / 100f - surfaceTint.copy(alpha = alpha).compositeOver(surface) - } - } - } - return color -} diff --git a/app/src/main/java/illyan/jay/util/Util.kt b/app/src/main/java/illyan/jay/util/Util.kt index 7c59f60..4ac5969 100644 --- a/app/src/main/java/illyan/jay/util/Util.kt +++ b/app/src/main/java/illyan/jay/util/Util.kt @@ -49,7 +49,6 @@ import com.mapbox.geojson.Point import com.mapbox.maps.CameraOptions import com.mapbox.maps.EdgeInsets import illyan.jay.domain.model.DomainLocation -import illyan.jay.ui.theme.statefulColorScheme import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.Deferred import kotlinx.coroutines.awaitAll @@ -168,7 +167,7 @@ fun Modifier.textPlaceholder( visible = visible, highlight = placeholderHighlight ?: PlaceholderHighlight.shimmer(), shape = shape, - color = MaterialTheme.statefulColorScheme.surfaceVariant, + color = MaterialTheme.colorScheme.surfaceVariant, ) } @@ -181,7 +180,7 @@ fun Modifier.largeTextPlaceholder( visible = visible, highlight = placeholderHighlight ?: PlaceholderHighlight.shimmer(), shape = shape, - color = MaterialTheme.statefulColorScheme.surfaceVariant, + color = MaterialTheme.colorScheme.surfaceVariant, ) } @@ -194,7 +193,7 @@ fun Modifier.cardPlaceholder( visible = visible, highlight = placeholderHighlight ?: PlaceholderHighlight.shimmer(), shape = shape, - color = MaterialTheme.statefulColorScheme.surfaceVariant, + color = MaterialTheme.colorScheme.surfaceVariant, ) }