MainView: fix toggle animation (#333)

Use persistent isOn state across recompositions

Updates tailscale/corp#18202
Fixes tailscale/corp#19194

Signed-off-by: kari-ts <kari@tailscale.com>
pull/334/head
kari-ts 8 months ago committed by GitHub
parent 1c3af6713c
commit 253c116f9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -101,6 +101,7 @@ fun MainView(
navigation: MainViewNavigation,
viewModel: MainViewModel = viewModel()
) {
val isOn = viewModel.vpnToggleState.collectAsState()
LoadingIndicator.Wrap {
Scaffold(contentWindowInsets = WindowInsets.Companion.statusBars) { paddingInsets ->
Column(
@ -115,7 +116,6 @@ fun MainView(
ListItem(
colors = MaterialTheme.colorScheme.surfaceContainerListItem,
leadingContent = {
val isOn = viewModel.vpnToggleState.collectAsState(initial = false)
TintedSwitch(onCheckedChange = { viewModel.toggleVpn() }, checked = isOn.value)
},
headlineContent = {

Loading…
Cancel
Save