-
Notifications
You must be signed in to change notification settings - Fork 887
[PM-20026] RTL text direction #5012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d8d0469
363a8a2
511c63e
d7f26e4
217929b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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(), | ||
) | ||
|
||
|
@@ -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(), | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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), | ||
) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
There was a problem hiding this comment.
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
andEnd
will respect the layout direction of the selected language.