mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-23 19:23:36 +00:00
android, desktop: show the Names and Directory headers above their results in the New chat sheet with the one-hand UI
This commit is contained in:
1 parent
b402bf4b3e
commit
48ca4d11ac
5 files changed
+44
-39
No files matched your search
+3
-3
@@ -554,12 +554,12 @@ private fun LazyListScope.directoryRows(rows: OnlineSearchRows, onlineSearch: On
|
||||
}
|
||||
|
||||
// the list is reversed in one-hand UI, so there the header follows its rows to be drawn above them
|
||||
private fun LazyListScope.searchPart(title: StringResource, oneHandUI: Boolean, content: LazyListScope.() -> Unit) {
|
||||
internal fun LazyListScope.searchPart(title: StringResource, oneHandUI: Boolean, header: @Composable (String) -> Unit = { SearchPartHeader(it) }, content: LazyListScope.() -> Unit) {
|
||||
if (oneHandUI) {
|
||||
content()
|
||||
item { SearchPartHeader(stringResource(title)) }
|
||||
item { header(stringResource(title)) }
|
||||
} else {
|
||||
item { SearchPartHeader(stringResource(title)) }
|
||||
item { header(stringResource(title)) }
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
+31
-26
@@ -188,40 +188,45 @@ private fun ModalData.NewChatSheetLayout(
|
||||
|
||||
@Composable
|
||||
fun OnlineSearchHeader(title: String) {
|
||||
SectionDividerSpaced(maxTopPadding = false, maxBottomPadding = false)
|
||||
SectionView(title, headerBottomPadding = DEFAULT_PADDING_HALF) {}
|
||||
}
|
||||
|
||||
// the divider is an item of its own: the reversed one-hand column also reverses the nodes inside an item,
|
||||
// which would put it between the header and its rows
|
||||
fun LazyListScope.onlineSearchSections(rows: OnlineSearchRows) {
|
||||
if (rows.names.isNotEmpty()) {
|
||||
item { OnlineSearchHeader(stringResource(MR.strings.online_search_names)) }
|
||||
items(rows.names, key = { it.id }) { result ->
|
||||
val view = LocalMultiplatformView()
|
||||
NameSearchRow(
|
||||
result,
|
||||
Modifier.clickable {
|
||||
hideKeyboard(view)
|
||||
withBGApi { planAndConnect(chatModel.remoteHostId(), result.target, close = close, cleanup = null) }
|
||||
}
|
||||
)
|
||||
item { SectionDividerSpaced(maxTopPadding = false, maxBottomPadding = false) }
|
||||
searchPart(MR.strings.online_search_names, oneHandUI.value, header = { OnlineSearchHeader(it) }) {
|
||||
items(rows.names, key = { it.id }) { result ->
|
||||
val view = LocalMultiplatformView()
|
||||
NameSearchRow(
|
||||
result,
|
||||
Modifier.clickable {
|
||||
hideKeyboard(view)
|
||||
withBGApi { planAndConnect(chatModel.remoteHostId(), result.target, close = close, cleanup = null) }
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rows.directory.isNotEmpty() || rows.footer != null) {
|
||||
item { OnlineSearchHeader(stringResource(MR.strings.online_search_directory)) }
|
||||
items(rows.directory, key = { it.id }) { result ->
|
||||
val view = LocalMultiplatformView()
|
||||
DirectorySearchRow(
|
||||
result.entry,
|
||||
Modifier.clickable {
|
||||
hideKeyboard(view)
|
||||
withBGApi { planAndConnect(chatModel.remoteHostId(), result.entry.link, close = close, cleanup = null) }
|
||||
}
|
||||
)
|
||||
}
|
||||
when (rows.footer) {
|
||||
DirectoryFooter.Retry -> item { DirectoryRetryRow(onlineSearch) }
|
||||
DirectoryFooter.ShowMore -> item { DirectoryShowMoreRow(onlineSearch) }
|
||||
null -> {}
|
||||
item { SectionDividerSpaced(maxTopPadding = false, maxBottomPadding = false) }
|
||||
searchPart(MR.strings.online_search_directory, oneHandUI.value, header = { OnlineSearchHeader(it) }) {
|
||||
items(rows.directory, key = { it.id }) { result ->
|
||||
val view = LocalMultiplatformView()
|
||||
DirectorySearchRow(
|
||||
result.entry,
|
||||
Modifier.clickable {
|
||||
hideKeyboard(view)
|
||||
withBGApi { planAndConnect(chatModel.remoteHostId(), result.entry.link, close = close, cleanup = null) }
|
||||
}
|
||||
)
|
||||
}
|
||||
when (rows.footer) {
|
||||
DirectoryFooter.Retry -> item { DirectoryRetryRow(onlineSearch) }
|
||||
DirectoryFooter.ShowMore -> item { DirectoryShowMoreRow(onlineSearch) }
|
||||
null -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user