Skip to content

Commit

Permalink
Fix split tunneling view and scrollable menu bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa authored and albin-mullvad committed Oct 6, 2023
1 parent f7db974 commit 7e28f78
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,17 @@ 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 = {
MullvadMediumTopBar(
title = appBarTitle,
navigationIcon = navigationIcon,
actions,
scrollBehavior = scrollBehavior
scrollBehavior = if (canScroll) scrollBehavior else null
)
},
content = {
Expand All @@ -118,19 +116,22 @@ 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 = {
MullvadMediumTopBar(
title = appBarTitle,
navigationIcon = navigationIcon,
actions,
scrollBehavior = scrollBehavior
scrollBehavior =
if (canScroll) {
scrollBehavior
} else {
null
}
)
},
content = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ private fun PreviewNothingTopBar() {
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MullvadTopBar(
containerColor: Color,
Expand Down Expand Up @@ -189,7 +188,6 @@ private fun PreviewSlimMediumTopBar() {
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MullvadMediumTopBar(
title: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 7e28f78

Please sign in to comment.