fix(gtk): show search and loading indicator

This commit is contained in:
Johannes Frohnmeyer 2024-10-04 17:46:40 +02:00
parent 45d16f82e8
commit 0176698242
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -64,15 +64,9 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
} }
} }
}) })
append(SearchBar().apply { append(Entry().apply {
hexpand = false setIconFromIconName(EntryIconPosition.PRIMARY, "edit-find-symbolic")
showCloseButton = false onChanged { updateSearch(text) }
searchMode = false
val entry = SearchEntry().apply {
onSearchChanged { updateSearch(text) }
}
child = entry
keyCaptureWidget = entry
}) })
listModel = StringList(arrayOf()) listModel = StringList(arrayOf())
append(Overlay().apply { append(Overlay().apply {
@ -104,6 +98,7 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
listModel.replaceAll(mods.map { it.name }.toTypedArray()) listModel.replaceAll(mods.map { it.name }.toTypedArray())
} else { } else {
loadingRevealer.setRunning(searchResult == null || !mds.isComplete(ScanStage.CROSSREFERENCE)) loadingRevealer.setRunning(searchResult == null || !mds.isComplete(ScanStage.CROSSREFERENCE))
loadingRevealer.pulse()
if (searchResult != null) { if (searchResult != null) {
for (mod in searchResult.orEmpty()) { for (mod in searchResult.orEmpty()) {
this@ModsTab.mods[mod.name] = mod this@ModsTab.mods[mod.name] = mod
@ -123,7 +118,6 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
private val search = AsyncRequest({ private val search = AsyncRequest({
searchResult = null searchResult = null
loadingRevealer.setRunning(true) loadingRevealer.setRunning(true)
loadingRevealer.pulse()
VoidFuture(ForkJoinPool.commonPool().submit { VoidFuture(ForkJoinPool.commonPool().submit {
val sources: List<ModSource> = when (page) { val sources: List<ModSource> = when (page) {
Page.CURSEFORGE -> { Page.CURSEFORGE -> {
@ -157,7 +151,6 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
updateSearch(currentSearchString) updateSearch(currentSearchString)
} }
fun updateSearch(search: String): Unit { fun updateSearch(search: String): Unit {
descriptionLabel.text = "Searching is currently unsupported"
currentSearchString = search currentSearchString = search
backgroundTask { this.search.request() } backgroundTask { this.search.request() }
} }