Add missing base text styles

This commit is contained in:
Andrew 2024-06-12 08:56:48 +09:30
parent 3c36f1247b
commit 48febb4f10
10 changed files with 92 additions and 58 deletions

View File

@ -33,7 +33,9 @@ import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNo
import org.thoughtcrime.securesms.onboarding.pickname.startPickDisplayNameActivity import org.thoughtcrime.securesms.onboarding.pickname.startPickDisplayNameActivity
import org.thoughtcrime.securesms.ui.AppTheme import org.thoughtcrime.securesms.ui.AppTheme
import org.thoughtcrime.securesms.ui.ProgressArc import org.thoughtcrime.securesms.ui.ProgressArc
import org.thoughtcrime.securesms.ui.base
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.h7
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
import javax.inject.Inject import javax.inject.Inject
@ -104,11 +106,20 @@ class LoadingActivity: BaseActionBarActivity() {
} }
AppTheme { AppTheme {
Column { Column(horizontalAlignment = Alignment.CenterHorizontally) {
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
ProgressArc(animatable.value, modifier = Modifier.align(Alignment.CenterHorizontally).contentDescription(R.string.AccessibilityId_loading_animation)) ProgressArc(
Text(stringResource(R.string.waitOneMoment), modifier = Modifier.align(Alignment.CenterHorizontally), style = MaterialTheme.typography.h6) animatable.value,
Text(stringResource(R.string.loadAccountProgressMessage), modifier = Modifier.align(Alignment.CenterHorizontally)) modifier = Modifier.contentDescription(R.string.AccessibilityId_loading_animation)
)
Text(
stringResource(R.string.waitOneMoment),
style = MaterialTheme.typography.h7
)
Text(
stringResource(R.string.loadAccountProgressMessage),
style = MaterialTheme.typography.base
)
Spacer(modifier = Modifier.weight(2f)) Spacer(modifier = Modifier.weight(2f))
} }
} }

View File

