Implement nicer UI for migrate list sorting

This commit is contained in:
arkon 2022-08-30 16:31:28 -04:00
parent 92e83f702c
commit 90c08303fa
3 changed files with 37 additions and 21 deletions

View File

@ -8,7 +8,13 @@ import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.items 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.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -75,25 +81,35 @@ fun MigrateSourceList(
ScrollbarLazyColumn( ScrollbarLazyColumn(
contentPadding = bottomNavPaddingValues + WindowInsets.navigationBars.asPaddingValues() + topPaddingValues, contentPadding = bottomNavPaddingValues + WindowInsets.navigationBars.asPaddingValues() + topPaddingValues,
) { ) {
stickyHeader { stickyHeader(key = "header") {
Row { Row(
Button(onClick = onToggleSortingMode) { modifier = Modifier
Text(sortingMode.toString()) .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))
}
}
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))
} }
Button(onClick = onToggleSortingDirection) {
Text(sortingDirection.toString())
} }
} }
} }
item(key = "title") { 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( items(

View File

@ -10,7 +10,7 @@ import nucleus.presenter.Presenter
abstract class FullComposeController<P : Presenter<*>>(bundle: Bundle? = null) : abstract class FullComposeController<P : Presenter<*>>(bundle: Bundle? = null) :
NucleusController<ComposeControllerBinding, P>(bundle), NucleusController<ComposeControllerBinding, P>(bundle),
FullComposeContentController { ComposeContentController {
override fun createBinding(inflater: LayoutInflater) = override fun createBinding(inflater: LayoutInflater) =
ComposeControllerBinding.inflate(inflater) ComposeControllerBinding.inflate(inflater)
@ -31,7 +31,7 @@ abstract class FullComposeController<P : Presenter<*>>(bundle: Bundle? = null) :
*/ */
abstract class BasicFullComposeController(bundle: Bundle? = null) : abstract class BasicFullComposeController(bundle: Bundle? = null) :
BaseController<ComposeControllerBinding>(bundle), BaseController<ComposeControllerBinding>(bundle),
FullComposeContentController { ComposeContentController {
override fun createBinding(inflater: LayoutInflater) = override fun createBinding(inflater: LayoutInflater) =
ComposeControllerBinding.inflate(inflater) ComposeControllerBinding.inflate(inflater)
@ -47,6 +47,6 @@ abstract class BasicFullComposeController(bundle: Bundle? = null) :
} }
} }
interface FullComposeContentController { interface ComposeContentController {
@Composable fun ComposeContent() @Composable fun ComposeContent()
} }

View File

@ -41,9 +41,9 @@ import eu.kanade.tachiyomi.data.updater.AppUpdateResult
import eu.kanade.tachiyomi.databinding.MainActivityBinding import eu.kanade.tachiyomi.databinding.MainActivityBinding
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity 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.DialogController
import eu.kanade.tachiyomi.ui.base.controller.FabController 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.RootController
import eu.kanade.tachiyomi.ui.base.controller.pushController import eu.kanade.tachiyomi.ui.base.controller.pushController
import eu.kanade.tachiyomi.ui.base.controller.setRoot import eu.kanade.tachiyomi.ui.base.controller.setRoot
@ -599,9 +599,9 @@ class MainActivity : BaseActivity() {
binding.fabLayout.rootFab.hide() binding.fabLayout.rootFab.hide()
} }
val isFullComposeController = internalTo is FullComposeContentController val isComposeController = internalTo is ComposeContentController
binding.appbar.isVisible = !isFullComposeController binding.appbar.isVisible = !isComposeController
binding.controllerContainer.enableScrollingBehavior(!isFullComposeController) binding.controllerContainer.enableScrollingBehavior(!isComposeController)
if (!isTablet()) { if (!isTablet()) {
// Save lift state // Save lift state