Tunal/crates/tunal/ui/dialogs/properties.slint
astar76 321ce8c244 S038: expressive restyle with shaped containers, ripples and rounded surfaces
Shape library (cookies, clover, scallop) with morphing Shape component,
press ripple in StateLayer, content card shell, shaped file glyphs,
card grid tiles, dialog header shapes, menu pills, wavy toast progress.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 19:24:41 -06:00

177 lines
4.4 KiB
Text

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ListView } from "std-widgets.slint";
import { Theme } from "../theme.slint";
import { Icon, Icons } from "../components/icon.slint";
import { Dialog } from "../components/dialog.slint";
import { ButtonKind } from "../components/button.slint";
export struct PropRow {
label: string,
value: string,
}
// What the Properties dialog shows, formatted by Rust. `perms` holds nine flags (owner,
// group, others × read, write, execute) when `has-perms`.
export struct PropertiesInfo {
title: string,
glyph: string,
rows: [PropRow],
size: string,
contents: string,
scanning: bool,
has-perms: bool,
perms: [bool],
perm-text: string,
}
component Line inherits HorizontalLayout {
in property <string> label;
in property <string> value;
spacing: Theme.space-4;
height: 20px;
Text {
width: 88px;
text: root.label;
color: Theme.on-surface-variant;
font-size: Theme.body-medium.size;
font-weight: Theme.body-medium.weight;
vertical-alignment: center;
}
Text {
horizontal-stretch: 1;
text: root.value;
color: Theme.on-surface;
font-size: Theme.body-medium.size;
font-weight: Theme.body-medium.weight;
vertical-alignment: center;
overflow: elide;
}
}
// One cell of the permission grid: a check when granted, a dash when not.
component Flag inherits Rectangle {
in property <bool> on;
width: 56px;
height: 20px;
if root.on: Icon {
glyph: Icons.check;
size: 18px;
color: Theme.primary;
}
if !root.on: Rectangle {
width: 8px;
height: 2px;
border-radius: 1px;
background: Theme.outline-variant;
}
}
component PermissionRow inherits HorizontalLayout {
in property <string> who;
in property <[bool]> perms;
in property <int> first;
spacing: Theme.space-2;
height: 20px;
Text {
width: 96px;
text: root.who;
color: Theme.on-surface-variant;
font-size: Theme.body-medium.size;
font-weight: Theme.body-medium.weight;
vertical-alignment: center;
}
for i in 3: Flag {
on: root.first + i < root.perms.length && root.perms[root.first + i];
}
}
// Read-only facts about the selection; the folder size is counted in the background and
// `info.scanning` shows while it grows.
export component PropertiesDialog inherits Dialog {
glyph: Icons.info;
in property <PropertiesInfo> info;
callback closed();
title: root.info.title;
dialog-width: 440px;
actions: [{ text: "Close", kind: ButtonKind.filled }];
default-action: 0;
cancel-action: 0;
action(i) => {
root.closed();
}
VerticalLayout {
spacing: Theme.space-2;
for row in root.info.rows: Line {
label: row.label;
value: row.value;
}
Line {
label: "Size";
value: root.info.size;
}
if root.info.contents != "": Line {
label: "Contains";
value: root.info.contents;
}
if root.info.has-perms: VerticalLayout {
spacing: Theme.space-1;
padding-top: Theme.space-2;
Text {
text: "Permissions " + root.info.perm-text;
color: Theme.primary;
font-size: Theme.label-medium.size;
font-weight: Theme.label-medium.weight;
}
HorizontalLayout {
spacing: Theme.space-2;
Rectangle {
width: 96px;
}
for name in ["Read", "Write", "Run"]: Text {
width: 56px;
text: name;
color: Theme.on-surface-variant;
font-size: Theme.body-small.size;
font-weight: Theme.body-small.weight;
horizontal-alignment: center;
}
}
PermissionRow {
who: "Owner";
perms: root.info.perms;
first: 0;
}
PermissionRow {
who: "Group";
perms: root.info.perms;
first: 3;
}
PermissionRow {
who: "Others";
perms: root.info.perms;
first: 6;
}
}
}
}