Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand Down Expand Up @@ -133,7 +132,6 @@ private fun EnterpriseSignOnScreenContent(
Spacer(modifier = Modifier.height(height = 12.dp))
Text(
text = stringResource(id = R.string.log_in_sso_summary),
textAlign = TextAlign.Start,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be removing alignment assignments in the screens. Start and End will respect the layout direction of the selected language.

style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand Down Expand Up @@ -136,7 +135,6 @@ private fun LoginWithDeviceScreenContent(
) {
Text(
text = state.title(),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.headlineMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand All @@ -148,7 +146,6 @@ private fun LoginWithDeviceScreenContent(

Text(
text = state.subtitle(),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand All @@ -160,7 +157,6 @@ private fun LoginWithDeviceScreenContent(

Text(
text = state.description(),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand All @@ -172,7 +168,6 @@ private fun LoginWithDeviceScreenContent(

Text(
text = stringResource(id = R.string.fingerprint_phrase),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.titleLarge,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand All @@ -184,7 +179,6 @@ private fun LoginWithDeviceScreenContent(

Text(
text = state.fingerprintPhrase,
textAlign = TextAlign.Start,
color = BitwardenTheme.colorScheme.text.codePink,
style = BitwardenTheme.typography.sensitiveInfoSmall,
minLines = 2,
Expand Down Expand Up @@ -223,7 +217,6 @@ private fun LoginWithDeviceScreenContent(

Text(
text = state.otherOptions(),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand Down Expand Up @@ -333,7 +332,6 @@ fun VaultUnlockScreen(
} else if (state.showBiometricInvalidatedMessage) {
Text(
text = stringResource(R.string.account_biometric_invalidated),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.status.error,
modifier = Modifier.standardHorizontalMargin(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
Expand All @@ -23,7 +22,6 @@ fun BitwardenInfoCalloutCard(
) {
Text(
text = text,
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -75,7 +74,6 @@ fun BitwardenClickableText(
}
Text(
text = label,
textAlign = TextAlign.Start,
color = color,
style = style,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -139,7 +138,6 @@ private fun DeleteAccountConfirmationContent(
) {
Text(
text = stringResource(id = R.string.a_verification_code_was_sent_to_your_email),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand All @@ -162,7 +160,6 @@ private fun DeleteAccountConfirmationContent(
Spacer(modifier = Modifier.height(12.dp))
Text(
text = stringResource(id = R.string.confirm_your_identity),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand Down Expand Up @@ -183,7 +182,6 @@ private fun LoginApprovalContent(

Text(
text = state.fingerprint,
textAlign = TextAlign.Start,
color = BitwardenTheme.colorScheme.text.codePink,
style = BitwardenTheme.typography.sensitiveInfoSmall,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.Lifecycle
Expand Down Expand Up @@ -286,7 +288,6 @@ private fun PendingRequestItem(
text = stringResource(id = R.string.fingerprint_phrase),
style = BitwardenTheme.typography.labelMedium,
color = BitwardenTheme.colorScheme.text.primary,
textAlign = TextAlign.Start,
modifier = Modifier.fillMaxWidth(),
)

Expand All @@ -296,7 +297,6 @@ private fun PendingRequestItem(
text = fingerprintPhrase,
color = BitwardenTheme.colorScheme.text.codePink,
style = BitwardenTheme.typography.sensitiveInfoSmall,
textAlign = TextAlign.Start,
modifier = Modifier
.testTag("FingerprintValueLabel")
.fillMaxWidth(),
Expand All @@ -313,14 +313,17 @@ private fun PendingRequestItem(
text = platform,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.secondary,
textAlign = TextAlign.Start,
)
Spacer(modifier = Modifier.width(width = 16.dp))
Text(
text = timestamp,
style = BitwardenTheme.typography.labelSmall,
color = BitwardenTheme.colorScheme.text.secondary,
textAlign = TextAlign.End,
textAlign = if (LocalLayoutDirection.current == LayoutDirection.Rtl) {
TextAlign.Left
} else {
TextAlign.Right
},
Comment on lines +322 to +326
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid manually setting the text alignment in screens like this.

We also do not want to use Left and Right alignments. We should be using Start and End so they respect the selected language's layout direction.

)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand Down Expand Up @@ -276,7 +275,6 @@ private fun ExportVaultScreenContent(

Text(
text = stringResource(id = R.string.send_verification_code_to_email),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.LayoutDirection
import androidx.core.view.WindowCompat
import com.x8bit.bitwarden.ui.platform.components.field.interceptor.IncognitoInput
import com.x8bit.bitwarden.ui.platform.feature.settings.appearance.model.AppTheme
Expand All @@ -30,6 +33,7 @@ import com.x8bit.bitwarden.ui.platform.theme.shape.bitwardenShapes
import com.x8bit.bitwarden.ui.platform.theme.type.BitwardenTypography
import com.x8bit.bitwarden.ui.platform.theme.type.bitwardenTypography
import com.x8bit.bitwarden.ui.platform.theme.type.toMaterialTypography
import com.x8bit.bitwarden.ui.platform.theme.type.updateTextAlign

/**
* Static wrapper to make accessing the theme components easier.
Expand Down Expand Up @@ -101,6 +105,15 @@ fun BitwardenTheme(
else -> lightBitwardenColorScheme
}

// Update text alignment according to the current layout direction.
val textAlign =
if (LocalLayoutDirection.current == LayoutDirection.Rtl) {
TextAlign.Right
} else {
TextAlign.Left
}
val bitwardenTypography = bitwardenTypography.updateTextAlign(textAlign)

// Update status bar according to scheme
val view = LocalView.current
if (!view.isInEditMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.x8bit.bitwarden.ui.platform.theme.type

import androidx.compose.runtime.Immutable
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign

/**
* Defines all the text-styles for the app.
Expand All @@ -28,3 +29,31 @@ data class BitwardenTypography(
val sensitiveInfoMedium: TextStyle,
val eyebrowMedium: TextStyle,
)

/**
* Updates the textAlign property of all text-styles.
* @param newTextAlign The new text alignment to be used.
*/
fun BitwardenTypography.updateTextAlign(newTextAlign: TextAlign): BitwardenTypography {
return this.copy(
displayLarge = displayLarge.copy(textAlign = newTextAlign),
displayMedium = displayMedium.copy(textAlign = newTextAlign),
displaySmall = displaySmall.copy(textAlign = newTextAlign),
headlineLarge = headlineLarge.copy(textAlign = newTextAlign),
headlineMedium = headlineMedium.copy(textAlign = newTextAlign),
headlineSmall = headlineSmall.copy(textAlign = newTextAlign),
titleLarge = titleLarge.copy(textAlign = newTextAlign),
titleMedium = titleMedium.copy(textAlign = newTextAlign),
titleSmall = titleSmall.copy(textAlign = newTextAlign),
bodyLarge = bodyLarge.copy(textAlign = newTextAlign),
bodyMedium = bodyMedium.copy(textAlign = newTextAlign),
bodyMediumEmphasis = bodyMediumEmphasis.copy(textAlign = newTextAlign),
bodySmall = bodySmall.copy(textAlign = newTextAlign),
labelLarge = labelLarge.copy(textAlign = newTextAlign),
labelMedium = labelMedium.copy(textAlign = newTextAlign),
labelSmall = labelSmall.copy(textAlign = newTextAlign),
sensitiveInfoSmall = sensitiveInfoSmall.copy(textAlign = newTextAlign),
sensitiveInfoMedium = sensitiveInfoMedium.copy(textAlign = newTextAlign),
eyebrowMedium = eyebrowMedium.copy(textAlign = newTextAlign),
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All files must end with a newline.

The Setup section of README has instructions on how to create a macro to enforce this and other Code style guidelines.

Loading
Loading