Use Stable interface for Updates screen + Cleanup (#7627)
* Use Stable interface for Updates screen + Cleanup Co-Authored-By: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> * Disable swipe refresh in selection mode * Review Changes Co-Authored-By: Andreas <6576096+ghostbear@users.noreply.github.com> * Review Changes 2 Co-authored-by: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Co-authored-by: Andreas <6576096+ghostbear@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package eu.kanade.presentation.updates
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesPresenter
|
||||
|
||||
@Stable
|
||||
interface UpdatesState {
|
||||
val isLoading: Boolean
|
||||
val uiModels: List<UpdatesUiModel>
|
||||
val selected: List<UpdatesUiModel.Item>
|
||||
val selectionMode: Boolean
|
||||
var dialog: UpdatesPresenter.Dialog?
|
||||
}
|
||||
fun UpdatesState(): UpdatesState = UpdatesStateImpl()
|
||||
class UpdatesStateImpl : UpdatesState {
|
||||
override var isLoading: Boolean by mutableStateOf(true)
|
||||
override var uiModels: List<UpdatesUiModel> by mutableStateOf(emptyList())
|
||||
override val selected: List<UpdatesUiModel.Item> by derivedStateOf {
|
||||
uiModels.filterIsInstance<UpdatesUiModel.Item>()
|
||||
.filter { it.item.selected }
|
||||
}
|
||||
override val selectionMode: Boolean by derivedStateOf { selected.isNotEmpty() }
|
||||
override var dialog: UpdatesPresenter.Dialog? by mutableStateOf(null)
|
||||
}
|
||||
Reference in New Issue
Block a user