Arjix 4 months ago
parent d653af4c53
commit 33d3f062a6

@ -1,33 +1,28 @@
package com.arjixwastaken.nyaadroid.screens
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material.Text
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.*
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Modifier
import com.arjixwastaken.nyaaapi.models.DataSize
import com.arjixwastaken.nyaadroid.components.TorrentItem
import com.arjixwastaken.nyaadroid.utils.TextSearchBar
import kotlin.concurrent.thread
import com.arjixwastaken.nyaaapi.models.TorrentPreview
import com.arjixwastaken.nyaaapi.models.TorrentState
import com.arjixwastaken.nyaaapi.models.payloads.SearchRequest
import com.arjixwastaken.nyaadroid.NyaaAPI
import kotlinx.coroutines.launch
import java.net.URI
import java.util.*
val BrowseItems by lazy { mutableStateListOf<TorrentPreview>() }
@Composable
fun Browse(Items: SnapshotStateList<TorrentPreview>){
val listState = rememberLazyListState()
val coroutine = rememberCoroutineScope()
var previousValue by remember { mutableStateOf("") }
@ -55,13 +50,19 @@ fun Browse(Items: SnapshotStateList<TorrentPreview>){
)
// TODO: Add a menu to edit the search parameters (eg category)
}
LazyColumn {
LazyColumn(state = listState) {
itemsIndexed(Items) { index, item ->
Column(modifier = Modifier.clickable { BrowseItems.removeAt(index) }) {
Column() {
TorrentItem(item)
}
// TODO: When the user scrolls to the last item, fetch the next page.
}
}
// val a = derivedStateOf { listState.layoutInfo }.value.visibleItemsInfo.lastOrNull()?.let {
// if (it.index == BrowseItems.size-1) {
// currentPage++
// coroutine.launch { BrowseItems.addAll(NyaaAPI.search(SearchRequest(value, page=currentPage))) }
// }
// }
}
}

Loading…
Cancel
Save