mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 16:21:49 +01:00
Fake library loading (#7717)
This commit is contained in:
parent
7892cc1519
commit
ec96a81735
@ -6,7 +6,11 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalUriHandler
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import com.google.accompanist.pager.rememberPagerState
|
import com.google.accompanist.pager.rememberPagerState
|
||||||
@ -22,6 +26,8 @@ import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
|||||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||||
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
|
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
|
||||||
import eu.kanade.tachiyomi.widget.EmptyView
|
import eu.kanade.tachiyomi.widget.EmptyView
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LibraryContent(
|
fun LibraryContent(
|
||||||
@ -50,6 +56,9 @@ fun LibraryContent(
|
|||||||
val coercedCurrentPage = remember { currentPage().coerceAtMost(categories.lastIndex) }
|
val coercedCurrentPage = remember { currentPage().coerceAtMost(categories.lastIndex) }
|
||||||
val pagerState = rememberPagerState(coercedCurrentPage)
|
val pagerState = rememberPagerState(coercedCurrentPage)
|
||||||
|
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
var isRefreshing by remember(pagerState.currentPage) { mutableStateOf(false) }
|
||||||
|
|
||||||
if (showPageTabs && categories.size > 1) {
|
if (showPageTabs && categories.size > 1) {
|
||||||
LibraryTabs(
|
LibraryTabs(
|
||||||
state = pagerState,
|
state = pagerState,
|
||||||
@ -73,8 +82,16 @@ fun LibraryContent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
SwipeRefresh(
|
SwipeRefresh(
|
||||||
state = rememberSwipeRefreshState(isRefreshing = false),
|
state = rememberSwipeRefreshState(isRefreshing = isRefreshing),
|
||||||
onRefresh = { onRefresh(categories[currentPage()]) },
|
onRefresh = {
|
||||||
|
onRefresh(categories[currentPage()])
|
||||||
|
scope.launch {
|
||||||
|
// Fake refresh status but hide it after a second as it's a long running task
|
||||||
|
isRefreshing = true
|
||||||
|
delay(1000)
|
||||||
|
isRefreshing = false
|
||||||
|
}
|
||||||
|
},
|
||||||
indicator = { s, trigger ->
|
indicator = { s, trigger ->
|
||||||
SwipeRefreshIndicator(
|
SwipeRefreshIndicator(
|
||||||
state = s,
|
state = s,
|
||||||
|
Loading…
Reference in New Issue
Block a user