Refactors horizontal dividers

This commit is contained in:
Vitor Pamplona
2024-03-20 15:18:00 -04:00
parent b819f24790
commit f2a8e51b20
22 changed files with 255 additions and 331 deletions

View File

@ -46,6 +46,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CurrencyBitcoin import androidx.compose.material.icons.filled.CurrencyBitcoin
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.LocalTextStyle
@ -98,6 +99,7 @@ import com.vitorpamplona.amethyst.ui.note.NoteCompose
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.screen.loggedIn.UserLine import com.vitorpamplona.amethyst.ui.screen.loggedIn.UserLine
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.amethyst.ui.theme.QuoteBorder import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
import com.vitorpamplona.amethyst.ui.theme.Size10dp import com.vitorpamplona.amethyst.ui.theme.Size10dp
import com.vitorpamplona.amethyst.ui.theme.Size5dp import com.vitorpamplona.amethyst.ui.theme.Size5dp
@ -448,6 +450,9 @@ fun ShowUserSuggestionListForEdit(
key = { _, item -> item.pubkeyHex }, key = { _, item -> item.pubkeyHex },
) { _, item -> ) { _, item ->
UserLine(item, accountViewModel) { editPostViewModel.autocompleteWithUser(item) } UserLine(item, accountViewModel) { editPostViewModel.autocompleteWithUser(item) }
HorizontalDivider(
thickness = DividerThickness,
)
} }
} }
} }

View File

@ -357,6 +357,10 @@ private fun RenderSearchResults(
searchBarViewModel.clear() searchBarViewModel.clear()
} }
HorizontalDivider(
thickness = DividerThickness,
)
} }
itemsIndexed( itemsIndexed(
@ -367,6 +371,10 @@ private fun RenderSearchResults(
nav("Channel/${item.idHex}") nav("Channel/${item.idHex}")
searchBarViewModel.clear() searchBarViewModel.clear()
} }
HorizontalDivider(
thickness = DividerThickness,
)
} }
} }
} }
@ -404,18 +412,15 @@ fun UserComposeForChat(
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
onClick: () -> Unit, onClick: () -> Unit,
) { ) {
Column( Row(
modifier = modifier =
Modifier.clickable( Modifier.clickable(
onClick = onClick, onClick = onClick,
), ).padding(
) {
Row(
modifier =
Modifier.padding(
start = 12.dp, start = 12.dp,
end = 12.dp, end = 12.dp,
top = 10.dp, top = 10.dp,
bottom = 10.dp,
), ),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
@ -432,12 +437,6 @@ fun UserComposeForChat(
DisplayUserAboutInfo(baseUser) DisplayUserAboutInfo(baseUser)
} }
} }
HorizontalDivider(
modifier = Modifier.padding(top = 10.dp),
thickness = DividerThickness,
)
}
} }
@Composable @Composable

View File

@ -294,7 +294,6 @@ private fun DisplayOwnerInformation(
UserCompose( UserCompose(
baseUser = it, baseUser = it,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
showDiviser = false,
nav = nav, nav = nav,
) )
} }

View File

