@@ -63,6 +63,7 @@ import androidx.compose.material3.OutlinedTextField
6363import androidx.compose.material3.Scaffold
6464import androidx.compose.material3.SnackbarHost
6565import androidx.compose.material3.SnackbarHostState
66+ import androidx.compose.material3.Surface
6667import androidx.compose.material3.Text
6768import androidx.compose.runtime.Composable
6869import androidx.compose.runtime.LaunchedEffect
@@ -74,6 +75,7 @@ import androidx.compose.runtime.setValue
7475import androidx.compose.ui.Alignment
7576import androidx.compose.ui.Modifier
7677import androidx.compose.ui.draw.clip
78+ import androidx.compose.ui.graphics.Color
7779import androidx.compose.ui.hapticfeedback.HapticFeedbackType
7880import androidx.compose.ui.platform.LocalHapticFeedback
7981import androidx.compose.ui.semantics.Role
@@ -86,6 +88,7 @@ import androidx.compose.ui.unit.dp
8688import androidx.lifecycle.compose.collectAsStateWithLifecycle
8789import org.jetbrains.compose.resources.painterResource
8890import org.jetbrains.compose.resources.stringResource
91+ import androidx.compose.ui.tooling.preview.PreviewLightDark
8992import org.koin.compose.viewmodel.koinViewModel
9093import org.meshtastic.core.resources.Res
9194import org.meshtastic.core.resources.action_select_network
@@ -139,6 +142,7 @@ import org.meshtastic.core.ui.icon.Serial
139142import org.meshtastic.core.ui.icon.Visibility
140143import org.meshtastic.core.ui.icon.VisibilityOff
141144import org.meshtastic.core.ui.icon.Wifi
145+ import org.meshtastic.core.ui.theme.AppTheme
142146import org.meshtastic.core.ui.util.rememberOpenUrl
143147import org.meshtastic.feature.wifiprovision.WifiProvisionError
144148import org.meshtastic.feature.wifiprovision.WifiProvisionUiState
@@ -528,47 +532,53 @@ private fun ProvisionSuccessContent(ipAddress: String?, onDone: () -> Unit) {
528532 modifier = Modifier .align(Alignment .CenterHorizontally ),
529533 )
530534
531- ProvisionInfoCard (
532- label = stringResource(Res .string.wifi_provision_success_ip_address),
533- value = resolvedIp,
534- copyEnabled = ipAddress != null ,
535- )
535+ Card (
536+ shape = MaterialTheme .shapes.large,
537+ colors = CardDefaults .cardColors(containerColor = MaterialTheme .colorScheme.surfaceContainerHigh),
538+ ) {
539+ ProvisionInfoItem (
540+ label = stringResource(Res .string.wifi_provision_success_ip_address),
541+ value = resolvedIp,
542+ copyEnabled = ipAddress != null ,
543+ )
544+ }
536545
537546 Card (
538547 shape = MaterialTheme .shapes.large,
539548 colors = CardDefaults .cardColors(containerColor = MaterialTheme .colorScheme.surfaceContainerHigh),
540549 ) {
541550 Column (
542- modifier = Modifier .fillMaxWidth().padding(16 .dp),
543- verticalArrangement = Arrangement .spacedBy(12 .dp),
551+ modifier = Modifier .fillMaxWidth().padding(vertical = 16 .dp),
544552 ) {
545553 Text (
546554 text = stringResource(Res .string.wifi_provision_success_setup_title),
547555 style = MaterialTheme .typography.titleLargeEmphasized,
556+ modifier = Modifier .padding(horizontal = 16 .dp).padding(bottom = 12 .dp),
548557 )
549558 Text (
550559 text = stringResource(Res .string.wifi_provision_success_setup_description),
551560 style = MaterialTheme .typography.bodyMedium,
552561 color = MaterialTheme .colorScheme.onSurfaceVariant,
562+ modifier = Modifier .padding(horizontal = 16 .dp).padding(bottom = 8 .dp),
553563 )
554- ProvisionInfoCard (
564+ ProvisionInfoItem (
555565 label = stringResource(Res .string.wifi_provision_success_username),
556566 value = defaultUsername,
557567 )
558- ProvisionInfoCard (
568+ ProvisionInfoItem (
559569 label = stringResource(Res .string.password),
560570 value = defaultPassword,
561571 )
562- ProvisionInfoCard (
572+ ProvisionInfoItem (
563573 label = stringResource(Res .string.wifi_provision_success_ssh_label),
564574 value = sshCommand,
565575 copyEnabled = ipAddress != null ,
566576 )
567577
568- Button (
578+ FilledTonalButton (
569579 onClick = { sshUri?.let (openUrl) },
570580 enabled = sshUri != null ,
571- modifier = Modifier .fillMaxWidth(),
581+ modifier = Modifier .fillMaxWidth().padding(horizontal = 16 .dp).padding(top = 8 .dp, bottom = 12 .dp) ,
572582 ) {
573583 Icon (imageVector = MeshtasticIcons .Serial , contentDescription = null , modifier = Modifier .size(18 .dp))
574584 Spacer (Modifier .width(8 .dp))
@@ -578,6 +588,7 @@ private fun ProvisionSuccessContent(ipAddress: String?, onDone: () -> Unit) {
578588 text = stringResource(Res .string.wifi_provision_success_open_ssh_fallback),
579589 style = MaterialTheme .typography.bodySmall,
580590 color = MaterialTheme .colorScheme.onSurfaceVariant,
591+ modifier = Modifier .padding(horizontal = 16 .dp),
581592 )
582593 }
583594 }
@@ -589,29 +600,17 @@ private fun ProvisionSuccessContent(ipAddress: String?, onDone: () -> Unit) {
589600}
590601
591602@Composable
592- private fun ProvisionInfoCard (label : String , value : String , copyEnabled : Boolean = true) {
593- Card (
594- shape = MaterialTheme .shapes.large,
595- colors = CardDefaults .cardColors(containerColor = MaterialTheme .colorScheme.surfaceContainerHigh),
596- ) {
597- Row (
598- modifier = Modifier .fillMaxWidth().padding(horizontal = 16 .dp, vertical = 12 .dp),
599- horizontalArrangement = Arrangement .spacedBy(12 .dp),
600- verticalAlignment = Alignment .CenterVertically ,
601- ) {
602- Column (modifier = Modifier .weight(1f ), verticalArrangement = Arrangement .spacedBy(4 .dp)) {
603- Text (
604- text = label,
605- style = MaterialTheme .typography.labelLarge,
606- color = MaterialTheme .colorScheme.onSurfaceVariant,
607- )
608- Text (text = value, style = MaterialTheme .typography.bodyLargeEmphasized)
609- }
603+ private fun ProvisionInfoItem (label : String , value : String , copyEnabled : Boolean = true) {
604+ ListItem (
605+ overlineContent = { Text (text = label, style = MaterialTheme .typography.labelLarge) },
606+ headlineContent = { Text (text = value, style = MaterialTheme .typography.bodyLargeEmphasized) },
607+ trailingContent = {
610608 if (copyEnabled) {
611609 CopyIconButton (valueToCopy = value)
612610 }
613- }
614- }
611+ },
612+ colors = ListItemDefaults .colors(containerColor = Color .Transparent ),
613+ )
615614}
616615
617616@Composable
@@ -695,3 +694,16 @@ private fun CenteredStatusContent(content: @Composable () -> Unit) {
695694 content()
696695 }
697696}
697+
698+ @PreviewLightDark
699+ @Composable
700+ private fun ProvisionSuccessContentPreview () {
701+ AppTheme {
702+ Surface {
703+ ProvisionSuccessContent (
704+ ipAddress = " 192.168.1.100" ,
705+ onDone = {}
706+ )
707+ }
708+ }
709+ }
0 commit comments