fix(ui): stabilize theme and navigation behavior
This commit is contained in:
+34
-23
@@ -50,7 +50,6 @@ import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.SwapVert
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -71,6 +70,7 @@ import androidx.compose.ui.unit.sp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.flagship.abox.manager.designsystem.ABoxSurface
|
||||
import com.flagship.abox.manager.designsystem.ABoxBackLayer
|
||||
import com.flagship.abox.manager.designsystem.ABoxIconButton
|
||||
import com.flagship.abox.manager.designsystem.ABoxDeviceDetailScaffold
|
||||
import com.flagship.abox.manager.designsystem.icon.ABoxIcon
|
||||
@@ -157,8 +157,6 @@ internal fun InfraredHubScreen(
|
||||
var showCreateDialog by remember { mutableStateOf(false) }
|
||||
var showManagement by remember { mutableStateOf(false) }
|
||||
|
||||
BackHandler(enabled = showManagement) { showManagement = false }
|
||||
|
||||
LaunchedEffect(state.message) {
|
||||
state.message?.let { msg ->
|
||||
when (msg) {
|
||||
@@ -188,18 +186,16 @@ internal fun InfraredHubScreen(
|
||||
|
||||
ABoxDeviceDetailScaffold(
|
||||
title = state.savedDeviceName.value,
|
||||
subtitle = if (showManagement) stringResource(R.string.infrared_settings_subtitle) else stringResource(R.string.infrared_center_subtitle),
|
||||
subtitle = stringResource(R.string.infrared_center_subtitle),
|
||||
icon = ABoxIconKey.INFRARED,
|
||||
onBack = if (showManagement) ({ showManagement = false }) else onBack,
|
||||
onBack = onBack,
|
||||
action = {
|
||||
if (!showManagement) {
|
||||
ABoxIconButton(
|
||||
key = ABoxIconKey.EDIT,
|
||||
contentDescription = stringResource(R.string.infrared_manage_action),
|
||||
onClick = { showManagement = true },
|
||||
modifier = Modifier.testTag("hub_settings_button"),
|
||||
)
|
||||
}
|
||||
ABoxIconButton(
|
||||
key = ABoxIconKey.EDIT,
|
||||
contentDescription = stringResource(R.string.infrared_manage_action),
|
||||
onClick = { showManagement = true },
|
||||
modifier = Modifier.testTag("hub_settings_button"),
|
||||
)
|
||||
},
|
||||
) { innerPadding ->
|
||||
ABoxSurface(
|
||||
@@ -207,16 +203,7 @@ internal fun InfraredHubScreen(
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding),
|
||||
) {
|
||||
if (showManagement) {
|
||||
InfraredManagementScreen(
|
||||
state = state,
|
||||
onAddRemote = { showCreateDialog = true },
|
||||
onDeleteRemote = onDeleteRemote,
|
||||
onSaveDeviceName = onSaveDeviceName,
|
||||
onMoveRemote = onMoveRemote,
|
||||
onUpdateRemote = onUpdateRemote,
|
||||
)
|
||||
} else Column(
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(horizontal = 16.dp, vertical = 10.dp),
|
||||
@@ -299,6 +286,30 @@ internal fun InfraredHubScreen(
|
||||
}
|
||||
}
|
||||
|
||||
if (showManagement) {
|
||||
ABoxBackLayer(onBack = { showManagement = false }) {
|
||||
ABoxDeviceDetailScaffold(
|
||||
title = state.savedDeviceName.value,
|
||||
subtitle = stringResource(R.string.infrared_settings_subtitle),
|
||||
icon = ABoxIconKey.INFRARED,
|
||||
onBack = { showManagement = false },
|
||||
) { innerPadding ->
|
||||
ABoxSurface(
|
||||
modifier = Modifier.fillMaxSize().padding(innerPadding),
|
||||
) {
|
||||
InfraredManagementScreen(
|
||||
state = state,
|
||||
onAddRemote = { showCreateDialog = true },
|
||||
onDeleteRemote = onDeleteRemote,
|
||||
onSaveDeviceName = onSaveDeviceName,
|
||||
onMoveRemote = onMoveRemote,
|
||||
onUpdateRemote = onUpdateRemote,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showCreateDialog) {
|
||||
CreateVirtualRemoteDialog(
|
||||
onDismiss = { showCreateDialog = false },
|
||||
|
||||
Reference in New Issue
Block a user