mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Improve listener system
This commit is contained in:
@@ -13,8 +13,8 @@ import androidx.compose.animation.core.MutableTransitionState
|
||||
import androidx.compose.animation.core.TweenSpec
|
||||
import androidx.compose.animation.core.animateDp
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
import androidx.compose.animation.core.rememberTransition
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.core.updateTransition
|
||||
import androidx.compose.animation.expandVertically
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
@@ -408,7 +408,7 @@ fun ExpandablePreference(
|
||||
targetState = !expanded
|
||||
}
|
||||
}
|
||||
val transition = updateTransition(transitionState)
|
||||
val transition = rememberTransition(transitionState)
|
||||
val elevation by transition.animateDp({
|
||||
tween(durationMillis = EXPAND_ANIMATION_DURATION)
|
||||
}) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package ca.gosyer.jui.ui.base.state
|
||||
|
||||
import ca.gosyer.jui.uicore.vm.ViewModel
|
||||
import kotlinx.coroutines.ExperimentalForInheritanceCoroutinesApi
|
||||
import kotlinx.coroutines.InternalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.internal.SynchronizedObject
|
||||
@@ -39,6 +40,7 @@ class SavedStateHandleDelegate<T>(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalForInheritanceCoroutinesApi::class)
|
||||
class SavedStateHandleStateFlow<T>(
|
||||
private val key: String,
|
||||
private val savedStateHandle: SavedStateHandle,
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
package ca.gosyer.jui.ui.library.components
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.PagerState
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -119,7 +118,5 @@ private fun LibraryLoadedPage(
|
||||
showLanguage = showLanguage,
|
||||
showLocal = showLocal,
|
||||
)
|
||||
|
||||
else -> Box {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ class MangaScreenViewModel(
|
||||
) {
|
||||
scope.launch {
|
||||
manga.value?.let {
|
||||
updateChapter.await(chapterIds, read = read, onError = { toast(it.message.orEmpty()) })
|
||||
updateChapter.await(chapterIds, listOf(params.mangaId), read = read, onError = { toast(it.message.orEmpty()) })
|
||||
selectedIds.value = persistentListOf()
|
||||
loadChapters()
|
||||
}
|
||||
@@ -308,7 +308,7 @@ class MangaScreenViewModel(
|
||||
) {
|
||||
scope.launch {
|
||||
manga.value?.let {
|
||||
updateChapter.await(chapterIds, bookmarked = bookmark, onError = { toast(it.message.orEmpty()) })
|
||||
updateChapter.await(chapterIds, listOf(params.mangaId), bookmarked = bookmark, onError = { toast(it.message.orEmpty()) })
|
||||
selectedIds.value = persistentListOf()
|
||||
loadChapters()
|
||||
}
|
||||
@@ -325,7 +325,7 @@ class MangaScreenViewModel(
|
||||
val chapters = chapters.value
|
||||
.sortedBy { it.chapter.index }
|
||||
.subList(0, index).map { it.chapter.id } // todo test
|
||||
updateChapter.await(chapters, read = true, onError = { toast(it.message.orEmpty()) })
|
||||
updateChapter.await(chapters, listOf(params.mangaId), read = true, onError = { toast(it.message.orEmpty()) })
|
||||
selectedIds.value = persistentListOf()
|
||||
loadChapters()
|
||||
}
|
||||
@@ -340,7 +340,7 @@ class MangaScreenViewModel(
|
||||
scope.launch {
|
||||
if (id == null) {
|
||||
val chapterIds = selectedIds.value
|
||||
deleteChapterDownload.await(chapterIds, onError = { toast(it.message.orEmpty()) })
|
||||
deleteChapterDownload.await(chapterIds, listOf(params.mangaId), onError = { toast(it.message.orEmpty()) })
|
||||
selectedItems.value.forEach {
|
||||
it.setNotDownloaded()
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ import kotlinx.collections.immutable.ImmutableMap
|
||||
import kotlinx.collections.immutable.persistentMapOf
|
||||
import kotlinx.collections.immutable.toImmutableMap
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.ExperimentalForInheritanceCoroutinesApi
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
@@ -137,6 +138,7 @@ expect class SettingsServerHostViewModel : ViewModel
|
||||
@Composable
|
||||
expect fun getServerHostItems(viewModel: @Composable () -> SettingsServerHostViewModel): LazyListScope.() -> Unit
|
||||
|
||||
@OptIn(ExperimentalForInheritanceCoroutinesApi::class)
|
||||
private class ServerSettingMutableStateFlow<T>(
|
||||
parent: StateFlow<Settings>,
|
||||
getSetting: (Settings) -> T,
|
||||
|
||||
@@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
|
||||
@Suppress("DATA_CLASS_COPY_VISIBILITY_WILL_BE_CHANGED_WARNING")
|
||||
sealed class SourceFiltersView<T : SourceFilter, R : Any?> {
|
||||
abstract val index: Int
|
||||
abstract val name: String
|
||||
|
||||
@@ -27,6 +27,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
|
||||
@Suppress("DATA_CLASS_COPY_VISIBILITY_WILL_BE_CHANGED_WARNING")
|
||||
sealed class SourceSettingsView<T : SourcePreference, R : Any?> {
|
||||
abstract val index: Int
|
||||
abstract val title: String?
|
||||
|
||||
@@ -118,7 +118,9 @@ class UpdatesScreenViewModel(
|
||||
read: Boolean,
|
||||
) {
|
||||
scope.launch {
|
||||
updateChapter.await(chapterIds, read = read, onError = { toast(it.message.orEmpty()) })
|
||||
val mangaIds = updates.value.filterIsInstance<UpdatesUI.Item>().filter { it.chapterDownloadItem.chapter.id in chapterIds }
|
||||
.mapNotNull { it.chapterDownloadItem.manga?.id }
|
||||
updateChapter.await(chapterIds, mangaIds, read = read, onError = { toast(it.message.orEmpty()) })
|
||||
selectedIds.value = persistentListOf()
|
||||
}
|
||||
}
|
||||
@@ -132,7 +134,9 @@ class UpdatesScreenViewModel(
|
||||
bookmark: Boolean,
|
||||
) {
|
||||
scope.launch {
|
||||
updateChapter.await(chapterIds, bookmarked = bookmark, onError = { toast(it.message.orEmpty()) })
|
||||
val mangaIds = updates.value.filterIsInstance<UpdatesUI.Item>().filter { it.chapterDownloadItem.chapter.id in chapterIds }
|
||||
.mapNotNull { it.chapterDownloadItem.manga?.id }
|
||||
updateChapter.await(chapterIds, mangaIds, bookmarked = bookmark, onError = { toast(it.message.orEmpty()) })
|
||||
selectedIds.value = persistentListOf()
|
||||
}
|
||||
}
|
||||
@@ -157,7 +161,9 @@ class UpdatesScreenViewModel(
|
||||
scope.launchDefault {
|
||||
if (chapter == null) {
|
||||
val selectedIds = selectedIds.value
|
||||
deleteChapterDownload.await(selectedIds, onError = { toast(it.message.orEmpty()) })
|
||||
val mangaIds = updates.value.filterIsInstance<UpdatesUI.Item>().filter { it.chapterDownloadItem.chapter.id in selectedIds }
|
||||
.mapNotNull { it.chapterDownloadItem.manga?.id }
|
||||
deleteChapterDownload.await(selectedIds, mangaIds, onError = { toast(it.message.orEmpty()) })
|
||||
selectedItems.value.forEach {
|
||||
it.setNotDownloaded()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user