11package to.bitkit.ui.screens.transfer
22
3+ import android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
4+ import androidx.activity.compose.LocalActivity
35import androidx.compose.foundation.Image
46import androidx.compose.foundation.layout.Box
57import androidx.compose.foundation.layout.Column
@@ -15,6 +17,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
1517import androidx.compose.material3.Icon
1618import androidx.compose.material3.IconButton
1719import androidx.compose.runtime.Composable
20+ import androidx.compose.runtime.DisposableEffect
1821import androidx.compose.runtime.LaunchedEffect
1922import androidx.compose.runtime.getValue
2023import androidx.compose.runtime.mutableStateOf
@@ -51,6 +54,7 @@ fun SavingsProgressScreen(
5154 onContinueClick : () -> Unit = {},
5255 onCloseClick : () -> Unit = {},
5356) {
57+ val window = LocalActivity .current?.window
5458 val transfer = transferViewModel ? : return
5559 val wallet = walletViewModel ? : return
5660 var progressState by remember { mutableStateOf(SavingsProgressState .PROGRESS ) }
@@ -60,6 +64,8 @@ fun SavingsProgressScreen(
6064 val channelsFailedToCoopClose = transfer.closeSelectedChannels()
6165
6266 if (channelsFailedToCoopClose.isEmpty()) {
67+ window?.clearFlags(FLAG_KEEP_SCREEN_ON )
68+
6369 wallet.refreshState()
6470 delay(5000 )
6571 progressState = SavingsProgressState .SUCCESS
@@ -70,6 +76,14 @@ fun SavingsProgressScreen(
7076 }
7177 }
7278
79+ // Keeps screen on while this view is active
80+ DisposableEffect (Unit ) {
81+ window?.addFlags(FLAG_KEEP_SCREEN_ON )
82+ onDispose {
83+ window?.clearFlags(FLAG_KEEP_SCREEN_ON )
84+ }
85+ }
86+
7387 SavingsProgressScreen (
7488 progressState = progressState,
7589 onContinueClick = { onContinueClick() },
0 commit comments