Skip to content

Commit

Permalink
fixed activate screen design
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Mar 17, 2024
1 parent 24c4cdd commit d07a245
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,35 @@ 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) {
nextEpisode
} else {
null
}

DefaultScreen(component, loadingEpisode)

availableEpisode?.let { next ->
ExtendedFloatingActionButton(
onClick = {
component.itemClicked(next)
},
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)
}
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

0 comments on commit d07a245

Please sign in to comment.