Remove ElementTextStyles. Only ElementTheme.typography.* styles must be used now.

This commit is contained in:
Benoit Marty 2023-07-10 16:15:19 +02:00 committed by Benoit Marty
parent e2f3f2966b
commit 5846af2aa4
22 changed files with 96 additions and 312 deletions

View file

@ -1,234 +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
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.sp
// TODO Remove
object ElementTextStyles {
@Suppress("DEPRECATION")
val Button = TextStyle(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
lineHeight = 22.sp,
fontStyle = FontStyle.Normal,
textAlign = TextAlign.Center,
platformStyle = PlatformTextStyle(includeFontPadding = false)
)
object Bold {
val largeTitle = TextStyle(
fontSize = 34.sp,
fontWeight = FontWeight.Bold,
fontStyle = FontStyle.Normal,
lineHeight = 41.sp,
textAlign = TextAlign.Center
)
val title1 = TextStyle(
fontSize = 28.sp,
fontWeight = FontWeight.Bold,
fontStyle = FontStyle.Normal,
lineHeight = 34.sp,
textAlign = TextAlign.Center
)
val title2 = TextStyle(
fontSize = 22.sp,
fontWeight = FontWeight.Bold,
fontStyle = FontStyle.Normal,
lineHeight = 28.sp,
textAlign = TextAlign.Center
)
val title3 = TextStyle(
fontSize = 20.sp,
fontWeight = FontWeight.SemiBold,
fontStyle = FontStyle.Normal,
lineHeight = 25.sp,
textAlign = TextAlign.Center
)
val headline = TextStyle(
fontSize = 17.sp,
fontWeight = FontWeight.SemiBold,
fontStyle = FontStyle.Normal,
lineHeight = 22.sp,
textAlign = TextAlign.Center
)
val body = TextStyle(
fontSize = 17.sp,
fontWeight = FontWeight.SemiBold,
fontStyle = FontStyle.Normal,
lineHeight = 22.sp,
textAlign = TextAlign.Center
)
val callout = TextStyle(
fontSize = 16.sp,
fontWeight = FontWeight.SemiBold,
fontStyle = FontStyle.Normal,
lineHeight = 21.sp,
textAlign = TextAlign.Center
)
val subheadline = TextStyle(
fontSize = 15.sp,
fontWeight = FontWeight.SemiBold,
fontStyle = FontStyle.Normal,
lineHeight = 20.sp,
textAlign = TextAlign.Center
)
val footnote = TextStyle(
fontSize = 13.sp,
fontWeight = FontWeight.SemiBold,
fontStyle = FontStyle.Normal,
lineHeight = 18.sp,
textAlign = TextAlign.Center
)
val caption1 = TextStyle(
fontSize = 12.sp,
fontWeight = FontWeight.Medium,
fontStyle = FontStyle.Normal,
lineHeight = 16.sp,
textAlign = TextAlign.Center
)
val caption2 = TextStyle(
fontSize = 11.sp,
fontWeight = FontWeight.Medium,
fontStyle = FontStyle.Normal,
lineHeight = 13.sp,
textAlign = TextAlign.Center
)
}
object Regular {
val largeTitle = TextStyle(
fontSize = 34.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 41.sp,
textAlign = TextAlign.Center
)
val title1 = TextStyle(
fontSize = 28.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 34.sp,
textAlign = TextAlign.Center
)
val title2 = TextStyle(
fontSize = 22.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 28.sp,
textAlign = TextAlign.Center
)
val title3 = TextStyle(
fontSize = 20.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 25.sp,
textAlign = TextAlign.Center
)
val headline = TextStyle(
fontSize = 17.sp,
fontWeight = FontWeight.SemiBold,
fontStyle = FontStyle.Normal,
lineHeight = 22.sp,
textAlign = TextAlign.Center
)
val body = TextStyle(
fontSize = 17.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 22.sp,
textAlign = TextAlign.Center
)
val callout = TextStyle(
fontSize = 16.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 21.sp,
textAlign = TextAlign.Center
)
val subheadline = TextStyle(
fontSize = 15.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 20.sp,
textAlign = TextAlign.Center
)
val formHeader = TextStyle(
fontSize = 14.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 20.sp,
textAlign = TextAlign.Start
)
val bodyMD = TextStyle(
fontSize = 14.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 20.sp,
textAlign = TextAlign.Start
)
val footnote = TextStyle(
fontSize = 13.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 18.sp,
textAlign = TextAlign.Center
)
val caption1 = TextStyle(
fontSize = 12.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 16.sp,
textAlign = TextAlign.Center
)
val caption2 = TextStyle(
fontSize = 11.sp,
fontWeight = FontWeight.Normal,
fontStyle = FontStyle.Normal,
lineHeight = 13.sp,
textAlign = TextAlign.Center
)
}
}

View file

