Skip to content

Commit 9c7477e

Browse files
authored
fix: reset sheet state on collapse (#1)
* fix: reset give kin sheet on collapse * fix: reset account sheet on collapse * fix: balance and get kin sheet on collapse
1 parent 7e0181d commit 9c7477e

File tree

1 file changed

+52
-1
lines changed
  • app/src/main/java/com/getcode/view/main/home

1 file changed

+52
-1
lines changed

app/src/main/java/com/getcode/view/main/home/HomeScan.kt

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import com.getcode.view.main.giveKin.GiveKinSheet
4747
import com.google.accompanist.systemuicontroller.rememberSystemUiController
4848
import kotlinx.coroutines.Dispatchers
4949
import kotlinx.coroutines.delay
50+
import kotlinx.coroutines.flow.distinctUntilChanged
5051
import kotlinx.coroutines.launch
5152
import kotlinx.coroutines.withContext
5253
import 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

Comments
 (0)