From 7e28f789dadaa07950101058330757769a76e70d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Thu, 5 Oct 2023 14:54:08 +0200 Subject: [PATCH] Fix split tunneling view and scrollable menu bar --- .../compose/component/Scaffolding.kt | 21 ++++++++++--------- .../mullvadvpn/compose/component/TopBar.kt | 2 -- .../compose/screen/SplitTunnelingScreen.kt | 8 +++++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Scaffolding.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Scaffolding.kt index e2ba1d4f764e..eb4d0d19a57d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Scaffolding.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Scaffolding.kt @@ -83,11 +83,9 @@ fun ScaffoldWithMediumTopBar( ) { val appBarState = rememberTopAppBarState() + val canScroll = lazyListState.canScrollForward || lazyListState.canScrollBackward val scrollBehavior = - TopAppBarDefaults.exitUntilCollapsedScrollBehavior( - appBarState, - canScroll = { lazyListState.canScrollBackward || lazyListState.canScrollForward } - ) + TopAppBarDefaults.exitUntilCollapsedScrollBehavior(appBarState, canScroll = { canScroll }) Scaffold( modifier = modifier.fillMaxSize().nestedScroll(scrollBehavior.nestedScrollConnection), topBar = { @@ -95,7 +93,7 @@ fun ScaffoldWithMediumTopBar( title = appBarTitle, navigationIcon = navigationIcon, actions, - scrollBehavior = scrollBehavior + scrollBehavior = if (canScroll) scrollBehavior else null ) }, content = { @@ -118,11 +116,9 @@ fun ScaffoldWithMediumTopBar( ) { val appBarState = rememberTopAppBarState() val scrollState = rememberScrollState() + val canScroll = scrollState.canScrollForward || scrollState.canScrollBackward val scrollBehavior = - TopAppBarDefaults.exitUntilCollapsedScrollBehavior( - appBarState, - canScroll = { scrollState.canScrollBackward || scrollState.canScrollForward } - ) + TopAppBarDefaults.exitUntilCollapsedScrollBehavior(appBarState, canScroll = { canScroll }) Scaffold( modifier = modifier.fillMaxSize().nestedScroll(scrollBehavior.nestedScrollConnection), topBar = { @@ -130,7 +126,12 @@ fun ScaffoldWithMediumTopBar( title = appBarTitle, navigationIcon = navigationIcon, actions, - scrollBehavior = scrollBehavior + scrollBehavior = + if (canScroll) { + scrollBehavior + } else { + null + } ) }, content = { diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/TopBar.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/TopBar.kt index 2cab654e727c..3c5e0e1bb7e0 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/TopBar.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/TopBar.kt @@ -85,7 +85,6 @@ private fun PreviewNothingTopBar() { } } -@OptIn(ExperimentalMaterial3Api::class) @Composable fun MullvadTopBar( containerColor: Color, @@ -189,7 +188,6 @@ private fun PreviewSlimMediumTopBar() { } } -@OptIn(ExperimentalMaterial3Api::class) @Composable fun MullvadMediumTopBar( title: String, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SplitTunnelingScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SplitTunnelingScreen.kt index 28d5e05fb34d..bf47a7a17f78 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SplitTunnelingScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SplitTunnelingScreen.kt @@ -87,8 +87,12 @@ fun SplitTunnelingScreen( modifier = Modifier.fillMaxSize(), appBarTitle = stringResource(id = R.string.split_tunneling), navigationIcon = { NavigateBackIconButton(onBackClick) } - ) { _, lazyListState -> - LazyColumn(horizontalAlignment = Alignment.CenterHorizontally, state = lazyListState) { + ) { modifier, lazyListState -> + LazyColumn( + modifier = modifier, + horizontalAlignment = Alignment.CenterHorizontally, + state = lazyListState + ) { item(key = CommonContentKey.DESCRIPTION, contentType = ContentType.DESCRIPTION) { Box(modifier = Modifier.fillMaxWidth()) { Text(