File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
core/src/main/java/com/alamkanak/weekview Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,19 @@ internal fun Canvas.draw(staticLayout: StaticLayout) {
1616 staticLayout.draw(this )
1717}
1818
19+ internal fun Canvas.drawRtl (staticLayout : StaticLayout ) {
20+ staticLayout.text.split(" \n " ).forEachIndexed { index, text ->
21+ val textPaint: Paint = staticLayout.paint
22+ val xPos: Int = staticLayout.width / 2
23+ drawText(
24+ text,
25+ xPos.toFloat(),
26+ ((staticLayout.height / 2 ) * (index + 1 ) - (textPaint.descent() + textPaint.ascent()) / 2 ),
27+ textPaint
28+ )
29+ }
30+ }
31+
1932internal fun Canvas.drawVerticalLine (
2033 horizontalOffset : Float ,
2134 startY : Float ,
Original file line number Diff line number Diff line change @@ -173,11 +173,16 @@ private class DateLabelsDrawer(
173173 val key = date.toEpochDays()
174174 val textLayout = dateLabelLayouts[key]
175175
176+ val offset = if (textLayout.text.toString().isArabic()) 0f else viewState.dayWidth / 2f
176177 withTranslation(
177- x = startPixel + viewState.dayWidth / 2f ,
178+ x = startPixel + offset ,
178179 y = viewState.headerPadding,
179180 ) {
180- draw(textLayout)
181+ if (textLayout.text.toString().isArabic()) {
182+ drawRtl(textLayout)
183+ } else {
184+ draw(textLayout)
185+ }
181186 }
182187 }
183188}
You can’t perform that action at this time.
0 commit comments