Simplifying Compose stack
This commit is contained in:
@@ -183,10 +183,6 @@ private fun FeedLoaded(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val baseModifier = remember {
|
|
||||||
Modifier
|
|
||||||
}
|
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
contentPadding = FeedPadding,
|
contentPadding = FeedPadding,
|
||||||
state = listState
|
state = listState
|
||||||
@@ -201,7 +197,7 @@ private fun FeedLoaded(
|
|||||||
NoteCompose(
|
NoteCompose(
|
||||||
item,
|
item,
|
||||||
routeForLastRead = routeForLastRead,
|
routeForLastRead = routeForLastRead,
|
||||||
modifier = baseModifier,
|
modifier = Modifier,
|
||||||
isBoostedNote = false,
|
isBoostedNote = false,
|
||||||
showHidden = state.showHidden.value,
|
showHidden = state.showHidden.value,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import androidx.compose.animation.Crossfade
|
|||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
import androidx.compose.foundation.layout.FlowRow
|
import androidx.compose.foundation.layout.FlowRow
|
||||||
@@ -104,16 +103,12 @@ fun VideoScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Column(Modifier.fillMaxHeight()) {
|
Column(Modifier.fillMaxHeight()) {
|
||||||
Column(
|
RenderPage(
|
||||||
modifier = Modifier.padding(vertical = 0.dp)
|
videoFeedView = videoFeedView,
|
||||||
) {
|
pagerStateKey = ScrollStateKeys.VIDEO_SCREEN,
|
||||||
SaveableFeedState(
|
accountViewModel = accountViewModel,
|
||||||
videoFeedView = videoFeedView,
|
nav = nav
|
||||||
accountViewModel = accountViewModel,
|
)
|
||||||
nav = nav,
|
|
||||||
scrollStateKey = ScrollStateKeys.VIDEO_SCREEN
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,16 +122,6 @@ fun WatchAccountForVideoScreen(videoFeedView: NostrVideoFeedViewModel, accountVi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun SaveableFeedState(
|
|
||||||
videoFeedView: NostrVideoFeedViewModel,
|
|
||||||
accountViewModel: AccountViewModel,
|
|
||||||
nav: (String) -> Unit,
|
|
||||||
scrollStateKey: String? = null
|
|
||||||
) {
|
|
||||||
RenderPage(videoFeedView, accountViewModel, scrollStateKey, nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
public fun WatchScrollToTop(
|
public fun WatchScrollToTop(
|
||||||
@@ -153,39 +138,35 @@ public fun WatchScrollToTop(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RenderPage(
|
fun RenderPage(
|
||||||
videoFeedView: NostrVideoFeedViewModel,
|
videoFeedView: NostrVideoFeedViewModel,
|
||||||
accountViewModel: AccountViewModel,
|
|
||||||
pagerStateKey: String?,
|
pagerStateKey: String?,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val feedState by videoFeedView.feedContent.collectAsStateWithLifecycle()
|
val feedState by videoFeedView.feedContent.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
Box() {
|
Crossfade(
|
||||||
Column {
|
targetState = feedState,
|
||||||
Crossfade(
|
animationSpec = tween(durationMillis = 100),
|
||||||
targetState = feedState,
|
label = "RenderPage"
|
||||||
animationSpec = tween(durationMillis = 100)
|
) { state ->
|
||||||
) { state ->
|
when (state) {
|
||||||
when (state) {
|
is FeedState.Empty -> {
|
||||||
is FeedState.Empty -> {
|
FeedEmpty {}
|
||||||
FeedEmpty {}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
is FeedState.FeedError -> {
|
is FeedState.FeedError -> {
|
||||||
FeedError(state.errorMessage) {}
|
FeedError(state.errorMessage) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
is FeedState.Loaded -> {
|
is FeedState.Loaded -> {
|
||||||
LoadedState(state, pagerStateKey, videoFeedView, accountViewModel, nav)
|
LoadedState(state, pagerStateKey, videoFeedView, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
is FeedState.Loading -> {
|
is FeedState.Loading -> {
|
||||||
LoadingFeed()
|
LoadingFeed()
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user