@ -197,7 +197,7 @@ fun InnerChannelCardWithReactions(
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: (String) -> Unit, nav: (String) -> Unit,
) { ) {
when (remember { baseNote.event }) { when (baseNote.event) {
is LiveActivitiesEvent -> { is LiveActivitiesEvent -> {
InnerCardRow(baseNote, accountViewModel, nav) InnerCardRow(baseNote, accountViewModel, nav)
} }
@ -496,12 +496,11 @@ fun RenderLiveActivityThumb(
Spacer(modifier = DoubleVertSpacer) Spacer(modifier = DoubleVertSpacer)
ChannelHeader( ChannelHeader(
channelHex = remember { baseNote.idHex }, channelHex = baseNote.idHex,
showVideo = false, showVideo = false,
showBottomDiviser = false,
showFlag = false, showFlag = false,
sendToChannel = true, sendToChannel = true,
modifier = remember { Modifier.padding(start = 0.dp, end = 0.dp, top = 5.dp, bottom = 5.dp) }, modifier = Modifier,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )

View File

@ -233,7 +233,6 @@ fun AcceptableNote(
ChannelHeader( ChannelHeader(
channelNote = baseNote, channelNote = baseNote,
showVideo = !makeItShort, showVideo = !makeItShort,
showBottomDiviser = true,
sendToChannel = true, sendToChannel = true,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
@ -267,7 +266,6 @@ fun AcceptableNote(
ChannelHeader( ChannelHeader(
channelNote = baseNote, channelNote = baseNote,
showVideo = !makeItShort, showVideo = !makeItShort,
showBottomDiviser = true,
sendToChannel = true, sendToChannel = true,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
@ -742,7 +740,6 @@ private fun ReplyRow(
ChannelHeader( ChannelHeader(
channelHex = it, channelHex = it,
showVideo = false, showVideo = false,
showBottomDiviser = false,
sendToChannel = true, sendToChannel = true,
modifier = MaterialTheme.colorScheme.replyModifier.padding(10.dp), modifier = MaterialTheme.colorScheme.replyModifier.padding(10.dp),
accountViewModel = accountViewModel, accountViewModel = accountViewModel,

View File

@ -20,13 +20,13 @@
*/ */
package com.vitorpamplona.amethyst.ui.note package com.vitorpamplona.amethyst.ui.note
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -47,7 +47,7 @@ import com.vitorpamplona.amethyst.model.RelayInfo
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
import com.vitorpamplona.amethyst.ui.theme.ButtonPadding import com.vitorpamplona.amethyst.ui.theme.ButtonPadding
import com.vitorpamplona.amethyst.ui.theme.DividerThickness import com.vitorpamplona.amethyst.ui.theme.StdPadding
import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.theme.placeholderText
import java.time.Instant import java.time.Instant
import java.time.ZoneId import java.time.ZoneId
@ -62,12 +62,13 @@ fun RelayCompose(
) { ) {
val context = LocalContext.current val context = LocalContext.current
Column {
Row( Row(
modifier = Modifier.padding(start = 12.dp, end = 12.dp, top = 10.dp), modifier = StdPadding,
verticalAlignment = Alignment.CenterVertically,
) { ) {
Column( Column(
modifier = Modifier.padding(start = 10.dp).weight(1f), modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.Center,
) { ) {
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) { Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
Text( Text(
@ -100,12 +101,6 @@ fun RelayCompose(
RelayOptions(accountViewModel, relay, onAddRelay, onRemoveRelay) RelayOptions(accountViewModel, relay, onAddRelay, onRemoveRelay)
} }
} }
HorizontalDivider(
modifier = Modifier.padding(top = 10.dp),
thickness = DividerThickness,
)
}
} }
@Composable @Composable

View File

@ -24,7 +24,6 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.HorizontalDivider
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@ -32,7 +31,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.amethyst.model.User
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.amethyst.ui.theme.Size55dp import com.vitorpamplona.amethyst.ui.theme.Size55dp
import com.vitorpamplona.amethyst.ui.theme.StdPadding import com.vitorpamplona.amethyst.ui.theme.StdPadding
@ -40,18 +38,14 @@ import com.vitorpamplona.amethyst.ui.theme.StdPadding
fun UserCompose( fun UserCompose(
baseUser: User, baseUser: User,
overallModifier: Modifier = StdPadding, overallModifier: Modifier = StdPadding,
showDiviser: Boolean = true,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: (String) -> Unit, nav: (String) -> Unit,
) { ) {
Column( Row(
modifier = modifier =
Modifier.clickable( overallModifier.clickable(
onClick = { nav("User/${baseUser.pubkeyHex}") }, onClick = { nav("User/${baseUser.pubkeyHex}") },
), ),
) {
Row(
modifier = overallModifier,
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
UserPicture(baseUser, Size55dp, accountViewModel = accountViewModel, nav = nav) UserPicture(baseUser, Size55dp, accountViewModel = accountViewModel, nav = nav)
@ -66,11 +60,4 @@ fun UserCompose(
UserActionOptions(baseUser, accountViewModel) UserActionOptions(baseUser, accountViewModel)
} }
} }
if (showDiviser) {
HorizontalDivider(
thickness = DividerThickness,
)
}
}
} }

View File

@ -31,7 +31,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -68,7 +67,6 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.screen.loggedIn.JoinCommunityButton import com.vitorpamplona.amethyst.ui.screen.loggedIn.JoinCommunityButton
import com.vitorpamplona.amethyst.ui.screen.loggedIn.LeaveCommunityButton import com.vitorpamplona.amethyst.ui.screen.loggedIn.LeaveCommunityButton
import com.vitorpamplona.amethyst.ui.screen.loggedIn.NormalTimeAgo import com.vitorpamplona.amethyst.ui.screen.loggedIn.NormalTimeAgo
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
import com.vitorpamplona.amethyst.ui.theme.HeaderPictureModifier import com.vitorpamplona.amethyst.ui.theme.HeaderPictureModifier
import com.vitorpamplona.amethyst.ui.theme.Size10dp import com.vitorpamplona.amethyst.ui.theme.Size10dp
@ -88,7 +86,6 @@ import java.util.Locale
@Composable @Composable
fun CommunityHeader( fun CommunityHeader(
baseNote: AddressableNote, baseNote: AddressableNote,
showBottomDiviser: Boolean,
sendToCommunity: Boolean, sendToCommunity: Boolean,
modifier: Modifier = StdPadding, modifier: Modifier = StdPadding,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
@ -125,12 +122,6 @@ fun CommunityHeader(
} }
} }
} }
if (showBottomDiviser) {
HorizontalDivider(
thickness = DividerThickness,
)
}
} }
} }

View File

@ -23,11 +23,13 @@ package com.vitorpamplona.amethyst.ui.note.types
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
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
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
@ -50,6 +52,7 @@ import com.vitorpamplona.amethyst.ui.components.ShowMoreButton
import com.vitorpamplona.amethyst.ui.note.UserCompose import com.vitorpamplona.amethyst.ui.note.UserCompose
import com.vitorpamplona.amethyst.ui.note.getGradient import com.vitorpamplona.amethyst.ui.note.getGradient
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.quartz.events.PeopleListEvent import com.vitorpamplona.quartz.events.PeopleListEvent
import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentListOf
@ -98,13 +101,16 @@ fun DisplayPeopleList(
Box { Box {
FlowRow(modifier = Modifier.padding(top = 5.dp)) { FlowRow(modifier = Modifier.padding(top = 5.dp)) {
toMembersShow.forEach { user -> toMembersShow.forEach { user ->
Row(modifier = Modifier.fillMaxWidth()) { Column(modifier = Modifier.fillMaxWidth()) {
UserCompose( UserCompose(
user, user,
overallModifier = Modifier,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
HorizontalDivider(
thickness = DividerThickness,
)
} }
} }
} }

View File

@ -60,7 +60,6 @@ fun RenderPostApproval(
baseNote?.let { baseNote?.let {
CommunityHeader( CommunityHeader(
baseNote = it, baseNote = it,
showBottomDiviser = false,
sendToCommunity = true, sendToCommunity = true,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,

View File

@ -26,6 +26,7 @@ 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.pullrefresh.PullRefreshIndicator import androidx.compose.material3.pullrefresh.PullRefreshIndicator
import androidx.compose.material3.pullrefresh.pullRefresh import androidx.compose.material3.pullrefresh.pullRefresh
import androidx.compose.material3.pullrefresh.rememberPullRefreshState import androidx.compose.material3.pullrefresh.rememberPullRefreshState
@ -47,6 +48,7 @@ import com.vitorpamplona.amethyst.ui.actions.NewRelayListView
import com.vitorpamplona.amethyst.ui.components.BundledUpdate import com.vitorpamplona.amethyst.ui.components.BundledUpdate
import com.vitorpamplona.amethyst.ui.note.RelayCompose import com.vitorpamplona.amethyst.ui.note.RelayCompose
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.amethyst.ui.theme.FeedPadding import com.vitorpamplona.amethyst.ui.theme.FeedPadding
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
@ -169,6 +171,9 @@ fun RelayFeedView(
onAddRelay = { wantsToAddRelay = item.url }, onAddRelay = { wantsToAddRelay = item.url },
onRemoveRelay = { wantsToAddRelay = item.url }, onRemoveRelay = { wantsToAddRelay = item.url },
) )
HorizontalDivider(
thickness = DividerThickness,
)
} }
} }

View File

@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
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.OutlinedButton import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -37,17 +38,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.amethyst.ui.theme.FeedPadding import com.vitorpamplona.amethyst.ui.theme.FeedPadding
@Composable
fun RefreshingFeedStringFeedView(
viewModel: StringFeedViewModel,
enablePullRefresh: Boolean = true,
inner: @Composable (String) -> Unit,
) {
RefresheableBox(viewModel, enablePullRefresh) { StringFeedView(viewModel, inner = inner) }
}
@Composable @Composable
fun StringFeedView( fun StringFeedView(
viewModel: StringFeedViewModel, viewModel: StringFeedViewModel,
@ -112,7 +105,13 @@ private fun FeedLoaded(
) { ) {
item { pre?.let { it() } } item { pre?.let { it() } }
itemsIndexed(state.feed.value, key = { _, item -> item }) { _, item -> inner(item) } itemsIndexed(state.feed.value, key = { _, item -> item }) { _, item ->
inner(item)
HorizontalDivider(
thickness = DividerThickness,
)
}
item { post?.let { it() } } item { post?.let { it() } }
} }

View File

@ -20,13 +20,10 @@
*/ */
package com.vitorpamplona.amethyst.ui.screen package com.vitorpamplona.amethyst.ui.screen
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
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.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
@ -35,6 +32,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
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.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
@ -49,9 +47,6 @@ import androidx.compose.material3.ProvideTextStyle
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextField import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.pullrefresh.PullRefreshIndicator
import androidx.compose.material3.pullrefresh.pullRefresh
import androidx.compose.material3.pullrefresh.rememberPullRefreshState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.derivedStateOf
@ -80,7 +75,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.em import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil.compose.AsyncImage import coil.compose.AsyncImage
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.LocalCache
@ -147,7 +141,6 @@ import com.vitorpamplona.amethyst.ui.theme.FeedPadding
import com.vitorpamplona.amethyst.ui.theme.Size15Modifier import com.vitorpamplona.amethyst.ui.theme.Size15Modifier
import com.vitorpamplona.amethyst.ui.theme.Size24Modifier import com.vitorpamplona.amethyst.ui.theme.Size24Modifier
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
import com.vitorpamplona.amethyst.ui.theme.StdTopPadding
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
import com.vitorpamplona.amethyst.ui.theme.lessImportantLink import com.vitorpamplona.amethyst.ui.theme.lessImportantLink
import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.theme.placeholderText
@ -195,36 +188,31 @@ fun ThreadFeedView(
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
nav: (String) -> Unit, nav: (String) -> Unit,
) { ) {
val feedState by viewModel.feedContent.collectAsStateWithLifecycle()
val listState = rememberLazyListState() val listState = rememberLazyListState()
var refreshing by remember { mutableStateOf(false) } RefresheableBox(viewModel) {
val refresh = { RenderFeedState(
refreshing = true viewModel = viewModel,
viewModel.invalidateData() accountViewModel = accountViewModel,
refreshing = false listState = listState,
nav = nav,
routeForLastRead = null,
onLoaded = {
RenderThreadFeed(noteId, it, listState, accountViewModel, nav)
},
)
} }
val pullRefreshState = rememberPullRefreshState(refreshing, onRefresh = refresh) }
Box(Modifier.pullRefresh(pullRefreshState)) { @Composable
Column { fun RenderThreadFeed(
Crossfade( noteId: String,
targetState = feedState, state: FeedState.Loaded,
animationSpec = tween(durationMillis = 100), listState: LazyListState,
label = "ThreadViewMainState", accountViewModel: AccountViewModel,
) { state -> nav: (String) -> Unit,
when (state) { ) {
is FeedState.Empty -> {
FeedEmpty { refreshing = true }
}
is FeedState.FeedError -> {
FeedError(state.errorMessage) { refreshing = true }
}
is FeedState.Loaded -> {
refreshing = false
LaunchedEffect(noteId) { LaunchedEffect(noteId) {
launch(Dispatchers.IO) {
// waits to load the thread to scroll to item. // waits to load the thread to scroll to item.
delay(100) delay(100)
val noteForPosition = state.feed.value.filter { it.idHex == noteId }.firstOrNull() val noteForPosition = state.feed.value.filter { it.idHex == noteId }.firstOrNull()
@ -235,8 +223,7 @@ fun ThreadFeedView(
position-- // show the replying note position-- // show the replying note
} }
withContext(Dispatchers.Main) { listState.scrollToItem(position) } listState.scrollToItem(position)
}
} }
} }
@ -292,21 +279,10 @@ fun ThreadFeedView(
} }
HorizontalDivider( HorizontalDivider(
modifier = StdTopPadding,
thickness = DividerThickness, thickness = DividerThickness,
) )
} }
} }
}
FeedState.Loading -> {
LoadingFeed()
}
}
}
}
PullRefreshIndicator(refreshing, pullRefreshState, Modifier.align(Alignment.TopCenter))
}
} }
// Creates a Zebra pattern where each bar is a reply level. // Creates a Zebra pattern where each bar is a reply level.
@ -504,7 +480,6 @@ fun NoteMaster(
ChannelHeader( ChannelHeader(
channelHex = note.channelHex()!!, channelHex = note.channelHex()!!,
showVideo = true, showVideo = true,
showBottomDiviser = false,
sendToChannel = true, sendToChannel = true,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,

View File

@ -25,11 +25,13 @@ import androidx.compose.animation.core.tween
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.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.vitorpamplona.amethyst.ui.note.UserCompose import com.vitorpamplona.amethyst.ui.note.UserCompose
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.amethyst.ui.theme.FeedPadding import com.vitorpamplona.amethyst.ui.theme.FeedPadding
@Composable @Composable
@ -82,6 +84,9 @@ private fun FeedLoaded(
) { ) {
itemsIndexed(state.feed.value, key = { _, item -> item.pubkeyHex }) { _, item -> itemsIndexed(state.feed.value, key = { _, item -> item.pubkeyHex }) { _, item ->
UserCompose(item, accountViewModel = accountViewModel, nav = nav) UserCompose(item, accountViewModel = accountViewModel, nav = nav)
HorizontalDivider(
thickness = DividerThickness,
)
} }
} }
} }

View File

@ -53,7 +53,6 @@ import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.LocalTextStyle
@ -139,7 +138,6 @@ import com.vitorpamplona.amethyst.ui.screen.RefreshingChatroomFeedView
import com.vitorpamplona.amethyst.ui.screen.equalImmutableLists import com.vitorpamplona.amethyst.ui.screen.equalImmutableLists
import com.vitorpamplona.amethyst.ui.theme.ButtonBorder import com.vitorpamplona.amethyst.ui.theme.ButtonBorder
import com.vitorpamplona.amethyst.ui.theme.ButtonPadding import com.vitorpamplona.amethyst.ui.theme.ButtonPadding
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
import com.vitorpamplona.amethyst.ui.theme.DoubleVertSpacer import com.vitorpamplona.amethyst.ui.theme.DoubleVertSpacer
import com.vitorpamplona.amethyst.ui.theme.EditFieldBorder import com.vitorpamplona.amethyst.ui.theme.EditFieldBorder
@ -557,7 +555,6 @@ fun MyTextField(
fun ChannelHeader( fun ChannelHeader(
channelNote: Note, channelNote: Note,
showVideo: Boolean, showVideo: Boolean,
showBottomDiviser: Boolean,
sendToChannel: Boolean, sendToChannel: Boolean,
modifier: Modifier = StdPadding, modifier: Modifier = StdPadding,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
@ -568,8 +565,8 @@ fun ChannelHeader(
ChannelHeader( ChannelHeader(
channelHex = it, channelHex = it,
showVideo = showVideo, showVideo = showVideo,
showBottomDiviser = showBottomDiviser,
sendToChannel = sendToChannel, sendToChannel = sendToChannel,
modifier = modifier,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
@ -580,7 +577,6 @@ fun ChannelHeader(
fun ChannelHeader( fun ChannelHeader(
channelHex: String, channelHex: String,
showVideo: Boolean, showVideo: Boolean,
showBottomDiviser: Boolean,
showFlag: Boolean = true, showFlag: Boolean = true,
sendToChannel: Boolean = false, sendToChannel: Boolean = false,
modifier: Modifier = StdPadding, modifier: Modifier = StdPadding,
@ -591,7 +587,6 @@ fun ChannelHeader(
ChannelHeader( ChannelHeader(
it, it,
showVideo, showVideo,
showBottomDiviser,
showFlag, showFlag,
sendToChannel, sendToChannel,
modifier, modifier,
@ -605,7 +600,6 @@ fun ChannelHeader(
fun ChannelHeader( fun ChannelHeader(
baseChannel: Channel, baseChannel: Channel,
showVideo: Boolean, showVideo: Boolean,
showBottomDiviser: Boolean,
showFlag: Boolean = true, showFlag: Boolean = true,
sendToChannel: Boolean = false, sendToChannel: Boolean = false,
modifier: Modifier = StdPadding, modifier: Modifier = StdPadding,
@ -641,12 +635,6 @@ fun ChannelHeader(
LongChannelHeader(baseChannel = baseChannel, accountViewModel = accountViewModel, nav = nav) LongChannelHeader(baseChannel = baseChannel, accountViewModel = accountViewModel, nav = nav)
} }
} }
if (showBottomDiviser) {
HorizontalDivider(
thickness = DividerThickness,
)
}
} }
} }

View File

@ -491,6 +491,9 @@ fun ShowUserSuggestionList(
key = { _, item -> item.pubkeyHex }, key = { _, item -> item.pubkeyHex },
) { _, item -> ) { _, item ->
UserLine(item, accountViewModel) { channelScreenModel.autocompleteWithUser(item) } UserLine(item, accountViewModel) { channelScreenModel.autocompleteWithUser(item) }
HorizontalDivider(
thickness = DividerThickness,
)
} }
} }
} }
@ -807,6 +810,9 @@ fun LongRoomHeader(
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
nav = nav, nav = nav,
) )
HorizontalDivider(
thickness = DividerThickness,
)
} }
} }
} }

View File

@ -27,7 +27,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.DisposableEffect
@ -47,7 +46,6 @@ import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.service.NostrHashtagDataSource import com.vitorpamplona.amethyst.service.NostrHashtagDataSource
import com.vitorpamplona.amethyst.ui.screen.NostrHashtagFeedViewModel import com.vitorpamplona.amethyst.ui.screen.NostrHashtagFeedViewModel
import com.vitorpamplona.amethyst.ui.screen.RefresheableFeedView import com.vitorpamplona.amethyst.ui.screen.RefresheableFeedView
import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.amethyst.ui.theme.StdPadding import com.vitorpamplona.amethyst.ui.theme.StdPadding
@Composable @Composable
@ -142,11 +140,8 @@ fun HashtagHeader(
account: AccountViewModel, account: AccountViewModel,
onClick: () -> Unit = {}, onClick: () -> Unit = {},
) { ) {
Column(
Modifier.fillMaxWidth().clickable { onClick() },
) {
Column(modifier = modifier) {
Row( Row(
modifier = Modifier.fillMaxWidth().clickable { onClick() }.then(modifier),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center, horizontalArrangement = Arrangement.Center,
) { ) {
@ -158,12 +153,6 @@ fun HashtagHeader(
HashtagActionOptions(tag, account) HashtagActionOptions(tag, account)
} }
}
HorizontalDivider(
thickness = DividerThickness,
)
}
} }
@Composable @Composable

View File

@ -312,10 +312,6 @@ fun MutedWordHeader(
MutedWordActionOptions(tag, account) MutedWordActionOptions(tag, account)
} }
} }
HorizontalDivider(
thickness = DividerThickness,
)
} }
} }

