From 540fb1bb7c36fda0b6c070caacd8fb2a4176ddc0 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 12 Oct 2023 22:49:21 -0400 Subject: [PATCH] Use AppBar abstraction in more places --- .../presentation/category/CategoryScreen.kt | 24 +++---------------- .../more/settings/PreferenceScaffold.kt | 17 ++++--------- .../settings/screen/SettingsMainScreen.kt | 20 ++++------------ .../about/OpenSourceLibraryLicenseScreen.kt | 22 +++-------------- .../screen/debug/BackupSchemaScreen.kt | 14 +++-------- .../settings/screen/debug/WorkerInfoScreen.kt | 14 +++-------- .../details/SourcePreferencesScreen.kt | 15 ++++-------- 7 files changed, 24 insertions(+), 102 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt b/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt index 3e3364d79d..485d3e4ff4 100644 --- a/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/category/CategoryScreen.kt @@ -8,17 +8,11 @@ import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.outlined.ArrowBack import androidx.compose.material.icons.outlined.SortByAlpha -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.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.dp import eu.kanade.presentation.category.components.CategoryFloatingActionButton import eu.kanade.presentation.category.components.CategoryListItem import eu.kanade.presentation.components.AppBar @@ -46,21 +40,9 @@ fun CategoryScreen( val lazyListState = rememberLazyListState() Scaffold( topBar = { scrollBehavior -> - TopAppBar( - title = { - Text( - text = stringResource(R.string.action_edit_categories), - modifier = Modifier.padding(start = 8.dp), - ) - }, - navigationIcon = { - IconButton(onClick = navigateUp) { - Icon( - imageVector = Icons.Outlined.ArrowBack, - contentDescription = stringResource(R.string.abc_action_bar_up_description), - ) - } - }, + AppBar( + title = stringResource(R.string.action_edit_categories), + navigateUp = navigateUp, actions = { AppBarActions( listOf( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceScaffold.kt b/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceScaffold.kt index fb9a3de2a1..7db2933794 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceScaffold.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/PreferenceScaffold.kt @@ -2,12 +2,9 @@ package eu.kanade.presentation.more.settings import androidx.annotation.StringRes import androidx.compose.foundation.layout.RowScope -import androidx.compose.material3.IconButton -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource -import eu.kanade.presentation.components.UpIcon +import eu.kanade.presentation.components.AppBar import tachiyomi.presentation.core.components.material.Scaffold @Composable @@ -19,15 +16,9 @@ fun PreferenceScaffold( ) { Scaffold( topBar = { - TopAppBar( - title = { Text(text = stringResource(titleRes)) }, - navigationIcon = { - if (onBackPressed != null) { - IconButton(onClick = onBackPressed) { - UpIcon() - } - } - }, + AppBar( + title = stringResource(titleRes), + navigateUp = onBackPressed, actions = actions, scrollBehavior = it, ) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt index 513acc39b8..86cb2790da 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsMainScreen.kt @@ -20,11 +20,8 @@ import androidx.compose.material.icons.outlined.Search import androidx.compose.material.icons.outlined.Security import androidx.compose.material.icons.outlined.SettingsBackupRestore import androidx.compose.material.icons.outlined.Sync -import androidx.compose.material3.IconButton import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.rememberTopAppBarState import androidx.compose.runtime.Composable @@ -44,7 +41,6 @@ import cafe.adriel.voyager.navigator.Navigator import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.AppBarActions -import eu.kanade.presentation.components.UpIcon import eu.kanade.presentation.more.settings.screen.about.AboutScreen import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget import eu.kanade.presentation.util.LocalBackPress @@ -82,21 +78,13 @@ object SettingsMainScreen : Screen() { val backPress = LocalBackPress.currentOrThrow val containerColor = if (twoPane) getPalerSurface() else MaterialTheme.colorScheme.surface val topBarState = rememberTopAppBarState() + Scaffold( topBarScrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(topBarState), topBar = { scrollBehavior -> - TopAppBar( - title = { - Text( - text = stringResource(R.string.label_settings), - modifier = Modifier.padding(start = 8.dp), - ) - }, - navigationIcon = { - IconButton(onClick = backPress::invoke) { - UpIcon() - } - }, + AppBar( + title = stringResource(R.string.label_settings), + navigateUp = backPress::invoke, actions = { AppBarActions( listOf( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/OpenSourceLibraryLicenseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/OpenSourceLibraryLicenseScreen.kt index 992f267a8f..964f503b0c 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/OpenSourceLibraryLicenseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/about/OpenSourceLibraryLicenseScreen.kt @@ -5,17 +5,11 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.Public -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.platform.LocalUriHandler import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import androidx.core.text.HtmlCompat @@ -41,19 +35,9 @@ class OpenSourceLibraryLicenseScreen( Scaffold( topBar = { - TopAppBar( - title = { - Text( - text = name, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - }, - navigationIcon = { - IconButton(onClick = navigator::pop) { - Icon(imageVector = Icons.Default.ArrowBack, contentDescription = null) - } - }, + AppBar( + title = name, + navigateUp = navigator::pop, actions = { if (!website.isNullOrEmpty()) { AppBarActions( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/BackupSchemaScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/BackupSchemaScreen.kt index bc89050503..4c4d22a691 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/BackupSchemaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/BackupSchemaScreen.kt @@ -4,12 +4,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.ContentCopy -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.runtime.remember import androidx.compose.ui.Modifier @@ -43,13 +39,9 @@ class BackupSchemaScreen : Screen() { Scaffold( topBar = { - TopAppBar( - title = { Text(text = title) }, - navigationIcon = { - IconButton(onClick = navigator::pop) { - Icon(imageVector = Icons.Default.ArrowBack, contentDescription = null) - } - }, + AppBar( + title = title, + navigateUp = navigator::pop, actions = { AppBarActions( listOf( diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/WorkerInfoScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/WorkerInfoScreen.kt index ff318a9b4c..e7e815df62 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/WorkerInfoScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/debug/WorkerInfoScreen.kt @@ -7,13 +7,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.rememberScrollState import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.ContentCopy -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.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -61,13 +57,9 @@ class WorkerInfoScreen : Screen() { Scaffold( topBar = { - TopAppBar( - title = { Text(text = title) }, - navigationIcon = { - IconButton(onClick = navigator::pop) { - Icon(imageVector = Icons.Default.ArrowBack, contentDescription = null) - } - }, + AppBar( + title = title, + navigateUp = navigator::pop, actions = { AppBarActions( listOf( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesScreen.kt index 4e391cb3e4..b4c1321c0b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/SourcePreferencesScreen.kt @@ -7,9 +7,6 @@ import android.view.View import androidx.appcompat.view.ContextThemeWrapper import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.material3.IconButton -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf @@ -34,7 +31,7 @@ import androidx.preference.forEach import androidx.preference.getOnBindEditTextListener import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow -import eu.kanade.presentation.components.UpIcon +import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.util.Screen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.SharedPreferencesDataStore @@ -55,13 +52,9 @@ class SourcePreferencesScreen(val sourceId: Long) : Screen() { Scaffold( topBar = { - TopAppBar( - title = { Text(text = Injekt.get().getOrStub(sourceId).toString()) }, - navigationIcon = { - IconButton(onClick = navigator::pop) { - UpIcon() - } - }, + AppBar( + title = Injekt.get().getOrStub(sourceId).toString(), + navigateUp = navigator::pop, scrollBehavior = it, ) },