mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 16:05:20 +00:00
Merge pull request #154 from anonfaded/fix/battery-screen-truncation
fix(onboarding): make battery screen scrollable
This commit is contained in:
@@ -2,6 +2,8 @@ package com.bitchat.android.onboarding
|
|||||||
|
|
||||||
import androidx.compose.animation.core.*
|
import androidx.compose.animation.core.*
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.*
|
import androidx.compose.material.icons.filled.*
|
||||||
import androidx.compose.material.icons.outlined.*
|
import androidx.compose.material.icons.outlined.*
|
||||||
@@ -76,117 +78,130 @@ private fun BatteryOptimizationEnabledContent(
|
|||||||
isLoading: Boolean
|
isLoading: Boolean
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(24.dp),
|
modifier = Modifier.fillMaxSize()
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
|
||||||
) {
|
) {
|
||||||
Text(
|
// Scrollable content area
|
||||||
text = "bitchat*",
|
Column(
|
||||||
style = MaterialTheme.typography.headlineLarge.copy(
|
modifier = Modifier
|
||||||
fontFamily = FontFamily.Monospace,
|
.weight(1f)
|
||||||
fontWeight = FontWeight.Bold,
|
.verticalScroll(rememberScrollState())
|
||||||
color = colorScheme.primary
|
.padding(bottom = 16.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(24.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "bitchat*",
|
||||||
|
style = MaterialTheme.typography.headlineLarge.copy(
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = colorScheme.primary
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
Icon(
|
||||||
Icon(
|
imageVector = Icons.Outlined.BatteryAlert,
|
||||||
imageVector = Icons.Outlined.BatteryAlert,
|
contentDescription = "Battery Optimization",
|
||||||
contentDescription = "Battery Optimization",
|
modifier = Modifier.size(64.dp),
|
||||||
modifier = Modifier.size(64.dp),
|
tint = colorScheme.error
|
||||||
tint = colorScheme.error
|
|
||||||
)
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.battery_optimization_detected),
|
|
||||||
style = MaterialTheme.typography.headlineSmall.copy(
|
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
color = colorScheme.onSurface
|
|
||||||
),
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
)
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.battery_optimization_explanation),
|
|
||||||
style = MaterialTheme.typography.bodyLarge.copy(
|
|
||||||
color = colorScheme.onSurfaceVariant
|
|
||||||
),
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
)
|
|
||||||
|
|
||||||
Card(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
colors = CardDefaults.cardColors(
|
|
||||||
containerColor = colorScheme.surfaceVariant.copy(alpha = 0.5f)
|
|
||||||
)
|
)
|
||||||
) {
|
|
||||||
Column(
|
Text(
|
||||||
modifier = Modifier.padding(16.dp),
|
text = stringResource(R.string.battery_optimization_detected),
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
style = MaterialTheme.typography.headlineSmall.copy(
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
color = colorScheme.onSurface
|
||||||
|
),
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.battery_optimization_explanation),
|
||||||
|
style = MaterialTheme.typography.bodyLarge.copy(
|
||||||
|
color = colorScheme.onSurfaceVariant
|
||||||
|
),
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
|
||||||
|
Card(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = colorScheme.surfaceVariant.copy(alpha = 0.5f)
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Text(
|
Column(
|
||||||
text = stringResource(R.string.battery_optimization_why_disable),
|
modifier = Modifier.padding(16.dp),
|
||||||
style = MaterialTheme.typography.titleSmall.copy(
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
fontWeight = FontWeight.SemiBold,
|
) {
|
||||||
color = colorScheme.onSurface
|
Text(
|
||||||
|
text = stringResource(R.string.battery_optimization_why_disable),
|
||||||
|
style = MaterialTheme.typography.titleSmall.copy(
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
color = colorScheme.onSurface
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
Text(
|
||||||
Text(
|
text = stringResource(R.string.battery_optimization_benefits),
|
||||||
text = stringResource(R.string.battery_optimization_benefits),
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
color = colorScheme.onSurfaceVariant
|
||||||
color = colorScheme.onSurfaceVariant
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
|
||||||
|
|
||||||
Button(
|
|
||||||
onClick = onDisableBatteryOptimization,
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
enabled = !isLoading
|
|
||||||
) {
|
|
||||||
if (isLoading) {
|
|
||||||
CircularProgressIndicator(
|
|
||||||
modifier = Modifier.size(16.dp),
|
|
||||||
strokeWidth = 2.dp,
|
|
||||||
color = colorScheme.onPrimary
|
|
||||||
)
|
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
|
||||||
}
|
|
||||||
Text(stringResource(R.string.battery_optimization_disable_button))
|
|
||||||
}
|
|
||||||
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
|
||||||
) {
|
|
||||||
OutlinedButton(
|
|
||||||
onClick = onRetry,
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
enabled = !isLoading
|
|
||||||
) {
|
|
||||||
Text(stringResource(R.string.battery_optimization_check_again))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextButton(
|
Text(
|
||||||
onClick = onSkip,
|
text = stringResource(R.string.battery_optimization_note),
|
||||||
modifier = Modifier.weight(1f),
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
enabled = !isLoading
|
color = colorScheme.onSurfaceVariant
|
||||||
) {
|
),
|
||||||
Text(stringResource(R.string.battery_optimization_skip))
|
textAlign = TextAlign.Center
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(
|
// Fixed buttons at the bottom
|
||||||
text = stringResource(R.string.battery_optimization_note),
|
Column(
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
color = colorScheme.onSurfaceVariant
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
),
|
) {
|
||||||
textAlign = TextAlign.Center
|
Button(
|
||||||
)
|
onClick = onDisableBatteryOptimization,
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
enabled = !isLoading
|
||||||
|
) {
|
||||||
|
if (isLoading) {
|
||||||
|
CircularProgressIndicator(
|
||||||
|
modifier = Modifier.size(16.dp),
|
||||||
|
strokeWidth = 2.dp,
|
||||||
|
color = colorScheme.onPrimary
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
|
}
|
||||||
|
Text(stringResource(R.string.battery_optimization_disable_button))
|
||||||
|
}
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||||
|
) {
|
||||||
|
OutlinedButton(
|
||||||
|
onClick = onRetry,
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
enabled = !isLoading
|
||||||
|
) {
|
||||||
|
Text(stringResource(R.string.battery_optimization_check_again))
|
||||||
|
}
|
||||||
|
|
||||||
|
TextButton(
|
||||||
|
onClick = onSkip,
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
enabled = !isLoading
|
||||||
|
) {
|
||||||
|
Text(stringResource(R.string.battery_optimization_skip))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user