Migrate More screen to full Compose

This commit is contained in:
arkon
2022-07-18 18:51:36 -04:00
parent e2510c144a
commit 4d9d587366
6 changed files with 105 additions and 122 deletions

View File

@@ -6,7 +6,6 @@ import androidx.core.net.toUri
import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import eu.kanade.tachiyomi.ui.main.MainActivity
import eu.kanade.tachiyomi.util.system.openInBrowser
fun Router.setRoot(controller: Controller, id: Int) {
@@ -44,10 +43,3 @@ fun Controller.withFadeTransaction(): RouterTransaction {
fun Controller.openInBrowser(url: String) {
activity?.openInBrowser(url.toUri())
}
/**
* Returns [MainActivity]'s app bar height
*/
fun Controller.getMainAppBarHeight(): Int {
return (activity as? MainActivity)?.binding?.appbar?.measuredHeight ?: 0
}

View File

@@ -1,3 +0,0 @@
package eu.kanade.tachiyomi.ui.base.controller
interface NoAppBarElevationController

View File

@@ -44,7 +44,6 @@ import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
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.NoAppBarElevationController
import eu.kanade.tachiyomi.ui.base.controller.RootController
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
import eu.kanade.tachiyomi.ui.base.controller.pushController
@@ -639,8 +638,6 @@ class MainActivity : BaseActivity() {
backstackLiftState.remove(it.instanceId)
}
}
binding.root.isLiftAppBarOnScroll = internalTo !is NoAppBarElevationController
}
}

View File

@@ -1,11 +1,9 @@
package eu.kanade.tachiyomi.ui.more
import androidx.compose.runtime.Composable
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import eu.kanade.presentation.more.MoreScreen
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.base.controller.ComposeController
import eu.kanade.tachiyomi.ui.base.controller.NoAppBarElevationController
import eu.kanade.tachiyomi.ui.base.controller.FullComposeController
import eu.kanade.tachiyomi.ui.base.controller.RootController
import eu.kanade.tachiyomi.ui.base.controller.pushController
import eu.kanade.tachiyomi.ui.category.CategoryController
@@ -14,18 +12,16 @@ import eu.kanade.tachiyomi.ui.setting.SettingsBackupController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
class MoreController :
ComposeController<MorePresenter>(),
RootController,
NoAppBarElevationController {
FullComposeController<MorePresenter>(),
RootController {
override fun getTitle() = resources?.getString(R.string.label_more)
override fun createPresenter() = MorePresenter()
@Composable
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
override fun ComposeContent() {
MoreScreen(
nestedScrollInterop = nestedScrollInterop,
presenter = presenter,
onClickDownloadQueue = { router.pushController(DownloadController()) },
onClickCategories = { router.pushController(CategoryController()) },

View File

@@ -34,25 +34,9 @@ class TachiyomiCoordinatorLayout @JvmOverloads constructor(
defStyleAttr: Int = R.attr.coordinatorLayoutStyle,
) : CoordinatorLayout(context, attrs, defStyleAttr) {
/**
* Keep lifted state and do nothing on tablet UI
*/
private val isTablet = context.isTablet()
private var appBarLayout: AppBarLayout? = null
private var tabLayout: TabLayout? = null
/**
* If true, [AppBarLayout] child will be lifted on nested scroll.
*/
var isLiftAppBarOnScroll = true
/**
* Internal check
*/
private val canLiftAppBarOnScroll
get() = !isTablet && isLiftAppBarOnScroll
override fun onNestedScroll(
target: View,
dxConsumed: Int,
@@ -64,7 +48,7 @@ class TachiyomiCoordinatorLayout @JvmOverloads constructor(
) {
super.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type, consumed)
// Disable elevation overlay when tabs are visible
if (canLiftAppBarOnScroll) {
if (context.isTablet().not()) {
if (target is ComposeView) {
val scrollCondition = if (type == ViewCompat.TYPE_NON_TOUCH) {
dyUnconsumed >= 0