mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Add ability to force RTL to compose previews.
This commit is contained in:
committed by
Cody Henthorne
parent
0e46ab33e8
commit
925e46ff3a
@@ -9,29 +9,42 @@ import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import org.signal.core.ui.compose.theme.SignalTheme
|
||||
|
||||
object Previews {
|
||||
@Composable
|
||||
fun Preview(
|
||||
forceRtl: Boolean = false,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
SignalTheme {
|
||||
Surface {
|
||||
content()
|
||||
val dir = if (forceRtl) LayoutDirection.Rtl else LocalLayoutDirection.current
|
||||
|
||||
CompositionLocalProvider(LocalLayoutDirection provides dir) {
|
||||
SignalTheme {
|
||||
Surface {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun BottomSheetPreview(
|
||||
forceRtl: Boolean = false,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
SignalTheme {
|
||||
Surface {
|
||||
Box(modifier = Modifier.background(color = SignalTheme.colors.colorSurface1)) {
|
||||
content()
|
||||
val dir = if (forceRtl) LayoutDirection.Rtl else LocalLayoutDirection.current
|
||||
|
||||
CompositionLocalProvider(LocalLayoutDirection provides dir) {
|
||||
SignalTheme {
|
||||
Surface {
|
||||
Box(modifier = Modifier.background(color = SignalTheme.colors.colorSurface1)) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user