RTL and LTR mixed languages fix for optimal timestamp support (#1055)

* fix

* fixed RTL and LTR timestamp for all the cases! also improved the testing

* changelog

* better and less convoluted solution

* Update ElementX/Sources/Screens/RoomScreen/View/Timeline/FormattedBodyText.swift

Co-authored-by: Alfonso Grillo <alfogrillo@gmail.com>

* pr suggestion and removed prefix in reality it creates more issues than improvements, and is not really needed

---------

Co-authored-by: Alfonso Grillo <alfogrillo@gmail.com>
This commit is contained in:
Mauro
2023-06-09 13:49:02 +02:00
committed by GitHub
parent 9b347c0ea4
commit 42e083dcaf
8 changed files with 83 additions and 14 deletions
@@ -64,15 +64,12 @@ extension String {
}
extension String {
static func generateBreakableWhitespaceEnd(whitespaceCount: Int, isRTL: Bool) -> String {
static func generateBreakableWhitespaceEnd(whitespaceCount: Int, layoutDirection: LayoutDirection) -> String {
guard whitespaceCount > 0 else {
return ""
}
var whiteSpaces = ""
if isRTL {
whiteSpaces = "\u{202e}"
}
var whiteSpaces = layoutDirection.isolateLayoutUnicodeString
// fixed size whitespace of size 1/3 em per character
whiteSpaces += String(repeating: "\u{2004}", count: whitespaceCount)