diff --git a/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReadViewModel.kt b/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReadViewModel.kt index 15f972af9..0782954ca 100644 --- a/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReadViewModel.kt +++ b/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReadViewModel.kt @@ -126,7 +126,9 @@ class ReadViewModel( loadPages(modelPath) } - var showInfo by mutableStateOf(false) + var showInfo by mutableStateOf(true) + + var firstScroll by mutableStateOf(true) fun addChapterToWatched(newChapter: Int, chapter: () -> Unit) { currentChapter = newChapter diff --git a/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReaderCompose.kt b/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReaderCompose.kt index 98c20b54f..cbd9e9a07 100644 --- a/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReaderCompose.kt +++ b/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReaderCompose.kt @@ -292,8 +292,16 @@ fun ReadView( activity.runOnUiThread { Toast.makeText(context, R.string.addedChapterItem, Toast.LENGTH_SHORT).show() } } - val listShowItems = (listState.isScrolledToTheEnd() || listState.isScrolledToTheBeginning()) && listOrPager - val pagerShowItems = (pagerState.currentPage == 0 || pagerState.currentPage >= pages.size) && !listOrPager + val listShowItems by remember { derivedStateOf { listState.isScrolledToTheEnd() && listOrPager } } + val pagerShowItems by remember { derivedStateOf { pagerState.currentPage >= pages.size && !listOrPager } } + + val listIndex by remember { derivedStateOf { listState.layoutInfo.visibleItemsInfo.firstOrNull()?.index ?: 0 } } + LaunchedEffect(listIndex, pagerState.currentPage, readVm.showInfo) { + if (readVm.firstScroll && (listIndex > 0 || pagerState.currentPage > 0)) { + readVm.showInfo = false + readVm.firstScroll = false + } + } LaunchedEffect(pagerState) { snapshotFlow { pagerState.currentPage }.collect { listState.scrollToItem(it) } @@ -303,7 +311,7 @@ fun ReadView( snapshotFlow { listState.firstVisibleItemIndex }.collect { pagerState.scrollToPage(it) } } - val showItems = readVm.showInfo || listShowItems || pagerShowItems + val showItems by remember { derivedStateOf { readVm.showInfo || listShowItems || pagerShowItems } } val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())