Restore navbar colors

This commit is contained in:
Oscar Mira 2025-04-09 01:16:33 +02:00
parent 47740b9c5b
commit 3d5a2da2b6
No known key found for this signature in database
GPG key ID: B371B98C5DC32237
6 changed files with 27 additions and 25 deletions

View file

@ -47,7 +47,7 @@ import kotlinx.coroutines.launch
import org.signal.core.ui.compose.BottomSheets
import org.signal.core.ui.compose.Buttons
import org.signal.core.ui.compose.theme.SignalTheme
import org.signal.core.ui.compose.theme.attributeColor
import org.signal.core.ui.compose.theme.colorAttribute
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.compose.ComposeBottomSheetDialogFragment
@ -234,7 +234,7 @@ private fun SafetyTipPreview() {
private fun SafetyTip(safetyTip: SafetyTipData) {
Surface(
shape = RoundedCornerShape(18.dp),
color = attributeColor(id = R.attr.safety_tip_background),
color = colorAttribute(id = R.attr.safety_tip_background),
contentColor = MaterialTheme.colorScheme.onSurface,
modifier = Modifier
.fillMaxWidth()
@ -247,7 +247,7 @@ private fun SafetyTip(safetyTip: SafetyTipData) {
) {
Surface(
shape = RoundedCornerShape(12.dp),
color = attributeColor(id = R.attr.safety_tip_image_background),
color = colorAttribute(id = R.attr.safety_tip_image_background),
modifier = Modifier
.padding(12.dp)
.fillMaxWidth()

View file

@ -23,8 +23,10 @@ import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults
import androidx.compose.material3.NavigationRail
import androidx.compose.material3.NavigationRailItem
import androidx.compose.material3.NavigationRailItemDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@ -58,7 +60,7 @@ import com.airbnb.lottie.compose.rememberLottieDynamicProperties
import com.airbnb.lottie.compose.rememberLottieDynamicProperty
import org.signal.core.ui.compose.Previews
import org.signal.core.ui.compose.SignalPreview
import org.signal.core.ui.compose.theme.SignalTheme
import org.signal.core.ui.compose.theme.colorAttribute
import org.thoughtcrime.securesms.R
private val LOTTIE_SIZE = 28.dp
@ -101,7 +103,7 @@ fun MainNavigationBar(
onDestinationSelected: (MainNavigationDestination) -> Unit
) {
NavigationBar(
containerColor = SignalTheme.colors.colorSurface2,
containerColor = colorAttribute(R.attr.navbar_container_color),
contentColor = MaterialTheme.colorScheme.onSurface,
modifier = Modifier.height(if (state.compact) 48.dp else 80.dp)
) {
@ -123,6 +125,9 @@ fun MainNavigationBar(
val selected = state.selectedDestination == destination
NavigationBarItem(
colors = NavigationBarItemDefaults.colors(
indicatorColor = colorAttribute(R.attr.navbar_active_indicator_color),
),
selected = selected,
icon = {
NavigationDestinationIcon(
@ -209,7 +214,7 @@ fun MainNavigationRail(
onDestinationSelected: (MainNavigationDestination) -> Unit
) {
NavigationRail(
containerColor = SignalTheme.colors.colorSurface1,
containerColor = colorAttribute(R.attr.navbar_container_color),
header = {
FilledTonalIconButton(
onClick = { },
@ -263,6 +268,9 @@ fun MainNavigationRail(
Box {
NavigationRailItem(
colors = NavigationRailItemDefaults.colors(
indicatorColor = colorAttribute(R.attr.navbar_active_indicator_color)
),
modifier = Modifier.padding(bottom = if (MainNavigationDestination.entries.lastIndex == idx) 0.dp else 16.dp),
icon = {
NavigationDestinationIcon(

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?attr/navbar_active_indicator_color" />
<corners android:radius="18dp" />
</shape>

View file

@ -369,7 +369,7 @@
<!-- signal_context_menu_background.xml -->
<item name="context_menu_container_color">@color/molly_surface_container_light</item>
<!-- conversation_tab_icon_background.xml, conversation_list_tabs*.xml -->
<!-- MainNavigation.kt -->
<item name="navbar_active_indicator_color">@color/molly_secondary_container_light</item>
<item name="navbar_container_color">@color/molly_surface_container_light</item>
</style>
@ -535,7 +535,7 @@
<!-- signal_context_menu_background.xml -->
<item name="context_menu_container_color">@color/molly_surface_container_high_dark</item>
<!-- conversation_tab_icon_background.xml, conversation_list_tabs*.xml -->
<!-- MainNavigation.kt -->
<item name="navbar_active_indicator_color">@color/molly_surface_bright_dark</item>
<item name="navbar_container_color">@color/molly_surface_container_dark</item>
</style>

View file

@ -46,7 +46,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.signal.core.ui.R
import org.signal.core.ui.compose.theme.SignalTheme
import org.signal.core.ui.compose.theme.attributeColor
import org.signal.core.ui.compose.theme.colorAttribute
object Buttons {
@ -99,8 +99,8 @@ object Buttons {
enabled: Boolean = true,
shape: Shape = ButtonDefaults.filledTonalShape,
colors: ButtonColors = ButtonDefaults.filledTonalButtonColors(
containerColor = attributeColor(R.attr.extended_action_button_container_color),
contentColor = attributeColor(R.attr.extended_action_button_icon_color)
containerColor = colorAttribute(R.attr.extended_action_button_container_color),
contentColor = colorAttribute(R.attr.extended_action_button_icon_color)
),
elevation: ButtonElevation? = ButtonDefaults.filledTonalButtonElevation(),
border: BorderStroke? = null,
@ -129,8 +129,8 @@ object Buttons {
enabled: Boolean = true,
shape: Shape = ButtonDefaults.filledTonalShape,
colors: ButtonColors = ButtonDefaults.filledTonalButtonColors(
containerColor = attributeColor(R.attr.extended_action_button_container_color),
contentColor = attributeColor(R.attr.extended_action_button_icon_color)
containerColor = colorAttribute(R.attr.extended_action_button_container_color),
contentColor = colorAttribute(R.attr.extended_action_button_icon_color)
),
elevation: ButtonElevation? = ButtonDefaults.filledTonalButtonElevation(),
border: BorderStroke? = null,
@ -160,8 +160,8 @@ object Buttons {
shape: Shape = ButtonDefaults.shape,
tonal: Boolean = false,
colors: ButtonColors = if (tonal) ButtonDefaults.filledTonalButtonColors(
containerColor = attributeColor(R.attr.extended_action_button_container_color),
contentColor = attributeColor(R.attr.extended_action_button_icon_color)
containerColor = colorAttribute(R.attr.extended_action_button_container_color),
contentColor = colorAttribute(R.attr.extended_action_button_icon_color)
) else ButtonDefaults.buttonColors(),
elevation: ButtonElevation? = ButtonDefaults.buttonElevation(),
border: BorderStroke? = null,
@ -205,7 +205,7 @@ object Buttons {
painter = painterResource(iconResId),
contentDescription = null,
modifier = Modifier.padding(16.dp),
colorFilter = ColorFilter.tint(attributeColor(R.attr.extended_action_button_icon_color))
colorFilter = ColorFilter.tint(colorAttribute(R.attr.extended_action_button_icon_color))
)
}
}
@ -227,8 +227,8 @@ object Buttons {
shape = RoundedCornerShape(18.dp),
modifier = Modifier.size(56.dp),
colors = IconButtonDefaults.filledTonalIconButtonColors(
containerColor = attributeColor(R.attr.extended_action_button_container_color),
contentColor = attributeColor(R.attr.extended_action_button_icon_color)
containerColor = colorAttribute(R.attr.extended_action_button_container_color),
contentColor = colorAttribute(R.attr.extended_action_button_icon_color)
),
enabled = enabled,
content = imageContent

View file

@ -277,7 +277,7 @@ private fun snackbarColors(colorScheme: ColorScheme, isDarkMode: Boolean, isDyna
}
@Composable
fun attributeColor(@AttrRes id: Int): Color {
fun colorAttribute(@AttrRes id: Int): Color {
val theme = LocalContext.current.theme
val typedValue = TypedValue()
return if (theme.resolveAttribute(id, typedValue, true) && typedValue.resourceId != 0) {