diff --git a/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/SeriesScreen.kt b/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/SeriesScreen.kt index 08026be5..1e8420b3 100644 --- a/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/SeriesScreen.kt +++ b/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/SeriesScreen.kt @@ -65,8 +65,7 @@ fun SeriesScreen(component: SeriesComponent) { Box( modifier = Modifier.fillMaxSize() ) { - DefaultScreen(component) - + val loadingEpisode by component.loadingEpisodeHref.collectAsStateWithLifecycle() val nextEpisode by component.nextEpisodeToWatch.collectAsStateWithLifecycle(initialValue = null) val nextSeason by component.nextSeasonToWatch.collectAsStateWithLifecycle(initialValue = null) val availableEpisode = if (nextEpisode?.hosters?.isNotEmpty() == true) { @@ -74,6 +73,9 @@ fun SeriesScreen(component: SeriesComponent) { } else { null } + + DefaultScreen(component, loadingEpisode) + availableEpisode?.let { next -> ExtendedFloatingActionButton( onClick = { @@ -81,11 +83,17 @@ fun SeriesScreen(component: SeriesComponent) { }, modifier = Modifier.align(Alignment.BottomEnd).localPadding(16.dp) ) { - Icon( - imageVector = Icons.Default.PlayArrow, - contentDescription = next.episodeTitle, - modifier = Modifier.size(ButtonDefaults.IconSize) - ) + if (loadingEpisode.equals(next.href, ignoreCase = true)) { + CircularProgressIndicator( + modifier = Modifier.size(ButtonDefaults.IconSize) + ) + } else { + Icon( + imageVector = Icons.Default.PlayArrow, + contentDescription = next.episodeTitle, + modifier = Modifier.size(ButtonDefaults.IconSize) + ) + } Spacer(modifier = Modifier.size(ButtonDefaults.IconSpacing)) Text(text = next.episodeTitle) } @@ -130,7 +138,7 @@ expect fun EnterSeriesScreen() @OptIn(ExperimentalMaterial3Api::class) @Composable -private fun DefaultScreen(component: SeriesComponent) { +private fun DefaultScreen(component: SeriesComponent, loadingEpisode: String?) { val seriesState by component.seriesState.collectAsStateWithLifecycle() val title by component.title.collectAsStateWithLifecycle() val coverHref by component.coverHref.collectAsStateWithLifecycle() @@ -150,7 +158,6 @@ private fun DefaultScreen(component: SeriesComponent) { modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(2.dp) ) { - val loadingEpisode by component.loadingEpisodeHref.collectAsStateWithLifecycle() val state = rememberLazyListState( initialFirstVisibleItemIndex = StateSaver.seriesListIndex, initialFirstVisibleItemScrollOffset = StateSaver.seriesListOffset diff --git a/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/activate/ActivateScreen.kt b/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/activate/ActivateScreen.kt index df834a16..c5f5b34e 100644 --- a/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/activate/ActivateScreen.kt +++ b/app/shared/src/commonMain/kotlin/dev/datlag/burningseries/shared/ui/screen/initial/series/activate/ActivateScreen.kt @@ -15,68 +15,64 @@ import com.arkivanov.decompose.extensions.compose.subscribeAsState import dev.datlag.burningseries.model.BSUtil import dev.datlag.burningseries.shared.SharedRes import dev.datlag.burningseries.shared.common.lifecycle.collectAsStateWithLifecycle +import dev.datlag.burningseries.shared.common.localPadding import dev.datlag.burningseries.shared.ui.custom.state.UnreachableState import dev.datlag.burningseries.shared.ui.screen.initial.series.activate.component.WebView import dev.icerock.moko.resources.compose.stringResource -@OptIn(ExperimentalMaterial3Api::class) @Composable fun ActivateScreen(component: ActivateComponent) { - Scaffold( - topBar = { - TopAppBar( - title = { - Text(text = stringResource(SharedRes.strings.activate_hint)) - }, - navigationIcon = { - IconButton( - onClick = { - component.back() - } - ) { - Icon( - imageVector = Icons.Default.ArrowBackIosNew, - contentDescription = stringResource(SharedRes.strings.back) - ) - } - }, - actions = { - Box( - contentAlignment = Alignment.Center - ) { - val isSaving by component.isSaving.collectAsStateWithLifecycle() + val dialogState by component.dialog.subscribeAsState() + val onDeviceReachable = remember { component.onDeviceReachable } - if (isSaving) { - Icon( - imageVector = Icons.Default.Save, - contentDescription = stringResource(SharedRes.strings.saving) - ) - CircularProgressIndicator() - } - } - } - ) - } + Column( + modifier = Modifier.localPadding(), + verticalArrangement = Arrangement.spacedBy(8.dp) ) { - val dialogState by component.dialog.subscribeAsState() - val onDeviceReachable = remember { component.onDeviceReachable } - - Column( - modifier = Modifier.padding(it), - verticalArrangement = Arrangement.spacedBy(8.dp) + Row( + modifier = Modifier.fillMaxWidth().defaultMinSize(minHeight = 56.dp), + verticalAlignment = Alignment.CenterVertically ) { - if (onDeviceReachable) { - dialogState.child?.instance?.render() - WebView( - url = BSUtil.getBurningSeriesLink(component.episode.href), - modifier = Modifier.fillMaxSize(), - onScraped = { data -> - component.onScraped(data) - } + val isSaving by component.isSaving.collectAsStateWithLifecycle() + + IconButton( + onClick = { + component.back() + } + ) { + Icon( + imageVector = Icons.Default.ArrowBackIosNew, + contentDescription = stringResource(SharedRes.strings.back) ) - } else { - UnreachableState(SharedRes.strings.activate_unreachable) } + Text( + modifier = Modifier.weight(1F), + text = stringResource(SharedRes.strings.activate_hint), + maxLines = 2 + ) + if (isSaving) { + Box( + contentAlignment = Alignment.Center + ) { + Icon( + imageVector = Icons.Default.Save, + contentDescription = stringResource(SharedRes.strings.saving) + ) + CircularProgressIndicator() + } + } + } + if (onDeviceReachable) { + dialogState.child?.instance?.render() + WebView( + url = BSUtil.getBurningSeriesLink(component.episode.href), + modifier = Modifier.fillMaxSize(), + onScraped = { data -> + component.onScraped(data) + } + ) + } else { + UnreachableState(SharedRes.strings.activate_unreachable) } } } \ No newline at end of file