@ -29,13 +29,13 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.ElementTextStyles
import io.element.android.libraries.designsystem.R
import io.element.android.libraries.designsystem.atomic.atoms.RoundedIconAtom
import io.element.android.libraries.designsystem.atomic.atoms.RoundedIconAtomSize
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.theme.ElementTheme
/**
* IconTitleSubtitleMolecule is a molecule which displays an icon, a title and a subtitle.
@ -71,7 +71,7 @@ fun IconTitleSubtitleMolecule(
modifier = Modifier
.fillMaxWidth(),
textAlign = TextAlign.Center,
style = ElementTextStyles.Bold.title2,
style = ElementTheme.typography.fontHeadingMdBold,
color = MaterialTheme.colorScheme.primary,
)
Spacer(Modifier.height(8.dp))
@ -79,7 +79,7 @@ fun IconTitleSubtitleMolecule(
text = subTitle,
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center,
style = ElementTextStyles.Regular.subheadline,
style = ElementTheme.typography.fontBodyMdRegular,
color = MaterialTheme.colorScheme.secondary,
)
}

View file

@ -32,13 +32,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.ElementTextStyles
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
import io.element.android.libraries.designsystem.preview.PreviewGroup
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.ElementButtonDefaults
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.theme.ElementTheme
/**
* A component that will display a button with an indeterminate circular progressbar.
@ -64,7 +64,9 @@ fun ButtonWithProgress(
) {
Button(
onClick = {
if (!showProgress) { onClick() }
if (!showProgress) {
onClick()
}
},
modifier = modifier,
enabled = enabled,
@ -85,10 +87,10 @@ fun ButtonWithProgress(
)
if (progressText != null) {
Spacer(Modifier.width(10.dp))
Text(progressText, style = ElementTextStyles.Button)
Text(progressText, style = ElementTheme.typography.fontBodyLgMedium)
}
} else if (text != null) {
Text(text, style = ElementTextStyles.Button)
Text(text, style = ElementTheme.typography.fontBodyLgMedium)
}
}
}

View file

@ -33,14 +33,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.ElementTextStyles
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
import io.element.android.libraries.designsystem.preview.PreviewGroup
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.theme.ElementTheme
@Composable
fun MainActionButton(
@ -71,7 +70,7 @@ fun MainActionButton(
Spacer(modifier = Modifier.height(14.dp))
Text(
title,
style = ElementTextStyles.Regular.bodyMD.copy(fontWeight = FontWeight.Medium),
style = ElementTheme.typography.fontBodyMdMedium,
color = tintColor,
)
}

View file

@ -38,8 +38,8 @@ import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.Placeable
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.ElementTextStyles
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.theme.ElementTheme
import kotlin.math.max
@Composable
@ -72,24 +72,26 @@ internal fun SimpleAlertDialogContent(
// If there is a 3rd item it should be at the end of the dialog
// Having this 3rd action is discouraged, see https://m3.material.io/components/dialogs/guidelines#e13b68f5-e367-4275-ad6f-c552ee8e358f
TextButton(onClick = onThirdButtonClicked) {
Text(thirdButtonText)
Text(
text = thirdButtonText,
style = ElementTheme.typography.fontBodyMdRegular,
)
}
}
TextButton(onClick = onCancelClicked) {
Text(cancelText)
Text(
text = cancelText,
style = ElementTheme.typography.fontBodyMdRegular,
)
}
if (submitText != null) {
TextButton(
onClick = {
onSubmitClicked()
},
) {
TextButton(onClick = onSubmitClicked) {
Text(
submitText,
text = submitText,
style = if (emphasizeSubmitButton) {
ElementTextStyles.Bold.subheadline
ElementTheme.typography.fontBodyMdMedium
} else {
MaterialTheme.typography.labelLarge
ElementTheme.typography.fontBodyMdRegular
}
)
}
@ -98,10 +100,18 @@ internal fun SimpleAlertDialogContent(
},
modifier = modifier,
title = {
if (title != null) { Text(text = title) }
if (title != null) {
Text(
text = title,
style = ElementTheme.typography.fontHeadingSmRegular,
)
}
},
text = {
Text(content)
Text(
text = content,
style = ElementTheme.typography.fontBodyMdRegular,
)
},
shape = shape,
containerColor = containerColor,

View file

@ -29,6 +29,7 @@ import androidx.compose.ui.unit.Dp
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
import io.element.android.libraries.designsystem.preview.PreviewGroup
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.theme.ElementTheme
import io.element.android.libraries.ui.strings.CommonStrings
@Composable
@ -51,19 +52,31 @@ fun RetryDialog(
modifier = modifier,
onDismissRequest = onDismiss,
title = {
Text(title)
Text(
text = title,
style = ElementTheme.typography.fontHeadingSmRegular,
)
},
text = {
Text(content)
Text(
text = content,
style = ElementTheme.typography.fontBodyMdRegular,
)
},
confirmButton = {
TextButton(onClick = onRetry) {
Text(retryText)
Text(
text = retryText,
style = ElementTheme.typography.fontBodyMdRegular,
)
}
},
dismissButton = {
TextButton(onClick = onDismiss) {
Text(dismissText)
Text(
text = dismissText,
style = ElementTheme.typography.fontBodyMdRegular,
)
}
},
shape = shape,