From 3b8e5841af7cf66eee45ee68e316d5b672b6f78f Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Sun, 14 Jan 2024 14:15:27 +0400 Subject: [PATCH] Replace m2 TopAppBar with m3 Also use default color tokens instead of overriding them. --- .../downloadmanager/AudioManagerActivity.kt | 2 -- .../ui/common/DownloadManagerToolbar.kt | 14 ++++---------- .../ui/sheikhdownload/SheikhDownloadToolbar.kt | 14 ++------------ feature/qarilist/build.gradle | 3 ++- .../mobile/feature/qarilist/QariListWrapper.kt | 15 ++++++--------- 5 files changed, 14 insertions(+), 34 deletions(-) diff --git a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/AudioManagerActivity.kt b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/AudioManagerActivity.kt index da0abc9d9a..f9002524af 100644 --- a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/AudioManagerActivity.kt +++ b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/AudioManagerActivity.kt @@ -46,8 +46,6 @@ class AudioManagerActivity : ComponentActivity() { ) { DownloadManagerToolbar( title = stringResource(R.string.audio_manager), - backgroundColor = MaterialTheme.colorScheme.primary, - tintColor = MaterialTheme.colorScheme.onPrimary, onBackPressed = { finish() } ) diff --git a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/ui/common/DownloadManagerToolbar.kt b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/ui/common/DownloadManagerToolbar.kt index 7c0c10d46d..2c52ba8872 100644 --- a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/ui/common/DownloadManagerToolbar.kt +++ b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/ui/common/DownloadManagerToolbar.kt @@ -1,23 +1,20 @@ 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) = {} ) { @@ -25,7 +22,6 @@ fun DownloadManagerToolbar( title = { Text( text = title, - color = tintColor, maxLines = 1, overflow = TextOverflow.Ellipsis ) @@ -35,12 +31,10 @@ fun DownloadManagerToolbar( Icon( imageVector = Icons.Filled.ArrowBack, contentDescription = "", - tint = tintColor, modifier = Modifier.autoMirror() ) } }, - backgroundColor = backgroundColor, actions = actions ) } diff --git a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/ui/sheikhdownload/SheikhDownloadToolbar.kt b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/ui/sheikhdownload/SheikhDownloadToolbar.kt index 7152464321..6a31bd5037 100644 --- a/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/ui/sheikhdownload/SheikhDownloadToolbar.kt +++ b/feature/downloadmanager/src/main/kotlin/com/quran/mobile/feature/downloadmanager/ui/sheikhdownload/SheikhDownloadToolbar.kt @@ -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 @@ -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) ) } } @@ -43,8 +36,7 @@ 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) ) } } @@ -52,8 +44,6 @@ fun SheikhDownloadToolbar( DownloadManagerToolbar( title = if (isContextual) "" else stringResource(titleResource), - backgroundColor = backgroundColor, - tintColor = tintColor, onBackPressed = onBackAction, actions = actions ) diff --git a/feature/qarilist/build.gradle b/feature/qarilist/build.gradle index 9ff392439c..1960c35131 100644 --- a/feature/qarilist/build.gradle +++ b/feature/qarilist/build.gradle @@ -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" ] } } diff --git a/feature/qarilist/src/main/kotlin/com/quran/mobile/feature/qarilist/QariListWrapper.kt b/feature/qarilist/src/main/kotlin/com/quran/mobile/feature/qarilist/QariListWrapper.kt index 2d7eb2c307..81dc76c956 100644 --- a/feature/qarilist/src/main/kotlin/com/quran/mobile/feature/qarilist/QariListWrapper.kt +++ b/feature/qarilist/src/main/kotlin/com/quran/mobile/feature/qarilist/QariListWrapper.kt @@ -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 @@ -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) ) } }