|
| 1 | +package com.aliucord.manager.ui.screens.install.components |
| 2 | + |
| 3 | +import androidx.compose.foundation.background |
| 4 | +import androidx.compose.foundation.border |
| 5 | +import androidx.compose.foundation.layout.* |
| 6 | +import androidx.compose.material3.* |
| 7 | +import androidx.compose.runtime.Composable |
| 8 | +import androidx.compose.runtime.remember |
| 9 | +import androidx.compose.ui.Alignment |
| 10 | +import androidx.compose.ui.Modifier |
| 11 | +import androidx.compose.ui.draw.clip |
| 12 | +import androidx.compose.ui.platform.LocalContext |
| 13 | +import androidx.compose.ui.res.painterResource |
| 14 | +import androidx.compose.ui.res.stringResource |
| 15 | +import androidx.compose.ui.unit.dp |
| 16 | +import com.aliucord.manager.R |
| 17 | +import com.aliucord.manager.ui.components.customColors |
| 18 | +import com.aliucord.manager.util.isIgnoringBatteryOptimizations |
| 19 | + |
| 20 | +@Composable |
| 21 | +fun MinimizationWarning(modifier: Modifier = Modifier) { |
| 22 | + val context = LocalContext.current |
| 23 | + val hide = remember(context) { context.isIgnoringBatteryOptimizations() } |
| 24 | + |
| 25 | + if (hide) return |
| 26 | + |
| 27 | + Box( |
| 28 | + contentAlignment = Alignment.Center, |
| 29 | + modifier = modifier |
| 30 | + .padding( |
| 31 | + start = 20.dp, |
| 32 | + end = 20.dp, |
| 33 | + top = 20.dp, |
| 34 | + bottom = 4.dp, |
| 35 | + ) |
| 36 | + .border( |
| 37 | + width = 2.dp, |
| 38 | + color = MaterialTheme.customColors.warning, |
| 39 | + shape = MaterialTheme.shapes.medium, |
| 40 | + ) |
| 41 | + .clip(MaterialTheme.shapes.medium) |
| 42 | + .background(MaterialTheme.customColors.warningContainer) |
| 43 | + ) { |
| 44 | + Row( |
| 45 | + horizontalArrangement = Arrangement.spacedBy(12.dp), |
| 46 | + verticalAlignment = Alignment.CenterVertically, |
| 47 | + modifier = Modifier |
| 48 | + .padding(horizontal = 20.dp, vertical = 14.dp) |
| 49 | + ) { |
| 50 | + Icon( |
| 51 | + painter = painterResource(R.drawable.ic_warning), |
| 52 | + tint = MaterialTheme.customColors.onWarningContainer, |
| 53 | + contentDescription = null, |
| 54 | + modifier = Modifier.size(28.dp), |
| 55 | + ) |
| 56 | + |
| 57 | + Text( |
| 58 | + text = stringResource(R.string.installer_minimization_warning), |
| 59 | + style = MaterialTheme.typography.labelMedium, |
| 60 | + ) |
| 61 | + } |
| 62 | + } |
| 63 | +} |
0 commit comments