bod
05/28/2022, 10:07 AMHorizontalPager
), and the default Activity's swipe to dismiss behavior "vaguely works" 🙂 By that I mean, if I swipe with a quick enough gesture, it works. If I swipe slowly, it doesn't. (not using NavHost
or SwipeToDismissBox
) Any idea/pointers?John Nichol
05/28/2022, 1:24 PMbod
05/28/2022, 1:26 PMyschimke
05/28/2022, 4:15 PMyschimke
05/28/2022, 4:16 PMbod
05/29/2022, 1:14 PMSteve Bower [G]
06/01/2022, 4:03 PM@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MainScreen( { ActivityCompat.finishAffinity(this) })
}
}
}
@Composable
private fun MainScreen(onDismissed: () -> Unit) {
CineTodayTheme {
Scaffold {
val swipeToDismissBoxState = rememberSwipeToDismissBoxState()
SwipeToDismissBox(onDismissed = onDismissed, state = swipeToDismissBoxState) { bg ->
if (!bg) MainScreenContent(swipeToDismissBoxState)
}
}
}
}
@OptIn(ExperimentalPagerApi::class)
@Composable
private fun MainScreenContent(state: SwipeToDismissBoxState) {
val pagerState: PagerState = rememberPagerState()
HorizontalPager(
count = PAGE_COUNT,
modifier = Modifier
.fillMaxSize()
.edgeSwipeToDismiss(state),
state = pagerState,
) { page ->
when (page) {
0 -> PageScreen(0)
1 -> PageScreen(1)
2 -> PageScreen(2)
}
}
}
bod
06/01/2022, 4:07 PMSwipeToDismissBox
a bit later today.Steve Bower [G]
06/01/2022, 4:41 PMprivate fun MainScreen(onDismissed: () -> Unit = {}) {
CineTodayTheme {
Scaffold {
val state = rememberSwipeToDismissBoxState()
SwipeToDismissBox(state = state) { bg ->
if (!bg ) MainScreenContent(state)
}
LaunchedEffect(state.currentValue) {
if (state.currentValue == SwipeToDismissValue.Dismissed) {
onDismissed()
}
}
}
}
}
bod
06/01/2022, 4:48 PMbod
06/02/2022, 10:37 AM<style name="Theme.CineToday" parent="@android:style/Theme.DeviceDefault">
<item name="android:windowBackground">@android:color/transparent</item>
</style>