mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-21 06:51:20 +00:00
fix contact list to be lazy
This commit is contained in:
+2
-1
@@ -27,6 +27,7 @@ import chat.simplex.res.MR
|
||||
|
||||
private val SectionCardShape = RoundedCornerShape(16.dp)
|
||||
val CARD_PADDING = 16.dp
|
||||
val ICON_TEXT_SPACING = 5.dp
|
||||
val CARD_ITEM_PADDING = CARD_PADDING - 1.dp
|
||||
|
||||
// Set to true by SectionView around its inner Column. SectionItemView reads it
|
||||
@@ -341,7 +342,7 @@ fun SectionBottomSpacer() {
|
||||
|
||||
@Composable
|
||||
fun TextIconSpaced(extraPadding: Boolean = false) {
|
||||
Spacer(Modifier.padding(horizontal = if (extraPadding) 17.dp else 5.dp))
|
||||
Spacer(Modifier.padding(horizontal = if (extraPadding) 17.dp else ICON_TEXT_SPACING))
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
+31
-53
@@ -322,36 +322,26 @@ private fun ModalData.NewChatSheetLayout(
|
||||
item {
|
||||
DeletedChatsItem(actionButtonsOriginal.asReversed())
|
||||
}
|
||||
item {
|
||||
when {
|
||||
filteredContactChats.isNotEmpty() && searchText.value.text.isEmpty() -> {
|
||||
if (filteredContactChats.isNotEmpty()) {
|
||||
if (searchText.value.text.isEmpty()) {
|
||||
item {
|
||||
SectionDividerSpaced()
|
||||
SectionView(stringResource(MR.strings.contact_list_header_title), headerBottomPadding = DEFAULT_PADDING_HALF) {
|
||||
filteredContactChats.forEachIndexed { index, chat ->
|
||||
val nextChatSelected = remember(chat.id, filteredContactChats) {
|
||||
derivedStateOf {
|
||||
chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value
|
||||
}
|
||||
}
|
||||
ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(DEFAULT_PADDING_HALF))
|
||||
SectionView(stringResource(MR.strings.contact_list_header_title), headerBottomPadding = DEFAULT_PADDING_HALF) {}
|
||||
}
|
||||
filteredContactChats.isNotEmpty() -> {
|
||||
SectionView {
|
||||
filteredContactChats.forEachIndexed { index, chat ->
|
||||
val nextChatSelected = remember(chat.id, filteredContactChats) {
|
||||
derivedStateOf {
|
||||
chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value
|
||||
}
|
||||
}
|
||||
ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> NoFilteredContactsItem()
|
||||
}
|
||||
itemsIndexed(filteredContactChats) { index, chat ->
|
||||
val nextChatSelected = remember(chat.id, filteredContactChats) {
|
||||
derivedStateOf {
|
||||
chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value
|
||||
}
|
||||
}
|
||||
ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true)
|
||||
}
|
||||
if (searchText.value.text.isEmpty()) {
|
||||
item { Spacer(Modifier.height(DEFAULT_PADDING_HALF)) }
|
||||
}
|
||||
} else {
|
||||
item { NoFilteredContactsItem() }
|
||||
}
|
||||
if (appPlatform.isAndroid) {
|
||||
item {
|
||||
@@ -420,35 +410,23 @@ private fun ModalData.NewChatSheetLayout(
|
||||
item {
|
||||
DeletedChatsItem(actionButtonsOriginal)
|
||||
}
|
||||
item {
|
||||
when {
|
||||
filteredContactChats.isNotEmpty() && searchText.value.text.isEmpty() -> {
|
||||
if (filteredContactChats.isNotEmpty()) {
|
||||
if (searchText.value.text.isEmpty()) {
|
||||
item {
|
||||
SectionDividerSpaced()
|
||||
SectionView(stringResource(MR.strings.contact_list_header_title), headerBottomPadding = DEFAULT_PADDING_HALF) {
|
||||
filteredContactChats.forEachIndexed { index, chat ->
|
||||
val nextChatSelected = remember(chat.id, filteredContactChats) {
|
||||
derivedStateOf {
|
||||
chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value
|
||||
}
|
||||
}
|
||||
ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true)
|
||||
}
|
||||
}
|
||||
SectionView(stringResource(MR.strings.contact_list_header_title), headerBottomPadding = DEFAULT_PADDING_HALF) {}
|
||||
}
|
||||
filteredContactChats.isNotEmpty() -> {
|
||||
SectionView {
|
||||
filteredContactChats.forEachIndexed { index, chat ->
|
||||
val nextChatSelected = remember(chat.id, filteredContactChats) {
|
||||
derivedStateOf {
|
||||
chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value
|
||||
}
|
||||
}
|
||||
ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> NoFilteredContactsItem()
|
||||
}
|
||||
itemsIndexed(filteredContactChats) { index, chat ->
|
||||
val nextChatSelected = remember(chat.id, filteredContactChats) {
|
||||
derivedStateOf {
|
||||
chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value
|
||||
}
|
||||
}
|
||||
ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true)
|
||||
}
|
||||
} else {
|
||||
item { NoFilteredContactsItem() }
|
||||
}
|
||||
if (appPlatform.isAndroid) {
|
||||
item {
|
||||
|
||||
Reference in New Issue
Block a user