@@ -47,6 +47,7 @@ import com.getcode.view.main.giveKin.GiveKinSheet
4747import com.google.accompanist.systemuicontroller.rememberSystemUiController
4848import kotlinx.coroutines.Dispatchers
4949import kotlinx.coroutines.delay
50+ import kotlinx.coroutines.flow.distinctUntilChanged
5051import kotlinx.coroutines.launch
5152import kotlinx.coroutines.withContext
5253import timber.log.Timber
@@ -219,19 +220,69 @@ fun HomeScan(
219220 }
220221 }
221222
223+ LaunchedEffect (giveKinSheetState) {
224+ snapshotFlow {
225+ giveKinSheetState.isVisible
226+ }.distinctUntilChanged().collect { isVisible ->
227+ if (isVisible.not ()) {
228+ isGiveKinSheetOpen = false
229+ }
230+ }
231+ }
232+
233+ LaunchedEffect (getKinSheetState) {
234+ snapshotFlow {
235+ getKinSheetState.isVisible
236+ }.distinctUntilChanged().collect { isVisible ->
237+ if (isVisible.not ()) {
238+ isGetKinSheetOpen = false
239+ }
240+ }
241+ }
242+
243+ LaunchedEffect (accountSheetState) {
244+ snapshotFlow {
245+ accountSheetState.isVisible
246+ }.distinctUntilChanged().collect { isVisible ->
247+ if (isVisible.not ()) {
248+ isAccountSheetOpen = false
249+ }
250+ }
251+ }
252+
253+ LaunchedEffect (balanceSheetState) {
254+ snapshotFlow {
255+ balanceSheetState.isVisible
256+ }.distinctUntilChanged().collect { isVisible ->
257+ if (isVisible.not ()) {
258+ isBalanceSheetOpen = false
259+ }
260+ }
261+ }
262+
263+ LaunchedEffect (accountSheetState) {
264+ snapshotFlow {
265+ accountSheetState.isVisible
266+ }.distinctUntilChanged().collect { isVisible ->
267+ if (isVisible.not ()) {
268+ isAccountSheetOpen = false
269+ }
270+ }
271+ }
272+
222273 fun hideSheet (bottomSheet : HomeBottomSheet ) {
223274 scope.launch {
224275 when (bottomSheet) {
225276 HomeBottomSheet .GIVE_KIN -> {
226277 giveKinSheetState.hide()
278+ isGiveKinSheetOpen = false
227279 }
228280 HomeBottomSheet .NONE -> {}
229281 HomeBottomSheet .ACCOUNT -> {
230282 accountSheetState.hide()
231283 }
232284 HomeBottomSheet .GET_KIN -> {
233285 getKinSheetState.hide()
234- isGiveKinSheetOpen = false
235286 }
236287 HomeBottomSheet .BALANCE -> {
237288 balanceSheetState.hide()
0 commit comments