Fixes Jump on FollowPack screens
This commit is contained in:
@@ -21,12 +21,14 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.screen
|
package com.vitorpamplona.amethyst.ui.screen
|
||||||
|
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
import com.vitorpamplona.amethyst.ui.actions.CrossfadeIfEnabled
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.FeedEmpty
|
import com.vitorpamplona.amethyst.ui.feeds.FeedEmpty
|
||||||
@@ -85,6 +87,7 @@ private fun FeedLoaded(
|
|||||||
val listState = rememberLazyListState()
|
val listState = rememberLazyListState()
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
contentPadding = FeedPadding,
|
contentPadding = FeedPadding,
|
||||||
state = listState,
|
state = listState,
|
||||||
) {
|
) {
|
||||||
|
|||||||
+101
-85
@@ -32,6 +32,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.statusBars
|
import androidx.compose.foundation.layout.statusBars
|
||||||
import androidx.compose.foundation.pager.HorizontalPager
|
import androidx.compose.foundation.pager.HorizontalPager
|
||||||
|
import androidx.compose.foundation.pager.PagerState
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
@@ -141,7 +142,6 @@ fun PrepareViewModelsFollowPackScreen(
|
|||||||
FollowPackFeedScreen(note, newThreadFeedViewModel, conversationsFeedViewModel, membersFeedViewModel, accountViewModel, nav)
|
FollowPackFeedScreen(note, newThreadFeedViewModel, conversationsFeedViewModel, membersFeedViewModel, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun FollowPackFeedScreen(
|
fun FollowPackFeedScreen(
|
||||||
note: AddressableNote,
|
note: AddressableNote,
|
||||||
@@ -162,90 +162,12 @@ fun FollowPackFeedScreen(
|
|||||||
DisappearingScaffold(
|
DisappearingScaffold(
|
||||||
isInvertedLayout = false,
|
isInvertedLayout = false,
|
||||||
topBar = {
|
topBar = {
|
||||||
Column {
|
FollowPackFeedTopBar(
|
||||||
val statusBarHeight = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
|
note,
|
||||||
val modifier = Modifier.fillMaxWidth().height(TopBarSize + statusBarHeight)
|
pagerState,
|
||||||
Box(
|
accountViewModel,
|
||||||
modifier = modifier, // Adjust height as needed for your banner
|
nav,
|
||||||
) {
|
)
|
||||||
DisplayBanner(note, Modifier.fillMaxSize(), accountViewModel)
|
|
||||||
|
|
||||||
ShorterTopAppBar(
|
|
||||||
title = {
|
|
||||||
FollowPackHeader(note, accountViewModel, nav)
|
|
||||||
},
|
|
||||||
navigationIcon = {
|
|
||||||
Row(TitleIconModifier, verticalAlignment = Alignment.CenterVertically) {
|
|
||||||
IconButton(
|
|
||||||
onClick = nav::popBack,
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
|
||||||
contentDescription = stringRes(R.string.back),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
actions = {
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = SpacedBy2dp) {
|
|
||||||
ReplyReaction(
|
|
||||||
baseNote = note,
|
|
||||||
grayTint = MaterialTheme.colorScheme.onBackground,
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
iconSizeModifier = Size18Modifier,
|
|
||||||
) {
|
|
||||||
nav.nav {
|
|
||||||
Route.Note(note.idHex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Spacer(modifier = HalfHorzSpacer)
|
|
||||||
LikeReaction(
|
|
||||||
baseNote = note,
|
|
||||||
grayTint = MaterialTheme.colorScheme.onBackground,
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
nav,
|
|
||||||
)
|
|
||||||
Spacer(modifier = HalfHorzSpacer)
|
|
||||||
ZapReaction(
|
|
||||||
baseNote = note,
|
|
||||||
grayTint = MaterialTheme.colorScheme.onBackground,
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
nav = nav,
|
|
||||||
)
|
|
||||||
Spacer(modifier = HalfHorzSpacer)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
colors =
|
|
||||||
TopAppBarDefaults.topAppBarColors(
|
|
||||||
containerColor = MaterialTheme.colorScheme.background.copy(alpha = 0.6f), // Make TopAppBar background transparent
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
TabRow(
|
|
||||||
containerColor = Color.Transparent,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onBackground,
|
|
||||||
modifier = TabRowHeight,
|
|
||||||
selectedTabIndex = pagerState.currentPage,
|
|
||||||
) {
|
|
||||||
val coroutineScope = rememberCoroutineScope()
|
|
||||||
Tab(
|
|
||||||
selected = pagerState.currentPage == 0,
|
|
||||||
text = { Text(text = stringRes(R.string.new_threads)) },
|
|
||||||
onClick = { coroutineScope.launch { pagerState.animateScrollToPage(0) } },
|
|
||||||
)
|
|
||||||
Tab(
|
|
||||||
selected = pagerState.currentPage == 1,
|
|
||||||
text = { Text(text = stringRes(R.string.conversations)) },
|
|
||||||
onClick = { coroutineScope.launch { pagerState.animateScrollToPage(1) } },
|
|
||||||
)
|
|
||||||
Tab(
|
|
||||||
selected = pagerState.currentPage == 2,
|
|
||||||
text = { Text(text = stringRes(R.string.members)) },
|
|
||||||
onClick = { coroutineScope.launch { pagerState.animateScrollToPage(2) } },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
) {
|
) {
|
||||||
@@ -279,6 +201,100 @@ fun FollowPackFeedScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
private fun FollowPackFeedTopBar(
|
||||||
|
note: AddressableNote,
|
||||||
|
pagerState: PagerState,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
nav: INav,
|
||||||
|
) {
|
||||||
|
Column {
|
||||||
|
val statusBarHeight = WindowInsets.statusBars.asPaddingValues().calculateTopPadding()
|
||||||
|
val modifier = Modifier.fillMaxWidth().height(TopBarSize + statusBarHeight)
|
||||||
|
Box(
|
||||||
|
modifier = modifier, // Adjust height as needed for your banner
|
||||||
|
) {
|
||||||
|
DisplayBanner(note, Modifier.fillMaxSize(), accountViewModel)
|
||||||
|
|
||||||
|
ShorterTopAppBar(
|
||||||
|
title = {
|
||||||
|
FollowPackHeader(note, accountViewModel, nav)
|
||||||
|
},
|
||||||
|
navigationIcon = {
|
||||||
|
Row(TitleIconModifier, verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
IconButton(
|
||||||
|
onClick = nav::popBack,
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||||
|
contentDescription = stringRes(R.string.back),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions = {
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = SpacedBy2dp) {
|
||||||
|
ReplyReaction(
|
||||||
|
baseNote = note,
|
||||||
|
grayTint = MaterialTheme.colorScheme.onBackground,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
iconSizeModifier = Size18Modifier,
|
||||||
|
) {
|
||||||
|
nav.nav {
|
||||||
|
Route.Note(note.idHex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer(modifier = HalfHorzSpacer)
|
||||||
|
LikeReaction(
|
||||||
|
baseNote = note,
|
||||||
|
grayTint = MaterialTheme.colorScheme.onBackground,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav,
|
||||||
|
)
|
||||||
|
Spacer(modifier = HalfHorzSpacer)
|
||||||
|
ZapReaction(
|
||||||
|
baseNote = note,
|
||||||
|
grayTint = MaterialTheme.colorScheme.onBackground,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav,
|
||||||
|
)
|
||||||
|
Spacer(modifier = HalfHorzSpacer)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
colors =
|
||||||
|
TopAppBarDefaults.topAppBarColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.background.copy(alpha = 0.6f), // Make TopAppBar background transparent
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
TabRow(
|
||||||
|
containerColor = Color.Transparent,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onBackground,
|
||||||
|
modifier = TabRowHeight,
|
||||||
|
selectedTabIndex = pagerState.currentPage,
|
||||||
|
) {
|
||||||
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
Tab(
|
||||||
|
selected = pagerState.currentPage == 0,
|
||||||
|
text = { Text(text = stringRes(R.string.new_threads)) },
|
||||||
|
onClick = { coroutineScope.launch { pagerState.animateScrollToPage(0) } },
|
||||||
|
)
|
||||||
|
Tab(
|
||||||
|
selected = pagerState.currentPage == 1,
|
||||||
|
text = { Text(text = stringRes(R.string.conversations)) },
|
||||||
|
onClick = { coroutineScope.launch { pagerState.animateScrollToPage(1) } },
|
||||||
|
)
|
||||||
|
Tab(
|
||||||
|
selected = pagerState.currentPage == 2,
|
||||||
|
text = { Text(text = stringRes(R.string.members)) },
|
||||||
|
onClick = { coroutineScope.launch { pagerState.animateScrollToPage(2) } },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DisplayBanner(
|
private fun DisplayBanner(
|
||||||
baseNote: AddressableNote,
|
baseNote: AddressableNote,
|
||||||
|
|||||||
Reference in New Issue
Block a user