Better positioning of the User Search (always at the bottom, independent of screen size)

This commit is contained in:
Vitor Pamplona
2023-02-13 18:08:38 -05:00
parent f5e61b9409
commit 05d71fd27e
@@ -76,7 +76,8 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, account: Account
) )
) { ) {
Surface(modifier = Modifier.fillMaxWidth().fillMaxHeight()) { Surface(modifier = Modifier.fillMaxWidth().fillMaxHeight()) {
Column(modifier = Modifier.padding(10.dp).imePadding().verticalScroll(scroolState)) { Column(modifier = Modifier.fillMaxWidth().fillMaxHeight().border(1.dp, Color.Red)) {
Column(modifier = Modifier.padding(10.dp).imePadding().weight(1f).border(1.dp, Color.Yellow)) {
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
@@ -103,6 +104,10 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, account: Account
) )
} }
Row(
modifier = Modifier.fillMaxWidth().weight(1f)
) {
Column(modifier = Modifier.fillMaxWidth().verticalScroll(scroolState)) {
if (postViewModel.replyTos != null && baseReplyTo?.event is TextNoteEvent) { if (postViewModel.replyTos != null && baseReplyTo?.event is TextNoteEvent) {
ReplyInformation(postViewModel.replyTos, postViewModel.mentions, "") { ReplyInformation(postViewModel.replyTos, postViewModel.mentions, "") {
postViewModel.removeFromReplyList(it) postViewModel.removeFromReplyList(it)
@@ -118,7 +123,7 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, account: Account
capitalization = KeyboardCapitalization.Sentences capitalization = KeyboardCapitalization.Sentences
), ),
modifier = Modifier modifier = Modifier
.fillMaxWidth().imePadding().heightIn(300.dp, 500.dp) .fillMaxWidth()
.border( .border(
width = 1.dp, width = 1.dp,
color = MaterialTheme.colors.surface, color = MaterialTheme.colors.surface,
@@ -145,28 +150,12 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, account: Account
textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content) textStyle = LocalTextStyle.current.copy(textDirection = TextDirection.Content)
) )
val userSuggestions = postViewModel.userSuggestions
if (userSuggestions.isNotEmpty()) {
LazyColumn(
contentPadding = PaddingValues(
top = 10.dp,
bottom = 10.dp
),
modifier = Modifier.heightIn(0.dp, 300.dp)
) {
itemsIndexed(userSuggestions, key = { _, item -> item.pubkeyHex }) { index, item ->
UserLine(item, account) {
postViewModel.autocompleteWithUser(item)
}
}
}
}
val myUrlPreview = postViewModel.urlPreview val myUrlPreview = postViewModel.urlPreview
if (myUrlPreview != null) { if (myUrlPreview != null) {
Row(modifier = Modifier.padding(top = 5.dp)) { Row(modifier = Modifier.padding(top = 5.dp)) {
if (isValidURL(myUrlPreview)) { if (isValidURL(myUrlPreview)) {
val removedParamsFromUrl = myUrlPreview.split("?")[0].toLowerCase() val removedParamsFromUrl =
myUrlPreview.split("?")[0].toLowerCase()
if (imageExtension.matcher(removedParamsFromUrl).matches()) { if (imageExtension.matcher(removedParamsFromUrl).matches()) {
AsyncImage( AsyncImage(
model = myUrlPreview, model = myUrlPreview,
@@ -182,7 +171,9 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, account: Account
RoundedCornerShape(15.dp) RoundedCornerShape(15.dp)
) )
) )
} else if (videoExtension.matcher(removedParamsFromUrl).matches()) { } else if (videoExtension.matcher(removedParamsFromUrl)
.matches()
) {
VideoView(myUrlPreview) VideoView(myUrlPreview)
} else { } else {
UrlPreview(myUrlPreview, myUrlPreview) UrlPreview(myUrlPreview, myUrlPreview)
@@ -193,6 +184,28 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, account: Account
} }
} }
} }
}
val userSuggestions = postViewModel.userSuggestions
if (userSuggestions.isNotEmpty()) {
LazyColumn(
contentPadding = PaddingValues(
top = 10.dp
),
modifier = Modifier.heightIn(0.dp, 300.dp)
) {
itemsIndexed(
userSuggestions,
key = { _, item -> item.pubkeyHex }) { index, item ->
UserLine(item, account) {
postViewModel.autocompleteWithUser(item)
}
}
}
}
}
}
} }
} }
} }