11package to.bitkit.ui.screens.wallets.receive
22
3- import android.app.Activity
43import android.graphics.Bitmap
5- import android.view.WindowManager
64import androidx.compose.animation.AnimatedVisibility
75import androidx.compose.foundation.layout.Arrangement
86import androidx.compose.foundation.layout.Column
@@ -24,7 +22,6 @@ import androidx.compose.material3.Icon
2422import androidx.compose.material3.Switch
2523import androidx.compose.material3.rememberTooltipState
2624import androidx.compose.runtime.Composable
27- import androidx.compose.runtime.DisposableEffect
2825import androidx.compose.runtime.MutableState
2926import androidx.compose.runtime.getValue
3027import androidx.compose.runtime.mutableIntStateOf
@@ -36,6 +33,7 @@ import androidx.compose.ui.Alignment
3633import androidx.compose.ui.Modifier
3734import androidx.compose.ui.draw.rotate
3835import androidx.compose.ui.graphics.painter.Painter
36+ import androidx.compose.ui.keepScreenOn
3937import androidx.compose.ui.platform.LocalContext
4038import androidx.compose.ui.platform.testTag
4139import androidx.compose.ui.res.painterResource
@@ -59,6 +57,7 @@ import to.bitkit.ui.components.PrimaryButton
5957import to.bitkit.ui.components.QrCodeImage
6058import to.bitkit.ui.components.Tooltip
6159import to.bitkit.ui.scaffold.SheetTopBar
60+ import to.bitkit.ui.shared.effects.SetMaxBrightness
6261import to.bitkit.ui.shared.modifiers.sheetHeight
6362import to.bitkit.ui.shared.util.gradientBackground
6463import to.bitkit.ui.shared.util.shareQrCode
@@ -80,32 +79,7 @@ fun ReceiveQrScreen(
8079 onClickReceiveOnSpending : () -> Unit ,
8180 modifier : Modifier = Modifier ,
8281) {
83- val context = LocalContext .current
84- val window = remember(context) { (context as ? Activity )?.window }
85-
86- // Keep screen on and set brightness to max while this composable is active
87- DisposableEffect (Unit ) {
88- val originalBrightness = window?.attributes?.screenBrightness
89- val originalFlags = window?.attributes?.flags
90-
91- window?.let { win ->
92- win.attributes?.let { attrs ->
93- attrs.screenBrightness = WindowManager .LayoutParams .BRIGHTNESS_OVERRIDE_FULL
94- attrs.flags = WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON
95- win.attributes = attrs
96- }
97- }
98-
99- onDispose {
100- window?.let { win ->
101- win.attributes?.let { attrs ->
102- if (originalBrightness != null ) attrs.screenBrightness = originalBrightness
103- if (originalFlags != null ) attrs.flags = originalFlags
104- win.attributes = attrs
105- }
106- }
107- }
108- }
82+ SetMaxBrightness ()
10983
11084 val qrLogoImageRes by remember(walletState, cjitInvoice.value) {
11185 val resId = when {
@@ -124,6 +98,7 @@ fun ReceiveQrScreen(
12498 .fillMaxSize()
12599 .gradientBackground()
126100 .navigationBarsPadding()
101+ .keepScreenOn()
127102 ) {
128103 SheetTopBar (stringResource(R .string.wallet__receive_bitcoin))
129104 Column (
0 commit comments