Skip to content

Commit

Permalink
Merge pull request quran#2544 from quran/use_m3_topappbar
Browse files Browse the repository at this point in the history
Replace m2 TopAppBar with m3
  • Loading branch information
ahmedre authored Jan 14, 2024
2 parents 4239955 + 3b8e584 commit f4b53ab
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class AudioManagerActivity : ComponentActivity() {
) {
DownloadManagerToolbar(
title = stringResource(R.string.audio_manager),
backgroundColor = MaterialTheme.colorScheme.primary,
tintColor = MaterialTheme.colorScheme.onPrimary,
onBackPressed = { finish() }
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
package com.quran.mobile.feature.downloadmanager.ui.common

import androidx.compose.foundation.layout.RowScope
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
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(
title: String,
backgroundColor: Color,
tintColor: Color,
onBackPressed: (() -> Unit),
actions: @Composable (RowScope.() -> Unit) = {}
) {
TopAppBar(
title = {
Text(
text = title,
color = tintColor,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
Expand All @@ -35,12 +31,10 @@ fun DownloadManagerToolbar(
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = "",
tint = tintColor,
modifier = Modifier.autoMirror()
)
}
},
backgroundColor = backgroundColor,
actions = actions
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand All @@ -22,19 +21,13 @@ fun SheikhDownloadToolbar(
eraseAction: (() -> Unit),
onBackAction: (() -> Unit)
) {
val backgroundColor =
if (isContextual) MaterialTheme.colorScheme.secondary else MaterialTheme.colorScheme.primary
val tintColor =
if (isContextual) MaterialTheme.colorScheme.onSecondary else MaterialTheme.colorScheme.onPrimary

val actions: @Composable() (RowScope.() -> Unit) = {
if (downloadIcon) {
IconButton(onClick = downloadAction) {
val contentDescription = if (isContextual) R.string.audio_manager_download_selection else R.string.audio_manager_download_all
Icon(
painterResource(id = R.drawable.ic_download),
contentDescription = stringResource(id = contentDescription),
tint = tintColor
contentDescription = stringResource(id = contentDescription)
)
}
}
Expand All @@ -43,17 +36,14 @@ fun SheikhDownloadToolbar(
IconButton(onClick = eraseAction) {
Icon(
imageVector = Icons.Filled.Close,
contentDescription = stringResource(id = R.string.audio_manager_delete_selection),
tint = tintColor
contentDescription = stringResource(id = R.string.audio_manager_delete_selection)
)
}
}
}

DownloadManagerToolbar(
title = if (isContextual) "" else stringResource(titleResource),
backgroundColor = backgroundColor,
tintColor = tintColor,
onBackPressed = onBackAction,
actions = actions
)
Expand Down
3 changes: 2 additions & 1 deletion feature/qarilist/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ android {
kotlinOptions {
freeCompilerArgs += [
"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
"-opt-in=androidx.compose.material.ExperimentalMaterialApi"
"-opt-in=androidx.compose.material.ExperimentalMaterialApi",
"-Xopt-in=androidx.compose.material3.ExperimentalMaterial3Api"
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import androidx.compose.foundation.layout.displayCutoutPadding
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.ModalBottomSheetDefaults
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
Expand Down Expand Up @@ -129,20 +129,17 @@ class QariListWrapper(
sheetContent = {
Column {
TopAppBar(
backgroundColor = MaterialTheme.colorScheme.primary,
title = {
Text(
stringResource(R.string.qarilist_select_qari),
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.primaryContainer
style = MaterialTheme.typography.titleLarge
)
},
navigationIcon = {
IconButton(onClick = { closeDialog() }) {
Icon(
imageVector = Icons.Filled.Close,
contentDescription = stringResource(R.string.qarilist_dismiss),
tint = MaterialTheme.colorScheme.primaryContainer
contentDescription = stringResource(R.string.qarilist_dismiss)
)
}
}
Expand Down

0 comments on commit f4b53ab

Please sign in to comment.