Feature/create custom preset UI#607
Conversation
Replace card-based layout with flat design using gray section headers Add syntax-highlighted JSON body editor (BasicTextField + TextFieldValue) Add custom status code chip dropdown with semantic colour coding Add segmented JSON/Plain Text body type toggle Inline char count and JSON validity indicator in Body header row Bound preset panel between top bar and logs (Column layout) Extract MiddleContentArea composable to fix ColumnScope.AnimatedVisibility ambiguity Remove rounded corner from preset panel overlay Add cancel/save header with progress indicator Add reformat param to buildHighlightedAnnotatedString for in-place highlighting Add missing i18n strings (cancel, endpointSubtitle, statusCodeRowLabel, etc.)
| // ── Middle content area (bounded: never spills into logs) ──── | ||
| // Extracted to its own composable so that ColumnScope is not an | ||
| // ambient implicit receiver — otherwise the compiler resolves | ||
| // AnimatedVisibility to ColumnScope.AnimatedVisibility and errors. |
There was a problem hiding this comment.
Not sure this comment is needed?
| val bodyTitle: String, | ||
| val bodyTypeJson: String, | ||
| val bodyTypePlain: String, | ||
| val bodyTypeXml: String, |
There was a problem hiding this comment.
Can we remove XML? Don't really want to support that
There was a problem hiding this comment.
Resolved, removed from Enum
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .background(MaterialTheme.colorScheme.surfaceContainerHigh) | ||
| .padding(horizontal = 16.dp, vertical = 14.dp), |
There was a problem hiding this comment.
We try to stick to multiples of 4 for padding, can this be 12 or 16?
There was a problem hiding this comment.
Yes, Resolved
| State.Editing.ResponseType.PlainText, | ||
| State.Editing.ResponseType.Xml, | ||
| State.Editing.ResponseType.Html, | ||
| State.Editing.ResponseType.None, |
There was a problem hiding this comment.
can this not just use State.Editing.ResponseType.entries?
There was a problem hiding this comment.
Good catch, of course can, the list was there to guard against Diktat reordering the enum alphabetically and breaking the UI order. Fixed by adding @Suppress("EnumEntryOrder") to the enum declaration so the order is owned by the enum itself, resolved switched to entries.
| Modifier | ||
| } | ||
| ) | ||
| .padding(horizontal = 14.dp, vertical = 8.dp), |
Redesigns the Create/Edit Preset panel with a clean flat layout, replacing the previous card-based approach.
Changes
UI / Layout
Flat panel with gray SectionLabel section headers (RESPONSE, HEADERS (N))
PanelHeader with bold title, endpoint subtitle, Cancel + Save buttons, and a slim progress indicator
Preset panel is now bounded between the top bar and the logs panel — no longer overlaps either
Removed rounded top-start corner from the preset panel overlay
Status Code
Custom StatusCodeDropdown with a StatusChip showing semantic colour coding (2xx = Ok/green, 3xx = Info, 4xx = Warn, 5xx = Err)
Dropdown wraps content, label left / control right (SpaceBetween)
Body
Segmented BodyTypeToggle (JSON / Plain Text) with teal selected state
JsonBodyTextField — BasicTextField + TextFieldValue with live JSON syntax highlighting via buildHighlightedAnnotatedString (reformat = false so typing is never interrupted)
Body header row shows char count + validity icon inline, both in primary (teal) colour
Headers
Existing headers displayed as inline key : value × rows (teal key, muted value)
Section label includes live count — HEADERS (1)
Add-header row: two single-line CustomTextField inputs with muted placeholder hints + teal + button
Architecture
Extracted MiddleContentArea composable to fix ColumnScope.AnimatedVisibility ambiguity
Added reformat: Boolean = true param to buildHighlightedAnnotatedString
Added onCancel to public CreateEditPresetWidget API
Added i18n strings: cancel, endpointSubtitle, statusCodeRowLabel, bodyTypeLabel, responseSectionLabel, bodyLabel
Testing
Build and run the desktop app
Open the Create Preset panel and verify: status code dropdown, body type toggle, JSON highlighting, header add/remove, cancel/save buttons, panel bounds (does not overlap top bar or logs)