mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-02 08:58:23 +02:00
Merge pull request #186 from rashedswen/main
temporary solution for mirroring arabic text
This commit is contained in:
commit
2a65b7241a
@ -13,6 +13,7 @@ import androidx.compose.material.ButtonDefaults
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@ -22,11 +23,13 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.compositeOver
|
||||
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||
import com.vitorpamplona.amethyst.R
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
|
||||
@Composable
|
||||
fun ExpandableRichTextViewer(
|
||||
@ -43,7 +46,17 @@ fun ExpandableRichTextViewer(
|
||||
val text = if (showFullText) content else content.take(350)
|
||||
|
||||
Box(contentAlignment = Alignment.BottomCenter) {
|
||||
RichTextViewer(text, canPreview, modifier, tags, backgroundColor, accountViewModel, navController)
|
||||
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
|
||||
RichTextViewer(
|
||||
text,
|
||||
canPreview,
|
||||
modifier,
|
||||
tags,
|
||||
backgroundColor,
|
||||
accountViewModel,
|
||||
navController
|
||||
)
|
||||
}
|
||||
|
||||
if (content.length > 350 && !showFullText) {
|
||||
Row(
|
||||
|
@ -29,6 +29,7 @@ import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.text.style.TextDirection
|
||||
import androidx.compose.ui.unit.dp
|
||||
@ -132,8 +133,8 @@ fun RichTextViewer(
|
||||
// FlowRow doesn't work well with paragraphs. So we need to split them
|
||||
content.split('\n').forEach { paragraph ->
|
||||
FlowRow() {
|
||||
paragraph.split(' ').forEach { word: String ->
|
||||
|
||||
val s = if (isArabic(paragraph)) paragraph.split(' ').reversed() else paragraph.split(' ');
|
||||
s.forEach { word: String ->
|
||||
if (canPreview) {
|
||||
// Explicit URL
|
||||
val lnInvoice = LnInvoiceUtil.findInvoice(word)
|
||||
@ -191,6 +192,10 @@ fun RichTextViewer(
|
||||
}
|
||||
}
|
||||
|
||||
private fun isArabic(text: String): Boolean {
|
||||
return text.any { it in '\u0600'..'\u06FF' || it in '\u0750'..'\u077F' }
|
||||
}
|
||||
|
||||
|
||||
fun isBechLink(word: String): Boolean {
|
||||
return word.startsWith("nostr:", true)
|
||||
|
@ -183,7 +183,6 @@ fun TranslateableRichTextViewer(
|
||||
|
||||
Spacer(modifier = Modifier.size(10.dp))
|
||||
|
||||
// TODO : Rashed translate this
|
||||
Text(
|
||||
"${stringResource(R.string.show_in)} ${Locale(source).displayName} ${
|
||||
stringResource(
|
||||
|
@ -241,7 +241,7 @@ fun NoteCompose(
|
||||
|
||||
if (noteEvent is RepostEvent) {
|
||||
Text(
|
||||
" boosted",
|
||||
" ${stringResource(id = R.string.boosted)}",
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
||||
)
|
||||
|
@ -35,6 +35,7 @@
|
||||
<string name="zaps">Zaps</string>
|
||||
<string name="view_count">مشاهدة العد</string>
|
||||
<string name="boost">تعزيز</string>
|
||||
<string name="boosted">معزز</string>
|
||||
<string name="quote">إقتباس</string>
|
||||
<string name="new_amount_in_sats">مبلغ جديد في Sats</string>
|
||||
<string name="add">إضافة</string>
|
||||
|
@ -37,6 +37,7 @@
|
||||
<string name="zaps">Zaps</string>
|
||||
<string name="view_count">Total vistas</string>
|
||||
<string name="boost">Impulsar</string>
|
||||
<string name="boosted">boosted</string>
|
||||
<string name="quote">Cita</string>
|
||||
<string name="new_amount_in_sats">Nueva cantidad en Sats</string>
|
||||
<string name="add">Añadir</string>
|
||||
|
@ -35,6 +35,7 @@
|
||||
<string name="zaps">Zaps</string>
|
||||
<string name="view_count">Contagem de visualizações</string>
|
||||
<string name="boost">Impulsionar</string>
|
||||
<string name="boosted">boosted</string>
|
||||
<string name="quote">Citar</string>
|
||||
<string name="new_amount_in_sats">Novo Valor em Sats</string>
|
||||
<string name="add">Adicionar</string>
|
||||
|
@ -36,6 +36,7 @@
|
||||
<string name="zaps">Запы</string>
|
||||
<string name="view_count">Просмотры</string>
|
||||
<string name="boost">Продвинуть</string>
|
||||
<string name="boosted">boosted</string>
|
||||
<string name="quote">Цитировать</string>
|
||||
<string name="new_amount_in_sats">Новая сумма в sat</string>
|
||||
<string name="add">Добавить</string>
|
||||
|
@ -36,6 +36,7 @@
|
||||
<string name="zaps">Запи</string>
|
||||
<string name="view_count">Перегляди</string>
|
||||
<string name="boost">Просувати</string>
|
||||
<string name="boosted">boosted</string>
|
||||
<string name="quote">Цитувати</string>
|
||||
<string name="new_amount_in_sats">Нова сума в sat</string>
|
||||
<string name="add">Додати</string>
|
||||
|
@ -36,6 +36,7 @@
|
||||
<string name="zaps">Zaps</string>
|
||||
<string name="view_count">View count</string>
|
||||
<string name="boost">Boost</string>
|
||||
<string name="boosted">boosted</string>
|
||||
<string name="quote">Quote</string>
|
||||
<string name="new_amount_in_sats">New Amount in Sats</string>
|
||||
<string name="add">Add</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user