refactor(#78): extract UI strings for toolsets webhooks pairing and config screens

This commit is contained in:
Hy4ri committed 2026-06-21 11:48:33 +03:00
1 parent dcb23ba0a3
commit b1950ece34
5 files changed
+68 -26

No files matched your search

@@ -26,10 +26,12 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.m57.hermescontrol.R
import com.m57.hermescontrol.ui.common.ErrorState
import com.m57.hermescontrol.ui.common.HermesScaffold
import com.m57.hermescontrol.ui.common.LoadingState
@@ -57,7 +59,7 @@ fun ConfigScreen(
}
HermesScaffold(
title = { Text("Configuration") },
title = { Text(stringResource(R.string.config_screen_title)) },
onOpenDrawer = onOpenDrawer,
isRefreshing = state.isLoading,
onRefresh = { viewModel.loadRawConfig() },
@@ -87,7 +89,7 @@ fun ConfigScreen(
Text(text = state.errorMessage ?: "", color = MaterialTheme.colorScheme.error)
Spacer(modifier = Modifier.height(16.dp))
Button(onClick = { viewModel.loadRawConfig() }) {
Text("Retry")
Text(stringResource(R.string.action_retry))
}
}
} else {
@@ -113,7 +115,7 @@ fun ConfigScreen(
Modifier
.fillMaxWidth()
.weight(1f),
placeholder = { Text("YAML Config...") },
placeholder = { Text(stringResource(R.string.config_placeholder_yaml)) },
textStyle = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace),
maxLines = Int.MAX_VALUE,
)
@@ -125,7 +127,7 @@ fun ConfigScreen(
onClick = { editingText = state.yamlText ?: "" },
modifier = Modifier.weight(1f),
) {
Text("Reset")
Text(stringResource(R.string.config_action_reset))
}
Spacer(modifier = Modifier.width(16.dp))
@@ -138,7 +140,7 @@ fun ConfigScreen(
if (state.isSaving) {
CircularProgressIndicator(modifier = Modifier.width(16.dp))
} else {
Text("Save Config")
Text(stringResource(R.string.config_action_save))
}
}
}
@@ -28,10 +28,12 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.m57.hermescontrol.R
import com.m57.hermescontrol.ui.common.ErrorState
import com.m57.hermescontrol.ui.common.HermesScaffold
import com.m57.hermescontrol.ui.common.LoadingState
@@ -58,7 +60,7 @@ fun PairingScreen(
}
HermesScaffold(
title = { Text("Device Pairing") },
title = { Text(stringResource(R.string.pairing_screen_title)) },
onOpenDrawer = onOpenDrawer,
isRefreshing = state.isLoading,
onRefresh = { viewModel.loadPairing() },
@@ -88,7 +90,7 @@ fun PairingScreen(
Text(text = state.errorMessage ?: "", color = MaterialTheme.colorScheme.error)
Spacer(modifier = Modifier.height(16.dp))
Button(onClick = { viewModel.loadPairing() }) {
Text("Retry")
Text(stringResource(R.string.action_retry))
}
}
} else {
@@ -109,7 +111,7 @@ fun PairingScreen(
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = "Pending Approvals",
text = stringResource(R.string.pairing_sec_pending),
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold,
)
@@ -121,7 +123,7 @@ fun PairingScreen(
contentColor = MaterialTheme.colorScheme.error,
),
) {
Text("Clear All")
Text(stringResource(R.string.pairing_action_clear_all))
}
}
}
@@ -170,7 +172,7 @@ fun PairingScreen(
containerColor = MaterialTheme.colorScheme.primary,
),
) {
Text("Approve")
Text(stringResource(R.string.pairing_action_approve))
}
}
}
@@ -179,7 +181,7 @@ fun PairingScreen(
item {
Text(
text = "Approved Devices",
text = stringResource(R.string.pairing_sec_approved),
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold,
)
@@ -198,7 +200,7 @@ fun PairingScreen(
contentAlignment = Alignment.Center,
) {
Text(
text = "No approved devices paired yet.",
text = stringResource(R.string.pairing_empty_approved),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
@@ -225,7 +227,11 @@ fun PairingScreen(
fontWeight = FontWeight.SemiBold,
)
Text(
text = "User ID: ${item.user_id ?: "Unknown"}",
text =
stringResource(
R.string.pairing_label_user_id,
item.user_id ?: "Unknown",
),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
@@ -246,7 +252,7 @@ fun PairingScreen(
contentColor = MaterialTheme.colorScheme.error,
),
) {
Text("Revoke")
Text(stringResource(R.string.pairing_action_revoke))
}
}
}
@@ -32,10 +32,12 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.m57.hermescontrol.R
import com.m57.hermescontrol.ui.common.EmptyState
import com.m57.hermescontrol.ui.common.ErrorState
import com.m57.hermescontrol.ui.common.HermesScaffold
@@ -63,7 +65,7 @@ fun ToolsetsScreen(
}
HermesScaffold(
title = { Text("Toolsets") },
title = { Text(stringResource(R.string.screen_toolsets)) },
onOpenDrawer = onOpenDrawer,
isRefreshing = state.isLoading,
onRefresh = { viewModel.loadToolsets() },
@@ -83,10 +85,10 @@ fun ToolsetsScreen(
state.toolsets.isEmpty() -> {
EmptyState(
title = "No toolsets reported",
subtitle = "Verify configuration or retry",
title = stringResource(R.string.toolsets_empty_title),
subtitle = stringResource(R.string.toolsets_empty_desc),
onAction = { viewModel.loadToolsets() },
actionLabel = "Refresh",
actionLabel = stringResource(R.string.content_desc_refresh),
modifier = Modifier.padding(paddingValues),
)
}
@@ -103,7 +105,10 @@ fun ToolsetsScreen(
Text(text = state.errorMessage ?: "", color = MaterialTheme.colorScheme.error)
Spacer(modifier = Modifier.height(16.dp))
IconButton(onClick = { viewModel.loadToolsets() }) {
Icon(imageVector = Icons.Filled.Refresh, contentDescription = "Retry")
Icon(
imageVector = Icons.Filled.Refresh,
contentDescription = stringResource(R.string.action_retry),
)
}
}
} else {
@@ -29,11 +29,13 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.m57.hermescontrol.R
import com.m57.hermescontrol.ui.common.ErrorState
import com.m57.hermescontrol.ui.common.HermesScaffold
import com.m57.hermescontrol.ui.common.LoadingState
@@ -60,7 +62,7 @@ fun WebhooksScreen(
}
HermesScaffold(
title = { Text("Webhooks") },
title = { Text(stringResource(R.string.screen_webhooks)) },
onOpenDrawer = onOpenDrawer,
isRefreshing = state.isLoading,
onRefresh = { viewModel.loadWebhooks() },
@@ -90,7 +92,7 @@ fun WebhooksScreen(
Text(text = state.errorMessage ?: "", color = MaterialTheme.colorScheme.error)
Spacer(modifier = Modifier.height(16.dp))
Button(onClick = { viewModel.loadWebhooks() }) {
Text("Retry")
Text(stringResource(R.string.action_retry))
}
}
} else {
@@ -123,7 +125,7 @@ fun WebhooksScreen(
) {
Column(modifier = Modifier.weight(1f)) {
Text(
text = "Global Webhooks Status",
text = stringResource(R.string.webhooks_sec_status),
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold,
)
@@ -147,7 +149,7 @@ fun WebhooksScreen(
// Subscriptions List Header
item {
Text(
text = "Subscriptions",
text = stringResource(R.string.webhooks_sec_subscriptions),
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold,
)
@@ -166,7 +168,7 @@ fun WebhooksScreen(
contentAlignment = Alignment.Center,
) {
Text(
text = "No webhook subscriptions configured.",
text = stringResource(R.string.webhooks_empty_desc),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
@@ -191,7 +193,7 @@ fun WebhooksScreen(
fontWeight = FontWeight.SemiBold,
)
Text(
text = "Target URL:",
text = stringResource(R.string.webhooks_label_target),
style = MaterialTheme.typography.bodySmall,
fontWeight = FontWeight.Bold,
)
@@ -207,7 +209,7 @@ fun WebhooksScreen(
if (events.isNotEmpty()) {
Spacer(modifier = Modifier.height(4.dp))
Text(
text = "Events Subscribed:",
text = stringResource(R.string.webhooks_label_events),
style = MaterialTheme.typography.bodySmall,
fontWeight = FontWeight.Bold,
)