From a84ba25a79c586a75d8ca1aa168e96c9aa3da2c0 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Mon, 15 Jul 2024 17:35:41 +1000 Subject: [PATCH] Migrating to Material3 --- app/build.gradle | 2 +- .../ui/DisappearingMessages.kt | 2 +- .../start/home/StartConversation.kt | 6 +- .../start/invitefriend/InviteFriend.kt | 4 +- .../start/newmessage/NewMessage.kt | 4 +- .../conversation/v2/MessageDetailActivity.kt | 6 +- .../thoughtcrime/securesms/home/EmptyView.kt | 4 +- .../securesms/home/SeedReminder.kt | 2 +- .../securesms/onboarding/landing/Landing.kt | 24 +++-- .../onboarding/loadaccount/LoadAccount.kt | 4 +- .../securesms/onboarding/loading/Loading.kt | 2 +- .../MessageNotifications.kt | 2 +- .../onboarding/pickname/PickDisplayName.kt | 2 +- .../securesms/preferences/QRCodeActivity.kt | 2 +- .../recoverypassword/RecoveryPassword.kt | 2 +- .../thoughtcrime/securesms/ui/AlertDialog.kt | 27 +++--- .../org/thoughtcrime/securesms/ui/Carousel.kt | 26 ++--- .../thoughtcrime/securesms/ui/Components.kt | 32 +++---- .../securesms/ui/components/AppBar.kt | 6 +- .../securesms/ui/components/Border.kt | 2 +- .../securesms/ui/components/Button.kt | 22 ++--- .../securesms/ui/components/ButtonStyle.kt | 8 +- .../securesms/ui/components/ButtonType.kt | 23 ++--- .../components/CircularProgressIndicator.kt | 6 +- .../securesms/ui/components/QR.kt | 22 ++--- .../securesms/ui/components/QrImage.kt | 13 ++- .../securesms/ui/components/RadioButton.kt | 6 +- .../securesms/ui/components/SessionTabRow.kt | 29 +++--- .../securesms/ui/components/Text.kt | 6 +- .../securesms/ui/theme/SessionTypography.kt | 25 +---- .../securesms/ui/theme/ThemeColors.kt | 95 +++++++++++-------- .../thoughtcrime/securesms/ui/theme/Themes.kt | 11 +-- 32 files changed, 204 insertions(+), 223 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b61e470001..afd8952dbd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -380,7 +380,7 @@ dependencies { implementation "androidx.compose.ui:ui-tooling:$composeVersion" implementation "androidx.compose.runtime:runtime-livedata:$composeVersion" implementation "androidx.compose.foundation:foundation-layout:$composeVersion" - implementation "androidx.compose.material:material:$composeVersion" + implementation "androidx.compose.material3:material3:1.2.1" androidTestImplementation "androidx.compose.ui:ui-test-junit4-android:$composeVersion" debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion" diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/DisappearingMessages.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/DisappearingMessages.kt index 46d301cdc4..ae17e6a09b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/DisappearingMessages.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/ui/DisappearingMessages.kt @@ -9,7 +9,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/home/StartConversation.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/home/StartConversation.kt index 5647fc9345..fcf13c9cf1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/home/StartConversation.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/home/StartConversation.kt @@ -7,9 +7,9 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/invitefriend/InviteFriend.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/invitefriend/InviteFriend.kt index 848afbe6b1..54abf66303 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/invitefriend/InviteFriend.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/invitefriend/InviteFriend.kt @@ -8,8 +8,8 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/newmessage/NewMessage.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/newmessage/NewMessage.kt index 14b93df571..510d666c49 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/start/newmessage/NewMessage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/start/newmessage/NewMessage.kt @@ -14,8 +14,8 @@ import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt index 31b49ebd41..9514552d28 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/MessageDetailActivity.kt @@ -27,9 +27,9 @@ import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Icon -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/EmptyView.kt b/app/src/main/java/org/thoughtcrime/securesms/home/EmptyView.kt index cc5f9c9a97..aa4e0d9017 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/EmptyView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/EmptyView.kt @@ -3,8 +3,8 @@ package org.thoughtcrime.securesms.home import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding -import androidx.compose.material.Icon -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/SeedReminder.kt b/app/src/main/java/org/thoughtcrime/securesms/home/SeedReminder.kt index ad2c660e78..33bdd2f2f6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/SeedReminder.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/SeedReminder.kt @@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.requiredWidth import androidx.compose.foundation.layout.width -import androidx.compose.material.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/landing/Landing.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/landing/Landing.kt index afb49a5e41..e40328b1d8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/landing/Landing.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/landing/Landing.kt @@ -5,6 +5,7 @@ import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.tween import androidx.compose.animation.fadeIn import androidx.compose.animation.slideInVertically +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -16,9 +17,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.Card -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -39,16 +39,16 @@ import network.loki.messenger.R import org.thoughtcrime.securesms.ui.AlertDialog import org.thoughtcrime.securesms.ui.DialogButtonModel import org.thoughtcrime.securesms.ui.GetString -import org.thoughtcrime.securesms.ui.theme.LocalDimensions -import org.thoughtcrime.securesms.ui.theme.PreviewTheme -import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider -import org.thoughtcrime.securesms.ui.theme.ThemeColors -import org.thoughtcrime.securesms.ui.theme.LocalColors import org.thoughtcrime.securesms.ui.components.BorderlessHtmlButton import org.thoughtcrime.securesms.ui.components.PrimaryFillButton import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton import org.thoughtcrime.securesms.ui.contentDescription +import org.thoughtcrime.securesms.ui.theme.LocalColors +import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.ui.theme.LocalType +import org.thoughtcrime.securesms.ui.theme.PreviewTheme +import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider +import org.thoughtcrime.securesms.ui.theme.ThemeColors import kotlin.time.Duration.Companion.milliseconds @Preview @@ -208,11 +208,9 @@ private fun MessageText( modifier: Modifier = Modifier, textColor: Color = Color.Unspecified ) { - Card( - modifier = modifier.fillMaxWidth(0.666f), - shape = MaterialTheme.shapes.small, - backgroundColor = color, - elevation = 0.dp + Box( + modifier = modifier.fillMaxWidth(0.666f) + .background(color = color, shape = MaterialTheme.shapes.small) ) { Text( text, diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/loadaccount/LoadAccount.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/loadaccount/LoadAccount.kt index b5c82e09ac..cc1033ee96 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/loadaccount/LoadAccount.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/loadaccount/LoadAccount.kt @@ -13,8 +13,8 @@ import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Icon -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/loading/Loading.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/loading/Loading.kt index 40468bab20..8c2e10e765 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/loading/Loading.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/loading/Loading.kt @@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.onboarding.loading import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height -import androidx.compose.material.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotifications.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotifications.kt index c63538f777..e56b55aaab 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotifications.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/messagenotifications/MessageNotifications.kt @@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayName.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayName.kt index 4a1670cd49..04124a5bfd 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayName.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/pickname/PickDisplayName.kt @@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/QRCodeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/QRCodeActivity.kt index bec9c6459c..b1fb2ab56f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/QRCodeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/QRCodeActivity.kt @@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState -import androidx.compose.material.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource diff --git a/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt b/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt index 22a6cc3f4f..5f59943432 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/recoverypassword/RecoveryPassword.kt @@ -11,7 +11,7 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt index 780a04581b..df66cef471 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/AlertDialog.kt @@ -1,5 +1,6 @@ package org.thoughtcrime.securesms.ui +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.IntrinsicSize @@ -8,11 +9,13 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.TextButton +import androidx.compose.material3.BasicAlertDialog +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -39,6 +42,7 @@ class DialogButtonModel( val onClick: () -> Unit = {}, ) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun AlertDialog( onDismissRequest: () -> Unit, @@ -48,12 +52,13 @@ fun AlertDialog( showCloseButton: Boolean = false, content: @Composable () -> Unit = {} ) { - androidx.compose.material.AlertDialog( - onDismissRequest, - shape = MaterialTheme.shapes.small, - backgroundColor = LocalColors.current.backgroundSecondary, - buttons = { - Box { + BasicAlertDialog( + onDismissRequest = onDismissRequest, + content = { + Box( + modifier = Modifier.background(color = LocalColors.current.backgroundSecondary, + shape = MaterialTheme.shapes.small) + ) { // only show the 'x' button is required if(showCloseButton) { IconButton( diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Carousel.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Carousel.kt index b9e19abb28..ea632d46e7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Carousel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Carousel.kt @@ -16,12 +16,8 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Card -import androidx.compose.material.ContentAlpha -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.LocalContentAlpha -import androidx.compose.material.LocalContentColor +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope @@ -47,19 +43,17 @@ import kotlin.math.sign @OptIn(ExperimentalFoundationApi::class) @Composable fun BoxScope.HorizontalPagerIndicator(pagerState: PagerState) { - if (pagerState.pageCount >= 2) Card( - shape = pillShape, - backgroundColor = blackAlpha40, + if (pagerState.pageCount >= 2) Box( modifier = Modifier + .background(color = blackAlpha40, shape = pillShape) .align(Alignment.BottomCenter) .padding(LocalDimensions.current.xxsSpacing) ) { Box(modifier = Modifier.padding(LocalDimensions.current.xxsSpacing)) { ClickableHorizontalPagerIndicator( pagerState = pagerState, - pageCount = pagerState.pageCount, - activeColor = Color.White, - inactiveColor = LocalColors.current.textSecondary) + pageCount = pagerState.pageCount + ) } } } @@ -76,8 +70,8 @@ fun ClickableHorizontalPagerIndicator( pageCount: Int, modifier: Modifier = Modifier, pageIndexMapping: (Int) -> Int = { it }, - activeColor: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current), - inactiveColor: Color = activeColor.copy(ContentAlpha.disabled), + activeColor: Color = Color.White, + inactiveColor: Color = LocalColors.current.disabled, indicatorWidth: Dp = LocalDimensions.current.xxsSpacing, indicatorHeight: Dp = indicatorWidth, spacing: Dp = indicatorWidth, @@ -118,8 +112,8 @@ private fun HorizontalPagerIndicator( pageCount: Int, modifier: Modifier = Modifier, pageIndexMapping: (Int) -> Int = { it }, - activeColor: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current), - inactiveColor: Color = activeColor.copy(ContentAlpha.disabled), + activeColor: Color = Color.White, + inactiveColor: Color = LocalColors.current.disabled, indicatorWidth: Dp = LocalDimensions.current.xxsSpacing, indicatorHeight: Dp = indicatorWidth, spacing: Dp = indicatorWidth, diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt index 206a2a72cc..7882bab054 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt @@ -7,6 +7,7 @@ import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.Canvas import androidx.compose.foundation.Image import androidx.compose.foundation.ScrollState +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.ColumnScope @@ -22,13 +23,14 @@ import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.material.ButtonColors -import androidx.compose.material.Card -import androidx.compose.material.Icon -import androidx.compose.material.LocalContentColor -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.TextButton +import androidx.compose.material3.ButtonColors +import androidx.compose.material3.Card +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Icon +import androidx.compose.material3.LocalContentColor +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.rememberCoroutineScope @@ -67,7 +69,6 @@ import org.thoughtcrime.securesms.ui.theme.LocalColors import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.ui.theme.LocalType import org.thoughtcrime.securesms.ui.theme.PreviewTheme -import org.thoughtcrime.securesms.ui.theme.divider import org.thoughtcrime.securesms.ui.theme.transparentButtonColors import kotlin.math.min import kotlin.math.roundToInt @@ -270,11 +271,10 @@ fun CellWithPaddingAndMargin( margin: Dp = LocalDimensions.current.spacing, content: @Composable () -> Unit ) { - Card( - backgroundColor = LocalColors.current.backgroundSecondary, - shape = MaterialTheme.shapes.medium, - elevation = 0.dp, + Box( modifier = Modifier + .background(color = LocalColors.current.backgroundSecondary, + shape = MaterialTheme.shapes.small) .wrapContentHeight() .fillMaxWidth() .padding(horizontal = margin), @@ -342,10 +342,10 @@ fun Modifier.fadingEdges( @Composable fun Divider(modifier: Modifier = Modifier, startIndent: Dp = 0.dp) { - androidx.compose.material.Divider( - modifier = modifier.padding(horizontal = LocalDimensions.current.smallSpacing), - color = LocalColors.current.divider, - startIndent = startIndent + HorizontalDivider( + modifier = modifier.padding(horizontal = LocalDimensions.current.smallSpacing) + .padding(start = startIndent), + color = LocalColors.current.borders, ) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/AppBar.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/AppBar.kt index 93490d3893..b64a482d8a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/AppBar.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/AppBar.kt @@ -5,9 +5,9 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.size -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Border.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Border.kt index f654142727..4420e91e78 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Border.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Border.kt @@ -1,7 +1,7 @@ package org.thoughtcrime.securesms.ui.components import androidx.compose.foundation.border -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.SolidColor diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Button.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Button.kt index d0844951ef..5834f2f859 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Button.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Button.kt @@ -16,8 +16,8 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding -import androidx.compose.material.ButtonColors -import androidx.compose.material.Text +import androidx.compose.material3.ButtonColors +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -66,16 +66,16 @@ fun Button( content: @Composable RowScope.() -> Unit ) { style.applyButtonConstraints { - androidx.compose.material.Button( - onClick, - modifier.heightIn(min = style.minHeight), - enabled, - interactionSource, + androidx.compose.material3.Button( + onClick = onClick, + modifier = modifier.heightIn(min = style.minHeight), + enabled = enabled, + interactionSource = interactionSource, elevation = null, - shape, - border, - colors, - contentPadding + shape = shape, + border = border, + colors = colors, + contentPadding = contentPadding ) { // Button sets LocalTextStyle, so text style is applied inside to override that. style.applyTextConstraints { diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/ButtonStyle.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/ButtonStyle.kt index ce7eb2dfe8..e8fcca06cf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/ButtonStyle.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/ButtonStyle.kt @@ -1,9 +1,9 @@ package org.thoughtcrime.securesms.ui.components import android.annotation.SuppressLint -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.LocalMinimumInteractiveComponentEnforcement -import androidx.compose.material.LocalTextStyle +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement +import androidx.compose.material3.LocalTextStyle import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.text.TextStyle @@ -14,7 +14,7 @@ import org.thoughtcrime.securesms.ui.theme.LocalType import org.thoughtcrime.securesms.ui.theme.bold interface ButtonStyle { - @OptIn(ExperimentalMaterialApi::class) + @OptIn(ExperimentalMaterial3Api::class) @SuppressLint("ComposableNaming") @Composable fun applyButtonConstraints(content: @Composable () -> Unit) { CompositionLocalProvider( diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/ButtonType.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/ButtonType.kt index b5a856b5bd..643f7a7e25 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/ButtonType.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/ButtonType.kt @@ -2,13 +2,13 @@ package org.thoughtcrime.securesms.ui.components import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.material.ButtonColors -import androidx.compose.material.ButtonDefaults +import androidx.compose.material3.ButtonColors +import androidx.compose.material3.ButtonDefaults import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.ui.theme.LocalColors +import org.thoughtcrime.securesms.ui.theme.LocalDimensions private val disabledBorder @Composable get() = BorderStroke( width = LocalDimensions.current.borderStroke, @@ -35,9 +35,9 @@ interface ButtonType { @Composable override fun buttonColors() = ButtonDefaults.buttonColors( contentColor = contentColor, - backgroundColor = Color.Unspecified, + containerColor = Color.Unspecified, disabledContentColor = LocalColors.current.disabled, - disabledBackgroundColor = Color.Unspecified + disabledContainerColor = Color.Transparent ) } @@ -47,9 +47,9 @@ interface ButtonType { @Composable override fun buttonColors() = ButtonDefaults.buttonColors( contentColor = LocalColors.current.background, - backgroundColor = LocalColors.current.text, + containerColor = LocalColors.current.text, disabledContentColor = LocalColors.current.disabled, - disabledBackgroundColor = Color.Unspecified + disabledContainerColor = Color.Transparent ) } @@ -59,9 +59,9 @@ interface ButtonType { @Composable override fun buttonColors() = ButtonDefaults.buttonColors( contentColor = LocalColors.current.primaryButtonFillText, - backgroundColor = LocalColors.current.primaryButtonFill, + containerColor = LocalColors.current.primaryButtonFill, disabledContentColor = LocalColors.current.disabled, - disabledBackgroundColor = Color.Unspecified + disabledContainerColor = Color.Transparent ) } @@ -73,8 +73,9 @@ interface ButtonType { @Composable override fun buttonColors() = ButtonDefaults.outlinedButtonColors( contentColor = color, - backgroundColor = Color.Transparent, - disabledContentColor = LocalColors.current.disabled + containerColor = Color.Transparent, + disabledContentColor = LocalColors.current.disabled, + disabledContainerColor = Color.Transparent ) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/CircularProgressIndicator.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/CircularProgressIndicator.kt index 259bbfe170..bbad82d29e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/CircularProgressIndicator.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/CircularProgressIndicator.kt @@ -1,7 +1,7 @@ package org.thoughtcrime.securesms.ui.components import androidx.compose.foundation.layout.size -import androidx.compose.material.LocalContentColor +import androidx.compose.material3.LocalContentColor import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -9,7 +9,7 @@ import androidx.compose.ui.unit.dp @Composable fun CircularProgressIndicator(color: Color = LocalContentColor.current) { - androidx.compose.material.CircularProgressIndicator( + androidx.compose.material3.CircularProgressIndicator( modifier = Modifier.size(40.dp), color = color, strokeWidth = 2.dp @@ -18,7 +18,7 @@ fun CircularProgressIndicator(color: Color = LocalContentColor.current) { @Composable fun SmallCircularProgressIndicator(color: Color = LocalContentColor.current) { - androidx.compose.material.CircularProgressIndicator( + androidx.compose.material3.CircularProgressIndicator( modifier = Modifier.size(20.dp), color = color, strokeWidth = 2.dp diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/QR.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/QR.kt index e0afc2db1b..8c72f82f09 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/QR.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/QR.kt @@ -22,11 +22,11 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Scaffold -import androidx.compose.material.Snackbar -import androidx.compose.material.SnackbarHost -import androidx.compose.material.Text -import androidx.compose.material.rememberScaffoldState +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Snackbar +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -56,8 +56,8 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch import network.loki.messenger.R import org.session.libsignal.utilities.Log -import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.ui.theme.LocalColors +import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.ui.theme.LocalType import java.util.concurrent.Executors @@ -158,13 +158,12 @@ fun ScanQrCode(errors: Flow, onScan: (String) -> Unit) { } } - val scaffoldState = rememberScaffoldState() - + val snackbarHostState = remember { SnackbarHostState() } val scope = rememberCoroutineScope() LaunchedEffect(Unit) { errors.collect { error -> - scaffoldState.snackbarHostState + snackbarHostState .takeIf { it.currentSnackbarData == null } ?.run { scope.launch { @@ -175,17 +174,16 @@ fun ScanQrCode(errors: Flow, onScan: (String) -> Unit) { // Don't use debounce() because many QR scans can come through each second, // and each scan could restart the timer which could mean no scan gets // through until the user stops scanning; quite perplexing. - showSnackbar(message = error) + snackbarHostState.showSnackbar(message = error) } } } } Scaffold( - scaffoldState = scaffoldState, snackbarHost = { SnackbarHost( - hostState = scaffoldState.snackbarHostState, + hostState = snackbarHostState, modifier = Modifier.padding(LocalDimensions.current.smallSpacing) ) { data -> Snackbar( diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/QrImage.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/QrImage.kt index c8c476244d..c5f927b4ab 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/QrImage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/QrImage.kt @@ -10,8 +10,8 @@ import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.material.Card -import androidx.compose.material.Icon +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -32,8 +32,8 @@ import androidx.compose.ui.unit.dp import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import network.loki.messenger.R -import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.ui.theme.LocalColors +import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.util.QRCodeUtilities @Composable @@ -56,10 +56,9 @@ fun QrImage( } } - Card( - backgroundColor = LocalColors.current.qrCodeBackground, - elevation = 0.dp, - modifier = modifier + Box( + modifier = modifier.background(color = LocalColors.current.qrCodeBackground, + shape = MaterialTheme.shapes.small) ) { Content(bitmap, icon, Modifier.padding(contentPadding), backgroundColor = LocalColors.current.qrCodeBackground) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/RadioButton.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/RadioButton.kt index 602bfde0eb..154c9ea3a1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/RadioButton.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/RadioButton.kt @@ -20,9 +20,9 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.selection.selectable import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.LocalContentColor -import androidx.compose.material.Text -import androidx.compose.material.TextButton +import androidx.compose.material3.LocalContentColor +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/SessionTabRow.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/SessionTabRow.kt index 960f5b9d0c..5dae714380 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/SessionTabRow.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/SessionTabRow.kt @@ -1,15 +1,15 @@ package org.thoughtcrime.securesms.ui.components import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState -import androidx.compose.material.Tab -import androidx.compose.material.TabRow -import androidx.compose.material.TabRowDefaults -import androidx.compose.material.TabRowDefaults.tabIndicatorOffset -import androidx.compose.material.Text +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Tab +import androidx.compose.material3.TabRow +import androidx.compose.material3.TabRowDefaults +import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier @@ -25,7 +25,6 @@ import org.thoughtcrime.securesms.ui.theme.LocalType import org.thoughtcrime.securesms.ui.theme.PreviewTheme import org.thoughtcrime.securesms.ui.theme.SessionColorsParameterProvider import org.thoughtcrime.securesms.ui.theme.ThemeColors -import org.thoughtcrime.securesms.ui.theme.divider private val TITLES = listOf(R.string.sessionRecoveryPassword, R.string.qrScan) @@ -33,31 +32,29 @@ private val TITLES = listOf(R.string.sessionRecoveryPassword, R.string.qrScan) @Composable fun SessionTabRow(pagerState: PagerState, titles: List) { TabRow( - backgroundColor = Color.Unspecified, + containerColor = Color.Unspecified, selectedTabIndex = pagerState.currentPage, contentColor = LocalColors.current.text, indicator = { tabPositions -> - TabRowDefaults.Indicator( + TabRowDefaults.SecondaryIndicator( Modifier.tabIndicatorOffset(tabPositions[pagerState.currentPage]), color = LocalColors.current.primary, height = LocalDimensions.current.indicatorHeight ) }, - divider = { TabRowDefaults.Divider(color = LocalColors.current.divider) }, - modifier = Modifier - .height(48.dp) - .background(color = Color.Unspecified) + divider = { HorizontalDivider(color = LocalColors.current.borders) } ) { val animationScope = rememberCoroutineScope() titles.forEachIndexed { i, it -> Tab( - i == pagerState.currentPage, + modifier = Modifier.heightIn(min = 48.dp), + selected = i == pagerState.currentPage, onClick = { animationScope.launch { pagerState.animateScrollToPage(i) } }, selectedContentColor = LocalColors.current.text, unselectedContentColor = LocalColors.current.text, ) { Text( - stringResource(id = it), + text = stringResource(id = it), style = LocalType.current.h8 ) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt index b7edb0dd56..5e09f78b65 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/components/Text.kt @@ -17,9 +17,9 @@ import androidx.compose.foundation.text.InlineTextContent import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.appendInlineContent -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/SessionTypography.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/SessionTypography.kt index 99fefce0c1..602affa6af 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/SessionTypography.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/SessionTypography.kt @@ -1,16 +1,13 @@ package org.thoughtcrime.securesms.ui.theme -import androidx.compose.material.Typography +import androidx.compose.material3.Typography import androidx.compose.runtime.Composable import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontFamily.Companion.Monospace import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.sp - fun TextStyle.bold() = TextStyle.Default.copy( fontWeight = FontWeight.Bold ) @@ -114,10 +111,9 @@ data class SessionTypography( fontWeight = FontWeight.Bold ) ) { - //todo ready to go when we switch to Material3 // An opinionated override of Material's defaults - /*@Composable + @Composable fun asMaterialTypography() = Typography( // Display displayLarge = h1, @@ -143,23 +139,6 @@ data class SessionTypography( labelLarge = extraSmall, labelMedium = fine, labelSmall = fine - )*/ - - @Composable - fun asMaterialTypography() = Typography( - h1 = h1, - h2 = h2, - h3 = h3, - h4 = h4, - h5 = h5, - h6 = h6, - subtitle1 = h7, - subtitle2 = h8, - body1 = base, - body2 = small, - button = base, - caption = small, - overline = fine ) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/ThemeColors.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/ThemeColors.kt index 354e5ac215..8d080b65b7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/ThemeColors.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/ThemeColors.kt @@ -4,12 +4,10 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.text.selection.TextSelectionColors -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.MaterialTheme -import androidx.compose.material.RadioButtonDefaults -import androidx.compose.material.TabRowDefaults -import androidx.compose.material.Text -import androidx.compose.material.primarySurface +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Text +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -37,55 +35,70 @@ interface ThemeColors { } // extra functions and properties that work for all themes -val ThemeColors.textSelectionColors get() = TextSelectionColors( - handleColor = primary, - backgroundColor = primary.copy(alpha = 0.5f) -) - -val ThemeColors.divider get() = text.copy(alpha = TabRowDefaults.DividerOpacity) +val ThemeColors.textSelectionColors + get() = TextSelectionColors( + handleColor = primary, + backgroundColor = primary.copy(alpha = 0.5f) + ) fun ThemeColors.text(isError: Boolean): Color = if (isError) danger else text fun ThemeColors.textSecondary(isError: Boolean): Color = if (isError) danger else textSecondary fun ThemeColors.textEnabled(enabled: Boolean) = if (enabled) text else disabled fun ThemeColors.borders(isError: Boolean): Color = if (isError) danger else borders -fun ThemeColors.toMaterialColors() = androidx.compose.material.Colors( - primary = background, - primaryVariant = backgroundSecondary, - secondary = background, - secondaryVariant = background, - background = background, - surface = background, - error = danger, - onPrimary = text, - onSecondary = text, - onBackground = text, - onSurface = text, - onError = text, - isLight = isLight -) +fun ThemeColors.toMaterialColors() = if (isLight) { + lightColorScheme( + primary = background, + secondary = backgroundSecondary, + tertiary = backgroundSecondary, + onPrimary = text, + onSecondary = text, + onTertiary = text, + background = background, + surface = background, + surfaceVariant = background, + onBackground = text, + onSurface = text, + scrim = blackAlpha40, + outline = text, + outlineVariant = text + ) +} else { + darkColorScheme( + primary = background, + secondary = backgroundSecondary, + tertiary = backgroundSecondary, + onPrimary = text, + onSecondary = text, + onTertiary = text, + background = background, + surface = background, + surfaceVariant = background, + onBackground = text, + onSurface = text, + scrim = blackAlpha40, + outline = text, + outlineVariant = text + ) +} -@Composable -fun ThemeColors.radioButtonColors() = RadioButtonDefaults.colors( - selectedColor = primary, - unselectedColor = text, - disabledColor = disabled -) - @Composable fun transparentButtonColors() = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent, - disabledBackgroundColor = Color.Transparent, + containerColor = Color.Transparent, + disabledContainerColor = Color.Transparent, disabledContentColor = LocalColors.current.disabled ) @Composable -fun dangerButtonColors() = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent, contentColor = LocalColors.current.danger) +fun dangerButtonColors() = ButtonDefaults.buttonColors( + containerColor = Color.Transparent, + contentColor = LocalColors.current.danger +) // Our themes -data class ClassicDark(override val primary: Color = primaryGreen): ThemeColors { +data class ClassicDark(override val primary: Color = primaryGreen) : ThemeColors { override val isLight = false override val danger = dangerDark override val disabled = disabledDark @@ -103,7 +116,7 @@ data class ClassicDark(override val primary: Color = primaryGreen): ThemeColors override val primaryButtonFillText = Color.Black } -data class ClassicLight(override val primary: Color = primaryGreen): ThemeColors { +data class ClassicLight(override val primary: Color = primaryGreen) : ThemeColors { override val isLight = true override val danger = dangerLight override val disabled = disabledLight @@ -121,7 +134,7 @@ data class ClassicLight(override val primary: Color = primaryGreen): ThemeColors override val primaryButtonFillText = Color.White } -data class OceanDark(override val primary: Color = primaryBlue): ThemeColors { +data class OceanDark(override val primary: Color = primaryBlue) : ThemeColors { override val isLight = false override val danger = dangerDark override val disabled = disabledDark @@ -139,7 +152,7 @@ data class OceanDark(override val primary: Color = primaryBlue): ThemeColors { override val primaryButtonFillText = Color.Black } -data class OceanLight(override val primary: Color = primaryBlue): ThemeColors { +data class OceanLight(override val primary: Color = primaryBlue) : ThemeColors { override val isLight = true override val danger = dangerLight override val disabled = disabledLight diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/Themes.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/Themes.kt index e0cd94ed66..87e91e0ab0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ui/theme/Themes.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/ui/theme/Themes.kt @@ -1,19 +1,16 @@ package org.thoughtcrime.securesms.ui.theme import androidx.compose.foundation.background -import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.selection.LocalTextSelectionColors -import androidx.compose.material.LocalContentColor -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Shapes +import androidx.compose.material3.LocalContentColor +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Shapes import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.compositionLocalOf -import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.unit.dp @@ -52,7 +49,7 @@ fun SessionMaterialTheme( content: @Composable () -> Unit ) { MaterialTheme( - colors = colors.toMaterialColors(), + colorScheme = colors.toMaterialColors(), typography = sessionTypography.asMaterialTypography(), shapes = sessionShapes, ) {