@ -40,6 +40,7 @@ import org.thoughtcrime.securesms.notifications.PushRegistry
import org.thoughtcrime.securesms.ui.AppTheme import org.thoughtcrime.securesms.ui.AppTheme
import org.thoughtcrime.securesms.ui.PreviewTheme import org.thoughtcrime.securesms.ui.PreviewTheme
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
import org.thoughtcrime.securesms.ui.base
import org.thoughtcrime.securesms.ui.components.OutlineButton import org.thoughtcrime.securesms.ui.components.OutlineButton
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.h8 import org.thoughtcrime.securesms.ui.h8
@ -106,7 +107,7 @@ fun MessageNotificationsScreen(
Spacer(Modifier.weight(1f)) Spacer(Modifier.weight(1f))
Text(stringResource(R.string.notificationsMessage), style = MaterialTheme.typography.h4) Text(stringResource(R.string.notificationsMessage), style = MaterialTheme.typography.h4)
Spacer(Modifier.height(16.dp)) Spacer(Modifier.height(16.dp))
Text(stringResource(R.string.onboardingMessageNotificationExplaination)) Text(stringResource(R.string.onboardingMessageNotificationExplaination), style = MaterialTheme.typography.base)
Spacer(Modifier.height(16.dp)) Spacer(Modifier.height(16.dp))
NotificationRadioButton( NotificationRadioButton(
R.string.activity_pn_mode_fast_mode, R.string.activity_pn_mode_fast_mode,

View File

@ -7,6 +7,7 @@ import androidx.activity.viewModels
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
@ -37,10 +38,12 @@ import org.thoughtcrime.securesms.BaseActionBarActivity
import org.thoughtcrime.securesms.onboarding.messagenotifications.MessageNotificationsActivity import org.thoughtcrime.securesms.onboarding.messagenotifications.MessageNotificationsActivity
import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity import org.thoughtcrime.securesms.onboarding.messagenotifications.startMessageNotificationsActivity
import org.thoughtcrime.securesms.ui.AppTheme import org.thoughtcrime.securesms.ui.AppTheme
import org.thoughtcrime.securesms.ui.GetString
import org.thoughtcrime.securesms.ui.PreviewTheme import org.thoughtcrime.securesms.ui.PreviewTheme
import org.thoughtcrime.securesms.ui.base import org.thoughtcrime.securesms.ui.base
import org.thoughtcrime.securesms.ui.baseBold import org.thoughtcrime.securesms.ui.baseBold
import org.thoughtcrime.securesms.ui.components.OutlineButton import org.thoughtcrime.securesms.ui.components.OutlineButton
import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.outlinedTextFieldColors import org.thoughtcrime.securesms.ui.outlinedTextFieldColors
import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo import org.thoughtcrime.securesms.util.setUpActionBarSessionLogo
@ -106,32 +109,17 @@ class PickDisplayNameActivity : BaseActionBarActivity() {
style = MaterialTheme.typography.base, style = MaterialTheme.typography.base,
modifier = Modifier.padding(bottom = 12.dp)) modifier = Modifier.padding(bottom = 12.dp))
OutlinedTextField( SessionOutlinedTextField(
value = state.displayName, text = state.displayName,
modifier = Modifier.contentDescription(R.string.AccessibilityId_enter_display_name), modifier = Modifier
onValueChange = { onChange(it) }, .fillMaxWidth()
placeholder = { Text(stringResource(R.string.displayNameEnter)) }, .contentDescription(R.string.AccessibilityId_enter_display_name),
colors = outlinedTextFieldColors(state.error != null), placeholder = stringResource(R.string.displayNameEnter),
singleLine = true, onChange = onChange,
keyboardActions = KeyboardActions( onContinue = onContinue,
onDone = { onContinue() }, error = state.error?.let { stringResource(it) }
onGo = { onContinue() },
onSearch = { onContinue() },
onSend = { onContinue() },
),
isError = state.error != null,
shape = RoundedCornerShape(12.dp)
) )
state.error?.let {
Text(
stringResource(it),
modifier = Modifier.contentDescription(R.string.AccessibilityId_error_message),
style = MaterialTheme.typography.baseBold,
color = MaterialTheme.colors.error
)
}
Spacer(modifier = Modifier.weight(2f)) Spacer(modifier = Modifier.weight(2f))
OutlineButton( OutlineButton(

View File

@ -73,7 +73,8 @@ class PickDisplayNameViewModel(
} }
fun onChange(value: String) { fun onChange(value: String) {
state.update { state -> state.copy( state.update { state ->
state.copy(
displayName = value, displayName = value,
error = value.takeIf { it.length > NAME_PADDED_LENGTH }?.let { R.string.displayNameErrorDescriptionShorter } error = value.takeIf { it.length > NAME_PADDED_LENGTH }?.let { R.string.displayNameErrorDescriptionShorter }
) )

View File

@ -26,7 +26,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameter
@ -41,6 +40,7 @@ import org.thoughtcrime.securesms.ui.PreviewTheme
import org.thoughtcrime.securesms.ui.SessionShieldIcon import org.thoughtcrime.securesms.ui.SessionShieldIcon
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
import org.thoughtcrime.securesms.ui.base import org.thoughtcrime.securesms.ui.base
import org.thoughtcrime.securesms.ui.baseBold
import org.thoughtcrime.securesms.ui.classicDarkColors import org.thoughtcrime.securesms.ui.classicDarkColors
import org.thoughtcrime.securesms.ui.components.DestructiveButtons import org.thoughtcrime.securesms.ui.components.DestructiveButtons
import org.thoughtcrime.securesms.ui.components.OutlineButton import org.thoughtcrime.securesms.ui.components.OutlineButton
@ -49,7 +49,7 @@ import org.thoughtcrime.securesms.ui.components.QrImage
import org.thoughtcrime.securesms.ui.components.SmallButtons import org.thoughtcrime.securesms.ui.components.SmallButtons
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.h8 import org.thoughtcrime.securesms.ui.h8
import org.thoughtcrime.securesms.ui.small import org.thoughtcrime.securesms.ui.smallMonospace
class RecoveryPasswordActivity : BaseActionBarActivity() { class RecoveryPasswordActivity : BaseActionBarActivity() {
@ -135,14 +135,20 @@ fun RecoveryPasswordCell(seed: String, copySeed:() -> Unit = {}) {
CellWithPaddingAndMargin { CellWithPaddingAndMargin {
Column { Column {
Row { Row {
Text(stringResource(R.string.sessionRecoveryPassword), style = MaterialTheme.typography.h8) Text(
Spacer(Modifier.width(8.dp)) stringResource(R.string.sessionRecoveryPassword),
style = MaterialTheme.typography.h8
)
Spacer(Modifier.width(LocalDimensions.current.itemSpacingExtraSmall))
SessionShieldIcon() SessionShieldIcon()
} }
Spacer(modifier = Modifier.height(LocalDimensions.current.marginTiny)) Spacer(modifier = Modifier.height(LocalDimensions.current.marginTiny))
Text(stringResource(R.string.recoveryPasswordDescription), style = MaterialTheme.typography.base) Text(
stringResource(R.string.recoveryPasswordDescription),
style = MaterialTheme.typography.base
)
AnimatedVisibility(!showQr) { AnimatedVisibility(!showQr) {
RecoveryPassword(seed) RecoveryPassword(seed)
@ -155,7 +161,7 @@ fun RecoveryPasswordCell(seed: String, copySeed:() -> Unit = {}) {
QrImage( QrImage(
seed, seed,
modifier = Modifier modifier = Modifier
.padding(vertical = 24.dp) .padding(vertical = LocalDimensions.current.marginSmall)
.contentDescription(R.string.AccessibilityId_qr_code), .contentDescription(R.string.AccessibilityId_qr_code),
icon = R.drawable.session_shield icon = R.drawable.session_shield
) )
@ -169,9 +175,16 @@ fun RecoveryPasswordCell(seed: String, copySeed:() -> Unit = {}) {
.contentDescription(R.string.AccessibilityId_copy_button), .contentDescription(R.string.AccessibilityId_copy_button),
onClick = copySeed onClick = copySeed
) { isTemporary -> ) { isTemporary ->
Text(stringResource( if (isTemporary) R.string.copied else R.string.copy)) Text(
stringResource( if (isTemporary) R.string.copied else R.string.copy),
style = MaterialTheme.typography.baseBold
)
} }
OutlineButton(textId = R.string.qrView, modifier = Modifier.weight(1f), onClick = { showQr = !showQr }) OutlineButton(
textId = R.string.qrView,
modifier = Modifier.weight(1f),
onClick = { showQr = !showQr }
)
} }
} }
@ -191,15 +204,15 @@ private fun RecoveryPassword(seed: String) {
seed, seed,
modifier = Modifier modifier = Modifier
.contentDescription(R.string.AccessibilityId_recovery_password_container) .contentDescription(R.string.AccessibilityId_recovery_password_container)
.padding(vertical = 24.dp) .padding(vertical = LocalDimensions.current.marginSmall)
.border( .border(
width = 1.dp, width = 1.dp,
color = classicDarkColors[3], color = classicDarkColors[3],
shape = RoundedCornerShape(11.dp) shape = RoundedCornerShape(11.dp)
) )
.padding(24.dp), .padding(LocalDimensions.current.marginSmall),
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
style = MaterialTheme.typography.small.copy(fontFamily = FontFamily.Monospace), style = MaterialTheme.typography.smallMonospace,
color = MaterialTheme.colors.run { if (isLight) onSurface else secondary }, color = MaterialTheme.colors.run { if (isLight) onSurface else secondary },
) )
} }
@ -211,8 +224,14 @@ private fun HideRecoveryPasswordCell(onHide: () -> Unit = {}) {
Column( Column(
Modifier.weight(1f) Modifier.weight(1f)
) { ) {
Text(text = stringResource(R.string.recoveryPasswordHideRecoveryPassword), style = MaterialTheme.typography.h8) Text(
Text(text = stringResource(R.string.recoveryPasswordHideRecoveryPasswordDescription)) stringResource(R.string.recoveryPasswordHideRecoveryPassword),
style = MaterialTheme.typography.h8
)
Text(
stringResource(R.string.recoveryPasswordHideRecoveryPasswordDescription),
style = MaterialTheme.typography.base
)
} }
DestructiveButtons { DestructiveButtons {
OutlineButton( OutlineButton(

View File

@ -23,6 +23,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.DisposableEffect
@ -79,6 +80,7 @@ import org.thoughtcrime.securesms.ui.Cell
import org.thoughtcrime.securesms.ui.Divider import org.thoughtcrime.securesms.ui.Divider
import org.thoughtcrime.securesms.ui.ItemButton import org.thoughtcrime.securesms.ui.ItemButton
import org.thoughtcrime.securesms.ui.ItemButtonWithDrawable import org.thoughtcrime.securesms.ui.ItemButtonWithDrawable
import org.thoughtcrime.securesms.ui.baseBold
import org.thoughtcrime.securesms.ui.components.OutlineButton import org.thoughtcrime.securesms.ui.components.OutlineButton
import org.thoughtcrime.securesms.ui.components.OutlineTemporaryStateButton import org.thoughtcrime.securesms.ui.components.OutlineTemporaryStateButton
import org.thoughtcrime.securesms.ui.contentDescription import org.thoughtcrime.securesms.ui.contentDescription
@ -394,18 +396,20 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
horizontalArrangement = Arrangement.spacedBy(16.dp), horizontalArrangement = Arrangement.spacedBy(16.dp),
) { ) {
OutlineButton( OutlineButton(
stringResource(R.string.share),
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
onClick = { sendInvitationToUseSession() } onClick = { sendInvitationToUseSession() }
) { )
Text(stringResource(R.string.share))
}
OutlineTemporaryStateButton( OutlineTemporaryStateButton(
modifier = Modifier.weight(1f) modifier = Modifier.weight(1f)
.contentDescription(R.string.AccessibilityId_copy_button), .contentDescription(R.string.AccessibilityId_copy_button),
onClick = { copyPublicKey() }, onClick = { copyPublicKey() },
) { isTemporary -> ) { isTemporary ->
Text(stringResource(if (isTemporary) R.string.copied else R.string.copy)) Text(
stringResource(if (isTemporary) R.string.copied else R.string.copy),
style = MaterialTheme.typography.baseBold
)
} }
} }

View File

@ -91,7 +91,10 @@ data class RadioOption<T>(
@Composable @Composable
fun <T> OptionsCard(card: OptionsCard<T>, callbacks: Callbacks<T>) { fun <T> OptionsCard(card: OptionsCard<T>, callbacks: Callbacks<T>) {
Text(text = card.title()) Text(
card.title(),
style = MaterialTheme.typography.base
)
CellNoMargin { CellNoMargin {
LazyColumn( LazyColumn(
modifier = Modifier.heightIn(max = 5000.dp) modifier = Modifier.heightIn(max = 5000.dp)
@ -348,7 +351,12 @@ fun ProgressArc(progress: Float, modifier: Modifier = Modifier) {
Box(modifier = modifier) { Box(modifier = modifier) {
Arc(percentage = progress, modifier = Modifier.align(Alignment.Center)) Arc(percentage = progress, modifier = Modifier.align(Alignment.Center))
Text("${text}%", color = Color.White, modifier = Modifier.align(Alignment.Center), style = MaterialTheme.typography.h2) Text(
"${text}%",
color = Color.White,
modifier = Modifier.align(Alignment.Center),
style = MaterialTheme.typography.h2
)
} }
} }

View File

@ -143,6 +143,7 @@ val Typography.base get() = defaultStyle(14.sp)
val Typography.baseBold get() = boldStyle(14.sp) val Typography.baseBold get() = boldStyle(14.sp)
val Typography.baseMonospace get() = defaultStyle(14.sp).copy(fontFamily = FontFamily.Monospace) val Typography.baseMonospace get() = defaultStyle(14.sp).copy(fontFamily = FontFamily.Monospace)
val Typography.small get() = defaultStyle(12.sp) val Typography.small get() = defaultStyle(12.sp)
val Typography.smallMonospace get() = defaultStyle(12.sp).copy(fontFamily = FontFamily.Monospace)
val Typography.extraSmall get() = defaultStyle(11.sp) val Typography.extraSmall get() = defaultStyle(11.sp)
val Typography.fine get() = defaultStyle(9.sp) val Typography.fine get() = defaultStyle(9.sp)

View File

@ -56,6 +56,7 @@ import kotlinx.coroutines.flow.buffer
import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filter
import network.loki.messenger.R import network.loki.messenger.R
import org.session.libsignal.utilities.Log import org.session.libsignal.utilities.Log
import org.thoughtcrime.securesms.ui.base
import java.util.concurrent.Executors import java.util.concurrent.Executors
private const val TAG = "NewMessageFragment" private const val TAG = "NewMessageFragment"
@ -89,23 +90,22 @@ fun MaybeScanQrCode(
) { ) {
Text( Text(
stringResource(R.string.activity_link_camera_permission_permanently_denied_configure_in_settings), stringResource(R.string.activity_link_camera_permission_permanently_denied_configure_in_settings),
style = MaterialTheme.typography.base,
textAlign = TextAlign.Center textAlign = TextAlign.Center
) )
Spacer(modifier = Modifier.size(20.dp)) Spacer(modifier = Modifier.size(20.dp))
OutlineButton( OutlineButton(
stringResource(R.string.sessionSettings),
modifier = Modifier.align(Alignment.CenterHorizontally), modifier = Modifier.align(Alignment.CenterHorizontally),
onClick = onClickSettings onClick = onClickSettings
) { )
Text(stringResource(R.string.sessionSettings))
}
} }
} else { } else {
OutlineButton( OutlineButton(
stringResource(R.string.cameraGrantAccess),
modifier = Modifier.align(Alignment.Center), modifier = Modifier.align(Alignment.Center),
onClick = { cameraPermissionState.run { launchPermissionRequest() } } onClick = { cameraPermissionState.run { launchPermissionRequest() } }
) { )
Text(stringResource(R.string.cameraGrantAccess))
}
} }
} }
} }
@ -117,8 +117,8 @@ fun ScanQrCode(errors: Flow<String>, onScan: (String) -> Unit) {
val preview = Preview.Builder().build() val preview = Preview.Builder().build()
val selector = CameraSelector.Builder() val selector = CameraSelector.Builder()
.requireLensFacing(CameraSelector.LENS_FACING_BACK) .requireLensFacing(CameraSelector.LENS_FACING_BACK)
.build() .build()
runCatching { runCatching {
cameraProvider.get().unbindAll() cameraProvider.get().unbindAll()

View File

@ -12,6 +12,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import org.thoughtcrime.securesms.ui.LocalDimensions
import org.thoughtcrime.securesms.ui.base import org.thoughtcrime.securesms.ui.base
import org.thoughtcrime.securesms.ui.baseBold import org.thoughtcrime.securesms.ui.baseBold
import org.thoughtcrime.securesms.ui.outlinedTextFieldColors import org.thoughtcrime.securesms.ui.outlinedTextFieldColors
@ -51,7 +52,7 @@ fun SessionOutlinedTextField(
error?.let { error?.let {
Text( Text(
it, it,
modifier = Modifier.padding(top = 12.dp), modifier = Modifier.padding(top = LocalDimensions.current.marginExtraExtraSmall),
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
style = MaterialTheme.typography.baseBold, style = MaterialTheme.typography.baseBold,
color = MaterialTheme.colors.error color = MaterialTheme.colors.error