From 90c08303fa484ca241d3c87dcc2e55f423328815 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 30 Aug 2022 16:31:28 -0400 Subject: [PATCH] Implement nicer UI for migrate list sorting --- .../browse/MigrateSourceScreen.kt | 44 +++++++++++++------ .../ui/base/controller/ComposeController.kt | 6 +-- .../kanade/tachiyomi/ui/main/MainActivity.kt | 8 ++-- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/browse/MigrateSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/MigrateSourceScreen.kt index 8c18b3e229..91c3c4d9f1 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/MigrateSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/MigrateSourceScreen.kt @@ -8,7 +8,13 @@ import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.items -import androidx.compose.material3.Button +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.ArrowDownward +import androidx.compose.material.icons.outlined.ArrowUpward +import androidx.compose.material.icons.outlined.Numbers +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.runtime.Composable @@ -75,25 +81,35 @@ fun MigrateSourceList( ScrollbarLazyColumn( contentPadding = bottomNavPaddingValues + WindowInsets.navigationBars.asPaddingValues() + topPaddingValues, ) { - stickyHeader { - Row { - Button(onClick = onToggleSortingMode) { - Text(sortingMode.toString()) + stickyHeader(key = "header") { + Row( + modifier = Modifier + .animateItemPlacement() + .padding(start = horizontalPadding), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = stringResource(R.string.migration_selection_prompt), + modifier = Modifier.weight(1f), + style = MaterialTheme.typography.header, + ) + + IconButton(onClick = onToggleSortingMode) { + when (sortingMode) { + SetMigrateSorting.Mode.ALPHABETICAL -> Icon(Icons.Outlined.SortByAlpha, contentDescription = stringResource(R.string.action_sort_alpha)) + SetMigrateSorting.Mode.TOTAL -> Icon(Icons.Outlined.Numbers, contentDescription = stringResource(R.string.action_sort_total)) + } } - Button(onClick = onToggleSortingDirection) { - Text(sortingDirection.toString()) + IconButton(onClick = onToggleSortingDirection) { + when (sortingDirection) { + SetMigrateSorting.Direction.ASCENDING -> Icon(Icons.Outlined.ArrowUpward, contentDescription = stringResource(R.string.action_asc)) + SetMigrateSorting.Direction.DESCENDING -> Icon(Icons.Outlined.ArrowDownward, contentDescription = stringResource(R.string.action_desc)) + } } } } item(key = "title") { - Text( - text = stringResource(R.string.migration_selection_prompt), - modifier = Modifier - .animateItemPlacement() - .padding(horizontal = horizontalPadding, vertical = 8.dp), - style = MaterialTheme.typography.header, - ) } items( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ComposeController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ComposeController.kt index 41237b3395..030a870530 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ComposeController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ComposeController.kt @@ -10,7 +10,7 @@ import nucleus.presenter.Presenter abstract class FullComposeController

>(bundle: Bundle? = null) : NucleusController(bundle), - FullComposeContentController { + ComposeContentController { override fun createBinding(inflater: LayoutInflater) = ComposeControllerBinding.inflate(inflater) @@ -31,7 +31,7 @@ abstract class FullComposeController

>(bundle: Bundle? = null) : */ abstract class BasicFullComposeController(bundle: Bundle? = null) : BaseController(bundle), - FullComposeContentController { + ComposeContentController { override fun createBinding(inflater: LayoutInflater) = ComposeControllerBinding.inflate(inflater) @@ -47,6 +47,6 @@ abstract class BasicFullComposeController(bundle: Bundle? = null) : } } -interface FullComposeContentController { +interface ComposeContentController { @Composable fun ComposeContent() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index f177d04462..44c0a55558 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -41,9 +41,9 @@ import eu.kanade.tachiyomi.data.updater.AppUpdateResult import eu.kanade.tachiyomi.databinding.MainActivityBinding import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi import eu.kanade.tachiyomi.ui.base.activity.BaseActivity +import eu.kanade.tachiyomi.ui.base.controller.ComposeContentController import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.FabController -import eu.kanade.tachiyomi.ui.base.controller.FullComposeContentController import eu.kanade.tachiyomi.ui.base.controller.RootController import eu.kanade.tachiyomi.ui.base.controller.pushController import eu.kanade.tachiyomi.ui.base.controller.setRoot @@ -599,9 +599,9 @@ class MainActivity : BaseActivity() { binding.fabLayout.rootFab.hide() } - val isFullComposeController = internalTo is FullComposeContentController - binding.appbar.isVisible = !isFullComposeController - binding.controllerContainer.enableScrollingBehavior(!isFullComposeController) + val isComposeController = internalTo is ComposeContentController + binding.appbar.isVisible = !isComposeController + binding.controllerContainer.enableScrollingBehavior(!isComposeController) if (!isTablet()) { // Save lift state