From 8dc67adad366997526be909f4a7708871a0ce29f Mon Sep 17 00:00:00 2001 From: jay-tux Date: Mon, 24 Aug 2026 18:42:18 +0200 Subject: [PATCH] Fix register view on WASM, remove edit buttons when viewing non-editable project --- .../jaytux/phoebench/clients/ui/HomeView.kt | 3 +- .../phoebench/clients/ui/ProjectView.kt | 82 ++++++++++--------- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/HomeView.kt b/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/HomeView.kt index c89e74d..fa27767 100644 --- a/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/HomeView.kt +++ b/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/HomeView.kt @@ -181,7 +181,6 @@ fun LoginView(server: String?, error: String?, onSwitchSignup: () -> Unit, onLog Text("Log in", style = MaterialTheme.typography.headlineMedium) ServerSelect(serverUrl) { serverUrl = it } -// OutlinedTextField(serverUrl, { serverUrl = it }, Modifier.fillMaxWidth(), label = { Text("Server URL") }, singleLine = true) OutlinedTextField(username, { username = it }, Modifier.fillMaxWidth(), label = { Text("Username") }, singleLine = true) OutlinedTextField(password, { password = it }, Modifier.fillMaxWidth(), label = { Text("Password") }, visualTransformation = PasswordVisualTransformation(), singleLine = true) @@ -213,7 +212,7 @@ fun SignupView(server: String?, error: String?, onSwitchLogin: () -> Unit, onSig Column(Modifier.padding(5.dp).widthIn(min = 250.dp).width(IntrinsicSize.Min), horizontalAlignment = Alignment.CenterHorizontally) { Text("Sign up", style = MaterialTheme.typography.headlineMedium) - OutlinedTextField(serverUrl, { serverUrl = it }, Modifier.fillMaxWidth(), label = { Text("Server URL") }, singleLine = true) + ServerSelect(serverUrl) { serverUrl = it } OutlinedTextField(inviteCode, { inviteCode = it }, Modifier.fillMaxWidth(), label = { Text("Invite code") }, singleLine = true) OutlinedTextField(username, { username = it }, Modifier.fillMaxWidth(), label = { Text("Username") }, singleLine = true) diff --git a/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/ProjectView.kt b/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/ProjectView.kt index d1dc46c..0219ae6 100644 --- a/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/ProjectView.kt +++ b/clients/compose/src/commonMain/kotlin/com/jaytux/phoebench/clients/ui/ProjectView.kt @@ -77,47 +77,49 @@ fun ProjectView(id: Uuid, forceBack: () -> Unit) { Box(Modifier.fillMaxSize().padding(15.dp)) { ProjectPlotArea(vm) - if(addOpen) { - CompositionLocalProvider(LocalIndication provides NoFeedbackIndication()) { - Box(Modifier.clickable { addOpen = false }.fillMaxSize()) - } - } - - Column(Modifier.align(Alignment.BottomEnd).padding(25.dp), horizontalAlignment = Alignment.End) { + if(editable) { if(addOpen) { - var lblWidth by mutableStateOf(1000.dp) - var dataWidth by mutableStateOf(1000.dp) - val density = LocalDensity.current - - Column(Modifier.width(maxOf(lblWidth, dataWidth)), horizontalAlignment = Alignment.End) { - Surface(Modifier.onGloballyPositioned { - lblWidth = with(density) { it.size.width.toDp() } - }, shape = MaterialTheme.shapes.small, shadowElevation = 10.dp) { - Row(Modifier.clickable { addingLabel = true }.padding(15.dp)) { - Icon(Lucide.CaseSensitive, "Add label") - Spacer(Modifier.width(5.dp)) - Text("Label") - } - } - - Spacer(Modifier.height(10.dp)) - - Surface(Modifier.onGloballyPositioned { - dataWidth = with(density) { it.size.width.toDp() } - }, shape = MaterialTheme.shapes.small, shadowElevation = 10.dp) { - Row(Modifier.clickable { addingData = true }.padding(15.dp)) { - Icon(Lucide.ChartLine, "Add data") - Spacer(Modifier.width(5.dp)) - Text("Data") - } - } - - Spacer(Modifier.height(15.dp)) + CompositionLocalProvider(LocalIndication provides NoFeedbackIndication()) { + Box(Modifier.clickable { addOpen = false }.fillMaxSize()) } } - IconButton({ addOpen = !addOpen }, Modifier.scale(1.5f), shape = MaterialTheme.shapes.medium) { - Icon(if(addOpen) Lucide.X else Lucide.Plus, if(addOpen) "Add data" else "Close menu") + Column(Modifier.align(Alignment.BottomEnd).padding(25.dp), horizontalAlignment = Alignment.End) { + if (addOpen) { + var lblWidth by mutableStateOf(1000.dp) + var dataWidth by mutableStateOf(1000.dp) + val density = LocalDensity.current + + Column(Modifier.width(maxOf(lblWidth, dataWidth)), horizontalAlignment = Alignment.End) { + Surface(Modifier.onGloballyPositioned { + lblWidth = with(density) { it.size.width.toDp() } + }, shape = MaterialTheme.shapes.small, shadowElevation = 10.dp) { + Row(Modifier.clickable { addingLabel = true }.padding(15.dp)) { + Icon(Lucide.CaseSensitive, "Add label") + Spacer(Modifier.width(5.dp)) + Text("Label") + } + } + + Spacer(Modifier.height(10.dp)) + + Surface(Modifier.onGloballyPositioned { + dataWidth = with(density) { it.size.width.toDp() } + }, shape = MaterialTheme.shapes.small, shadowElevation = 10.dp) { + Row(Modifier.clickable { addingData = true }.padding(15.dp)) { + Icon(Lucide.ChartLine, "Add data") + Spacer(Modifier.width(5.dp)) + Text("Data") + } + } + + Spacer(Modifier.height(15.dp)) + } + } + + IconButton({ addOpen = !addOpen }, Modifier.scale(1.5f), shape = MaterialTheme.shapes.medium) { + Icon(if (addOpen) Lucide.X else Lucide.Plus, if (addOpen) "Add data" else "Close menu") + } } } } @@ -621,8 +623,10 @@ fun ProjectPlotArea(vm: ProjectVM){ } else Icon(Lucide.RulerDimensionLine, "Use as baseline") } - IconButton({ deletingVersion = lbl }, Modifier.align(Alignment.CenterVertically)) { - Icon(Lucide.Trash, "Delete version") + if(editable) { + IconButton({ deletingVersion = lbl }, Modifier.align(Alignment.CenterVertically)) { + Icon(Lucide.Trash, "Delete version") + } } } }