Skip to content

Commit

Permalink
Merge pull request #2201 from quran/fix_rtl_back_button
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre authored Feb 22, 2023
2 parents c42e1f1 + f98694c commit fa5ca97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.quran.labs.androidquran.common.ui.core.modifier

import androidx.compose.runtime.Stable
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.draw.scale
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.LayoutDirection

// via https://stackoverflow.com/questions/69849631/auto-mirroring-in-jetpack-compose-icons
@Stable
fun Modifier.autoMirror(): Modifier = composed {
if (LocalLayoutDirection.current == LayoutDirection.Rtl) {
this.scale(scaleX = -1f, scaleY = 1f)
} else { this }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextOverflow
import com.quran.labs.androidquran.common.ui.core.modifier.autoMirror

@Composable
fun DownloadManagerToolbar(
Expand All @@ -33,7 +35,8 @@ fun DownloadManagerToolbar(
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = "",
tint = tintColor
tint = tintColor,
modifier = Modifier.autoMirror()
)
}
},
Expand Down

0 comments on commit fa5ca97

Please sign in to comment.