mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 01:39:19 +01:00
Lift Compose theme to abstract controller
This commit is contained in:
parent
7c8e8317a8
commit
032aa64195
@ -46,7 +46,6 @@ import eu.kanade.domain.history.model.HistoryWithRelations
|
|||||||
import eu.kanade.presentation.components.EmptyScreen
|
import eu.kanade.presentation.components.EmptyScreen
|
||||||
import eu.kanade.presentation.components.MangaCover
|
import eu.kanade.presentation.components.MangaCover
|
||||||
import eu.kanade.presentation.components.MangaCoverAspect
|
import eu.kanade.presentation.components.MangaCoverAspect
|
||||||
import eu.kanade.presentation.theme.TachiyomiTheme
|
|
||||||
import eu.kanade.presentation.util.horizontalPadding
|
import eu.kanade.presentation.util.horizontalPadding
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
@ -61,12 +60,6 @@ import java.text.DecimalFormat
|
|||||||
import java.text.DecimalFormatSymbols
|
import java.text.DecimalFormatSymbols
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
val chapterFormatter = DecimalFormat(
|
|
||||||
"#.###",
|
|
||||||
DecimalFormatSymbols()
|
|
||||||
.apply { decimalSeparator = '.' },
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HistoryScreen(
|
fun HistoryScreen(
|
||||||
composeView: ComposeView,
|
composeView: ComposeView,
|
||||||
@ -76,27 +69,25 @@ fun HistoryScreen(
|
|||||||
onClickDelete: (HistoryWithRelations, Boolean) -> Unit,
|
onClickDelete: (HistoryWithRelations, Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
val nestedScrollInterop = rememberNestedScrollInteropConnection(composeView)
|
val nestedScrollInterop = rememberNestedScrollInteropConnection(composeView)
|
||||||
TachiyomiTheme {
|
val state by presenter.state.collectAsState()
|
||||||
val state by presenter.state.collectAsState()
|
val history = state.list?.collectAsLazyPagingItems()
|
||||||
val history = state.list?.collectAsLazyPagingItems()
|
when {
|
||||||
when {
|
history == null -> {
|
||||||
history == null -> {
|
CircularProgressIndicator()
|
||||||
CircularProgressIndicator()
|
}
|
||||||
}
|
history.itemCount == 0 -> {
|
||||||
history.itemCount == 0 -> {
|
EmptyScreen(
|
||||||
EmptyScreen(
|
textResource = R.string.information_no_recent_manga
|
||||||
textResource = R.string.information_no_recent_manga
|
)
|
||||||
)
|
}
|
||||||
}
|
else -> {
|
||||||
else -> {
|
HistoryContent(
|
||||||
HistoryContent(
|
nestedScroll = nestedScrollInterop,
|
||||||
nestedScroll = nestedScrollInterop,
|
history = history,
|
||||||
history = history,
|
onClickItem = onClickItem,
|
||||||
onClickItem = onClickItem,
|
onClickResume = onClickResume,
|
||||||
onClickResume = onClickResume,
|
onClickDelete = onClickDelete,
|
||||||
onClickDelete = onClickDelete,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,10 +137,7 @@ fun HistoryContent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
item {
|
item {
|
||||||
Spacer(
|
Spacer(Modifier.navigationBarsPadding())
|
||||||
modifier = Modifier
|
|
||||||
.navigationBarsPadding()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,3 +290,8 @@ fun RemoveHistoryDialog(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val chapterFormatter = DecimalFormat(
|
||||||
|
"#.###",
|
||||||
|
DecimalFormatSymbols().apply { decimalSeparator = '.' },
|
||||||
|
)
|
||||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.base.controller
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import eu.kanade.presentation.theme.TachiyomiTheme
|
||||||
import eu.kanade.tachiyomi.databinding.ComposeControllerBinding
|
import eu.kanade.tachiyomi.databinding.ComposeControllerBinding
|
||||||
import nucleus.presenter.Presenter
|
import nucleus.presenter.Presenter
|
||||||
|
|
||||||
@ -15,7 +16,9 @@ abstract class ComposeController<P : Presenter<*>> : NucleusController<ComposeCo
|
|||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
|
|
||||||
binding.root.setContent {
|
binding.root.setContent {
|
||||||
ComposeContent()
|
TachiyomiTheme {
|
||||||
|
ComposeContent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user