Skip to content

Commit

Permalink
fix: monogram text render
Browse files Browse the repository at this point in the history
  • Loading branch information
urFate committed Jan 20, 2025
1 parent 3ae931f commit d4264e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fun ExtendedListItem(
else -> Monogram(str = headlineText)
}
}
}
} ?: Monogram(str = headlineText)
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
Expand All @@ -19,8 +20,11 @@ fun Monogram(modifier: Modifier = Modifier, str: String) {
val background = MaterialTheme.colorScheme.primary
val onPrimary = MaterialTheme.colorScheme.onPrimary

val text = str.replace(Regex("[a-z]"), "")
.replace(Regex("[а-я]"), "").uppercase().take(2)
val text = remember {
str.filter { it.isUpperCase() }
.take(2)
.takeIf { it.length == 2 } ?: str.uppercase().take(2)
}

Box(
modifier = Modifier
Expand Down

0 comments on commit d4264e1

Please sign in to comment.