From bbe10382b0b38dd450b8c9904cf163b7b2eb2c7f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 3 Feb 2023 10:15:30 +0100 Subject: [PATCH] ElementTheme + MaterialTheme3 --- .../login/changeserver/ChangeServerView.kt | 12 ++-- .../features/login/root/LoginRootScreen.kt | 7 ++- features/messages/build.gradle.kts | 3 - .../messages/actionlist/ActionListView.kt | 6 +- .../messages/timeline/TimelineView.kt | 9 +-- .../components/TimelineItemImageView.kt | 7 +-- .../components/TimelineItemInformativeView.kt | 6 +- .../components/TimelineItemReactionsView.kt | 8 +-- .../timeline/components/html/HtmlDocument.kt | 38 ++++++------ .../rageshake/bugreport/BugReportView.kt | 6 +- features/roomlist/build.gradle.kts | 3 - .../roomlist/components/RoomListTopBar.kt | 8 +-- .../roomlist/components/RoomSummaryRow.kt | 17 +++--- .../android/features/template/TemplateView.kt | 5 +- libraries/designsystem/build.gradle.kts | 3 - .../libraries/designsystem/ColorUtil.kt | 6 +- .../components/ClickableLinkText.kt | 4 +- .../components/LabelledCheckbox.kt | 4 +- .../designsystem/components/ProgressDialog.kt | 8 +-- .../components/dialogs/ConfirmationDialog.kt | 10 ++-- .../components/dialogs/ErrorDialog.kt | 10 ++-- .../preferences/PreferenceCategory.kt | 6 +- .../components/preferences/PreferenceSlide.kt | 6 +- .../preferences/PreferenceSwitch.kt | 3 +- .../components/preferences/PreferenceText.kt | 6 +- .../designsystem/preview/ElementPreview.kt | 3 +- .../designsystem/theme/ColorAliases.kt | 21 +++++-- .../designsystem/theme/ColorsDark.kt | 15 +---- .../designsystem/theme/ColorsLight.kt | 17 +----- .../designsystem/theme/ContentColor.kt | 40 ------------- .../designsystem/theme/ElementColors.kt | 60 ------------------- .../designsystem/theme/ElementSpaces.kt | 27 --------- .../designsystem/theme/ElementTheme.kt | 47 +++++++-------- .../designsystem/theme/ElementTypography.kt | 15 +---- .../designsystem/theme/components/Button.kt | 49 +++++++-------- .../designsystem/theme/components/Checkbox.kt | 13 +--- .../components/CircularProgressIndicator.kt | 3 +- .../designsystem/theme/components/Divider.kt | 3 +- .../theme/components/MediumTopAppBar.kt | 9 +-- .../components/ModalBottomSheetLayout.kt | 9 ++- .../theme/components/OutlinedTextField.kt | 37 +----------- .../designsystem/theme/components/Scaffold.kt | 8 +-- .../designsystem/theme/components/Slider.kt | 15 +---- .../designsystem/theme/components/Surface.kt | 8 +-- .../theme/components/TextField.kt | 12 +--- .../theme/components/TopAppBar.kt | 9 +-- .../matrix/ui/components/MatrixUserHeader.kt | 6 +- .../matrix/ui/components/MatrixUserRow.kt | 6 +- .../libraries/textcomposer/TextComposer.kt | 4 +- .../kotlin/extension/DependencyHandleScope.kt | 1 + .../android/tests/uitests/ScreenshotTest.kt | 6 +- .../tests/uitests/TypographyTestPreview.kt | 4 +- 52 files changed, 202 insertions(+), 446 deletions(-) delete mode 100644 libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ContentColor.kt delete mode 100644 libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementSpaces.kt diff --git a/features/login/src/main/kotlin/io/element/android/features/login/changeserver/ChangeServerView.kt b/features/login/src/main/kotlin/io/element/android/features/login/changeserver/ChangeServerView.kt index c64b3f0625..32fdeedb1d 100644 --- a/features/login/src/main/kotlin/io/element/android/features/login/changeserver/ChangeServerView.kt +++ b/features/login/src/main/kotlin/io/element/android/features/login/changeserver/ChangeServerView.kt @@ -31,6 +31,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue @@ -50,7 +51,6 @@ import io.element.android.libraries.designsystem.components.VectorIcon import io.element.android.libraries.designsystem.components.form.textFieldState import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Button import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator import io.element.android.libraries.designsystem.theme.components.OutlinedTextField @@ -86,7 +86,7 @@ fun ChangeServerView( .size(width = 81.dp, height = 73.dp) .align(Alignment.CenterHorizontally) .background( - color = ElementTheme.colors.surfaceVariant, + color = MaterialTheme.colorScheme.surfaceVariant, shape = RoundedCornerShape(32.dp) ) ) { @@ -108,7 +108,7 @@ fun ChangeServerView( textAlign = TextAlign.Center, fontWeight = FontWeight.Bold, fontSize = 24.sp, - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) Text( text = "A server is a home for all your data.\n" + @@ -119,7 +119,7 @@ fun ChangeServerView( .padding(top = 16.dp), textAlign = TextAlign.Center, fontSize = 16.sp, - color = ElementTheme.colors.secondary, + color = MaterialTheme.colorScheme.secondary, ) var homeserverFieldState by textFieldState(stateValue = state.homeserver) OutlinedTextField( @@ -150,8 +150,8 @@ fun ChangeServerView( state.homeserver, state.changeServerAction.error ), - color = ElementTheme.colors.error, - style = ElementTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + style = MaterialTheme.typography.bodySmall, modifier = Modifier.padding(start = 16.dp) ) } diff --git a/features/login/src/main/kotlin/io/element/android/features/login/root/LoginRootScreen.kt b/features/login/src/main/kotlin/io/element/android/features/login/root/LoginRootScreen.kt index 3242197ce2..2d5381f99c 100644 --- a/features/login/src/main/kotlin/io/element/android/features/login/root/LoginRootScreen.kt +++ b/features/login/src/main/kotlin/io/element/android/features/login/root/LoginRootScreen.kt @@ -30,6 +30,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Visibility import androidx.compose.material.icons.filled.VisibilityOff +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -98,7 +99,7 @@ fun LoginRootScreen( textAlign = TextAlign.Center, fontWeight = FontWeight.Bold, fontSize = 24.sp, - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) // Form Column( @@ -189,8 +190,8 @@ fun LoginRootScreen( if (state.loggedInState is LoggedInState.ErrorLoggingIn) { Text( text = loginError(state.formState, state.loggedInState.failure), - color = ElementTheme.colors.error, - style = ElementTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + style = MaterialTheme.typography.bodySmall, modifier = Modifier.padding(start = 16.dp) ) } diff --git a/features/messages/build.gradle.kts b/features/messages/build.gradle.kts index 5931450294..975c7b5c0e 100644 --- a/features/messages/build.gradle.kts +++ b/features/messages/build.gradle.kts @@ -47,7 +47,4 @@ dependencies { testImplementation(libs.test.junit) androidTestImplementation(libs.test.junitext) ksp(libs.showkase.processor) - - // Not for components, but other classes. - implementation("androidx.compose.material3:material3") } diff --git a/features/messages/src/main/kotlin/io/element/android/features/messages/actionlist/ActionListView.kt b/features/messages/src/main/kotlin/io/element/android/features/messages/actionlist/ActionListView.kt index e580b48001..f2fe33f1c7 100644 --- a/features/messages/src/main/kotlin/io/element/android/features/messages/actionlist/ActionListView.kt +++ b/features/messages/src/main/kotlin/io/element/android/features/messages/actionlist/ActionListView.kt @@ -32,6 +32,7 @@ import androidx.compose.material.LocalContentColor import androidx.compose.material.ModalBottomSheetState import androidx.compose.material.ModalBottomSheetValue import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.rememberCoroutineScope @@ -42,7 +43,6 @@ import androidx.compose.ui.unit.dp import io.element.android.features.messages.actionlist.model.TimelineItemAction import io.element.android.features.messages.timeline.model.TimelineItem import io.element.android.libraries.designsystem.components.VectorIcon -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.ModalBottomSheetLayout import kotlinx.coroutines.flow.filter import kotlinx.coroutines.launch @@ -115,13 +115,13 @@ private fun SheetContent( text = { Text( text = action.title, - color = if (action.destructive) ElementTheme.colors.error else Color.Unspecified, + color = if (action.destructive) MaterialTheme.colorScheme.error else Color.Unspecified, ) }, icon = { VectorIcon( resourceId = action.icon, - tint = if (action.destructive) ElementTheme.colors.error else LocalContentColor.current, + tint = if (action.destructive) MaterialTheme.colorScheme.error else LocalContentColor.current, ) } ) diff --git a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/TimelineView.kt b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/TimelineView.kt index 13127271c2..91b9cc6023 100644 --- a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/TimelineView.kt +++ b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/TimelineView.kt @@ -39,6 +39,7 @@ import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowDownward +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf @@ -269,7 +270,7 @@ private fun MessageSenderInformation( } Text( text = sender, - style = ElementTheme.typography.titleMedium, + style = MaterialTheme.typography.titleMedium, modifier = Modifier .alignBy(LastBaseline) ) @@ -328,8 +329,8 @@ internal fun BoxScope.TimelineScrollHelper( modifier = Modifier .align(Alignment.BottomCenter) .size(40.dp), - containerColor = ElementTheme.colors.surfaceVariant, - contentColor = ElementTheme.colors.onSurfaceVariant + containerColor = MaterialTheme.colorScheme.surfaceVariant, + contentColor = MaterialTheme.colorScheme.onSurfaceVariant ) { Icon(Icons.Default.ArrowDownward, "") } @@ -347,7 +348,7 @@ internal fun TimelineLoadingMoreIndicator() { ) { CircularProgressIndicator( strokeWidth = 2.dp, - color = ElementTheme.colors.primary + color = MaterialTheme.colorScheme.primary ) } } diff --git a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemImageView.kt b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemImageView.kt index cce7e21896..e497a52523 100644 --- a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemImageView.kt +++ b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemImageView.kt @@ -14,14 +14,12 @@ * limitations under the License. */ -@file:OptIn(ExperimentalFoundationApi::class) - package io.element.android.features.messages.timeline.components -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable @@ -33,7 +31,6 @@ import androidx.compose.ui.platform.LocalContext import coil.compose.AsyncImage import coil.request.ImageRequest import io.element.android.features.messages.timeline.model.content.TimelineItemImageContent -import io.element.android.libraries.designsystem.theme.ElementTheme @Composable fun TimelineItemImageView( @@ -60,7 +57,7 @@ fun TimelineItemImageView( AsyncImage( model = model, contentDescription = null, - placeholder = ColorPainter(ElementTheme.colors.surfaceVariant), + placeholder = ColorPainter(MaterialTheme.colorScheme.surfaceVariant), contentScale = ContentScale.Crop, onSuccess = { isLoading.value = false }, ) diff --git a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemInformativeView.kt b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemInformativeView.kt index 5ad33a72ad..d7960f2ef9 100644 --- a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemInformativeView.kt +++ b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemInformativeView.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Delete +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -32,7 +33,6 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Icon import io.element.android.libraries.designsystem.theme.components.Text @@ -49,14 +49,14 @@ fun TimelineItemInformativeView( ) { Icon( imageVector = icon, - tint = ElementTheme.colors.secondary, + tint = MaterialTheme.colorScheme.secondary, contentDescription = iconDescription, modifier = Modifier.size(16.dp) ) Spacer(modifier = Modifier.width(4.dp)) Text( fontStyle = FontStyle.Italic, - color = ElementTheme.colors.secondary, + color = MaterialTheme.colorScheme.secondary, fontSize = 14.sp, text = text ) diff --git a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemReactionsView.kt b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemReactionsView.kt index 22a9b306f1..50185bdb50 100644 --- a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemReactionsView.kt +++ b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/TimelineItemReactionsView.kt @@ -23,6 +23,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CornerSize import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -31,7 +32,6 @@ import androidx.compose.ui.unit.sp import com.google.accompanist.flowlayout.FlowRow import io.element.android.features.messages.timeline.model.AggregatedReaction import io.element.android.features.messages.timeline.model.TimelineItemReactions -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Surface import io.element.android.libraries.designsystem.theme.components.Text @@ -56,8 +56,8 @@ fun TimelineItemReactionsView( fun MessagesReactionButton(reaction: AggregatedReaction, modifier: Modifier = Modifier) { Surface( modifier = modifier, - color = ElementTheme.colors.surfaceVariant, - border = BorderStroke(2.dp, ElementTheme.colors.background), + color = MaterialTheme.colorScheme.surfaceVariant, + border = BorderStroke(2.dp, MaterialTheme.colorScheme.background), shape = RoundedCornerShape(corner = CornerSize(12.dp)), ) { Row( @@ -66,7 +66,7 @@ fun MessagesReactionButton(reaction: AggregatedReaction, modifier: Modifier = Mo ) { Text(text = reaction.key, fontSize = 12.sp) Spacer(modifier = Modifier.width(4.dp)) - Text(text = reaction.count, color = ElementTheme.colors.secondary, fontSize = 12.sp) + Text(text = reaction.count, color = MaterialTheme.colorScheme.secondary, fontSize = 12.sp) } } } diff --git a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/html/HtmlDocument.kt b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/html/HtmlDocument.kt index a3be7d3bd1..b7e8685656 100644 --- a/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/html/HtmlDocument.kt +++ b/features/messages/src/main/kotlin/io/element/android/features/messages/timeline/components/html/HtmlDocument.kt @@ -25,7 +25,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.InlineTextContent import androidx.compose.foundation.text.appendInlineContent +import androidx.compose.material3.ColorScheme import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawBehind @@ -45,8 +47,6 @@ import androidx.compose.ui.unit.sp import com.google.accompanist.flowlayout.FlowRow import io.element.android.libraries.designsystem.LinkColor import io.element.android.libraries.designsystem.components.ClickableLinkText -import io.element.android.libraries.designsystem.theme.ElementColors -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Surface import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.matrix.permalink.PermalinkData @@ -214,7 +214,7 @@ private fun HtmlInline( ) { Box(modifier) { val styledText = buildAnnotatedString { - appendInlineElement(element, ElementTheme.colors) + appendInlineElement(element, MaterialTheme.colorScheme) } HtmlText( text = styledText, @@ -232,7 +232,7 @@ private fun HtmlPreformatted( ) { val isCode = pre.firstElementChild()?.normalName() == "code" val backgroundColor = - if (isCode) ElementTheme.colors.codeBackground() else Color.Unspecified + if (isCode) MaterialTheme.colorScheme.codeBackground() else Color.Unspecified Box( modifier .background(color = backgroundColor) @@ -255,7 +255,7 @@ private fun HtmlParagraph( ) { Box(modifier) { val styledText = buildAnnotatedString { - appendInlineChildrenElements(paragraph.childNodes(), ElementTheme.colors) + appendInlineChildrenElements(paragraph.childNodes(), MaterialTheme.colorScheme) } HtmlText( text = styledText, onClick = onTextClicked, @@ -272,7 +272,7 @@ private fun HtmlBlockquote( onTextClicked: () -> Unit = {}, onTextLongClicked: () -> Unit = {}, ) { - val color = ElementTheme.colors.onBackground + val color = MaterialTheme.colorScheme.onBackground Box( modifier = modifier .drawBehind { @@ -287,7 +287,7 @@ private fun HtmlBlockquote( ) { val text = buildAnnotatedString { withStyle(style = SpanStyle(fontStyle = FontStyle.Italic)) { - appendInlineChildrenElements(blockquote.childNodes(), ElementTheme.colors) + appendInlineChildrenElements(blockquote.childNodes(), MaterialTheme.colorScheme) } } HtmlText( @@ -306,19 +306,19 @@ private fun HtmlHeading( onTextLongClicked: () -> Unit = {}, ) { val style = when (heading.normalName()) { - "h1" -> ElementTheme.typography.headlineLarge.copy(fontSize = 30.sp) - "h2" -> ElementTheme.typography.headlineLarge.copy(fontSize = 26.sp) - "h3" -> ElementTheme.typography.headlineMedium.copy(fontSize = 22.sp) - "h4" -> ElementTheme.typography.headlineMedium.copy(fontSize = 18.sp) - "h5" -> ElementTheme.typography.headlineSmall.copy(fontSize = 14.sp) - "h6" -> ElementTheme.typography.headlineSmall.copy(fontSize = 12.sp) + "h1" -> MaterialTheme.typography.headlineLarge.copy(fontSize = 30.sp) + "h2" -> MaterialTheme.typography.headlineLarge.copy(fontSize = 26.sp) + "h3" -> MaterialTheme.typography.headlineMedium.copy(fontSize = 22.sp) + "h4" -> MaterialTheme.typography.headlineMedium.copy(fontSize = 18.sp) + "h5" -> MaterialTheme.typography.headlineSmall.copy(fontSize = 14.sp) + "h6" -> MaterialTheme.typography.headlineSmall.copy(fontSize = 12.sp) else -> { return } } Box(modifier) { val text = buildAnnotatedString { - appendInlineChildrenElements(heading.childNodes(), ElementTheme.colors) + appendInlineChildrenElements(heading.childNodes(), MaterialTheme.colorScheme) } HtmlText( text = text, @@ -344,7 +344,7 @@ private fun HtmlMxReply( modifier = modifier .padding(bottom = 4.dp) .offset(x = -(8.dp)), - color = ElementTheme.colors.background, + color = MaterialTheme.colorScheme.background, shape = shape, ) { val text = buildAnnotatedString { @@ -354,7 +354,7 @@ private fun HtmlMxReply( withStyle( style = SpanStyle( fontSize = 12.sp, - color = ElementTheme.colors.secondary + color = MaterialTheme.colorScheme.secondary ) ) { append(blockquoteNode.text()) @@ -462,13 +462,13 @@ private fun HtmlListItems( } } -private fun ElementColors.codeBackground(): Color { +private fun ColorScheme.codeBackground(): Color { return background.copy(alpha = 0.3f) } private fun AnnotatedString.Builder.appendInlineChildrenElements( childNodes: List, - colors: ElementColors + colors: ColorScheme ) { for (node in childNodes) { when (node) { @@ -482,7 +482,7 @@ private fun AnnotatedString.Builder.appendInlineChildrenElements( } } -private fun AnnotatedString.Builder.appendInlineElement(element: Element, colors: ElementColors) { +private fun AnnotatedString.Builder.appendInlineElement(element: Element, colors: ColorScheme) { when (element.normalName()) { "br" -> { append('\n') diff --git a/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportView.kt b/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportView.kt index 0cd9ff0334..f2fbd7f8f5 100644 --- a/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportView.kt +++ b/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportView.kt @@ -26,6 +26,7 @@ import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -49,7 +50,6 @@ import io.element.android.libraries.designsystem.components.dialogs.ErrorDialog import io.element.android.libraries.designsystem.components.form.textFieldState import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Button import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator import io.element.android.libraries.designsystem.theme.components.OutlinedTextField @@ -97,7 +97,7 @@ fun BugReportView( textAlign = TextAlign.Center, fontWeight = FontWeight.Bold, fontSize = 24.sp, - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) // Form Text( @@ -106,7 +106,7 @@ fun BugReportView( .fillMaxWidth() .padding(horizontal = 16.dp, vertical = 16.dp), fontSize = 16.sp, - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) var descriptionFieldState by textFieldState( stateValue = state.formState.description diff --git a/features/roomlist/build.gradle.kts b/features/roomlist/build.gradle.kts index 08b043a17f..fc0402eafc 100644 --- a/features/roomlist/build.gradle.kts +++ b/features/roomlist/build.gradle.kts @@ -54,7 +54,4 @@ dependencies { androidTestImplementation(libs.test.junitext) ksp(libs.showkase.processor) - - // Not for components, but other classes. - implementation("androidx.compose.material3:material3") } diff --git a/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomListTopBar.kt b/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomListTopBar.kt index 70b4d974c7..f622164af9 100644 --- a/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomListTopBar.kt +++ b/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomListTopBar.kt @@ -27,6 +27,7 @@ import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.filled.Settings import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -45,7 +46,6 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp import io.element.android.libraries.designsystem.components.avatar.Avatar import io.element.android.libraries.designsystem.components.form.textFieldState -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Icon import io.element.android.libraries.designsystem.theme.components.IconButton import io.element.android.libraries.designsystem.theme.components.MediumTopAppBar @@ -130,7 +130,7 @@ fun SearchRoomListTopBar( placeholder = { Text( text = "Search", - color = ElementTheme.colors.onBackground.copy(alpha = ContentAlpha.medium) + color = MaterialTheme.colorScheme.onBackground.copy(alpha = ContentAlpha.medium) ) }, singleLine = true, @@ -144,7 +144,7 @@ fun SearchRoomListTopBar( Icon( imageVector = Icons.Default.Close, contentDescription = "clear", - tint = ElementTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } } @@ -160,7 +160,7 @@ fun SearchRoomListTopBar( Icon( imageVector = Icons.Default.ArrowBack, contentDescription = "close", - tint = ElementTheme.colors.onBackground + tint = MaterialTheme.colorScheme.onBackground ) } }, diff --git a/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomSummaryRow.kt b/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomSummaryRow.kt index 580d0ebc4b..53ca8b5d1f 100644 --- a/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomSummaryRow.kt +++ b/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomSummaryRow.kt @@ -31,6 +31,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.ripple.rememberRipple +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -103,7 +104,7 @@ internal fun DefaultRoomSummaryRow( modifier = Modifier.placeholder( visible = room.isPlaceholder, shape = CircleShape, - color = ElementTheme.colors.roomListPlaceHolder, + color = ElementTheme.colors.roomListPlaceHolder(), ) ) Column( @@ -117,12 +118,12 @@ internal fun DefaultRoomSummaryRow( modifier = Modifier.placeholder( visible = room.isPlaceholder, shape = TextPlaceholderShape, - color = ElementTheme.colors.roomListPlaceHolder, + color = ElementTheme.colors.roomListPlaceHolder(), ), fontSize = 16.sp, fontWeight = FontWeight.SemiBold, text = room.name, - color = ElementTheme.colors.roomListRoomName, + color = MaterialTheme.roomListRoomName(), maxLines = 1, overflow = TextOverflow.Ellipsis ) @@ -131,10 +132,10 @@ internal fun DefaultRoomSummaryRow( modifier = Modifier.placeholder( visible = room.isPlaceholder, shape = TextPlaceholderShape, - color = ElementTheme.colors.roomListPlaceHolder, + color = ElementTheme.colors.roomListPlaceHolder(), ), text = room.lastMessage?.toString().orEmpty(), - color = ElementTheme.colors.roomListRoomMessage, + color = MaterialTheme.roomListRoomMessage(), fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis @@ -149,15 +150,15 @@ internal fun DefaultRoomSummaryRow( modifier = Modifier.placeholder( visible = room.isPlaceholder, shape = TextPlaceholderShape, - color = ElementTheme.colors.roomListPlaceHolder, + color = ElementTheme.colors.roomListPlaceHolder(), ), fontSize = 12.sp, text = room.timestamp ?: "", - color = ElementTheme.colors.roomListRoomMessageDate, + color = MaterialTheme.roomListRoomMessageDate(), ) Spacer(Modifier.size(4.dp)) val unreadIndicatorColor = - if (room.hasUnread) ElementTheme.colors.roomListUnreadIndicator else Color.Transparent + if (room.hasUnread) MaterialTheme.roomListUnreadIndicator() else Color.Transparent Box( modifier = Modifier .size(12.dp) diff --git a/features/template/src/main/kotlin/io/element/android/features/template/TemplateView.kt b/features/template/src/main/kotlin/io/element/android/features/template/TemplateView.kt index a98912d958..8069b3a991 100644 --- a/features/template/src/main/kotlin/io/element/android/features/template/TemplateView.kt +++ b/features/template/src/main/kotlin/io/element/android/features/template/TemplateView.kt @@ -17,13 +17,14 @@ package io.element.android.features.template import androidx.compose.foundation.layout.Box +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme +import io.element.android.libraries.designsystem.theme.components.Text @Composable fun TemplateView( @@ -33,7 +34,7 @@ fun TemplateView( Box(modifier, contentAlignment = Alignment.Center) { Text( "Template feature view", - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) } } diff --git a/libraries/designsystem/build.gradle.kts b/libraries/designsystem/build.gradle.kts index 10e51c8aec..45430e5d82 100644 --- a/libraries/designsystem/build.gradle.kts +++ b/libraries/designsystem/build.gradle.kts @@ -31,8 +31,5 @@ android { implementation(projects.libraries.elementresources) implementation(projects.libraries.uiStrings) ksp(libs.showkase.processor) - - // This is the only module to have a (temporary) dependence to material3. - implementation("androidx.compose.material3:material3") } } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/ColorUtil.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/ColorUtil.kt index f6a0122a80..469c70913a 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/ColorUtil.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/ColorUtil.kt @@ -16,15 +16,15 @@ package io.element.android.libraries.designsystem +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color -import io.element.android.libraries.designsystem.theme.ElementTheme @Composable fun Boolean.toEnabledColor(): Color { return if (this) { - ElementTheme.colors.primary + MaterialTheme.colorScheme.primary } else { - ElementTheme.colors.primary.copy(alpha = 0.40f) + MaterialTheme.colorScheme.primary.copy(alpha = 0.40f) } } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/ClickableLinkText.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/ClickableLinkText.kt index a8a5b94ff4..54a8be0334 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/ClickableLinkText.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/ClickableLinkText.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.PressInteraction import androidx.compose.foundation.text.InlineTextContent import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -31,7 +32,6 @@ import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextLayoutResult import androidx.compose.ui.text.TextStyle -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Text import kotlinx.collections.immutable.ImmutableMap import kotlinx.collections.immutable.persistentMapOf @@ -85,6 +85,6 @@ fun ClickableLinkText( layoutResult.value = it }, inlineContent = inlineContent, - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/LabelledCheckbox.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/LabelledCheckbox.kt index cd381af63b..698d2fb6ee 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/LabelledCheckbox.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/LabelledCheckbox.kt @@ -18,13 +18,13 @@ package io.element.android.libraries.designsystem.components import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Checkbox import io.element.android.libraries.designsystem.theme.components.Text @@ -47,7 +47,7 @@ fun LabelledCheckbox( ) Text( text = text, - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) } } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/ProgressDialog.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/ProgressDialog.kt index 6f8ec96118..5028bcc030 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/ProgressDialog.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/ProgressDialog.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -31,7 +32,6 @@ import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator import io.element.android.libraries.designsystem.theme.components.Text @@ -50,19 +50,19 @@ fun ProgressDialog( modifier = modifier .fillMaxWidth() .background( - color = ElementTheme.colors.surfaceVariant, + color = MaterialTheme.colorScheme.surfaceVariant, shape = RoundedCornerShape(8.dp) ) ) { Column(horizontalAlignment = Alignment.CenterHorizontally) { CircularProgressIndicator( modifier = Modifier.padding(16.dp), - color = ElementTheme.colors.onSurfaceVariant + color = MaterialTheme.colorScheme.onSurfaceVariant ) if (!text.isNullOrBlank()) { Text( text = text, - color = ElementTheme.colors.onSurfaceVariant, + color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(16.dp) ) } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/dialogs/ConfirmationDialog.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/dialogs/ConfirmationDialog.kt index b4b910ac3b..aee26ba7f2 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/dialogs/ConfirmationDialog.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/dialogs/ConfirmationDialog.kt @@ -23,6 +23,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.AlertDialog import androidx.compose.material3.AlertDialogDefaults +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -33,7 +34,6 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Button import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.ui.strings.R as StringR @@ -51,10 +51,10 @@ fun ConfirmationDialog( onThirdButtonClicked: () -> Unit = {}, onDismiss: () -> Unit = {}, shape: Shape = AlertDialogDefaults.shape, - containerColor: Color = ElementTheme.colors.surfaceVariant, - iconContentColor: Color = ElementTheme.colors.onSurfaceVariant, - titleContentColor: Color = ElementTheme.colors.onSurfaceVariant, - textContentColor: Color = ElementTheme.colors.onSurfaceVariant, + containerColor: Color = MaterialTheme.colorScheme.surfaceVariant, + iconContentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, + titleContentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, + textContentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, tonalElevation: Dp = AlertDialogDefaults.TonalElevation, ) { AlertDialog( diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/dialogs/ErrorDialog.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/dialogs/ErrorDialog.kt index b9740c2074..fc4aefe6f1 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/dialogs/ErrorDialog.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/dialogs/ErrorDialog.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.AlertDialog import androidx.compose.material3.AlertDialogDefaults +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -32,7 +33,6 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Button import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.ui.strings.R as StringR @@ -45,10 +45,10 @@ fun ErrorDialog( submitText: String = stringResource(id = StringR.string.ok), onDismiss: () -> Unit = {}, shape: Shape = AlertDialogDefaults.shape, - containerColor: Color = ElementTheme.colors.surfaceVariant, - iconContentColor: Color = ElementTheme.colors.onSurfaceVariant, - titleContentColor: Color = ElementTheme.colors.onSurfaceVariant, - textContentColor: Color = ElementTheme.colors.onSurfaceVariant, + containerColor: Color = MaterialTheme.colorScheme.surfaceVariant, + iconContentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, + titleContentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, + textContentColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, tonalElevation: Dp = AlertDialogDefaults.TonalElevation, ) { AlertDialog( diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceCategory.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceCategory.kt index 7206fb1081..eeed206e5f 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceCategory.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceCategory.kt @@ -23,13 +23,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Announcement import androidx.compose.material.icons.filled.BugReport +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Divider import io.element.android.libraries.designsystem.theme.components.Text @@ -45,12 +45,12 @@ fun PreferenceCategory( ) { Divider( modifier = Modifier.padding(horizontal = 16.dp), - color = ElementTheme.colors.secondary, + color = MaterialTheme.colorScheme.secondary, thickness = 1.dp ) Text( modifier = Modifier.padding(top = 8.dp, start = 56.dp), - style = ElementTheme.typography.titleSmall, + style = MaterialTheme.typography.titleSmall, text = title ) content() diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceSlide.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceSlide.kt index 315f7caeab..c16eaab45b 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceSlide.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceSlide.kt @@ -23,6 +23,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -31,7 +32,6 @@ import androidx.compose.ui.tooling.preview.Preview import io.element.android.libraries.designsystem.components.preferences.components.PreferenceIcon import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Slider import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.designsystem.toEnabledColor @@ -63,14 +63,14 @@ fun PreferenceSlide( ) { Text( modifier = Modifier.fillMaxWidth(), - style = ElementTheme.typography.bodyLarge, + style = MaterialTheme.typography.bodyLarge, color = enabled.toEnabledColor(), text = title ) summary?.let { Text( modifier = Modifier.fillMaxWidth(), - style = ElementTheme.typography.bodyMedium, + style = MaterialTheme.typography.bodyMedium, color = enabled.toEnabledColor(), text = summary ) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceSwitch.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceSwitch.kt index 629148c071..7a4177a5ae 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceSwitch.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceSwitch.kt @@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Announcement +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -63,7 +64,7 @@ fun PreferenceSwitch( ) Text( modifier = Modifier.weight(1f), - style = ElementTheme.typography.bodyLarge, + style = MaterialTheme.typography.bodyLarge, color = enabled.toEnabledColor(), text = title ) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceText.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceText.kt index b7b7662045..1c10d6259a 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceText.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/preferences/PreferenceText.kt @@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.BugReport +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -32,7 +33,6 @@ import androidx.compose.ui.tooling.preview.Preview import io.element.android.libraries.designsystem.components.preferences.components.PreferenceIcon import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Text @Composable @@ -58,9 +58,9 @@ fun PreferenceText( modifier = Modifier .weight(1f) .padding(end = preferencePaddingEnd), - style = ElementTheme.typography.bodyLarge, + style = MaterialTheme.typography.bodyLarge, text = title, - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) } } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/preview/ElementPreview.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/preview/ElementPreview.kt index 7a286f5314..f79cfed70b 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/preview/ElementPreview.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/preview/ElementPreview.kt @@ -18,6 +18,7 @@ package io.element.android.libraries.designsystem.preview import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import io.element.android.libraries.designsystem.theme.ElementTheme @@ -54,7 +55,7 @@ private fun ElementPreview( ) { ElementTheme(darkTheme = darkTheme) { if (showBackground) { - Box(modifier = Modifier.background(ElementTheme.colors.background)) { + Box(modifier = Modifier.background(MaterialTheme.colorScheme.background)) { content() } } else { diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorAliases.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorAliases.kt index 1325211232..33c4032dc9 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorAliases.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorAliases.kt @@ -16,14 +16,25 @@ package io.element.android.libraries.designsystem.theme +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable import io.element.android.libraries.designsystem.SystemGrey4Dark import io.element.android.libraries.designsystem.SystemGrey6Light /** * Room list */ -val ElementColors.roomListRoomName get() = primary -val ElementColors.roomListRoomMessage get() = secondary -val ElementColors.roomListRoomMessageDate get() = secondary -val ElementColors.roomListUnreadIndicator get() = primary -val ElementColors.roomListPlaceHolder get() = if (isLight) SystemGrey6Light else SystemGrey4Dark +@Composable +fun MaterialTheme.roomListRoomName() = colorScheme.primary + +@Composable +fun MaterialTheme.roomListRoomMessage() = colorScheme.secondary + +@Composable +fun MaterialTheme.roomListRoomMessageDate() = colorScheme.secondary + +@Composable +fun MaterialTheme.roomListUnreadIndicator() = colorScheme.primary + +@Composable +fun ElementColors.roomListPlaceHolder() = if (isLight) SystemGrey6Light else SystemGrey4Dark diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorsDark.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorsDark.kt index 19c7c2f49a..80b6122ba5 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorsDark.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorsDark.kt @@ -16,6 +16,7 @@ package io.element.android.libraries.designsystem.theme +import androidx.compose.material3.darkColorScheme import androidx.compose.ui.graphics.Color import io.element.android.libraries.designsystem.Azure import io.element.android.libraries.designsystem.DarkGrey @@ -23,24 +24,13 @@ import io.element.android.libraries.designsystem.SystemGrey5Dark import io.element.android.libraries.designsystem.SystemGrey6Dark fun elementColorsDark() = ElementColors( - primary = Color.White, - onPrimary = Color.Black, - secondary = DarkGrey, - text = Color.White, - background = Color.Black, - onBackground = Color.White, - surfaceVariant = SystemGrey5Dark, - onSurfaceVariant = Color.White, messageFromMeBackground = SystemGrey5Dark, messageFromOtherBackground = SystemGrey6Dark, messageHighlightedBackground = Azure, - success = Color.Green, - error = Color.Red, isLight = false, ) -/* -private val DarkColorScheme = darkColorScheme( +val materialColorSchemeDark = darkColorScheme( primary = Color.White, secondary = DarkGrey, tertiary = Color.White, @@ -50,4 +40,3 @@ private val DarkColorScheme = darkColorScheme( surfaceVariant = SystemGrey5Dark, onSurface = Color.White, ) - */ diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorsLight.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorsLight.kt index 6d7c7f62ea..8e8e41c9d6 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorsLight.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorsLight.kt @@ -16,6 +16,7 @@ package io.element.android.libraries.designsystem.theme +import androidx.compose.material3.lightColorScheme import androidx.compose.ui.graphics.Color import io.element.android.libraries.designsystem.Azure import io.element.android.libraries.designsystem.LightGrey @@ -23,24 +24,13 @@ import io.element.android.libraries.designsystem.SystemGrey5Light import io.element.android.libraries.designsystem.SystemGrey6Light fun elementColorsLight() = ElementColors( - primary = Color.Black, - onPrimary = Color.White, - secondary = LightGrey, - text = Color.Black, - background = Color.White, - onBackground = Color.Black, - surfaceVariant = SystemGrey5Light, - onSurfaceVariant = Color.Black, messageFromMeBackground = SystemGrey5Light, messageFromOtherBackground = SystemGrey6Light, messageHighlightedBackground = Azure, - success = Color.Green, - error = Color.Red, isLight = true, ) -/* -private val LightColorScheme = lightColorScheme( +val materialColorSchemeLight = lightColorScheme( primary = Color.Black, secondary = LightGrey, tertiary = Color.Black, @@ -50,5 +40,4 @@ private val LightColorScheme = lightColorScheme( surfaceVariant = SystemGrey5Light, onSurface = Color.Black, onSurfaceVariant = Color.Black, - - */ +) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ContentColor.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ContentColor.kt deleted file mode 100644 index 1af916a109..0000000000 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ContentColor.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.element.android.libraries.designsystem.theme - -import androidx.compose.material3.LocalContentColor -import androidx.compose.runtime.Composable -import androidx.compose.runtime.ReadOnlyComposable -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.takeOrElse - -@Composable -@ReadOnlyComposable -fun elementContentColorFor(backgroundColor: Color): Color { - return ElementTheme.colors.elementContentColorFor(backgroundColor).takeOrElse { - LocalContentColor.current - } -} - -fun ElementColors.elementContentColorFor(backgroundColor: Color): Color { - return when (backgroundColor) { - primary -> onPrimary - surfaceVariant -> onSurfaceVariant - background -> onBackground - else -> Color.Unspecified - } -} diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementColors.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementColors.kt index 38da8e7816..b39c31d157 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementColors.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementColors.kt @@ -22,41 +22,11 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.graphics.Color class ElementColors( - primary: Color, - onPrimary: Color, - secondary: Color, - text: Color, - background: Color, - onBackground: Color, - surfaceVariant: Color, - onSurfaceVariant: Color, messageFromMeBackground: Color, messageFromOtherBackground: Color, messageHighlightedBackground: Color, - success: Color, - error: Color, isLight: Boolean, ) { - var primary by mutableStateOf(primary) - private set - var onPrimary by mutableStateOf(onPrimary) - private set - var secondary by mutableStateOf(secondary) - private set - var text by mutableStateOf(text) - private set - var success by mutableStateOf(success) - private set - var error by mutableStateOf(error) - private set - var background by mutableStateOf(background) - private set - var onBackground by mutableStateOf(onBackground) - private set - var surfaceVariant by mutableStateOf(surfaceVariant) - private set - var onSurfaceVariant by mutableStateOf(onSurfaceVariant) - private set var messageFromMeBackground by mutableStateOf(messageFromMeBackground) private set var messageFromOtherBackground by mutableStateOf(messageFromOtherBackground) @@ -68,51 +38,21 @@ class ElementColors( private set fun copy( - primary: Color = this.primary, - onPrimary: Color = this.onPrimary, - secondary: Color = this.secondary, - text: Color = this.text, - background: Color = this.background, - onBackground: Color = this.onBackground, - surfaceVariant: Color = this.surfaceVariant, - onSurfaceVariant: Color = this.onSurfaceVariant, messageFromMeBackground: Color = this.messageFromMeBackground, messageFromOtherBackground: Color = this.messageFromOtherBackground, messageHighlightedBackground: Color = this.messageHighlightedBackground, - success: Color = this.success, - error: Color = this.error, isLight: Boolean = this.isLight, ) = ElementColors( - primary = primary, - onPrimary = onPrimary, - secondary = secondary, - text = text, - background = background, - onBackground = onBackground, - surfaceVariant = surfaceVariant, - onSurfaceVariant = onSurfaceVariant, messageFromMeBackground = messageFromMeBackground, messageFromOtherBackground = messageFromOtherBackground, messageHighlightedBackground = messageHighlightedBackground, - success = success, - error = error, isLight = isLight, ) fun updateColorsFrom(other: ElementColors) { - primary = other.primary - onPrimary = other.onPrimary - secondary = other.secondary - text = other.text - success = other.success - background = other.background - onBackground = other.onBackground - surfaceVariant = other.surfaceVariant - onSurfaceVariant = other.onSurfaceVariant messageFromMeBackground = other.messageFromMeBackground messageFromOtherBackground = other.messageFromOtherBackground messageHighlightedBackground = other.messageHighlightedBackground - error = other.error isLight = other.isLight } } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementSpaces.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementSpaces.kt deleted file mode 100644 index e5f2236cf0..0000000000 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementSpaces.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2023 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.element.android.libraries.designsystem.theme - -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp - -data class ElementSpaces( - val small: Dp = 4.dp, - val medium: Dp = 8.dp, - val large: Dp = 16.dp, - val extraLarge: Dp = 40.dp, -) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementTheme.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementTheme.kt index 5281888b17..7e7d4d8caf 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementTheme.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementTheme.kt @@ -17,7 +17,8 @@ package io.element.android.libraries.designsystem.theme import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.ProvideTextStyle +import androidx.compose.material3.ColorScheme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.ReadOnlyComposable @@ -35,50 +36,42 @@ object ElementTheme { @Composable @ReadOnlyComposable get() = LocalColors.current - - val typography: ElementTypography - @Composable - @ReadOnlyComposable - get() = LocalTypography.current - - val spaces: ElementSpaces - @Composable - @ReadOnlyComposable - get() = LocalSpaces.current } /* Global variables (application level) */ -val LocalSpaces = staticCompositionLocalOf { ElementSpaces() } val LocalColors = staticCompositionLocalOf { elementColorsLight() } -val LocalTypography = staticCompositionLocalOf { ElementTypography() } @Composable fun ElementTheme( darkTheme: Boolean = isSystemInDarkTheme(), lightColors: ElementColors = elementColorsLight(), darkColors: ElementColors = elementColorsDark(), - typography: ElementTypography = ElementTheme.typography, - spaces: ElementSpaces = ElementTheme.spaces, + materialLightColors: ColorScheme = materialColorSchemeLight, + materialDarkColors: ColorScheme = materialColorSchemeDark, content: @Composable () -> Unit, ) { val systemUiController = rememberSystemUiController() val useDarkIcons = !darkTheme val currentColor = remember { if (darkTheme) darkColors else lightColors } - SideEffect { - systemUiController.setStatusBarColor( - color = currentColor.background - ) - systemUiController.setSystemBarsColor( - color = Color.Transparent, - darkIcons = useDarkIcons - ) - } val rememberedColors = remember { currentColor.copy() }.apply { updateColorsFrom(currentColor) } CompositionLocalProvider( LocalColors provides rememberedColors, - LocalSpaces provides spaces, - LocalTypography provides typography, ) { - ProvideTextStyle(typography.body1, content = content) + MaterialTheme( + colorScheme = if (darkTheme) materialDarkColors else materialLightColors + ) { + val bgColor = MaterialTheme.colorScheme.background + SideEffect { + systemUiController.setStatusBarColor( + color = bgColor + ) + systemUiController.setSystemBarsColor( + color = Color.Transparent, + darkIcons = useDarkIcons + ) + } + + content() + } } } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementTypography.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementTypography.kt index 57d0beaa36..b2159522c8 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementTypography.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ElementTypography.kt @@ -22,6 +22,9 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp import com.airbnb.android.showkase.annotation.ShowkaseTypography +/** + * TODO Provide the typo to Material3 theme. + */ @ShowkaseTypography(name = "H1", group = "Element") val h1Default: TextStyle = TextStyle( fontFamily = FontFamily.SansSerif, @@ -104,15 +107,3 @@ val titleMediumDefault: TextStyle = TextStyle( letterSpacing = 0.5.sp ) -data class ElementTypography( - val h1: TextStyle = h1Default, - val body1: TextStyle = body1Default, - val bodySmall: TextStyle = bodySmallDefault, - val bodyMedium: TextStyle = bodyMediumDefault, - val bodyLarge: TextStyle = bodyLargeDefault, - val headlineSmall: TextStyle = headlineSmallDefault, - val headlineMedium: TextStyle = headlineMediumDefault, - val headlineLarge: TextStyle = headlineLargeDefault, - val titleSmall: TextStyle = titleSmallDefault, - val titleMedium: TextStyle = titleMediumDefault, -) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Button.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Button.kt index cb49ebdcd7..d20e5f9651 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Button.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Button.kt @@ -16,55 +16,46 @@ package io.element.android.libraries.designsystem.theme.components +import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.RowScope -import androidx.compose.material.ContentAlpha -import androidx.compose.material.ProvideTextStyle +import androidx.compose.material3.ButtonColors import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.ButtonElevation import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.compositeOver +import androidx.compose.ui.graphics.Shape import androidx.compose.ui.tooling.preview.Preview import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme -import io.element.android.libraries.designsystem.theme.elementContentColorFor @Composable fun Button( onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, - containerColor: Color = ElementTheme.colors.primary, + shape: Shape = ButtonDefaults.shape, + colors: ButtonColors = ButtonDefaults.buttonColors(), + elevation: ButtonElevation? = ButtonDefaults.buttonElevation(), + border: BorderStroke? = null, + contentPadding: PaddingValues = ButtonDefaults.ContentPadding, + interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, content: @Composable RowScope.() -> Unit ) { androidx.compose.material3.Button( - colors = ButtonDefaults.buttonColors( - containerColor = containerColor, - contentColor = elementContentColorFor(backgroundColor = containerColor), - disabledContainerColor = containerColor - .copy(alpha = 0.12f) - .compositeOver(containerColor), - disabledContentColor = elementContentColorFor(backgroundColor = containerColor) - .copy(alpha = ContentAlpha.disabled) - ), - // TODO shape = ButtonShape, - // TODO elevation = ButtonDefaults.elevation( - // defaultElevation = ElementTheme.elevation.default, - // pressedElevation = ElementTheme.elevation.pressed - // /* disabledElevation = 0.dp */ - // ), onClick = onClick, modifier = modifier, enabled = enabled, - content = { - ProvideTextStyle( - value = ElementTheme.typography.body1 - ) { - content() - } - } + shape = shape, + colors = colors, + elevation = elevation, + border = border, + contentPadding = contentPadding, + interactionSource = interactionSource, + content = content, ) } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Checkbox.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Checkbox.kt index 25b1637ac8..2c8a7411fb 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Checkbox.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Checkbox.kt @@ -23,11 +23,9 @@ import androidx.compose.material3.CheckboxDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme @Composable fun Checkbox( @@ -35,16 +33,7 @@ fun Checkbox( onCheckedChange: ((Boolean) -> Unit)?, modifier: Modifier = Modifier, enabled: Boolean = true, - colors: CheckboxColors = CheckboxDefaults.colors( - checkedColor = ElementTheme.colors.primary, - uncheckedColor = Color.Gray, // TODO ElementTheme.colors. - checkmarkColor = Color.Gray, // TODO ElementTheme.colors. - disabledCheckedColor = Color.Gray // TODO ElementTheme.colors. - .copy(alpha = 0.2F), - disabledUncheckedColor = Color.Gray // TODO ElementTheme.colors. - .copy(alpha = 0.2F), - disabledIndeterminateColor = Color.Gray // TODO ElementTheme.colors. - ), + colors: CheckboxColors = CheckboxDefaults.colors(), interactionSource: MutableInteractionSource = remember { MutableInteractionSource() } ) { androidx.compose.material3.Checkbox( diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/CircularProgressIndicator.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/CircularProgressIndicator.kt index 38eb970828..00a0f8c0de 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/CircularProgressIndicator.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/CircularProgressIndicator.kt @@ -21,7 +21,6 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp -import io.element.android.libraries.designsystem.theme.ElementTheme @Composable fun CircularProgressIndicator( @@ -41,7 +40,7 @@ fun CircularProgressIndicator( @Composable fun CircularProgressIndicator( modifier: Modifier = Modifier, - color: Color = ElementTheme.colors.primary, + color: Color = ProgressIndicatorDefaults.circularColor, strokeWidth: Dp = ProgressIndicatorDefaults.CircularStrokeWidth, ) { androidx.compose.material3.CircularProgressIndicator( diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Divider.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Divider.kt index 832f3b89d4..f15b81129e 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Divider.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Divider.kt @@ -24,13 +24,12 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme @Composable fun Divider( modifier: Modifier = Modifier, thickness: Dp = DividerDefaults.Thickness, - color: Color = ElementTheme.colors.onBackground, + color: Color = DividerDefaults.color, ) { androidx.compose.material3.Divider( modifier = modifier, diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/MediumTopAppBar.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/MediumTopAppBar.kt index 579583757f..cbc215717d 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/MediumTopAppBar.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/MediumTopAppBar.kt @@ -24,7 +24,6 @@ import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import io.element.android.libraries.designsystem.theme.ElementTheme @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -34,13 +33,7 @@ fun MediumTopAppBar( navigationIcon: @Composable () -> Unit = {}, actions: @Composable RowScope.() -> Unit = {}, windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, - colors: TopAppBarColors = TopAppBarDefaults.mediumTopAppBarColors( - containerColor = ElementTheme.colors.background, - scrolledContainerColor = ElementTheme.colors.background, - navigationIconContentColor = ElementTheme.colors.onBackground, - titleContentColor = ElementTheme.colors.onBackground, - actionIconContentColor = ElementTheme.colors.onBackground, - ), + colors: TopAppBarColors = TopAppBarDefaults.mediumTopAppBarColors(), scrollBehavior: TopAppBarScrollBehavior? = null ) { androidx.compose.material3.MediumTopAppBar( diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/ModalBottomSheetLayout.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/ModalBottomSheetLayout.kt index d3ca206832..6b558e3418 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/ModalBottomSheetLayout.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/ModalBottomSheetLayout.kt @@ -22,14 +22,13 @@ import androidx.compose.material.MaterialTheme import androidx.compose.material.ModalBottomSheetDefaults import androidx.compose.material.ModalBottomSheetState import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.contentColorFor import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape import androidx.compose.ui.unit.Dp -import io.element.android.libraries.designsystem.theme.ElementTheme -import io.element.android.libraries.designsystem.theme.elementContentColorFor @OptIn(ExperimentalMaterialApi::class) @Composable @@ -39,9 +38,9 @@ fun ModalBottomSheetLayout( sheetState: ModalBottomSheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden), sheetShape: Shape = MaterialTheme.shapes.large, sheetElevation: Dp = ModalBottomSheetDefaults.Elevation, - sheetBackgroundColor: Color = ElementTheme.colors.surfaceVariant, - sheetContentColor: Color = elementContentColorFor(sheetBackgroundColor), - scrimColor: Color = ElementTheme.colors.onSurfaceVariant.copy(alpha = 0.32f), + sheetBackgroundColor: Color = MaterialTheme.colors.surface, + sheetContentColor: Color = contentColorFor(sheetBackgroundColor), + scrimColor: Color = ModalBottomSheetDefaults.scrimColor, content: @Composable () -> Unit = {} ) { androidx.compose.material.ModalBottomSheetLayout( diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/OutlinedTextField.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/OutlinedTextField.kt index fe178bb28d..fae6c06328 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/OutlinedTextField.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/OutlinedTextField.kt @@ -23,6 +23,7 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.selection.TextSelectionColors import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.TextFieldColors import androidx.compose.material3.TextFieldDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.remember @@ -35,7 +36,6 @@ import androidx.compose.ui.tooling.preview.Preview import io.element.android.libraries.designsystem.ElementGreen import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -59,6 +59,7 @@ fun OutlinedTextField( maxLines: Int = Int.MAX_VALUE, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, shape: Shape = TextFieldDefaults.outlinedShape, + colors: TextFieldColors = TextFieldDefaults.outlinedTextFieldColors() ) { androidx.compose.material3.OutlinedTextField( value = value, @@ -80,39 +81,7 @@ fun OutlinedTextField( maxLines = maxLines, interactionSource = interactionSource, shape = shape, - colors = TextFieldDefaults.outlinedTextFieldColors( - textColor = ElementTheme.colors.primary, - disabledTextColor = ElementTheme.colors.primary.copy(alpha = 0.38f), - containerColor = Color.Transparent, - cursorColor = ElementTheme.colors.primary, - errorCursorColor = ElementTheme.colors.error, - selectionColors = TextSelectionColors( - handleColor = ElementGreen, - backgroundColor = ElementGreen.copy(alpha = 0.4f) - ), - focusedBorderColor = ElementTheme.colors.primary, - unfocusedBorderColor = ElementTheme.colors.secondary, - disabledBorderColor = ElementTheme.colors.secondary.copy(alpha = 0.12f), - errorBorderColor = ElementTheme.colors.error, - focusedLeadingIconColor = ElementTheme.colors.primary, - unfocusedLeadingIconColor = ElementTheme.colors.secondary, - disabledLeadingIconColor = ElementTheme.colors.secondary.copy(0.12f), - errorLeadingIconColor = ElementTheme.colors.error, - focusedTrailingIconColor = ElementTheme.colors.primary, - unfocusedTrailingIconColor = ElementTheme.colors.secondary, - disabledTrailingIconColor = ElementTheme.colors.secondary.copy(alpha = 0.12f), - errorTrailingIconColor = ElementTheme.colors.error, - focusedLabelColor = ElementTheme.colors.primary, - unfocusedLabelColor = ElementTheme.colors.secondary, - disabledLabelColor = ElementTheme.colors.secondary.copy(alpha = 0.12f), - errorLabelColor = ElementTheme.colors.error, - placeholderColor = ElementTheme.colors.secondary, - disabledPlaceholderColor = ElementTheme.colors.secondary.copy(alpha = 0.12f), - focusedSupportingTextColor = ElementTheme.colors.primary, - unfocusedSupportingTextColor = ElementTheme.colors.secondary, - disabledSupportingTextColor = ElementTheme.colors.primary.copy(alpha = 0.12f), - errorSupportingTextColor = ElementTheme.colors.error, - ), + colors = colors, ) } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Scaffold.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Scaffold.kt index 7a1ede6d70..99a69c0553 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Scaffold.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Scaffold.kt @@ -20,12 +20,12 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.WindowInsets import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.FabPosition +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ScaffoldDefaults +import androidx.compose.material3.contentColorFor import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import io.element.android.libraries.designsystem.theme.ElementTheme -import io.element.android.libraries.designsystem.theme.elementContentColorFor @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -36,8 +36,8 @@ fun Scaffold( snackbarHost: @Composable () -> Unit = {}, floatingActionButton: @Composable () -> Unit = {}, floatingActionButtonPosition: FabPosition = FabPosition.End, - containerColor: Color = ElementTheme.colors.background, - contentColor: Color = elementContentColorFor(containerColor), + containerColor: Color = MaterialTheme.colorScheme.background, + contentColor: Color = contentColorFor(containerColor), contentWindowInsets: WindowInsets = ScaffoldDefaults.contentWindowInsets, content: @Composable (PaddingValues) -> Unit ) { diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Slider.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Slider.kt index 87e1757dd7..edefe1ab98 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Slider.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Slider.kt @@ -18,6 +18,7 @@ package io.element.android.libraries.designsystem.theme.components import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Column +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SliderColors import androidx.compose.material3.SliderDefaults import androidx.compose.runtime.Composable @@ -26,7 +27,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme @Composable fun Slider( @@ -38,18 +38,7 @@ fun Slider( /*@IntRange(from = 0)*/ steps: Int = 0, onValueChangeFinished: (() -> Unit)? = null, - colors: SliderColors = SliderDefaults.colors( - thumbColor = ElementTheme.colors.primary, - activeTrackColor = ElementTheme.colors.primary, - activeTickColor = ElementTheme.colors.primary, - inactiveTrackColor = ElementTheme.colors.primary, - inactiveTickColor = ElementTheme.colors.primary, - disabledThumbColor = ElementTheme.colors.primary.copy(alpha = 0.40f), - disabledActiveTrackColor = ElementTheme.colors.primary.copy(alpha = 0.40f), - disabledActiveTickColor = ElementTheme.colors.primary.copy(alpha = 0.40f), - disabledInactiveTrackColor = ElementTheme.colors.primary.copy(alpha = 0.40f), - disabledInactiveTickColor = ElementTheme.colors.primary.copy(alpha = 0.40f), - ), + colors: SliderColors = SliderDefaults.colors(), interactionSource: MutableInteractionSource = remember { MutableInteractionSource() } ) { androidx.compose.material3.Slider( diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Surface.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Surface.kt index 0689680972..8518d8a715 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Surface.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/Surface.kt @@ -17,6 +17,8 @@ package io.element.android.libraries.designsystem.theme.components import androidx.compose.foundation.BorderStroke +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.contentColorFor import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -24,15 +26,13 @@ import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.Shape import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import io.element.android.libraries.designsystem.theme.ElementTheme -import io.element.android.libraries.designsystem.theme.elementContentColorFor @Composable fun Surface( modifier: Modifier = Modifier, shape: Shape = RectangleShape, - color: Color = ElementTheme.colors.surfaceVariant, - contentColor: Color = elementContentColorFor(color), + color: Color = MaterialTheme.colorScheme.surface, + contentColor: Color = contentColorFor(color), tonalElevation: Dp = 0.dp, shadowElevation: Dp = 0.dp, border: BorderStroke? = null, diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt index 3a16b8fedb..dba39fccf1 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.ContentAlpha import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.TextFieldColors import androidx.compose.material3.TextFieldDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.remember @@ -30,7 +31,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.VisualTransformation -import io.element.android.libraries.designsystem.theme.ElementTheme @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -54,6 +54,7 @@ fun TextField( maxLines: Int = Int.MAX_VALUE, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, shape: Shape = TextFieldDefaults.filledShape, + colors: TextFieldColors = TextFieldDefaults.textFieldColors() ) { androidx.compose.material3.TextField( value = value, @@ -75,13 +76,6 @@ fun TextField( maxLines = maxLines, interactionSource = interactionSource, shape = shape, - colors = TextFieldDefaults.textFieldColors( - textColor = ElementTheme.colors.onBackground, - containerColor = Color.Transparent, - cursorColor = ElementTheme.colors.onBackground.copy(alpha = ContentAlpha.medium), - focusedIndicatorColor = Color.Transparent, - unfocusedIndicatorColor = Color.Transparent, - disabledIndicatorColor = Color.Transparent - ), + colors = colors, ) } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TopAppBar.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TopAppBar.kt index 3930e2e3c1..76c388cefe 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TopAppBar.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TopAppBar.kt @@ -24,7 +24,6 @@ import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import io.element.android.libraries.designsystem.theme.ElementTheme @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -34,13 +33,7 @@ fun TopAppBar( navigationIcon: @Composable () -> Unit = {}, actions: @Composable RowScope.() -> Unit = {}, windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, - colors: TopAppBarColors = TopAppBarDefaults.smallTopAppBarColors( - containerColor = ElementTheme.colors.background, - scrolledContainerColor = ElementTheme.colors.background, - navigationIconContentColor = ElementTheme.colors.onBackground, - titleContentColor = ElementTheme.colors.onBackground, - actionIconContentColor = ElementTheme.colors.onBackground, - ), + colors: TopAppBarColors = TopAppBarDefaults.smallTopAppBarColors(), scrollBehavior: TopAppBarScrollBehavior? = null ) { androidx.compose.material3.TopAppBar( diff --git a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/MatrixUserHeader.kt b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/MatrixUserHeader.kt index a8ce4af56f..e83c486476 100644 --- a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/MatrixUserHeader.kt +++ b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/MatrixUserHeader.kt @@ -23,6 +23,7 @@ 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.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -36,7 +37,6 @@ import io.element.android.libraries.designsystem.components.avatar.AvatarData import io.element.android.libraries.designsystem.components.avatar.AvatarSize import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.matrix.core.UserId import io.element.android.libraries.matrix.ui.model.MatrixUser @@ -67,14 +67,14 @@ fun MatrixUserHeader( text = matrixUser.getBestName(), maxLines = 1, overflow = TextOverflow.Ellipsis, - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) // Id if (matrixUser.username.isNullOrEmpty().not()) { Spacer(modifier = Modifier.height(4.dp)) Text( text = matrixUser.id.value, - color = ElementTheme.colors.secondary, + color = MaterialTheme.colorScheme.secondary, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis diff --git a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/MatrixUserRow.kt b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/MatrixUserRow.kt index 5b6db5b7e6..50bb7d377f 100644 --- a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/MatrixUserRow.kt +++ b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/MatrixUserRow.kt @@ -23,6 +23,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -35,7 +36,6 @@ import io.element.android.libraries.designsystem.components.avatar.Avatar import io.element.android.libraries.designsystem.components.avatar.AvatarData import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.matrix.core.UserId import io.element.android.libraries.matrix.ui.model.MatrixUser @@ -71,13 +71,13 @@ fun MatrixUserRow( text = matrixUser.getBestName(), maxLines = 1, overflow = TextOverflow.Ellipsis, - color = ElementTheme.colors.primary, + color = MaterialTheme.colorScheme.primary, ) // Id if (matrixUser.username.isNullOrEmpty().not()) { Text( text = matrixUser.id.value, - color = ElementTheme.colors.secondary, + color = MaterialTheme.colorScheme.secondary, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis diff --git a/libraries/textcomposer/src/main/kotlin/io/element/android/libraries/textcomposer/TextComposer.kt b/libraries/textcomposer/src/main/kotlin/io/element/android/libraries/textcomposer/TextComposer.kt index ab736f4177..2c5cc26798 100644 --- a/libraries/textcomposer/src/main/kotlin/io/element/android/libraries/textcomposer/TextComposer.kt +++ b/libraries/textcomposer/src/main/kotlin/io/element/android/libraries/textcomposer/TextComposer.kt @@ -21,6 +21,7 @@ import android.net.Uri import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -34,7 +35,6 @@ import androidx.core.view.isInvisible import androidx.core.view.isVisible import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.ElementTheme import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.ui.strings.R as StringR @@ -127,7 +127,7 @@ private fun FakeComposer( textAlign = TextAlign.Center, text = "Composer Preview", fontSize = 20.sp, - color = ElementTheme.colors.secondary, + color = MaterialTheme.colorScheme.secondary, ) } } diff --git a/plugins/src/main/kotlin/extension/DependencyHandleScope.kt b/plugins/src/main/kotlin/extension/DependencyHandleScope.kt index 49cf6dd1cd..710f603cad 100644 --- a/plugins/src/main/kotlin/extension/DependencyHandleScope.kt +++ b/plugins/src/main/kotlin/extension/DependencyHandleScope.kt @@ -38,6 +38,7 @@ fun DependencyHandlerScope.composeDependencies() { androidTestImplementation(composeBom) implementation("androidx.compose.ui:ui") implementation("androidx.compose.material:material") + implementation("androidx.compose.material3:material3") implementation("androidx.compose.material:material-icons-extended") implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.activity:activity-compose:1.6.1") diff --git a/tests/uitests/src/test/kotlin/io/element/android/tests/uitests/ScreenshotTest.kt b/tests/uitests/src/test/kotlin/io/element/android/tests/uitests/ScreenshotTest.kt index bcd78869cf..1ccb0d76b2 100644 --- a/tests/uitests/src/test/kotlin/io/element/android/tests/uitests/ScreenshotTest.kt +++ b/tests/uitests/src/test/kotlin/io/element/android/tests/uitests/ScreenshotTest.kt @@ -24,6 +24,7 @@ import androidx.activity.OnBackPressedDispatcherOwner import androidx.activity.compose.LocalOnBackPressedDispatcherOwner import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalConfiguration @@ -74,7 +75,6 @@ class ScreenshotTest { @TestParameter(valuesProvider = PreviewProvider::class) componentTestPreview: TestPreview, @TestParameter baseDeviceConfig: BaseDeviceConfig, @TestParameter(value = ["1.0"/*, "1.5"*/]) fontScale: Float, - @TestParameter(value = ["light", "dark"]) theme: String, @TestParameter(value = ["en" /*"fr", "de", "ru"*/]) localeStr: String, ) { paparazzi.unsafeUpdateConfig( @@ -100,8 +100,8 @@ class ScreenshotTest { override fun getOnBackPressedDispatcher() = OnBackPressedDispatcher() } ) { - ElementTheme(darkTheme = (theme == "dark")) { - Box(modifier = Modifier.background(ElementTheme.colors.background)) { + ElementTheme { + Box(modifier = Modifier.background(MaterialTheme.colorScheme.background)) { componentTestPreview.Content() } } diff --git a/tests/uitests/src/test/kotlin/io/element/android/tests/uitests/TypographyTestPreview.kt b/tests/uitests/src/test/kotlin/io/element/android/tests/uitests/TypographyTestPreview.kt index 6f3b4f4bbf..80f27c25a0 100644 --- a/tests/uitests/src/test/kotlin/io/element/android/tests/uitests/TypographyTestPreview.kt +++ b/tests/uitests/src/test/kotlin/io/element/android/tests/uitests/TypographyTestPreview.kt @@ -19,11 +19,11 @@ package io.element.android.tests.uitests import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.text.BasicText +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.airbnb.android.showkase.models.ShowkaseBrowserTypography import com.airbnb.android.showkase.ui.padding4x -import io.element.android.libraries.designsystem.theme.ElementTheme import java.util.Locale class TypographyTestPreview( @@ -39,7 +39,7 @@ class TypographyTestPreview( .fillMaxWidth() .padding(padding4x), style = showkaseBrowserTypography.textStyle.copy( - color = ElementTheme.colors.onBackground + color = MaterialTheme.colorScheme.onBackground ) ) }