Add abstract ComposeController
This commit is contained in:
parent
f1e5cccee7
commit
eb1cfc4cd4
@ -0,0 +1,23 @@
|
||||
package eu.kanade.tachiyomi.ui.base.controller
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.compose.runtime.Composable
|
||||
import eu.kanade.tachiyomi.databinding.ComposeControllerBinding
|
||||
import nucleus.presenter.Presenter
|
||||
|
||||
abstract class ComposeController<P : Presenter<*>> : NucleusController<ComposeControllerBinding, P>() {
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater): ComposeControllerBinding =
|
||||
ComposeControllerBinding.inflate(inflater)
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
|
||||
binding.root.setContent {
|
||||
ComposeContent()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable abstract fun ComposeContent()
|
||||
}
|
@ -1,16 +1,14 @@
|
||||
package eu.kanade.tachiyomi.ui.recent.history
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.compose.runtime.Composable
|
||||
import eu.kanade.domain.chapter.model.Chapter
|
||||
import eu.kanade.presentation.history.HistoryScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.ComposeControllerBinding
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.ComposeController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
@ -21,26 +19,16 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import reactivecircus.flowbinding.appcompat.queryTextChanges
|
||||
|
||||
/**
|
||||
* Fragment that shows recently read manga.
|
||||
*/
|
||||
class HistoryController :
|
||||
NucleusController<ComposeControllerBinding, HistoryPresenter>(),
|
||||
RootController {
|
||||
class HistoryController : ComposeController<HistoryPresenter>(), RootController {
|
||||
|
||||
private var query = ""
|
||||
|
||||
override fun getTitle(): String? = resources?.getString(R.string.label_recent_manga)
|
||||
override fun getTitle() = resources?.getString(R.string.label_recent_manga)
|
||||
|
||||
override fun createPresenter(): HistoryPresenter = HistoryPresenter()
|
||||
override fun createPresenter() = HistoryPresenter()
|
||||
|
||||
override fun createBinding(inflater: LayoutInflater): ComposeControllerBinding =
|
||||
ComposeControllerBinding.inflate(inflater)
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
|
||||
binding.root.setContent {
|
||||
@Composable
|
||||
override fun ComposeContent() {
|
||||
HistoryScreen(
|
||||
composeView = binding.root,
|
||||
presenter = presenter,
|
||||
@ -61,7 +49,6 @@ class HistoryController :
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.history, menu)
|
||||
|
Loading…
Reference in New Issue
Block a user