Skip to content

Commit

Permalink
migrate to skeo and prepare for k2 compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Dec 3, 2023
1 parent 5dd0fa3 commit 78cbf29
Show file tree
Hide file tree
Showing 38 changed files with 112 additions and 400 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import androidx.compose.ui.graphics.asImageBitmap
import com.arkivanov.decompose.ExperimentalDecomposeApi
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.StackAnimation
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.fade
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.predictiveBackAnimation
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.predictiveback.materialPredictiveBackAnimatable
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.predictiveback.predictiveBackAnimation
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation
import com.arkivanov.essenty.backhandler.BackHandler
import com.vanniktech.blurhash.BlurHash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ actual fun VideoScreen(component: VideoComponent) {
mutableStateOf(streamList[streamIndex].headers)
}
val mediaItem = remember(streamList, streamIndex, sourceIndex) {
MediaItem.fromUri(streamList[streamIndex].list[sourceIndex])
MediaItem.fromUri(streamList[streamIndex].sources.toList()[sourceIndex])
}
val startingPos by component.startingPos.collectAsStateWithLifecycle()

Expand Down Expand Up @@ -146,7 +146,7 @@ actual fun VideoScreen(component: VideoComponent) {
override fun onPlayerError(error: PlaybackException) {
super.onPlayerError(error)

if (streamList[streamIndex].list.size - 1 > sourceIndex) {
if (streamList[streamIndex].sources.size - 1 > sourceIndex) {
sourceIndex++
} else if (streamList.size - 1 > streamIndex) {
streamIndex++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class NavHostComponent(
private val navigation = StackNavigation<ScreenConfig>()
private val stack = childStack(
source = navigation,
serializer = ScreenConfig.serializer(),
initialConfiguration = ScreenConfig.Home,
childFactory = ::createScreenComponent
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
package dev.datlag.burningseries.shared.ui.navigation

import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
import dev.datlag.burningseries.model.Series
import dev.datlag.burningseries.model.Stream
import dev.datlag.skeo.Stream
import kotlinx.serialization.Serializable

@Parcelize
sealed class ScreenConfig : Parcelable {
@Serializable
sealed class ScreenConfig {

@Parcelize
data object Home : ScreenConfig(), Parcelable
@Serializable
data object Home : ScreenConfig()

@Parcelize
@Serializable
data class Video(
val schemeKey: String,
val series: Series,
val episode: Series.Episode,
val streams: List<Stream>
) : ScreenConfig(), Parcelable
) : ScreenConfig()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import com.arkivanov.decompose.ExperimentalDecomposeApi
import com.arkivanov.decompose.router.pages.*
import com.arkivanov.decompose.value.Value
import dev.datlag.burningseries.model.Series
import dev.datlag.burningseries.model.Stream
import dev.datlag.burningseries.shared.SharedRes
import dev.datlag.burningseries.shared.ui.navigation.Component
import dev.datlag.burningseries.shared.ui.screen.initial.favorite.FavoriteScreenComponent
import dev.datlag.burningseries.shared.ui.screen.initial.home.HomeScreenComponent
import dev.datlag.burningseries.shared.ui.screen.initial.search.SearchScreenComponent
import dev.datlag.skeo.Stream
import kotlinx.coroutines.flow.MutableStateFlow
import org.kodein.di.DI

Expand Down Expand Up @@ -46,6 +46,7 @@ class InitialScreenComponent(
@OptIn(ExperimentalDecomposeApi::class)
override val pages: Value<ChildPages<*, Component>> = childPages(
source = pagesNavigation,
serializer = View.serializer(),
initialPages = {
Pages(
items = listOf(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package dev.datlag.burningseries.shared.ui.screen.initial

import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
import kotlinx.serialization.Serializable

@Parcelize
sealed class View : Parcelable {
@Serializable
sealed class View {

@Parcelize
data object Home : View(), Parcelable
@Serializable
data object Home : View()

@Parcelize
data object Favorite : View(), Parcelable
@Serializable
data object Favorite : View()

@Parcelize
data object Search : View(), Parcelable
@Serializable
data object Search : View()
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package dev.datlag.burningseries.shared.ui.screen.initial.favorite

import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
import kotlinx.serialization.Serializable
import dev.datlag.burningseries.database.Series as DBSeries

@Parcelize
sealed class FavoriteConfig : Parcelable {
@Parcelize
@Serializable
sealed class FavoriteConfig {
@Serializable
data class Series(
val title: String,
val href: String,
val coverHref: String?
) : FavoriteConfig(), Parcelable {
) : FavoriteConfig() {
constructor(item: DBSeries) : this(item.title, item.href, item.coverHref)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import com.arkivanov.decompose.router.slot.*
import com.arkivanov.decompose.value.Value
import dev.datlag.burningseries.database.BurningSeries
import dev.datlag.burningseries.database.Series
import dev.datlag.burningseries.model.Stream
import dev.datlag.burningseries.model.algorithm.JaroWinkler
import dev.datlag.burningseries.model.common.safeSubList
import dev.datlag.burningseries.shared.common.ioDispatcher
import dev.datlag.burningseries.shared.common.ioScope
import dev.datlag.burningseries.shared.ui.navigation.Component
import dev.datlag.burningseries.shared.ui.screen.initial.series.SeriesScreenComponent
import dev.datlag.skeo.Stream
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
Expand Down Expand Up @@ -63,6 +63,7 @@ class FavoriteScreenComponent(
private val navigation = SlotNavigation<FavoriteConfig>()
override val child: Value<ChildSlot<*, Component>> = childSlot(
source = navigation,
serializer = FavoriteConfig.serializer(),
handleBackButton = false
) { config, context ->
when (config) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package dev.datlag.burningseries.shared.ui.screen.initial.home

import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
import dev.datlag.burningseries.model.Home
import kotlinx.serialization.Serializable

@Parcelize
sealed class HomeConfig : Parcelable {
@Serializable
sealed class HomeConfig {

@Parcelize
@Serializable
data class Series(
val title: String,
val href: String,
val coverHref: String?,
) : HomeConfig(), Parcelable {
) : HomeConfig() {
constructor(series: Home.Series) : this(series.title, series.href, series.coverHref)
constructor(episode: Home.Episode) : this(episode.series ?: episode.title, episode.href, episode.coverHref)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.arkivanov.decompose.router.slot.*
import com.arkivanov.decompose.value.Value
import dev.datlag.burningseries.model.Release
import dev.datlag.burningseries.model.Series
import dev.datlag.burningseries.model.Stream
import dev.datlag.burningseries.model.common.getDigitsOrNull
import dev.datlag.burningseries.model.state.HomeAction
import dev.datlag.burningseries.model.state.HomeState
Expand All @@ -18,6 +17,7 @@ import dev.datlag.burningseries.shared.common.ioScope
import dev.datlag.burningseries.shared.common.launchIO
import dev.datlag.burningseries.shared.ui.navigation.Component
import dev.datlag.burningseries.shared.ui.screen.initial.series.SeriesScreenComponent
import dev.datlag.skeo.Stream
import kotlinx.coroutines.flow.*
import org.kodein.di.DI
import org.kodein.di.instance
Expand Down Expand Up @@ -52,6 +52,7 @@ class HomeScreenComponent(
private val navigation = SlotNavigation<HomeConfig>()
override val child: Value<ChildSlot<*, Component>> = childSlot(
source = navigation,
serializer = HomeConfig.serializer(),
handleBackButton = false
) { config, context ->
when (config) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package dev.datlag.burningseries.shared.ui.screen.initial.search

import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
import dev.datlag.burningseries.model.Genre
import kotlinx.serialization.Serializable

@Parcelize
sealed class SearchConfig : Parcelable {
@Parcelize
@Serializable
sealed class SearchConfig {
@Serializable
data class Series(
val title: String,
val href: String,
) : SearchConfig(), Parcelable {
) : SearchConfig() {
constructor(item: Genre.Item) : this(item.title, item.href)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.arkivanov.decompose.router.slot.*
import com.arkivanov.decompose.value.Value
import dev.datlag.burningseries.model.Genre
import dev.datlag.burningseries.model.Series
import dev.datlag.burningseries.model.Stream
import dev.datlag.burningseries.model.algorithm.JaroWinkler
import dev.datlag.burningseries.model.common.safeSubList
import dev.datlag.burningseries.model.state.SearchAction
Expand All @@ -17,6 +16,7 @@ import dev.datlag.burningseries.shared.common.ioScope
import dev.datlag.burningseries.shared.common.launchIO
import dev.datlag.burningseries.shared.ui.navigation.Component
import dev.datlag.burningseries.shared.ui.screen.initial.series.SeriesScreenComponent
import dev.datlag.skeo.Stream
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
Expand Down Expand Up @@ -73,6 +73,7 @@ class SearchScreenComponent(
private val navigation = SlotNavigation<SearchConfig>()
override val child: Value<ChildSlot<*, Component>> = childSlot(
source = navigation,
serializer = SearchConfig.serializer(),
handleBackButton = false
) { config, context ->
when (config) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
package dev.datlag.burningseries.shared.ui.screen.initial.series

import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
import dev.datlag.burningseries.model.Series
import kotlinx.serialization.Serializable

@Parcelize
sealed class DialogConfig : Parcelable {
@Serializable
sealed class DialogConfig {

@Parcelize
@Serializable
data class Season(
val selected: Series.Season,
val seasons: List<Series.Season>
) : DialogConfig(), Parcelable
) : DialogConfig()

@Parcelize
@Serializable
data class Language(
val selected: Series.Language,
val languages: List<Series.Language>
) : DialogConfig(), Parcelable
) : DialogConfig()

@Parcelize
@Serializable
data class StreamUnavailable(
val series: Series,
val episode: Series.Episode
) : DialogConfig(), Parcelable
) : DialogConfig()

@Parcelize
@Serializable
data class Activate(
val series: Series,
val episode: Series.Episode
) : DialogConfig(), Parcelable
) : DialogConfig()
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package dev.datlag.burningseries.shared.ui.screen.initial.series

import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
import dev.datlag.burningseries.model.Series
import kotlinx.serialization.Serializable

@Parcelize
sealed class SeriesConfig : Parcelable {
@Serializable
sealed class SeriesConfig {

@Parcelize
@Serializable
data class Activate(
val series: Series,
val episode: Series.Episode
) : SeriesConfig(), Parcelable
) : SeriesConfig()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.arkivanov.essenty.backhandler.BackCallback
import dev.datlag.burningseries.database.BurningSeries
import dev.datlag.burningseries.model.BSUtil
import dev.datlag.burningseries.model.Series
import dev.datlag.burningseries.model.Stream
import dev.datlag.burningseries.model.state.EpisodeAction
import dev.datlag.burningseries.model.state.EpisodeState
import dev.datlag.burningseries.model.state.SeriesAction
Expand All @@ -33,6 +32,7 @@ import dev.datlag.burningseries.shared.ui.screen.initial.series.dialog.activate.
import dev.datlag.burningseries.shared.ui.screen.initial.series.dialog.language.LanguageDialogComponent
import dev.datlag.burningseries.shared.ui.screen.initial.series.dialog.season.SeasonDialogComponent
import dev.datlag.burningseries.shared.ui.screen.initial.series.dialog.unavailable.UnavailableDialogComponent
import dev.datlag.skeo.Stream
import io.ktor.client.*
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.flow.*
Expand Down Expand Up @@ -107,6 +107,7 @@ class SeriesScreenComponent(
private val navigation = SlotNavigation<SeriesConfig>()
override val child: Value<ChildSlot<*, Component>> = childSlot(
source = navigation,
serializer = SeriesConfig.serializer(),
handleBackButton = false
) { config, context ->
when (config) {
Expand All @@ -124,7 +125,8 @@ class SeriesScreenComponent(
private val dialogNavigation = SlotNavigation<DialogConfig>()
private val _dialog = childSlot(
key = "DialogChildSlot",
source = dialogNavigation
source = dialogNavigation,
serializer = DialogConfig.serializer()
) { config, slotContext ->
when (config) {
is DialogConfig.Season -> SeasonDialogComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.arkivanov.decompose.router.slot.dismiss
import com.arkivanov.essenty.backhandler.BackCallback
import dev.datlag.burningseries.model.HosterScraping
import dev.datlag.burningseries.model.Series
import dev.datlag.burningseries.model.Stream
import dev.datlag.burningseries.model.common.scopeCatching
import dev.datlag.burningseries.model.state.SaveAction
import dev.datlag.burningseries.model.state.SaveState
Expand All @@ -21,6 +20,7 @@ import dev.datlag.burningseries.shared.ui.navigation.DialogComponent
import dev.datlag.burningseries.shared.ui.screen.initial.series.activate.component.DialogConfig
import dev.datlag.burningseries.shared.ui.screen.initial.series.activate.dialog.error.ErrorDialogComponent
import dev.datlag.burningseries.shared.ui.screen.initial.series.activate.dialog.success.SuccessDialogComponent
import dev.datlag.skeo.Stream
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
Expand All @@ -46,7 +46,8 @@ class ActivateScreenComponent(

private val dialogNavigation = SlotNavigation<DialogConfig>()
override val dialog = childSlot(
source = dialogNavigation
source = dialogNavigation,
serializer = DialogConfig.serializer()
) { config, slotContext ->
when (config) {
is DialogConfig.Success -> SuccessDialogComponent(
Expand Down
Loading

0 comments on commit 78cbf29

Please sign in to comment.