View File

@ -120,7 +120,9 @@ fun NotificationScreen(
SummaryBar( SummaryBar(
model = userReactionsStatsModel, model = userReactionsStatsModel,
) )
HorizontalDivider(
thickness = DividerThickness,
)
RefreshableCardView( RefreshableCardView(
viewModel = notifFeedViewModel, viewModel = notifFeedViewModel,
accountViewModel = accountViewModel, accountViewModel = accountViewModel,
@ -229,10 +231,6 @@ fun SummaryBar(model: UserReactionsViewModel) {
} }
} }
} }
HorizontalDivider(
thickness = DividerThickness,
)
} }
@Composable @Composable

View File

@ -1547,10 +1547,7 @@ fun TabFollowedTags(
account: AccountViewModel, account: AccountViewModel,
nav: (String) -> Unit, nav: (String) -> Unit,
) { ) {
Column(Modifier.fillMaxHeight()) { Column(Modifier.fillMaxHeight().padding(vertical = 0.dp)) {
Column(
modifier = Modifier.padding(vertical = 0.dp),
) {
baseUser.latestContactList?.let { baseUser.latestContactList?.let {
it.unverifiedFollowTagSet().forEach { hashtag -> it.unverifiedFollowTagSet().forEach { hashtag ->
HashtagHeader( HashtagHeader(
@ -1558,7 +1555,9 @@ fun TabFollowedTags(
account = account, account = account,
onClick = { nav("Hashtag/$hashtag") }, onClick = { nav("Hashtag/$hashtag") },
) )
} HorizontalDivider(
thickness = DividerThickness,
)
} }
} }
} }

View File

@ -374,6 +374,11 @@ private fun DisplaySearchResults(
key = { _, item -> "#$item" }, key = { _, item -> "#$item" },
) { _, item -> ) { _, item ->
HashtagLine(item) { nav("Hashtag/$item") } HashtagLine(item) { nav("Hashtag/$item") }
HorizontalDivider(
modifier = Modifier.padding(top = 10.dp),
thickness = DividerThickness,
)
} }
itemsIndexed( itemsIndexed(
@ -381,6 +386,10 @@ private fun DisplaySearchResults(
key = { _, item -> "u" + item.pubkeyHex }, key = { _, item -> "u" + item.pubkeyHex },
) { _, item -> ) { _, item ->
UserCompose(item, accountViewModel = accountViewModel, nav = nav) UserCompose(item, accountViewModel = accountViewModel, nav = nav)
HorizontalDivider(
thickness = DividerThickness,
)
} }
itemsIndexed( itemsIndexed(
@ -432,12 +441,9 @@ fun HashtagLine(
tag: String, tag: String,
onClick: () -> Unit, onClick: () -> Unit,
) { ) {
Column(
modifier = Modifier.fillMaxWidth().clickable(onClick = onClick),
) {
Row( Row(
modifier = modifier =
Modifier.padding( Modifier.fillMaxWidth().clickable(onClick = onClick).padding(
start = 12.dp, start = 12.dp,
end = 12.dp, end = 12.dp,
top = 10.dp, top = 10.dp,
@ -454,12 +460,6 @@ fun HashtagLine(
) )
} }
} }
HorizontalDivider(
modifier = Modifier.padding(top = 10.dp),
thickness = DividerThickness,
)
}
} }
@Composable @Composable
@ -468,15 +468,13 @@ fun UserLine(
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
onClick: () -> Unit, onClick: () -> Unit,
) { ) {
Column(
modifier = Modifier.fillMaxWidth().clickable(onClick = onClick),
) {
Row( Row(
modifier = modifier =
Modifier.padding( Modifier.fillMaxWidth().clickable(onClick = onClick).padding(
start = 12.dp, start = 12.dp,
end = 12.dp, end = 12.dp,
top = 10.dp, top = 10.dp,
bottom = 10.dp,
), ),
) { ) {
ClickableUserPicture(baseUser, 55.dp, accountViewModel, Modifier, null) ClickableUserPicture(baseUser, 55.dp, accountViewModel, Modifier, null)
@ -489,10 +487,4 @@ fun UserLine(
AboutDisplay(baseUser) AboutDisplay(baseUser)
} }
} }
HorizontalDivider(
modifier = Modifier.padding(top = 10.dp),
thickness = DividerThickness,
)
}
} }

View File

@ -20,11 +20,8 @@
*/ */
package com.vitorpamplona.amethyst.ui.screen.loggedIn package com.vitorpamplona.amethyst.ui.screen.loggedIn
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleEventObserver
@ -79,7 +76,5 @@ fun ThreadScreen(
onDispose { lifeCycleOwner.lifecycle.removeObserver(observer) } onDispose { lifeCycleOwner.lifecycle.removeObserver(observer) }
} }
Column(Modifier.fillMaxHeight()) { ThreadFeedView(noteId, feedViewModel, accountViewModel, nav)
Column { ThreadFeedView(noteId, feedViewModel, accountViewModel, nav) }
}
} }