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 @@ -138,7 +137,6 @@ private fun EnterpriseSignOnScreenContent(
Spacer(modifier = Modifier.height(height = 12.dp))
Text(
text = stringResource(id = BitwardenString.log_in_sso_summary),
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.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 @@ -122,7 +121,6 @@ private fun LoginWithDeviceScreenContent(
) {
Text(
text = state.title(),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.headlineMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand All @@ -134,7 +132,6 @@ private fun LoginWithDeviceScreenContent(

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

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

Text(
text = stringResource(id = BitwardenString.fingerprint_phrase),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.titleLarge,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand All @@ -170,7 +165,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 @@ -209,7 +203,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 @@ -29,7 +29,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 @@ -326,7 +325,6 @@ fun VaultUnlockScreen(
} else if (state.showBiometricInvalidatedMessage) {
Text(
text = stringResource(BitwardenString.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 @@ -21,7 +21,6 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
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 @@ -132,7 +131,6 @@ private fun DeleteAccountConfirmationContent(
) {
Text(
text = stringResource(id = BitwardenString.a_verification_code_was_sent_to_your_email),
textAlign = TextAlign.Start,
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
modifier = Modifier
Expand All @@ -155,7 +153,6 @@ private fun DeleteAccountConfirmationContent(
Spacer(modifier = Modifier.height(12.dp))
Text(
text = stringResource(id = BitwardenString.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 @@ -23,7 +23,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 @@ -176,7 +175,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 @@ -32,9 +32,11 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
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 @@ -283,7 +285,6 @@ private fun PendingRequestItem(
text = stringResource(id = BitwardenString.fingerprint_phrase),
style = BitwardenTheme.typography.labelMedium,
color = BitwardenTheme.colorScheme.text.primary,
textAlign = TextAlign.Start,
modifier = Modifier.fillMaxWidth(),
)

Expand All @@ -293,7 +294,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 @@ -310,14 +310,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
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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 @@ -277,7 +276,6 @@ private fun ExportVaultScreenContent(

Text(
text = stringResource(id = BitwardenString.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 @@ -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.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 @@ -13,6 +13,9 @@ import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.LayoutDirection
import com.bitwarden.ui.platform.components.field.interceptor.IncognitoInput
import com.bitwarden.ui.platform.feature.settings.appearance.model.AppTheme
import com.bitwarden.ui.platform.theme.color.BitwardenColorScheme
Expand All @@ -25,6 +28,7 @@ import com.bitwarden.ui.platform.theme.shape.bitwardenShapes
import com.bitwarden.ui.platform.theme.type.BitwardenTypography
import com.bitwarden.ui.platform.theme.type.bitwardenTypography
import com.bitwarden.ui.platform.theme.type.toMaterialTypography
import com.bitwarden.ui.platform.theme.type.updateTextAlign
import com.bitwarden.ui.platform.util.isDarkMode

/**
Expand Down Expand Up @@ -92,6 +96,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)

CompositionLocalProvider(
LocalBitwardenColorScheme provides bitwardenColorScheme,
LocalBitwardenShapes provides bitwardenShapes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.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),
)
}
Loading
Loading