From f255597362ff520d7eaade51586f0b9e576104aa Mon Sep 17 00:00:00 2001 From: Thomas Horta Date: Thu, 4 Apr 2024 11:49:20 -0300 Subject: [PATCH 1/3] Add experimental badge --- .../ReadingPreferencesScreen.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt index 4fb7a92b216b..bcb56b3ed328 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt @@ -4,6 +4,7 @@ import androidx.compose.animation.animateColorAsState import androidx.compose.foundation.background import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow @@ -15,6 +16,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.verticalScroll import androidx.compose.material.MaterialTheme @@ -98,6 +100,26 @@ fun ReadingPreferencesScreen( onNavigationIconClick = onCloseClick, backgroundColor = backgroundColor, contentColor = baseTextColor, + actions = { + Box( + modifier = Modifier + .background(baseTextColor, shape = CircleShape) + .padding( + vertical = Margin.Medium.value, + horizontal = Margin.Large.value, + ), + contentAlignment = Alignment.Center, + ) { + Text( + text = "Experimental", + style = TextStyle( + color = backgroundColor, + fontSize = 14.sp, + fontWeight = FontWeight.Medium, + ), + ) + } + } ) // Preview section From 9e5f733eebe1dc2626db05a461d2d15c998ad986 Mon Sep 17 00:00:00 2001 From: Thomas Horta Date: Fri, 5 Apr 2024 16:45:30 -0300 Subject: [PATCH 2/3] Text-only experimental badge in Reading Preferences screen --- .../ReadingPreferencesScreen.kt | 40 +++++++++---------- WordPress/src/main/res/values/strings.xml | 2 + 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt index bcb56b3ed328..a820c248400d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt @@ -4,7 +4,6 @@ import androidx.compose.animation.animateColorAsState import androidx.compose.foundation.background import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow @@ -16,7 +15,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.text.ClickableText import androidx.compose.foundation.verticalScroll import androidx.compose.material.MaterialTheme @@ -101,24 +99,10 @@ fun ReadingPreferencesScreen( backgroundColor = backgroundColor, contentColor = baseTextColor, actions = { - Box( - modifier = Modifier - .background(baseTextColor, shape = CircleShape) - .padding( - vertical = Margin.Medium.value, - horizontal = Margin.Large.value, - ), - contentAlignment = Alignment.Center, - ) { - Text( - text = "Experimental", - style = TextStyle( - color = backgroundColor, - fontSize = 14.sp, - fontWeight = FontWeight.Medium, - ), - ) - } + ExperimentalBadge( + contentColor = textColor, + modifier = Modifier.padding(end = Margin.Large.value), + ) } ) @@ -254,6 +238,22 @@ fun ReadingPreferencesScreen( } } +@Composable +private fun ExperimentalBadge( + contentColor: Color, + modifier: Modifier = Modifier, +) { + Text( + text = stringResource(R.string.experimental_badge), + modifier = modifier, + style = TextStyle( + color = contentColor.copy(alpha = 0.6f), + fontWeight = FontWeight.Medium, + fontFamily = FontFamily.Monospace, + ), + ) +} + @Composable private fun ReadingPreferencesPreviewFeedback( onSendFeedbackClick: () -> Unit, diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 634a93666360..c3201b709286 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -120,6 +120,8 @@ Me Everyone + [Experimental] + %d selected From d74a6f5b6d0e79d5e74346377540c2b5d9a98ed6 Mon Sep 17 00:00:00 2001 From: Thomas Horta Date: Fri, 5 Apr 2024 17:41:38 -0300 Subject: [PATCH 3/3] Change font family of badge according to selection --- .../compose/readingpreferences/ReadingPreferencesScreen.kt | 4 +++- WordPress/src/main/res/values/strings.xml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt index a820c248400d..f7ae9bbac88b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/views/compose/readingpreferences/ReadingPreferencesScreen.kt @@ -101,6 +101,7 @@ fun ReadingPreferencesScreen( actions = { ExperimentalBadge( contentColor = textColor, + fontFamily = fontFamily, modifier = Modifier.padding(end = Margin.Large.value), ) } @@ -241,6 +242,7 @@ fun ReadingPreferencesScreen( @Composable private fun ExperimentalBadge( contentColor: Color, + fontFamily: FontFamily, modifier: Modifier = Modifier, ) { Text( @@ -249,7 +251,7 @@ private fun ExperimentalBadge( style = TextStyle( color = contentColor.copy(alpha = 0.6f), fontWeight = FontWeight.Medium, - fontFamily = FontFamily.Monospace, + fontFamily = fontFamily, ), ) } diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index c3201b709286..41803994841e 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -120,7 +120,7 @@ Me Everyone - [Experimental] + <Experimental> %d selected