From 8609c8b22ea7367a7852e24c9ce4e1bb3bedac3d Mon Sep 17 00:00:00 2001 From: ArthurKun <16458204+ArthurKun21@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:55:59 +0800 Subject: [PATCH] Fix inconsistent card color caused by Compose update (#1907) --- .../battle_config_item/BattleConfigScreen.kt | 26 ++++++++++++++--- .../battle_config_item/ShuffleCardsGroup.kt | 8 +++++- .../ui/battle_config_item/SupportGroup.kt | 19 +++++++++++-- .../BattleConfigListScreen.kt | 7 ++++- .../ui/card_priority/Render.kt | 8 +++++- .../ui/fine_tune/FineTuneScreen.kt | 7 ++++- .../fate_grand_automata/ui/main/MainScreen.kt | 13 +++++++-- .../ui/more/AdvancedGroup.kt | 8 +++++- .../ui/more/MoreOptionsScreen.kt | 8 +++++- .../ui/pref_support/PreferredSupportScreen.kt | 28 +++++++++++++++---- .../fate_grand_automata/ui/spam/SpamScreen.kt | 13 +++++++-- 11 files changed, 122 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/BattleConfigScreen.kt b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/BattleConfigScreen.kt index 02e04db4c..a1a2f7aec 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/BattleConfigScreen.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/BattleConfigScreen.kt @@ -16,6 +16,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ContentCopy import androidx.compose.material.icons.filled.Delete import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -141,7 +142,11 @@ private fun BattleConfigContent( item { Card( modifier = Modifier - .padding(16.dp) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column { config.name.EditTextPreference( @@ -163,7 +168,11 @@ private fun BattleConfigContent( Card( modifier = Modifier .padding(horizontal = 16.dp) - .padding(bottom = 16.dp) + .padding(bottom = 16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { SkillCommandGroup( config = config, @@ -177,7 +186,11 @@ private fun BattleConfigContent( Card( modifier = Modifier .padding(horizontal = 16.dp) - .padding(bottom = 5.dp) + .padding(bottom = 5.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column { Row( @@ -274,7 +287,12 @@ private fun CardPrioritySummary(cardPriority: CardPriorityPerWave) { style = MaterialTheme.typography.bodyMedium ) - Card { + Card( + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) + ) { val priorityString = buildAnnotatedString { priorities.forEachIndexed { index, it -> if (index != 0) { diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/ShuffleCardsGroup.kt b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/ShuffleCardsGroup.kt index 992f5f213..cd1937103 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/ShuffleCardsGroup.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/ShuffleCardsGroup.kt @@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier @@ -24,7 +26,11 @@ fun ShuffleCardsGroup(config: BattleConfigCore) { Card( modifier = Modifier .padding(horizontal = 16.dp) - .padding(bottom = 16.dp) + .padding(bottom = 16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column( modifier = Modifier diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/SupportGroup.kt b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/SupportGroup.kt index 7bf4c27a5..94bce0cd0 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/SupportGroup.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_item/SupportGroup.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.shape.CutCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Star import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.CardDefaults.cardElevation import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -66,7 +67,11 @@ fun SupportGroup( Card( modifier = Modifier .padding(horizontal = 16.dp) - .padding(bottom = 16.dp) + .padding(bottom = 16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column( modifier = Modifier @@ -167,7 +172,11 @@ fun SupportClassPicker( elevation = cardElevation(2.dp), modifier = Modifier .padding(16.dp, 5.dp) - .fillMaxWidth() + .fillMaxWidth(), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { LazyRow( modifier = Modifier @@ -261,7 +270,11 @@ fun PreferredSummary( if (servants.isNotEmpty()) { Card( - elevation = cardElevation(2.dp) + elevation = cardElevation(2.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Text( maxSkillText, diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_list/BattleConfigListScreen.kt b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_list/BattleConfigListScreen.kt index c708bd13a..c217ad9a8 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_list/BattleConfigListScreen.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/battle_config_list/BattleConfigListScreen.kt @@ -20,6 +20,7 @@ import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Delete import androidx.compose.material3.* +import androidx.compose.material3.CardDefaults import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -384,7 +385,11 @@ private fun BattleConfigListItem( shape = RoundedCornerShape(25), elevation = CardDefaults.cardElevation(defaultElevation = if (isSelected) 5.dp else 1.dp), modifier = Modifier - .padding(5.dp) + .padding(5.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Row( verticalAlignment = Alignment.CenterVertically, diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/card_priority/Render.kt b/app/src/main/java/io/github/fate_grand_automata/ui/card_priority/Render.kt index a76fea895..99e596029 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/card_priority/Render.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/card_priority/Render.kt @@ -6,9 +6,11 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.Checkbox import androidx.compose.material3.ListItem import androidx.compose.material3.Text +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue @@ -37,7 +39,11 @@ fun CardPriorityListItem.Render( Card( modifier = Modifier - .padding(16.dp) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Row( verticalAlignment = Alignment.CenterVertically diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/fine_tune/FineTuneScreen.kt b/app/src/main/java/io/github/fate_grand_automata/ui/fine_tune/FineTuneScreen.kt index 7e6915608..0eaf6f275 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/fine_tune/FineTuneScreen.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/fine_tune/FineTuneScreen.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExtendedFloatingActionButton import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -47,7 +48,11 @@ fun FineTuneScreen( Card( modifier = Modifier .padding(horizontal = 16.dp) - .padding(bottom = 16.dp) + .padding(bottom = 16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { it.FineTuneSetter() } diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/main/MainScreen.kt b/app/src/main/java/io/github/fate_grand_automata/ui/main/MainScreen.kt index 01dfcab9b..1c47ceec5 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/main/MainScreen.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/main/MainScreen.kt @@ -19,6 +19,7 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Language import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.ExtendedFloatingActionButton import androidx.compose.material3.Icon @@ -262,7 +263,11 @@ private fun MainScreenContent( item { Card( modifier = Modifier - .padding(16.dp) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column { Preference( @@ -356,7 +361,11 @@ private fun AccessibilityServiceBlock( Card( modifier = Modifier .padding(horizontal = 16.dp) - .fillMaxWidth() + .fillMaxWidth(), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column( modifier = Modifier diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/more/AdvancedGroup.kt b/app/src/main/java/io/github/fate_grand_automata/ui/more/AdvancedGroup.kt index 38de41393..3e816b4f9 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/more/AdvancedGroup.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/more/AdvancedGroup.kt @@ -10,9 +10,11 @@ import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Fullscreen import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.CardDefaults.cardElevation import androidx.compose.material3.Switch import androidx.compose.material3.Text +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -96,7 +98,11 @@ fun LazyListScope.advancedGroup( AnimatedVisibility(gameAreaMode == GameAreaMode.Custom) { Card( modifier = Modifier.padding(5.dp), - elevation = cardElevation(5.dp) + elevation = cardElevation(5.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column( modifier = Modifier.scale(0.9f) diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/more/MoreOptionsScreen.kt b/app/src/main/java/io/github/fate_grand_automata/ui/more/MoreOptionsScreen.kt index 2d5010d5a..7064242d4 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/more/MoreOptionsScreen.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/more/MoreOptionsScreen.kt @@ -8,7 +8,9 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.Text +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier @@ -54,7 +56,11 @@ private fun MoreOptionsContent( content = { Card( modifier = Modifier - .padding(16.dp) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { LazyColumn( contentPadding = PaddingValues(bottom = 16.dp) diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/pref_support/PreferredSupportScreen.kt b/app/src/main/java/io/github/fate_grand_automata/ui/pref_support/PreferredSupportScreen.kt index fa2caa1a3..9ac7eed72 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/pref_support/PreferredSupportScreen.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/pref_support/PreferredSupportScreen.kt @@ -9,7 +9,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.Card -import androidx.compose.material3.CardDefaults.cardColors +import androidx.compose.material3.CardDefaults import androidx.compose.material3.CardDefaults.cardElevation import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -76,7 +76,11 @@ private fun PreferredSupport( item { Card( modifier = Modifier - .padding(16.dp) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column( modifier = Modifier @@ -121,7 +125,11 @@ private fun PreferredSupport( item { Card( modifier = Modifier - .padding(16.dp) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column( modifier = Modifier @@ -148,7 +156,11 @@ private fun PreferredSupport( item { Card( modifier = Modifier - .padding(16.dp) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column { PreferenceGroupHeader( @@ -182,7 +194,11 @@ private fun PreferredSupport( item { Card( modifier = Modifier - .padding(16.dp) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { PreferredSupportHelp() } @@ -240,7 +256,7 @@ private fun MaxSkills( Card( elevation = cardElevation(5.dp), - colors = cardColors( + colors = CardDefaults.cardColors( containerColor = backgroundColor, contentColor = foregroundColor ) diff --git a/app/src/main/java/io/github/fate_grand_automata/ui/spam/SpamScreen.kt b/app/src/main/java/io/github/fate_grand_automata/ui/spam/SpamScreen.kt index 9c90e82cd..501c01a43 100644 --- a/app/src/main/java/io/github/fate_grand_automata/ui/spam/SpamScreen.kt +++ b/app/src/main/java/io/github/fate_grand_automata/ui/spam/SpamScreen.kt @@ -15,6 +15,7 @@ import androidx.compose.foundation.lazy.items import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.ListItem import androidx.compose.material3.MaterialTheme @@ -217,14 +218,22 @@ private fun SpamView( Column { Card( modifier = Modifier - .padding(16.dp) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { NpSpamView(spamConfig = selectedConfig.np) } Card( modifier = Modifier - .padding(horizontal = 16.dp) + .padding(horizontal = 16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant + ) ) { Column { selectedConfig.skills.mapIndexed { index, skillConfig ->