Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace m2 TopAppBar with m3 #2544

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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