Skip to content

Commit

Permalink
Remove select location horizontal pager on TV
Browse files Browse the repository at this point in the history
  • Loading branch information
kl committed Dec 11, 2024
1 parent e946529 commit 4e44f77
Showing 1 changed file with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.mullvad.mullvadvpn.compose.screen.location

import android.annotation.SuppressLint
import android.content.res.Configuration
import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -352,33 +353,44 @@ private fun RelayLists(
openDaitaSettings: () -> Unit,
onUpdateBottomSheetState: (LocationBottomSheetState) -> Unit,
) {
val pagerState =
rememberPagerState(
initialPage = state.relayListType.ordinal,
pageCount = { RelayListType.entries.size },
)
LaunchedEffect(state.relayListType) {
val index = state.relayListType.ordinal
pagerState.animateScrollToPage(index)
}

HorizontalPager(
state = pagerState,
userScrollEnabled = false,
beyondViewportPageCount =
if (state.multihopEnabled) {
1
} else {
0
},
) { pageIndex ->
val configuration = LocalContext.current.resources.configuration
if (configuration.navigation == Configuration.NAVIGATION_DPAD) {
SelectLocationList(
backgroundColor = backgroundColor,
relayListType = RelayListType.entries[pageIndex],
relayListType = state.relayListType,
onSelectRelay = onSelectRelay,
openDaitaSettings = openDaitaSettings,
onUpdateBottomSheetState = onUpdateBottomSheetState,
)
} else {
val pagerState =
rememberPagerState(
initialPage = state.relayListType.ordinal,
pageCount = { RelayListType.entries.size },
)
LaunchedEffect(state.relayListType) {
val index = state.relayListType.ordinal
pagerState.animateScrollToPage(index)
}

HorizontalPager(
state = pagerState,
userScrollEnabled = false,
beyondViewportPageCount =
if (state.multihopEnabled) {
1
} else {
0
},
) { pageIndex ->
SelectLocationList(
backgroundColor = backgroundColor,
relayListType = RelayListType.entries[pageIndex],
onSelectRelay = onSelectRelay,
openDaitaSettings = openDaitaSettings,
onUpdateBottomSheetState = onUpdateBottomSheetState,
)
}
}
}

Expand Down

0 comments on commit 4e44f77

Please sign in to comment.