diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index be8c7ffcf..6776f1950 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -28,7 +28,7 @@ ziplineVersion = "1.1.0" landscapist = "2.2.8" protobufVersion = "3.24.2" sketchVersion = "3.2.5" -composeBomVersion = "2023.10.00-alpha01" +composeBomVersion = "2023.10.00-alpha02" ### MangaWorld piasy = "1.8.1" 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 cbd9e9a07..1fc31f2f0 100644 --- a/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReaderCompose.kt +++ b/mangaworld/src/main/java/com/programmersbox/mangaworld/reader/ReaderCompose.kt @@ -15,11 +15,7 @@ import androidx.compose.animation.animateColorAsState import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.expandHorizontally -import androidx.compose.animation.fadeIn -import androidx.compose.animation.fadeOut import androidx.compose.animation.shrinkHorizontally -import androidx.compose.animation.slideInVertically -import androidx.compose.animation.slideOutVertically import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background @@ -77,6 +73,8 @@ import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState import androidx.compose.material3.AlertDialog import androidx.compose.material3.BottomAppBar +import androidx.compose.material3.BottomAppBarDefaults +import androidx.compose.material3.BottomAppBarScrollBehavior import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.CenterAlignedTopAppBar @@ -313,7 +311,20 @@ fun ReadView( val showItems by remember { derivedStateOf { readVm.showInfo || listShowItems || pagerShowItems } } - val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) + val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(canScroll = { !showItems }) + val bottomBarScrollBehavior = BottomAppBarDefaults.exitAlwaysScrollBehavior(canScroll = { !showItems }) + + LaunchedEffect(showItems) { + if (showItems) { + //Expand + scrollBehavior.state.heightOffset = 0f + bottomBarScrollBehavior.state.heightOffset = 0f + } else { + //Collapse + scrollBehavior.state.heightOffset = -1000f + bottomBarScrollBehavior.state.heightOffset = -1000f + } + } val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed) var showBottomSheet by remember { mutableStateOf(false) } @@ -353,34 +364,37 @@ fun ReadView( gesturesEnabled = readVm.list.size > 1 ) { Scaffold( - modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), + modifier = Modifier + .nestedScroll(scrollBehavior.nestedScrollConnection) + .nestedScroll(bottomBarScrollBehavior.nestedScrollConnection), topBar = { - AnimatedVisibility( + /*AnimatedVisibility( visible = showItems, enter = slideInVertically() + fadeIn(), exit = slideOutVertically() + fadeOut() - ) { - TopBar( - scrollBehavior = scrollBehavior, - pages = pages, - currentPage = currentPage, - vm = readVm - ) - } + ) {*/ + TopBar( + scrollBehavior = scrollBehavior, + pages = pages, + currentPage = currentPage, + vm = readVm + ) + //} }, bottomBar = { - AnimatedVisibility( + /*AnimatedVisibility( visible = showItems, enter = slideInVertically { it / 2 } + fadeIn(), exit = slideOutVertically { it / 2 } + fadeOut() - ) { - BottomBar( - onPageSelectClick = { showBottomSheet = true }, - onSettingsClick = { settingsPopup = true }, - chapterChange = ::showToast, - vm = readVm - ) - } + ) {*/ + BottomBar( + onPageSelectClick = { showBottomSheet = true }, + onSettingsClick = { settingsPopup = true }, + chapterChange = ::showToast, + vm = readVm, + scrollBehavior = bottomBarScrollBehavior + ) + //} } ) { paddingValues -> Box( @@ -1068,17 +1082,20 @@ private fun TopBar( ) } +@OptIn(ExperimentalMaterial3Api::class) @Composable private fun BottomBar( vm: ReadViewModel, onPageSelectClick: () -> Unit, onSettingsClick: () -> Unit, chapterChange: () -> Unit, + scrollBehavior: BottomAppBarScrollBehavior, modifier: Modifier = Modifier, ) { BottomAppBar( modifier = modifier, - windowInsets = WindowInsets(0.dp) + windowInsets = WindowInsets(0.dp), + scrollBehavior = scrollBehavior ) { val prevShown = vm.currentChapter < vm.list.lastIndex val nextShown = vm.currentChapter > 0