MigrateSourceState.kt 1.1 KB

12345678910111213141516171819202122232425262728
  1. package eu.kanade.presentation.browse
  2. import androidx.compose.runtime.derivedStateOf
  3. import androidx.compose.runtime.getValue
  4. import androidx.compose.runtime.mutableStateOf
  5. import androidx.compose.runtime.setValue
  6. import eu.kanade.domain.source.interactor.SetMigrateSorting
  7. import eu.kanade.domain.source.model.Source
  8. interface MigrateSourceState {
  9. val isLoading: Boolean
  10. val items: List<Pair<Source, Long>>
  11. val isEmpty: Boolean
  12. val sortingMode: SetMigrateSorting.Mode
  13. val sortingDirection: SetMigrateSorting.Direction
  14. }
  15. fun MigrateSourceState(): MigrateSourceState {
  16. return MigrateSourceStateImpl()
  17. }
  18. class MigrateSourceStateImpl : MigrateSourceState {
  19. override var isLoading: Boolean by mutableStateOf(true)
  20. override var items: List<Pair<Source, Long>> by mutableStateOf(emptyList())
  21. override val isEmpty: Boolean by derivedStateOf { items.isEmpty() }
  22. override var sortingMode: SetMigrateSorting.Mode by mutableStateOf(SetMigrateSorting.Mode.ALPHABETICAL)
  23. override var sortingDirection: SetMigrateSorting.Direction by mutableStateOf(SetMigrateSorting.Direction.ASCENDING)
  24. }