Skip to content

Commit

Permalink
Hide country list sheet after connecting
Browse files Browse the repository at this point in the history
  • Loading branch information
chRyNaN committed Mar 4, 2025
1 parent 7acdb7c commit c199849
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.mooncloak.vpn.app.shared.feature.country
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.snap
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
Expand All @@ -26,7 +25,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand Down Expand Up @@ -60,7 +58,6 @@ public fun CountryListScreen(
}
val viewModel = remember { componentDependencies.viewModel }
val snackbarHostState = remember { SnackbarHostState() }
val coroutineScope = rememberCoroutineScope()

val countryLazyListState = rememberLazyListState()
val regionLazyListState = rememberLazyListState()
Expand All @@ -70,6 +67,12 @@ public fun CountryListScreen(
viewModel.load()
}

LaunchedEffect(viewModel.state.current.value.hideSheet) {
if (viewModel.state.current.value.hideSheet) {
sheetState.hide()
}
}

ManagedModalBottomSheet(
modifier = modifier,
sheetState = sheetState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public data class CountryListStateModel public constructor(
public val connection: VPNConnection = VPNConnection.Disconnected(),
public val subscription: ServiceSubscription? = null,
public val layout: LayoutStateModel = CountryListLayoutStateModel(),
public val errorMessage: String? = null
public val errorMessage: String? = null,
public val hideSheet: Boolean = false
)

public val CountryListStateModel.canAppendMore: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public class CountryListViewModel @Inject public constructor(
coroutineScope.launch {
mutex.withLock {
connectToServerInLocationCode(locationCode = country.code)

emit { current -> current.copy(hideSheet = true) }
}
}
}
Expand All @@ -125,6 +127,8 @@ public class CountryListViewModel @Inject public constructor(
coroutineScope.launch {
mutex.withLock {
connectToServerInLocationCode(locationCode = region.code)

emit { current -> current.copy(hideSheet = true) }
}
}
}
Expand All @@ -133,6 +137,8 @@ public class CountryListViewModel @Inject public constructor(
coroutineScope.launch {
mutex.withLock {
connectToServer(server = server)

emit { current -> current.copy(hideSheet = true) }
}
}
}
Expand Down

0 comments on commit c199849

Please sign in to comment.