diff --git a/Cargo.lock b/Cargo.lock index 7b4434a..7da098a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4244,14 +4244,14 @@ dependencies = [ [[package]] name = "tempo-ui" -version = "0.1.0" +version = "0.5.0" dependencies = [ "slint", ] [[package]] name = "tempo-ui-showcase" -version = "0.1.0" +version = "0.5.0" dependencies = [ "png", "slint", diff --git a/Cargo.toml b/Cargo.toml index 3e6cd23..4a34f5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["examples/showcase"] resolver = "3" [workspace.package] -version = "0.1.0" +version = "0.5.0" edition = "2024" rust-version = "1.95" license = "MIT" @@ -15,7 +15,7 @@ slint-build = "=1.19.1" [package] name = "tempo-ui" -description = "Rust helpers for the Tempo UI component library for Slint" +description = "Tempo UI — a crisp, cross-platform Slint component library and Rust host helpers" version.workspace = true edition.workspace = true rust-version.workspace = true @@ -25,7 +25,7 @@ publish = false [features] default = [] -finui-font-fallback = ["dep:slint"] +cjk-font-fallback = ["dep:slint"] [dependencies] slint = { workspace = true, optional = true, features = ["std", "unstable-fontique-012", "compat-1-2"] } diff --git a/README.md b/README.md index cd76c40..a96178c 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,48 @@ -# Tempo UI +# Tempo UI `v0.5.0` -Tempo UI is a Slint component library derived from FinUI. It includes themed controls, responsive navigation, dialogs and sheets, refreshable and reorderable lists, motion helpers, and a set of Fluent icons. The Slint components share a single import. The optional Rust helpers cover route history and CJK font fallback. +**Tempo UI** 是一套面向 Rust + Slint 跨平台应用的现代组件库,专注于克制的几何比例、清晰的多层表面对比与一致的交互动效,覆盖桌面宽屏与移动窄屏的完整使用场景。 ![Tempo UI desktop component gallery](docs/images/catalog-desktop.png) -## Run the showcase +## 设计特色 -Use Rust 1.95 or later and a desktop graphical session. +- **克制圆角与柔和配色**:采用 `4px / 6px / 8px / 10px` 克制圆角与清晰 `1px` 描边;亮/暗两套主题均避免刺眼的纯白(`#FFFFFF`)与纯黑(`#000000`),通过画布、侧边栏、卡片与浮层四级表面色自然拉开空间层次。 +- **桌面与移动一体化适配**:`TempoNavigationShell` 自动在桌面展开侧边栏、窄 Rail(含贴底统一页面切换的 `footer-destinations`)与移动端底部导航栏之间切换;`TempoToastHost` 在桌面端以右上角通知卡片展示,在移动端以底部居中紧凑条展示;`TempoTransfer`、`TempoDatePicker`、`TempoTimePicker` 均内置窄屏布局与视口边界防溢出。 +- **统一动效体系**:全库统一使用快速响应、平滑落位的减速缓动曲线,提供 `TempoRouteTransition`(`none` / `fade-through` / `shared-axis-x` / `shared-axis-y`)及全局 `TempoMotionSettings.reduced` 减弱动态开关。 +- **跨平台 CJK 字体回退**:内置 `tempo_ui::fonts::configure_cjk_fallbacks()`,为 Slint/fontique 补全简体/繁体中文、日文、韩文的多区域与通用无衬线回退链,解决 Linux / Windows / macOS / Android 上的汉字豆腐块与混排错字问题。 + +## 组件一览(58+) + +| 分类 | 组件 | +| :--- | :--- | +| **按钮与操作** | `TempoButton`(7 种语义变体)、`TempoIconButton`、`TempoSplitButton`、`TempoFloatingActionButton`、`TempoLink`、`TempoMenuButton` | +| **表单与选择** | `TempoTextField`(内置清除与密码显隐)、`TempoTextArea`、`TempoSearch`、`TempoComboBox`、`TempoDatePicker`、`TempoTimePicker`、`TempoCheckBox`、`TempoRadioButton`、`TempoSwitch`、`TempoSpinBox`、`TempoSlider`、`TempoRangeSlider`、`TempoRate`、`TempoChip`、`TempoColorPicker`、`TempoSelectionTile`、`TempoRadioTile`、`TempoSwitchTile`、`TempoSegmentedControl` | +| **导航与布局** | `TempoNavigationShell`、`TempoNav`、`TempoAppBar`、`TempoPageHead`、`TempoPage`、`TempoAdaptiveSplit`、`TempoSplitPane`、`TempoTabBar`、`TempoButtonGroupTabBar`、`TempoBreadcrumb`、`TempoPagination`、`TempoStepBar`、`TempoIndexedStack`、`TempoVirtualList`、`TempoReorderList`、`TempoRefresh` | +| **反馈与浮层** | `TempoDialog`、`TempoSheet`、`TempoDrawer`、`TempoPopover`、`TempoImageViewer`、`TempoToastHost`、`TempoInfoBar`、`TempoBanner`、`TempoProgressBar`、`TempoProgressRing`、`TempoLoadingOverlay`、`TempoEmptyState`、`TempoSkeleton` | +| **数据与展示** | `TempoSurface`、`TempoClickableSurface`、`TempoCard`、`TempoSection`、`TempoTile`、`TempoExpander`、`TempoTable`、`TempoTreeView`、`TempoCalendar`、`TempoCarousel`、`TempoTransfer`、`TempoTimeline`、`TempoStatCard`、`TempoKeyValue`、`TempoAvatar`、`TempoBadge`、`TempoTag`、`TempoStatusDot`、`TempoKeyCap`、`TempoDivider` | + +## 运行 Showcase + +需要 Rust 1.95+ 及图形环境: ```sh cargo run --release --locked -p tempo-ui-showcase ``` -| Arguments after `--` | Showcase | -| --- | --- | -| `--compact --dark` | Narrow dark layout | -| `--layout --wide` | Three-pane layout | -| `--lists` | Virtualized list, queue reordering, and action menu | -| `--music` | FMusic-inspired sample browser with simulated playback | +常用预览参数: -The showcase prefers FemtoVG and includes a software renderer. Set `SLINT_BACKEND=winit-software` to select software rendering. See the [narrow layout](docs/images/catalog-compact.png) and [list controls](docs/images/flutter-replacements-compact.png). +```sh +cargo run -p tempo-ui-showcase -- --dark # 暗色桌面 +cargo run -p tempo-ui-showcase -- --wide # 宽屏展开侧边栏与三栏布局 +cargo run -p tempo-ui-showcase -- --compact # 移动端窄屏布局 +cargo run -p tempo-ui-showcase -- --compact --dark # 移动端暗色 +``` -## Use the components +支持 FemtoVG 与软件渲染器,可通过 `SLINT_BACKEND=winit-software` 切换软件渲染。 -Add Tempo UI to your application checkout, for example under `vendor/TempoUI`. Use Slint and `slint-build` 1.19.1 to match the tested version. Register the library entry from your application's `build.rs`. +## 快速接入 + +在应用 `build.rs` 中注册 `@tempo-ui` 库入口(推荐匹配 Slint `1.19.1`): ```rust use std::{collections::HashMap, env, path::PathBuf}; @@ -39,30 +58,47 @@ fn main() { } ``` +在 `main.rs` 创建窗口前启用 CJK 字体回退(开启 `cjk-font-fallback` feature): + +```rust +fn main() -> Result<(), Box> { + tempo_ui::fonts::configure_cjk_fallbacks()?; + // 创建并运行 Slint 窗口... + Ok(()) +} +``` + +在 `.slint` 中直接导入组件: + ```slint -import { TempoButton, TempoTheme } from "@tempo-ui"; +import { TempoButton, TempoCard, TempoTheme } from "@tempo-ui"; export component App inherits Window { background: TempoTheme.background; VerticalLayout { padding: 16px; - TempoButton { label: "Continue"; } + TempoCard { + title: "Hello Tempo UI"; + TempoButton { label: "Continue"; } + } } } ``` -The [showcase build script](examples/showcase/build.rs) uses this same import mechanism. For Rust route history, add `tempo-ui = { path = "vendor/TempoUI" }` under `[dependencies]`. Enable the `finui-font-fallback` feature to use `tempo_ui::fonts::configure_finui_fallbacks()` before constructing a window. - -## Verification +## 验证与测试 ```sh cargo test --workspace --locked ./scripts/check.sh ``` -The smoke checks require a graphical session and cover wide and narrow layouts, keyboard and pointer input, overlays, refresh, list virtualization, and animations. GitHub Actions runs the software-renderer checks on Linux. See the [FinUI component mapping](docs/PORTING.md) and [Flutter-to-Slint implementation notes](docs/REPLACEMENTS.md) for the scope of platform-specific behavior. +## 致谢 + +- 衷心感谢 **[HandyControl](https://github.com/HandyOrg/HandyControl)**(WPF 开源控件库):Tempo UI `v0.5.0` 的视觉语言、克制圆角比例、亮暗色彩分层、Growl 通知、语义色体系及大量桌面组件设计均深受 HandyControl 启发。 +- 感谢 **Microsoft Fluent Design** 与 **Fluent System Icons** 提供的交互规范与图标资源。 +- 感谢 **Material Design 3** 的动效规范与 **Slint** 团队打造的跨平台 UI 引擎。 -## License +## 许可证 -Tempo UI uses the [MIT license](LICENSE). Attribution for the FinUI adaptation and Microsoft Fluent System Icons is in [LICENSES](LICENSES/). +本项目基于 [MIT License](LICENSE) 开源。第三方声明见 [LICENSES](LICENSES/)。 diff --git a/docs/PORTING.md b/docs/PORTING.md deleted file mode 100644 index d21a8f9..0000000 --- a/docs/PORTING.md +++ /dev/null @@ -1,59 +0,0 @@ -# FinUI → Tempo UI 对照 - -按 Flutter 版 `lib/fin_ui.dart` 的 **29 个公开导出文件**逐项对照。下面每项已有可用对应,合并模块不重复计组件。迁移的是 Slint/Rust 的外观和功能,不兼容 Dart Widget、Flutter 路由或插件 API。 - -| FinUI 导出文件 | Tempo UI 对应实现 | -| --- | --- | -| `app_bar` | `TempoAppBar` | -| `app_bottom_tab_bar` | `TempoNav` 的底栏模式 | -| `app_button_group_tab_bar` | `TempoButtonGroupTabBar`,含图标模式和按选项宽度滑动的选中块 | -| `app_button` | `TempoButton`,含变体、禁用态和加载态 | -| `app_colors` | `TempoTheme` 的浅色、深色和强调色 | -| `app_combo_box` | `TempoComboBox`,窄屏底部选择面板、宽屏锚定下拉,支持禁用项和键盘选择 | -| `app_context` | `TempoTheme` 全局语义色,替代 Flutter 主题上下文扩展 | -| `app_dialog` | `TempoDialog`,宽窄屏居中,支持滚动内容、确认/取消、遮罩和 Esc | -| `app_empty_state` | `TempoEmptyState` | -| `app_floating_action_button` | `TempoFloatingActionButton`,常规和紧凑大小 | -| `app_icon_button` | `TempoIconButton`,含变体、加载和提示 | -| `app_icons` | `TempoIcons`,60 个别名对应 58 个官方 SVG | -| `app_page` | `TempoPage`,含滚动、边距和安全区 | -| `app_progress_bar` | `TempoProgressBar`,确定与不确定进度模式 | -| `app_refresh` | `TempoRefresh`、`TempoRefreshText`,刷新、加载、结束状态和原版五语种文案 | -| `app_section` | `TempoSection` + `TempoDivider`。Slint 子节点间显式放分隔线 | -| `app_segmented_control` | `TempoSegmentedControl` | -| `app_selection_tile` | `TempoSelectionTile`、`TempoRadioTile` | -| `app_slider` | `TempoSlider`,范围、步进、禁用、键盘与指针操作 | -| `app_surface` | `TempoSurface`、`TempoClickableSurface` | -| `app_tag` | `TempoTag`,五种变体和可选图标 | -| `app_text_field` | `TempoTextField`、`TempoSearch`,普通/密码/数字/搜索输入和编辑/提交事件 | -| `app_tile` | `TempoTile`,图标前缀、自定义尾部内容和尾部图标 | -| `app_toast` | `TempoToastHost`,底部胶囊、四种状态、超时、手动关闭和替换 | -| `app_tokens` | `TempoTokens` | -| `fui_adaptive_split` | `TempoAdaptiveSplit`,紧凑页/底部面板/弹窗、双栏和三栏 | -| `fui_navigation` | `TempoNavigationShell`、`TempoNavigationContent`、`TempoNav` + Rust `RouteStacks` | -| `fui_page_head` | `TempoPageHead` | -| `fui_theme` | `TempoTheme` + 宿主字体回退,支持宿主明确设置或读取 Slint 提供的配色 | - -## 五轮交付记录 - -1. 补下拉框、对话框、Toast、浮动按钮、刷新和独立按钮组标签栏。 -2. 补页面栏、滚动页、页面标题、自适应分栏和导航历史。完善通用输入、进度/步进、单选、主题和图标。 -3. 用临时 Flutter 3.44.0 环境跑原库 15 个测试,另加同尺寸截图夹具。对照修复了初始图标标签选中块、Toast 位置、窄屏详情遮盖底栏和桌面侧栏视觉差异。 -4. 用 Slint 的原生指针和键盘事件验证了标签点击、输入提交、禁用下拉项、弹窗 Esc、受控刷新、分页结束和模拟安全区。验证窄屏、普通桌面、超宽分栏及两个渲染器。截图不是像素级金标。 -5. 整理公共导出、可重复检查脚本、截图和使用说明。发布构建内嵌 SVG 等资源,不依赖原 Flutter 工作区。 - -## 保留的实现差异和平台验收边界 - -- Flutter 的 Widget 插槽、路由转场、Hero 和 GetX root overlay 不直接移植。Slint 由宿主提供导航内容和返回事件,Toast 使用每窗口的 Host。当前不实现 Flutter 的 Android predictive-back 转场和 Cupertino 交互式返回动画。 -- 安全区接的是 Slint Window 输入,并测了合成 inset。系统状态栏样式、触屏惯性与输入法、系统自动填充、TalkBack/VoiceOver 和原生返回手势仍需实际移动端宿主验收。Windows、Android 和 iOS 没有本轮真机验证。 -- 平台强调色和字体以宿主能提供的信息为准。当前支持手动语义色、Slint 平台配色入口及已安装字体回退。不同系统和渲染器的字形、行高、阴影和动效不承诺像素相同。 -- Flutter 的 `EasyRefresh` 自定义物理、控制器插件和横向滚动模式不作为 Slint API。当前纵向刷新提供下拉、分页、结果与可定制阈值/文案。 -- 音乐库横幅、曲目行和迷你播放器仍是 FMusic 演示,不是原 FinUI 控件或正式客户端。长列表、真实音频和自建服务端没有加入这次 UI 移植。 - -## 组件截图 - -- [桌面组件展板](images/catalog-desktop.png) -- [窄屏深色展板](images/catalog-compact.png) -- [窄屏列表和排序](images/flutter-replacements-compact.png) - -Flutter 原始对照和截图夹具位于移植时使用的 FMusic 工作区。 diff --git a/docs/REPLACEMENTS.md b/docs/REPLACEMENTS.md deleted file mode 100644 index 26b97a9..0000000 --- a/docs/REPLACEMENTS.md +++ /dev/null @@ -1,30 +0,0 @@ -# Flutter 平替复核 - -范围是 FinUI 的 Flutter 基元,以及 FMusic 曲库、歌单、队列页直接依赖的列表和菜单。这里区分现成控件、需要在 Tempo UI 保留的产品行为,以及平台宿主职责。 - -| Flutter / FinUI 的用法 | Slint 的可用基元 | Tempo UI 的选择 | -| --- | --- | --- | -| Row / Column / Stack / Align / Padding / LayoutBuilder | HorizontalLayout、VerticalLayout、Rectangle、宽高绑定 | 直接使用。响应式栏宽和安全区集中在 `TempoNavigationShell`、`TempoAdaptiveSplit` | -| Wrap | FlexboxLayout | 直接用它。对话框动作栏已使用自动换行,不在应用中重复计算宽度 | -| ThemeData / ThemeExtension / MediaQuery | Palette、Window 的宽高与 safe-area-insets | `TempoTheme`、`TempoInsets`。动态系统强调色取决于后端 | -| ListView.builder / SliverList.builder | ListView 的直接 model repeater | `TempoVirtualList`,直接重导出原生 ListView,保留编译器的行虚拟化。VirtualList 展板实际挂了 5,000 行 | -| CustomScrollView / SliverPersistentHeader | ScrollView、ListView,没有一套等价的 Flutter sliver 协议 | 当前建议展板结构,即固定页面栏 + 一个虚拟列表,分组标题可作为数据行;未封装可折叠/吸顶 sliver 协议 | -| ReorderableListView.builder | 交互基元与 ListView,没有现成可排序列表 | `TempoReorderList`,固定行高、拖拽把手、边缘滚动、上/下移按钮。应用负责更新模型、权限和持久化 | -| PopupMenuButton | ContextMenuArea、PopupWindow;前者适合右键/长按上下文菜单 | `TempoMenuButton` 保留按钮锚定、禁用项和键盘操作。上下文菜单直接用原生 ContextMenuArea | -| IndexedStack | 常驻节点 + visible,没有专用 IndexedStack | `TempoIndexedStack`、`TempoStackPage`。调用者绑定索引,不用条件实例化反复卸载当前页 | -| Navigator / MaterialPageRoute / showModalBottomSheet | PopupWindow、FocusScope、Window,不提供完整路径栈 | `RouteStacks` + `TempoRouteMotion`、`TempoDialog`、`TempoSheet`。交互式系统返回仍需要宿主适配 | -| Dialog content / arbitrary actions、TextField suffix | @children 单插槽;可用模型描述动作 | Dialog 支持任意内容 + 自定义动作模型,动作栏换行。输入框后缀是原生插槽。不能传递任意 Flutter Widget | -| ListTile leading / trailing | Slint 子项、图标、布局 | `TempoTile` 已有图标前缀和任意尾部插槽。非图标前缀用自定义行,暂无通用双命名插槽 | -| RefreshIndicator / EasyRefresh / OverlayEntry | SwipeGestureHandler、PopupWindow、Timer | `TempoRefresh`、`TempoToastHost`。不替换整个 Flutter 滚动物理或 GetX 约定 | -| TextField / FocusNode / Tooltip / Material 按键反馈 | TextInput、FocusScope、Tooltip、触摸和键盘事件 | Tempo 控件封装外观、编辑/提交、焦点、禁用与动效。自动填充和移动端软键盘动作标签走平台适配,不冒充 autofill | -| Checkbox / Radio / Slider / ProgressIndicator / IconButton | CheckBox、RadioGroup、Slider、ProgressIndicator、Button、Spinner | 通用原生控件直接可用。FinUI 外观继续使用 Tempo 封装 | - -## 本次动效 - -- `TempoPresence` 在关闭时保留视觉节点直到退出完成,避免直接靠 `if visible` 切掉动画。Toast 沿用 FinUI 的 180 ms 入场、120 ms 退场和 26 px 垂直偏移。 -- Dialog 在窗口中居中。Sheet 从底部进入。ComboBox 在窄屏使用底部面板,宽屏在控件旁展开,下面空间不足时优先向上展开。按钮菜单和 ComboBox 都有入场动画。 -- `TempoRouteMotion` 提供程序级详情推进/回退动效。窄屏页从侧面过渡,底部详情从下方进入;它不是 Flutter 的手势驱动转场。 -- 保留并补齐标签指示条、分段选择、复选状态、焦点、刷新指示条和图标按钮反馈。可通过 `TempoMotionSettings.reduced` 关闭这些动效。Slint 也会在支持的后端自动遵循系统减少动态效果设置。 -- 运行 `cargo run --release --locked -p tempo-ui-showcase -- --motion-smoke` 检查真实中间帧、退出后释放弹层和减少动态效果,不以静态截图作为动效验收。 - -不属于本次 UI 封装范围的还有真实音频、文件选择实现、系统凭据,以及 Windows/Android/iOS 原生宿主验收。 diff --git a/docs/images/catalog-compact.png b/docs/images/catalog-compact.png index c4ca1d2..563b8cb 100644 Binary files a/docs/images/catalog-compact.png and b/docs/images/catalog-compact.png differ diff --git a/docs/images/catalog-desktop.png b/docs/images/catalog-desktop.png index 5e32937..06e8653 100644 Binary files a/docs/images/catalog-desktop.png and b/docs/images/catalog-desktop.png differ diff --git a/docs/images/flutter-replacements-compact.png b/docs/images/flutter-replacements-compact.png deleted file mode 100644 index 5e50c7e..0000000 Binary files a/docs/images/flutter-replacements-compact.png and /dev/null differ diff --git a/docs/images/list-controls-compact.png b/docs/images/list-controls-compact.png new file mode 100644 index 0000000..fd62261 Binary files /dev/null and b/docs/images/list-controls-compact.png differ diff --git a/examples/showcase/Cargo.toml b/examples/showcase/Cargo.toml index 19e2d69..3a90214 100644 --- a/examples/showcase/Cargo.toml +++ b/examples/showcase/Cargo.toml @@ -8,7 +8,7 @@ repository.workspace = true publish = false [dependencies] -tempo-ui = { path = "../..", features = ["finui-font-fallback"] } +tempo-ui = { path = "../..", features = ["cjk-font-fallback"] } slint = { workspace = true, features = ["std", "backend-winit", "renderer-femtovg", "renderer-software", "accessibility", "compat-1-2"] } png = "0.18" diff --git a/examples/showcase/build.rs b/examples/showcase/build.rs index 72d945b..ec86825 100644 --- a/examples/showcase/build.rs +++ b/examples/showcase/build.rs @@ -8,5 +8,6 @@ fn main() { let config = slint_build::CompilerConfiguration::new() .with_library_paths(libraries) .embed_resources(slint_build::EmbedResourcesKind::EmbedFiles); - slint_build::compile_with_config("ui/demo.slint", config).expect("compile Tempo UI showcase"); + slint_build::compile_with_config("ui/catalog.slint", config) + .expect("compile Tempo UI showcase"); } diff --git a/examples/showcase/src/main.rs b/examples/showcase/src/main.rs index b78874c..05cf637 100644 --- a/examples/showcase/src/main.rs +++ b/examples/showcase/src/main.rs @@ -19,9 +19,6 @@ type Result = std::result::Result>; struct Options { compact: bool, dark: bool, - settings: bool, - catalog: bool, - music: bool, wide: bool, layout: bool, lists: bool, @@ -37,27 +34,21 @@ fn options() -> Result { match arg.as_str() { "--compact" => options.compact = true, "--dark" => options.dark = true, - "--settings" => options.settings = true, - "--catalog" => options.catalog = true, - "--music" => options.music = true, "--wide" => options.wide = true, "--layout" => { - options.catalog = true; options.layout = true; } "--lists" => { - options.catalog = true; options.lists = true; } "--motion-smoke" => { - options.catalog = true; options.motion_smoke = true; } "--screenshot" => options.screenshot = Some(args.next().ok_or("missing PNG path")?), "--smoke" => options.smoke = true, "--help" | "-h" => { println!( - "tempo-ui-showcase [--compact] [--dark] [--catalog|--music|--settings|--layout|--lists] [--wide] [--screenshot PATH] [--smoke|--motion-smoke]" + "tempo-ui-showcase [--compact] [--dark] [--layout|--lists] [--wide] [--screenshot PATH] [--smoke|--motion-smoke]" ); std::process::exit(0); } @@ -67,89 +58,6 @@ fn options() -> Result { Ok(options) } -fn filtered(tracks: &[DemoTrack], query: &str) -> Vec { - let query = query.trim().to_lowercase(); - tracks - .iter() - .filter(|track| { - [&track.title, &track.artist, &track.record] - .into_iter() - .any(|field| field.to_lowercase().contains(&query)) - }) - .cloned() - .collect() -} - -fn queue_index(current: i32, delta: i32, length: i32) -> Option { - (length > 0).then(|| (current + delta).rem_euclid(length)) -} - -fn select(ui: &DemoWindow, index: i32) { - ui.set_current(index); - ui.set_position(0.0); - ui.set_playing(true); -} - -fn wire(ui: &DemoWindow) { - let tracks = Rc::new(ui.get_tracks().iter().collect::>()); - let visible = Rc::new(VecModel::from(tracks.as_ref().clone())); - ui.set_shown_tracks(visible.clone().into()); - let data = tracks.clone(); - ui.on_filter(move |query| visible.set_vec(filtered(&data, &query))); - - let weak = ui.as_weak(); - let data = tracks.clone(); - ui.on_choose(move |title| { - if let (Some(ui), Some(index)) = ( - weak.upgrade(), - data.iter().position(|track| track.title == title), - ) { - select(&ui, index as i32); - } - }); - - let weak = ui.as_weak(); - let length = tracks.len() as i32; - ui.on_step(move |delta| { - if let Some(ui) = weak.upgrade() { - if let Some(index) = queue_index(ui.get_current(), delta, length) { - select(&ui, index); - } - } - }); - - let timer = Timer::default(); - let weak = ui.as_weak(); - ui.on_playback_changed(move |playing| { - if !playing { - timer.stop(); - return; - } - let weak = weak.clone(); - let tracks = tracks.clone(); - let last_tick = Cell::new(Instant::now()); - timer.start( - slint::TimerMode::Repeated, - Duration::from_millis(200), - move || { - let Some(ui) = weak.upgrade() else { return }; - if !ui.get_playing() { - return; - } - let now = Instant::now(); - let elapsed = now.duration_since(last_tick.replace(now)).as_secs_f32(); - let track = &tracks[ui.get_current() as usize]; - let position = ui.get_position() + elapsed / track.seconds as f32; - if position >= 1.0 { - ui.invoke_step(1); - } else { - ui.set_position(position); - } - }, - ); - }); -} - fn save_screenshot(window: &slint::Window, path: &Path) -> Result<()> { let snapshot = window.take_snapshot()?; let mut encoder = png::Encoder::new(File::create(path)?, snapshot.width(), snapshot.height()); @@ -170,10 +78,6 @@ fn click_in(window: &slint::Window, x: f32, y: f32) { window.dispatch_event(WindowEvent::PointerReleased { position, button }); } -fn click(ui: &DemoWindow, x: f32, y: f32) { - click_in(ui.window(), x, y); -} - fn drag(window: &slint::Window, x: f32, y: f32, dy: f32) { use slint::platform::{PointerEventButton, WindowEvent}; let start = slint::LogicalPosition::new(x, y); @@ -194,48 +98,6 @@ fn drag(window: &slint::Window, x: f32, y: f32, dy: f32) { }); } -fn smoke_check(ui: &DemoWindow, compact: bool, dark: bool) -> Result<()> { - if ui.get_compact() != compact || ui.get_dark() != dark { - return Err("initial viewport or theme did not apply".into()); - } - ui.invoke_filter(" NORTHBOUND ".into()); - if ui.get_shown_tracks().row_count() != 2 { - return Err("artist filter did not update the visible model".into()); - } - let window = ui.window(); - let size = window.size().to_logical(window.scale_factor()); - if compact { - click(ui, size.width * 0.625, size.height - 28.0); - } else { - click(ui, size.width - 39.0, size.height - 38.0); - } - if ui.get_page() != 2 { - return Err("queue navigation did not respond to pointer input".into()); - } - ui.invoke_choose("Sea Glass".into()); - if ui.get_page() != 2 || ui.get_current() != 2 || !ui.get_playing() || ui.get_position() != 0.0 - { - return Err("queue selection did not update player state".into()); - } - ui.invoke_step(-1); - if ui.get_current() != 1 { - return Err("previous track did not update the queue".into()); - } - click(ui, size.width - if compact { 37.0 } else { 47.0 }, 33.0); - if ui.get_dark() == dark { - return Err("theme control did not respond to pointer input".into()); - } - if compact { - click(ui, size.width * 0.875, size.height - 28.0); - } else { - click(ui, 60.0, 265.0); - } - if ui.get_page() != 3 { - return Err("settings showcase did not open".into()); - } - Ok(()) -} - fn sync_route(ui: &TempoCatalogWindow, stack: &navigation::RouteStacks, tab: usize) { ui.set_detail(stack.top(tab).copied().unwrap_or(-1)); ui.set_route_depth(stack.depth(tab) as i32); @@ -279,6 +141,122 @@ fn wire_catalog(ui: &TempoCatalogWindow) { queue.set_vec(items); } }); + let tree = Rc::new(VecModel::from(vec![ + TempoTreeNode { + label: "Music Library".into(), + depth: 0, + has_children: true, + expanded: true, + hidden: false, + icon: Default::default(), + }, + TempoTreeNode { + label: "Lossless FLAC".into(), + depth: 1, + has_children: true, + expanded: true, + hidden: false, + icon: Default::default(), + }, + TempoTreeNode { + label: "Midnight Echoes".into(), + depth: 2, + has_children: false, + expanded: false, + hidden: false, + icon: Default::default(), + }, + TempoTreeNode { + label: "Ambient Sessions".into(), + depth: 2, + has_children: false, + expanded: false, + hidden: false, + icon: Default::default(), + }, + TempoTreeNode { + label: "Offline Downloads".into(), + depth: 1, + has_children: false, + expanded: false, + hidden: false, + icon: Default::default(), + }, + ])); + ui.set_tree_nodes(tree.clone().into()); + ui.on_tree_toggle(move |idx| { + let Ok(idx) = usize::try_from(idx) else { + return; + }; + let mut nodes: Vec<_> = tree.iter().collect(); + if let Some(target) = nodes.get_mut(idx) + && target.has_children + { + target.expanded = !target.expanded; + let mut collapsed_at: Option = None; + for node in &mut nodes { + if let Some(depth) = collapsed_at { + if node.depth > depth { + node.hidden = true; + continue; + } else { + collapsed_at = None; + } + } + node.hidden = false; + if node.has_children && !node.expanded { + collapsed_at = Some(node.depth); + } + } + tree.set_vec(nodes); + } + }); + let transfer_src = Rc::new(VecModel::from(vec![ + slint::SharedString::from("Ambient"), + "Electronic".into(), + "Jazz".into(), + "Soundtrack".into(), + ])); + let transfer_dst = Rc::new(VecModel::from(vec![ + slint::SharedString::from("Lossless"), + "Favorites".into(), + ])); + ui.set_transfer_source(transfer_src.clone().into()); + ui.set_transfer_target(transfer_dst.clone().into()); + { + let src = transfer_src.clone(); + let dst = transfer_dst.clone(); + ui.on_transfer_to_target(move |idx| { + let Ok(idx) = usize::try_from(idx) else { + return; + }; + let mut s: Vec<_> = src.iter().collect(); + if idx < s.len() { + let item = s.remove(idx); + let mut d: Vec<_> = dst.iter().collect(); + d.push(item); + src.set_vec(s); + dst.set_vec(d); + } + }); + } + { + let src = transfer_src.clone(); + let dst = transfer_dst.clone(); + ui.on_transfer_to_source(move |idx| { + let Ok(idx) = usize::try_from(idx) else { + return; + }; + let mut d: Vec<_> = dst.iter().collect(); + if idx < d.len() { + let item = d.remove(idx); + let mut s: Vec<_> = src.iter().collect(); + s.push(item); + dst.set_vec(d); + src.set_vec(s); + } + }); + } let stack = Rc::new(RefCell::new(navigation::RouteStacks::default())); let weak = ui.as_weak(); let routes = stack.clone(); @@ -375,8 +353,8 @@ fn catalog_smoke_start( return Err("text input did not edit and submit through the keyboard".into()); } ui.invoke_open_combo(); - if !ui.get_combo_open() || ui.get_combo_is_sheet() != compact { - return Err("choice popup did not use the expected desktop or compact presentation".into()); + if !ui.get_combo_open() || ui.get_combo_is_sheet() { + return Err("choice popup did not open as a dropdown".into()); } press(ui.window(), Key::DownArrow); press(ui.window(), Key::Return); @@ -640,13 +618,24 @@ fn run_motion_smoke(ui: &TempoCatalogWindow, screenshot: Option) -> Resu if !sampled_route.get() || ui.get_detail_progress() < 0.98 { return Err("route transition had no intermediate frames or never settled".into()); } + ui.set_route_direction(0); + ui.set_detail(2); + stage.set(4); started.set(Instant::now()); + } + } + 4 => { + if mid(ui.get_detail_progress()) { ui.set_reduced_motion(true); + ui.invoke_pop_detail(); ui.invoke_show_dialog(); - if ui.get_dialog_progress() < 0.999 { + if ui.get_detail_progress() < 0.999 || ui.get_dialog_progress() < 0.999 { return Err("reduced motion did not bypass animation".into()); } return Ok(true); } + if elapsed >= Duration::from_millis(250) { + return Err("sibling destination did not animate".into()); + } } _ => {} } @@ -670,86 +659,6 @@ fn run_motion_smoke(ui: &TempoCatalogWindow, screenshot: Option) -> Resu } fn main() -> Result<()> { - let options = options()?; - tempo_ui::fonts::configure_finui_fallbacks()?; - if options.catalog || (!options.music && !options.settings) { - return run_catalog(options); - } - let ui = DemoWindow::new()?; - ui.set_dark(options.dark); - if options.settings { - ui.set_page(3); - } - wire(&ui); - if options.compact { - ui.window().set_size(LogicalSize::new(390.0, 780.0)); - } else { - ui.window().set_size(LogicalSize::new(1180.0, 820.0)); - } - - if options.screenshot.is_some() || options.smoke { - let outcome = Rc::new(std::cell::RefCell::new(None)); - let result = outcome.clone(); - let weak = ui.as_weak(); - Timer::single_shot(Duration::from_millis(450), move || { - let result_value = (|| -> Result<()> { - let ui = weak.upgrade().ok_or("preview disappeared before capture")?; - if let Some(path) = &options.screenshot { - save_screenshot(ui.window(), Path::new(path))?; - } - if options.smoke { - ui.set_page(0); - smoke_check(&ui, options.compact, options.dark)?; - println!("Tempo UI smoke check passed"); - } - Ok(()) - })(); - *result.borrow_mut() = Some(result_value); - let _ = slint::quit_event_loop(); - }); - ui.run()?; - return outcome - .borrow_mut() - .take() - .ok_or("preview closed before checks completed")?; - } - - ui.run()?; - Ok(()) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn filtering_matches_titles_artists_and_albums() { - let track = DemoTrack { - title: "Sea Glass".into(), - artist: "Northbound".into(), - record: "Coastline".into(), - ..Default::default() - }; - let tracks = [track]; - for query in ["", " GLASS ", "north", "coast"] { - assert_eq!(filtered(&tracks, query).len(), 1, "{query}"); - } - assert!(filtered(&tracks, "unknown").is_empty()); - } - - #[test] - fn reorder_keeps_the_moved_entry_and_validates_indexes() { - let mut entries = vec!["one", "two", "three"]; - assert!(move_index(&mut entries, 0, 2)); - assert_eq!(entries, ["two", "three", "one"]); - assert!(!move_index(&mut entries, 7, 0)); - assert_eq!(entries.len(), 3); - } - - #[test] - fn queue_wraps_in_both_directions() { - assert_eq!(queue_index(0, -1, 6), Some(5)); - assert_eq!(queue_index(5, 1, 6), Some(0)); - assert_eq!(queue_index(0, 1, 0), None); - } + tempo_ui::fonts::configure_cjk_fallbacks()?; + run_catalog(options()?) } diff --git a/examples/showcase/ui/assets/check.svg b/examples/showcase/ui/assets/check.svg deleted file mode 100644 index a2e77e9..0000000 --- a/examples/showcase/ui/assets/check.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/showcase/ui/assets/chevron.svg b/examples/showcase/ui/assets/chevron.svg deleted file mode 100644 index a9cf90f..0000000 --- a/examples/showcase/ui/assets/chevron.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/showcase/ui/assets/cover-0.svg b/examples/showcase/ui/assets/cover-0.svg deleted file mode 100644 index f2eea8d..0000000 --- a/examples/showcase/ui/assets/cover-0.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/examples/showcase/ui/assets/cover-1.svg b/examples/showcase/ui/assets/cover-1.svg deleted file mode 100644 index ab53dbc..0000000 --- a/examples/showcase/ui/assets/cover-1.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/examples/showcase/ui/assets/cover-2.svg b/examples/showcase/ui/assets/cover-2.svg deleted file mode 100644 index 29fb65f..0000000 --- a/examples/showcase/ui/assets/cover-2.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/examples/showcase/ui/assets/cover-3.svg b/examples/showcase/ui/assets/cover-3.svg deleted file mode 100644 index 63d9732..0000000 --- a/examples/showcase/ui/assets/cover-3.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/examples/showcase/ui/assets/cover-4.svg b/examples/showcase/ui/assets/cover-4.svg deleted file mode 100644 index 43609d6..0000000 --- a/examples/showcase/ui/assets/cover-4.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/examples/showcase/ui/assets/cover-5.svg b/examples/showcase/ui/assets/cover-5.svg deleted file mode 100644 index 6160a40..0000000 --- a/examples/showcase/ui/assets/cover-5.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/examples/showcase/ui/assets/device.svg b/examples/showcase/ui/assets/device.svg deleted file mode 100644 index 0d11522..0000000 --- a/examples/showcase/ui/assets/device.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/showcase/ui/assets/library-filled.svg b/examples/showcase/ui/assets/library-filled.svg deleted file mode 100644 index a7d0027..0000000 --- a/examples/showcase/ui/assets/library-filled.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/showcase/ui/assets/library.svg b/examples/showcase/ui/assets/library.svg deleted file mode 100644 index 3646e45..0000000 --- a/examples/showcase/ui/assets/library.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/showcase/ui/assets/moon.svg b/examples/showcase/ui/assets/moon.svg deleted file mode 100644 index 1794c83..0000000 --- a/examples/showcase/ui/assets/moon.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/showcase/ui/assets/next.svg b/examples/showcase/ui/assets/next.svg deleted file mode 100644 index 8f5f0cb..0000000 --- a/examples/showcase/ui/assets/next.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/showcase/ui/assets/note.svg b/examples/showcase/ui/assets/note.svg deleted file mode 100644 index 552748f..0000000 --- a/examples/showcase/ui/assets/note.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/showcase/ui/assets/pause.svg b/examples/showcase/ui/assets/pause.svg deleted file mode 100644 index c98f268..0000000 --- a/examples/showcase/ui/assets/pause.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/showcase/ui/assets/play.svg b/examples/showcase/ui/assets/play.svg deleted file mode 100644 index 6d9d6af..0000000 --- a/examples/showcase/ui/assets/play.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/showcase/ui/assets/prev.svg b/examples/showcase/ui/assets/prev.svg deleted file mode 100644 index 934b64e..0000000 --- a/examples/showcase/ui/assets/prev.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/showcase/ui/assets/queue.svg b/examples/showcase/ui/assets/queue.svg deleted file mode 100644 index 6d72910..0000000 --- a/examples/showcase/ui/assets/queue.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/showcase/ui/assets/search.svg b/examples/showcase/ui/assets/search.svg deleted file mode 100644 index 54afa3e..0000000 --- a/examples/showcase/ui/assets/search.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/showcase/ui/assets/settings-filled.svg b/examples/showcase/ui/assets/settings-filled.svg deleted file mode 100644 index e3b9c05..0000000 --- a/examples/showcase/ui/assets/settings-filled.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/showcase/ui/assets/settings.svg b/examples/showcase/ui/assets/settings.svg deleted file mode 100644 index cdb8776..0000000 --- a/examples/showcase/ui/assets/settings.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/showcase/ui/assets/sun.svg b/examples/showcase/ui/assets/sun.svg deleted file mode 100644 index 858b1b0..0000000 --- a/examples/showcase/ui/assets/sun.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/showcase/ui/assets/volume.svg b/examples/showcase/ui/assets/volume.svg deleted file mode 100644 index a10b013..0000000 --- a/examples/showcase/ui/assets/volume.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/showcase/ui/catalog.slint b/examples/showcase/ui/catalog.slint index 8f12f31..eb32a4b 100644 --- a/examples/showcase/ui/catalog.slint +++ b/examples/showcase/ui/catalog.slint @@ -1,14 +1,14 @@ import { TempoTheme, TempoIcons, TempoInsets, TempoNavigationShell, TempoPage, TempoPageHead, TempoAppBar, - TempoSection, TempoDivider, TempoButton, TempoIconButton, TempoFloatingActionButton, TempoButtonGroupTabBar, - TempoComboBox, TempoDialog, TempoToastHost, TempoTextField, TempoRadioTile, TempoSlider, TempoProgressBar, - TempoRefresh, TempoRefreshText, TempoSurface, TempoClickableSurface, TempoAdaptiveSplit, TempoDetailPresentation, - TempoPresence, TempoRouteMotion, TempoMotionSettings, TempoVirtualList, TempoReorderList, TempoReorderItem, + TempoSection, TempoCard, TempoInfoBar, TempoExpander, TempoPagination, TempoStepBar, TempoBreadcrumb, TempoAvatar, TempoStatCard, TempoProgressRing, TempoTimeline, TempoKeyValue, TempoBanner, TempoTabBar, TempoTable, TempoTreeView, TempoTreeNode, TempoColorPicker, TempoCalendar, TempoCarousel, TempoTransfer, TempoDivider, TempoButton, TempoIconButton, TempoFloatingActionButton, TempoButtonGroupTabBar, + TempoComboBox, TempoDialog, TempoDrawer, TempoPopover, TempoDatePicker, TempoTimePicker, TempoImageViewer, TempoToastHost, TempoTextField, TempoTextArea, TempoCheckBox, TempoRadioButton, TempoSpinBox, TempoBadge, TempoChip, TempoRate, TempoSkeleton, TempoSplitButton, TempoLink, TempoKeyCap, TempoStatusDot, TempoRadioTile, TempoSwitchTile, TempoSlider, TempoRangeSlider, TempoProgressBar, + TempoRefresh, TempoRefreshText, TempoSurface, TempoClickableSurface, TempoAdaptiveSplit, TempoDetailPresentation, TempoSplitPane, + TempoPresence, TempoRouteMotion, TempoRouteTransition, TempoMotionSettings, TempoVirtualList, TempoReorderList, TempoReorderItem, TempoMenuButton, TempoIndexedStack, TempoStackPage } from "@tempo-ui"; export component TempoCatalogWindow inherits Window { - title: "Tempo UI · FinUI comparison"; + title: "Tempo UI · Components"; preferred-width: 1180px; preferred-height: 820px; min-width: 340px; @@ -42,6 +42,10 @@ export component TempoCatalogWindow inherits Window { out property dialog-progress: modal.motion-progress; out property toast-progress: toasts.motion-progress; in property <[TempoReorderItem]> queue-samples; + in property <[TempoTreeNode]> tree-nodes; + in property <[string]> transfer-source; + in property <[string]> transfer-target; + in-out property carousel-index: 0; in-out property reorder-count; in-out property chosen-menu: -1; in-out property instantiated-rows; @@ -50,6 +54,9 @@ export component TempoCatalogWindow inherits Window { out property first-queue-entry: root.queue-samples.length > 0 ? root.queue-samples[0].label : ""; out property menu-open: menu.opened; callback reorder-request(int, int); + callback tree-toggle(int); + callback transfer-to-target(int); + callback transfer-to-source(int); public function open-actions() { menu.open(); } public function reveal-large-row() { scale-test.ensure-row-visible(3800, instant); } out property large-scroll-y: scale-test.content-y; @@ -95,6 +102,10 @@ export component TempoCatalogWindow inherits Window { {label: "Refresh", icon: TempoIcons.refresh}, {label: "Lists", icon: TempoIcons.list}, ]; + footer-destinations: [ + {label: "About", icon: TempoIcons.info, tooltip: "About"}, + {label: "Settings", icon: TempoIcons.settings, selected-icon: TempoIcons.settings-filled, tooltip: "Settings"}, + ]; retained := TempoIndexedStack { current-index <=> root.tab; controls := TempoPage { @@ -102,7 +113,7 @@ export component TempoCatalogWindow inherits Window { spacing: 16px; catalog-head := TempoPageHead { title: "Components"; - subtitle: "FinUI comparison · Tempo UI"; + subtitle: "Interactive component gallery"; TempoIconButton { label: "Toggle theme"; tooltip: "Toggle theme"; variant: outline; icon: root.dark ? TempoIcons.light-mode : TempoIcons.dark-mode; @@ -130,7 +141,7 @@ export component TempoCatalogWindow inherits Window { ]; } field := TempoTextField { - label: "Server"; placeholder: "Type the server name"; icon: TempoIcons.search; + label: "Server"; placeholder: "Type the server name"; icon: TempoIcons.search; clearable: true; text <=> root.field-value; submitted(value) => { root.submitted = value; } } TempoTextField { @@ -141,7 +152,6 @@ export component TempoCatalogWindow inherits Window { TempoTextField { label: "Input with validation"; error: "A name is required."; } selector := TempoComboBox { sheet-width: root.width; sheet-height: root.height; - use-bottom-sheet: shell.compact; sheet-origin: root.absolute-position; bottom-inset: root.insets.bottom; label: "Quality"; placeholder: "Choose a format"; selected <=> root.selected-choice; items: [{label: "Original", enabled: true}, {label: "FLAC (unavailable)", enabled: false}, {label: "MP3", enabled: true}]; @@ -158,6 +168,7 @@ export component TempoCatalogWindow inherits Window { HorizontalLayout { alignment: start; spacing: 8px; cross-axis-alignment: center; TempoButton { label: "Dialog"; compact: true; activated => { root.show-dialog(); } } + TempoButton { label: "Drawer"; compact: true; variant: outline; activated => { side-drawer.show(); } } TempoButton { label: "Toast"; compact: true; variant: secondary; activated => { toasts.show("Tempo UI", "One toast per window.", info, 2s); } } TempoIconButton { label: "Loading"; icon: TempoIcons.refresh; loading: true; } } @@ -171,6 +182,417 @@ export component TempoCatalogWindow inherits Window { } } } + TempoCard { + title: "Status & toggles"; + subtitle: "Cards, info bars, labeled dividers, and switches"; + TempoInfoBar { + title: "Synced with server"; + message: "Offline library and playback state are up to date."; + variant: success; + } + TempoInfoBar { + title: "Reduced motion"; + message: "Toggle below to bypass route and overlay animations."; + variant: primary; + } + TempoDivider { label: "PREFERENCES"; } + TempoSwitchTile { + icon: TempoIcons.palette; + label: "Dark theme"; + subtitle: "Switch between light and dark surface hierarchy"; + checked <=> root.dark; + } + TempoSwitchTile { + icon: TempoIcons.settings; + label: "Reduced motion"; + subtitle: "Disable transition animations across all TempoUI components"; + checked <=> root.reduced-motion; + } + } + TempoCard { + title: "Form & feedback controls"; + subtitle: "Semantic buttons, badges, checkbox/radio, spinbox, multiline input, expander, pagination"; + FlexboxLayout { + spacing: 8px; + flex-wrap: wrap; + TempoButton { label: "Primary"; compact: true; variant: primary; } + TempoButton { label: "Success"; compact: true; variant: success; } + TempoButton { label: "Warning"; compact: true; variant: warning; } + TempoButton { label: "Danger"; compact: true; variant: danger; } + TempoButton { label: "Outline"; compact: true; variant: outline; } + TempoBadge { + count: 12; + TempoIconButton { label: "Notifications"; icon: TempoIcons.notification; variant: outline; } + } + TempoBadge { + dot-only: true; + variant: success; + TempoIconButton { label: "Online"; icon: TempoIcons.person; variant: outline; } + } + } + HorizontalLayout { + spacing: 16px; + cross-axis-alignment: center; + TempoCheckBox { label: "Auto cache"; checked: true; } + TempoCheckBox { label: "Lossless only"; } + TempoRadioButton { label: "FLAC"; checked: root.radio-selected == 0; selected => { root.radio-selected = 0; } } + TempoRadioButton { label: "AAC"; checked: root.radio-selected == 1; selected => { root.radio-selected = 1; } } + } + HorizontalLayout { + spacing: 16px; + cross-axis-alignment: end; + TempoSpinBox { label: "Cache limit (GiB)"; value: 8; minimum: 1; maximum: 64; } + TempoPagination { current-page: 2; page-count: 5; } + } + TempoTextArea { + label: "Notes"; + placeholder: "Multiline notes with bottom accent focus bar…"; + } + TempoExpander { + icon: TempoIcons.info; + title: "Advanced details"; + subtitle: "Click to expand or collapse"; + Text { + text: "TempoExpander provides collapsible sections with crisp 1px borders and compact radius."; + color: TempoTheme.text-secondary; + font-size: 13px; + wrap: word-wrap; + } + } + } + TempoCard { + title: "Navigation & dashboard extensions"; + subtitle: "Breadcrumb, StepBar, Avatar, and KPI StatCards"; + TempoBreadcrumb { + items: ["Library", "Albums", "Midnight Echoes"]; + activated(idx) => { toasts.show("Breadcrumb", "Navigated to level " + (idx + 1), info, 2s); } + } + TempoStepBar { + steps: ["Prepare", "Upload", "Preview", "Confirm"]; + current: 2; + } + HorizontalLayout { + spacing: 12px; + cross-axis-alignment: center; + TempoAvatar { initials: "FM"; size: 38px; online: true; } + TempoAvatar { initials: "HC"; size: 38px; rounded-square: true; } + TempoAvatar { size: 38px; } + Rectangle { horizontal-stretch: 1; } + } + HorizontalLayout { + spacing: 10px; + TempoStatCard { + horizontal-stretch: 1; + icon: TempoIcons.apps; + label: "Tracks"; + value: "1,284"; + hint: "+24 this week"; + hint-variant: success; + } + TempoStatCard { + horizontal-stretch: 1; + icon: TempoIcons.save; + label: "Offline Cache"; + value: "3.6 GiB"; + hint: "42 albums saved"; + hint-variant: primary; + } + } + TempoDivider { label: "CHIPS, RATING & SKELETON"; } + FlexboxLayout { + spacing: 8px; + flex-wrap: wrap; + TempoChip { label: "FLAC"; selected: true; } + TempoChip { label: "Hi-Res"; icon: TempoIcons.check; selected: true; closable: true; closed => { toasts.show("Chip", "Removed Hi-Res filter.", info, 2s); } } + TempoChip { label: "Offline only"; } + TempoRate { value: 4; changed-value(v) => { toasts.show("Rating", "Rated " + v + " / 5", success, 2s); } } + } + HorizontalLayout { + spacing: 10px; + cross-axis-alignment: center; + TempoSkeleton { circle: true; bar-height: 36px; } + VerticalLayout { + horizontal-stretch: 1; + spacing: 6px; + TempoSkeleton { width: 160px; bar-height: 12px; } + TempoSkeleton { width: 100px; bar-height: 10px; } + } + } + FlexboxLayout { + spacing: 10px; + flex-wrap: wrap; + TempoSplitButton { + label: "Save"; + icon: TempoIcons.save; + primary-style: true; + activated => { toasts.show("Saved", "Primary split button clicked.", success, 2s); } + menu-requested => { toasts.show("Save options", "Split dropdown clicked.", info, 2s); } + } + TempoSplitButton { + label: "Export"; + activated => { toasts.show("Export", "Outline split button clicked.", info, 2s); } + menu-requested => { toasts.show("Export formats", "FLAC / WAV / MP3", info, 2s); } + } + TempoLink { + label: "Documentation"; + external: true; + activated => { toasts.show("Link", "Opened documentation link.", info, 2s); } + } + HorizontalLayout { + spacing: 4px; + cross-axis-alignment: center; + TempoKeyCap { text: "Ctrl"; } + TempoKeyCap { text: "K"; } + } + } + TempoDivider { label: "PROGRESS RING, TIMELINE, KEY-VALUE & BANNER"; } + TempoBanner { + message: "Offline mode active — showing cached library items."; + action-label: "Reconnect"; + variant: warning; + action => { toasts.show("Reconnect", "Reconnecting to server…", info, 2s); } + } + HorizontalLayout { + spacing: 16px; + cross-axis-alignment: center; + TempoProgressRing { value: root.stepped / 8; size: 58px; variant: primary; } + TempoProgressRing { value: 0.78; size: 58px; variant: success; } + VerticalLayout { + horizontal-stretch: 1; + spacing: 2px; + TempoKeyValue { label: "Server"; value: "https://music.local"; copyable: true; copied(v) => { toasts.show("Copied", v, success, 2s); } } + TempoKeyValue { label: "Format"; value: "FLAC · 24-bit / 96kHz"; } + TempoKeyValue { label: "Version"; value: "0.5.0"; } + } + } + TempoTabBar { + tabs: ["Overview", "Activity", "Storage", "Security"]; + selected: 0; + selected-index(i) => { toasts.show("Tab", "Switched to tab " + (i + 1), info, 1.5s); } + } + TempoTimeline { + items: [ + { title: "Import batch confirmed", subtitle: "12 tracks added to library", time: "2m ago", variant: success }, + { title: "Offline cache synced", subtitle: "3 albums verified on disk", time: "18m ago", variant: primary }, + { title: "Retry queued", subtitle: "1 file skipped due to hash change", time: "1h ago", variant: warning }, + ]; + } + } + TempoCard { + title: "Data Table, TreeView & ColorPicker"; + subtitle: "Structured data display, pickers, transfer, and split panes"; + TempoTable { + columns: ["Track", "Format", "Size", "Status"]; + rows: [ + ["Earthly Light", "FLAC 24-bit", "48.2 MiB", "Offline"], + ["Sea Glass", "FLAC 16-bit", "31.4 MiB", "Cached"], + ["Blue Hour", "AAC 256k", "8.6 MiB", "Cloud"], + ]; + selected-row: 0; + row-activated(r) => { toasts.show("Table", "Selected row " + (r + 1), info, 1.5s); } + } + TempoTreeView { + nodes: root.tree-nodes; + selected: 2; + toggled(i) => { root.tree-toggle(i); } + selected-index(i) => { toasts.show("TreeView", "Selected node " + (i + 1), info, 1.5s); } + } + if !shell.compact : HorizontalLayout { + spacing: 16px; + cross-axis-alignment: start; + TempoCalendar { + day-selected(d) => { toasts.show("Calendar", "Selected Nov " + d + ", 2026", info, 1.5s); } + prev-month => { toasts.show("Calendar", "Previous month", info, 1.2s); } + next-month => { toasts.show("Calendar", "Next month", info, 1.2s); } + } + VerticalLayout { + horizontal-stretch: 1; + spacing: 12px; + TempoColorPicker { + label: "Accent swatch"; + color-changed(c) => { toasts.show("ColorPicker", "Swatch updated.", success, 1.5s); } + } + HorizontalLayout { + spacing: 8px; + alignment: start; + Rectangle { + width: 120px; height: 34px; + TempoButton { + x: 0px; y: 0px; + label: "Open Popover"; + variant: outline; + compact: true; + activated => { demo-popover-wide.toggle(); } + } + demo-popover-wide := TempoPopover { + x: 0px; y: 0px; + width: 120px; height: 34px; + title: "Quick Filter"; + subtitle: "Anchored contextual flyout card."; + TempoCheckBox { label: "Only FLAC"; checked: true; } + TempoCheckBox { label: "Downloaded"; } + } + } + TempoButton { + label: "Image Viewer"; + variant: outline; + compact: true; + activated => { viewer.show(); } + } + } + TempoCarousel { + count: 3; + current <=> root.carousel-index; + viewport-height: 100px; + Rectangle { + background: root.carousel-index == 0 ? TempoTheme.primary-soft + : root.carousel-index == 1 ? TempoTheme.success-soft : TempoTheme.warning-soft; + VerticalLayout { + padding-left: 46px; padding-right: 46px; + alignment: center; + spacing: 4px; + Text { + text: root.carousel-index == 0 ? "Slide 1 · Featured Album" + : root.carousel-index == 1 ? "Slide 2 · Offline Ready" : "Slide 3 · Smart Mix"; + color: TempoTheme.text-primary; + font-size: 14px; + font-weight: 700; + horizontal-alignment: center; + overflow: elide; + } + Text { + text: "Click arrows or dots to switch slides"; + color: TempoTheme.text-secondary; + font-size: 12px; + horizontal-alignment: center; + overflow: elide; + } + } + } + } + } + } + if shell.compact : VerticalLayout { + spacing: 12px; + TempoCalendar { + day-selected(d) => { toasts.show("Calendar", "Selected Nov " + d + ", 2026", info, 1.5s); } + prev-month => { toasts.show("Calendar", "Previous month", info, 1.2s); } + next-month => { toasts.show("Calendar", "Next month", info, 1.2s); } + } + TempoColorPicker { + label: "Accent swatch"; + color-changed(c) => { toasts.show("ColorPicker", "Swatch updated.", success, 1.5s); } + } + HorizontalLayout { + spacing: 8px; + alignment: start; + TempoButton { + label: "Image Viewer"; + variant: outline; + compact: true; + activated => { viewer.show(); } + } + } + TempoCarousel { + count: 3; + current <=> root.carousel-index; + viewport-height: 96px; + Rectangle { + background: root.carousel-index == 0 ? TempoTheme.primary-soft + : root.carousel-index == 1 ? TempoTheme.success-soft : TempoTheme.warning-soft; + VerticalLayout { + padding-left: 46px; padding-right: 46px; + alignment: center; + spacing: 4px; + Text { + text: root.carousel-index == 0 ? "Slide 1 · Featured Album" + : root.carousel-index == 1 ? "Slide 2 · Offline Ready" : "Slide 3 · Smart Mix"; + color: TempoTheme.text-primary; + font-size: 13px; + font-weight: 700; + horizontal-alignment: center; + overflow: elide; + } + Text { + text: "Swipe / tap arrows or dots"; + color: TempoTheme.text-secondary; + font-size: 11px; + horizontal-alignment: center; + overflow: elide; + } + } + } + } + } + TempoDivider { label: "DATE / TIME PICKER, RANGE SLIDER & STATUS"; } + HorizontalLayout { + spacing: 12px; + TempoDatePicker { + horizontal-stretch: 1; + sheet-width: root.width; sheet-height: root.height; + sheet-origin: root.absolute-position; bottom-inset: root.insets.bottom; + label: "Release date"; + value-text: "2026-11-" + (self.selected-day < 10 ? "0" : "") + self.selected-day; + day-selected(d) => { toasts.show("DatePicker", "Picked Nov " + d, info, 1.5s); } + } + TempoTimePicker { + horizontal-stretch: 1; + sheet-width: root.width; sheet-height: root.height; + sheet-origin: root.absolute-position; bottom-inset: root.insets.bottom; + label: "Scheduled sync"; + hour: 22; minute: 30; + time-changed(h, m) => { toasts.show("TimePicker", "Set " + h + ":" + m, info, 1.5s); } + } + } + TempoRangeSlider { + low: 0.25; high: 0.75; + } + HorizontalLayout { + spacing: 16px; + TempoStatusDot { label: "Connected"; variant: success; } + TempoStatusDot { label: "Syncing"; variant: primary; } + TempoStatusDot { label: "Rate limited"; variant: warning; } + TempoStatusDot { label: "Offline"; variant: danger; } + } + TempoDivider { label: "TRANSFER & RESIZABLE SPLIT PANE"; } + TempoTransfer { + compact: shell.compact; + source-title: "Library Tags"; + target-title: "Active Filters"; + source-items: root.transfer-source; + target-items: root.transfer-target; + move-to-target(i) => { root.transfer-to-target(i); } + move-to-source(i) => { root.transfer-to-source(i); } + } + TempoSurface { + height: 92px; + clip: true; + split-demo := TempoSplitPane { + width: parent.width; + height: parent.height; + Rectangle { + x: 0px; y: 0px; width: split-demo.first-width; height: parent.height; + background: TempoTheme.surface-alt; + Text { + text: "Left Pane (" + round(split-demo.ratio * 100) + "%)"; + color: TempoTheme.text-secondary; + font-size: 12px; font-weight: 600; + horizontal-alignment: center; vertical-alignment: center; + } + } + Rectangle { + x: split-demo.second-x; y: 0px; width: split-demo.second-width; height: parent.height; + background: TempoTheme.surface; + Text { + text: "Drag center divider"; + color: TempoTheme.text-primary; + font-size: 12px; font-weight: 600; + horizontal-alignment: center; vertical-alignment: center; + } + } + } + } + } } layout-tab := FocusScope { visible: root.tab == 1; @@ -184,7 +606,7 @@ export component TempoCatalogWindow inherits Window { show-back: root.detail >= 0; back => { root.pop-detail(); } TempoIconButton { - icon: TempoIcons.palette; label: "Toggle theme"; + icon: TempoIcons.palette; variant: outline; label: "Toggle theme"; activated => { root.dark = !root.dark; } } } @@ -217,6 +639,7 @@ export component TempoCatalogWindow inherits Window { TouchArea {} route-motion := TempoRouteMotion { route-key: root.detail > 0 ? root.detail : 0; + transition: root.route-direction == 0 ? TempoRouteTransition.fade-through : TempoRouteTransition.shared-axis-x; direction: root.route-direction; enabled: root.detail >= 0; TempoPage { @@ -250,8 +673,8 @@ export component TempoCatalogWindow inherits Window { VerticalLayout { TempoAppBar { title: "Refresh"; subtitle: "Pull down or use the buttons"; - TempoIconButton { label: "Refresh"; icon: TempoIcons.refresh; activated => { refresh-pane.request-refresh(); } } - TempoIconButton { label: "Load more"; icon: TempoIcons.add; activated => { refresh-pane.request-load-more(); } } + TempoIconButton { label: "Refresh"; variant: outline; icon: TempoIcons.refresh; activated => { refresh-pane.request-refresh(); } } + TempoIconButton { label: "Load more"; variant: outline; icon: TempoIcons.add; activated => { refresh-pane.request-load-more(); } } } refresh-pane := TempoRefresh { can-load-more: true; @@ -269,8 +692,9 @@ export component TempoCatalogWindow inherits Window { index: 3; selected-index: retained.current-index; VerticalLayout { TempoAppBar { - title: "Flutter replacements"; subtitle: "Virtual list · reorder · action menu"; + title: "Lists and menus"; subtitle: "Virtual list · reorder · action menu"; menu := TempoMenuButton { + outline: true; items: [ { label: "Play", enabled: true }, { label: "Unavailable", enabled: false }, @@ -304,6 +728,44 @@ export component TempoCatalogWindow inherits Window { } } } + about-tab := TempoPage { + visible: root.tab == 4; + spacing: 16px; + TempoPageHead { + title: "About TempoUI"; + subtitle: "Opened directly from the desktop NavRail footer"; + } + TempoCard { + title: "TempoUI"; + subtitle: "Cross-platform Slint component library"; + TempoKeyValue { label: "Version"; value: "0.5.0"; } + TempoKeyValue { label: "Motion"; value: "Emphasized Decelerate"; } + TempoKeyValue { label: "Navigation"; value: "Unified Rail + Footer + Bottom Bar"; } + } + } + settings-tab := TempoPage { + visible: root.tab == 5; + spacing: 16px; + TempoPageHead { + title: "Settings"; + subtitle: "Opened directly from the desktop NavRail footer"; + } + TempoCard { + title: "Appearance & Motion"; + TempoSwitchTile { + icon: TempoIcons.palette; + label: "Dark theme"; + subtitle: "Switch between light and dark surface hierarchy"; + checked <=> root.dark; + } + TempoSwitchTile { + icon: TempoIcons.settings; + label: "Reduced motion"; + subtitle: "Bypass route and overlay animations"; + checked <=> root.reduced-motion; + } + } + } } } reveal := TempoPresence { @@ -322,6 +784,25 @@ export component TempoCatalogWindow inherits Window { confirmed => { root.confirmations += 1; toasts.show("Confirmed", "The dialog returned a result.", success, 2s); } Text { text: "This only changes the example."; color: TempoTheme.text-primary; wrap: word-wrap; } } + side-drawer := TempoDrawer { + width: root.width; + height: root.height; + title: "Inspector Drawer"; + subtitle: "Slide-in side panel"; + TempoInfoBar { + title: "Side Drawer"; + message: "Slides smoothly from the right (or left with from-left: true)."; + variant: primary; + } + TempoKeyValue { label: "Layout"; value: shell.compact ? "Compact" : shell.extended ? "Extended" : "Rail"; } + TempoKeyValue { label: "Theme"; value: root.dark ? "Dark" : "Light"; } + TempoButton { label: "Close"; variant: outline; compact: true; activated => { side-drawer.close(); } } + } + viewer := TempoImageViewer { + width: root.width; + height: root.height; + title: "Artwork Lightbox Preview"; + } toasts := TempoToastHost { bottom-inset: root.insets.bottom; left-inset: root.insets.left; right-inset: root.insets.right; } refresh-finish := Timer { interval: 250ms; running: false; diff --git a/examples/showcase/ui/demo.slint b/examples/showcase/ui/demo.slint deleted file mode 100644 index b1d800a..0000000 --- a/examples/showcase/ui/demo.slint +++ /dev/null @@ -1,457 +0,0 @@ -import { ScrollView } from "std-widgets.slint"; -import { - TempoTheme, TempoTokens, TempoAction, TempoButton, TempoIcon, TempoIconButton, TempoNav, - TempoSearch, TempoSlider, TempoSurface, TempoTag, TempoDestination, TempoSection, TempoDivider, - TempoSegmentedControl, TempoTile, TempoSelectionTile, TempoProgressBar, TempoEmptyState -} from "@tempo-ui"; - -export struct DemoTrack { - title: string, - artist: string, - record: string, - format: string, - duration: string, - seconds: int, - cover: image, -} - -component Cover inherits Rectangle { - in property artwork; - border-radius: TempoTokens.radius-sm; - clip: true; - background: TempoTheme.background-alt; - Image { source: root.artwork; image-fit: cover; } -} - -component TrackRow inherits TempoAction { - in property track; - in property active; - in property wide; - in property playing; - in property number; - label: "Play " + root.track.title; - min-height: TempoTokens.tile-min-height + 2px; - border-radius: TempoTokens.radius-sm; - background: root.active ? TempoTheme.primary-soft - : root.pressed ? TempoTheme.surface-pressed - : root.hovered ? TempoTheme.surface-alt : transparent; - HorizontalLayout { - padding-left: 10px; - padding-right: 12px; - spacing: 10px; - if root.wide : Text { - width: 24px; - text: root.number; - color: TempoTheme.text-secondary; - font-size: 12px; - horizontal-alignment: center; - vertical-alignment: center; - } - Cover { artwork: root.track.cover; width: 38px; height: 38px; cross-axis-self-alignment: center; border-radius: 7px; } - VerticalLayout { - horizontal-stretch: 1; - alignment: center; - spacing: 3px; - Text { - text: root.track.title; - color: root.active ? TempoTheme.primary : TempoTheme.text-primary; - font-size: 14px; - font-weight: 700; - overflow: elide; - } - Text { text: root.track.artist; color: TempoTheme.text-secondary; font-size: 11px; overflow: elide; } - } - if root.wide : Text { - width: 135px; - text: root.track.record; - color: TempoTheme.text-secondary; - font-size: 12px; - overflow: elide; - vertical-alignment: center; - } - if root.wide : Rectangle { - width: 58px; - TempoTag { label: root.track.format; x: 0px; width: self.preferred-width; } - } - Rectangle { - width: 16px; - if root.active : TempoIcon { - source: root.playing ? @image-url("assets/pause.svg") : @image-url("assets/play.svg"); - tint: TempoTheme.primary; - width: 16px; height: 16px; - } - } - Text { - width: 34px; - text: root.track.duration; - color: root.active ? TempoTheme.primary : TempoTheme.text-secondary; - font-size: 12px; - horizontal-alignment: right; - vertical-alignment: center; - } - } -} - -component PlayerDock inherits Rectangle { - in property track; - in property wide; - in property playing; - in-out property position; - in-out property volume; - out property elapsed: { - let seconds = floor(root.position * root.track.seconds); - let minutes = floor(seconds / 60); - let rest = seconds - minutes * 60; - return minutes + ":" + (rest < 10 ? "0" : "") + rest; - } - callback toggle(); - callback previous(); - callback next(); - callback queue(); - background: TempoTheme.surface; - min-height: root.wide ? 76px : 65px; - Rectangle { height: 1px; y: 0px; background: TempoTheme.border; } - if !root.wide : Rectangle { - height: 2px; y: 0px; x: 0px; - width: root.width * root.position; - background: TempoTheme.primary; - } - HorizontalLayout { - padding-left: root.wide ? 22px : 12px; - padding-right: root.wide ? 22px : 9px; - spacing: root.wide ? 12px : 7px; - Cover { artwork: root.track.cover; width: root.wide ? 48px : 38px; height: self.width; cross-axis-self-alignment: center; } - VerticalLayout { - min-width: root.wide ? 134px : 0px; - max-width: root.wide ? 134px : 10000px; - horizontal-stretch: root.wide ? 0 : 1; - alignment: center; - spacing: 3px; - Text { text: root.track.title; font-size: 13px; font-weight: 700; color: TempoTheme.text-primary; overflow: elide; } - Text { text: root.track.artist; font-size: 11px; color: TempoTheme.text-secondary; overflow: elide; } - } - if root.wide : TempoIconButton { - icon: @image-url("assets/prev.svg"); label: "Previous track"; size: 34px; - width: 34px; height: 34px; cross-axis-self-alignment: center; - activated => { root.previous(); } - } - TempoButton { - icon: root.playing ? @image-url("assets/pause.svg") : @image-url("assets/play.svg"); - label: root.playing ? "Pause preview" : "Play preview"; icon-only: true; - width: 42px; height: 42px; cross-axis-self-alignment: center; - activated => { root.toggle(); } - } - TempoIconButton { - icon: @image-url("assets/next.svg"); label: "Next track"; size: 34px; - width: 34px; height: 34px; cross-axis-self-alignment: center; - activated => { root.next(); } - } - if root.wide : Text { text: root.elapsed; width: 30px; font-size: 11px; color: TempoTheme.text-secondary; vertical-alignment: center; } - if root.wide : TempoSlider { value <=> root.position; horizontal-stretch: 1; label: "Track position"; } - if root.wide : Text { text: root.track.duration; width: 30px; font-size: 11px; color: TempoTheme.text-secondary; vertical-alignment: center; } - if root.wide : TempoIcon { source: @image-url("assets/volume.svg"); width: 18px; height: 18px; cross-axis-self-alignment: center; } - if root.wide : TempoSlider { value <=> root.volume; width: 66px; label: "Preview volume"; } - if root.wide : TempoIconButton { - icon: @image-url("assets/queue.svg"); label: "Open queue"; size: 34px; - width: 34px; height: 34px; cross-axis-self-alignment: center; - activated => { root.queue(); } - } - } -} - -export component DemoWindow inherits Window { - title: "Tempo UI · FMusic Next"; - preferred-width: 1180px; - preferred-height: 820px; - min-width: 340px; - min-height: 480px; - background: TempoTheme.background; - default-font-size: 14px; - - in-out property dark <=> TempoTheme.dark; - out property compact: root.width < TempoTokens.rail-breakpoint; - private property extended: root.width >= TempoTokens.extended-rail-breakpoint; - private property gutter: root.compact ? 16px : 26px; - in-out property page: 0; - in-out property query; - in-out property current: 0; - in-out property playing: false; - in-out property keep-offline: false; - in-out property show-button-states: true; - in-out property position: 0.34; - in-out property volume: 0.72; - in property <[DemoTrack]> shown-tracks; - in property <[DemoTrack]> tracks: [ - { title: "Earthly Light", artist: "FMusic Sessions", record: "After hours", format: "MP3", duration: "3:42", seconds: 222, cover: @image-url("assets/cover-0.svg") }, - { title: "Prelude", artist: "FMusic Sessions", record: "First light", format: "M4A", duration: "4:16", seconds: 256, cover: @image-url("assets/cover-1.svg") }, - { title: "Sea Glass", artist: "Northbound", record: "Coastline", format: "FLAC", duration: "3:28", seconds: 208, cover: @image-url("assets/cover-2.svg") }, - { title: "City Static", artist: "Soft Circuit", record: "Night service", format: "MP3", duration: "3:55", seconds: 235, cover: @image-url("assets/cover-3.svg") }, - { title: "Blue Hour", artist: "Northbound", record: "Coastline", format: "FLAC", duration: "5:02", seconds: 302, cover: @image-url("assets/cover-4.svg") }, - { title: "Paper Planes", artist: "Mono Field", record: "Field notes", format: "M4A", duration: "2:58", seconds: 178, cover: @image-url("assets/cover-5.svg") }, - ]; - private property <[TempoDestination]> nav-items: [ - { label: "Library", icon: @image-url("assets/library.svg"), selected-icon: @image-url("assets/library-filled.svg") }, - { label: "Search", icon: @image-url("assets/search.svg") }, - { label: "Queue", icon: @image-url("assets/queue.svg") }, - { label: "Settings", icon: @image-url("assets/settings.svg"), selected-icon: @image-url("assets/settings-filled.svg") }, - ]; - callback filter(string); - callback choose(string); - callback step(int); - callback playback-changed(bool); - - VerticalLayout { - x: 0px; y: 0px; width: root.width; height: root.height; - HorizontalLayout { - vertical-stretch: 1; - if !root.compact : Rectangle { - width: root.extended ? TempoTokens.desktop-nav-rail-extended-width : TempoTokens.desktop-nav-rail-width; - background: TempoTheme.surface; - Rectangle { width: 1px; x: parent.width - 1px; background: TempoTheme.border; } - VerticalLayout { - padding: root.extended ? 14px : 8px; - spacing: 21px; - HorizontalLayout { - height: 48px; - alignment: root.extended ? start : center; - spacing: 10px; - Rectangle { - width: 34px; height: 34px; cross-axis-self-alignment: center; - border-radius: 10px; background: TempoTheme.primary; - TempoIcon { source: @image-url("assets/note.svg"); tint: TempoTheme.text-inverse; width: 20px; height: 20px; } - } - if root.extended : VerticalLayout { - alignment: center; spacing: 2px; - Text { text: "FMusic Next"; font-size: 15px; font-weight: 800; color: TempoTheme.text-primary; } - Text { text: "Tempo UI"; font-size: 11px; color: TempoTheme.text-secondary; } - } - } - TempoNav { destinations: root.nav-items; selected: root.page; extended: root.extended; selected-index(i) => { root.page = i; } } - Rectangle { vertical-stretch: 1; } - if root.extended : Rectangle { - height: 55px; - border-radius: 10px; - background: TempoTheme.surface-alt; - HorizontalLayout { - padding: 9px; spacing: 9px; - TempoIcon { source: @image-url("assets/device.svg"); width: 18px; height: 18px; cross-axis-self-alignment: center; } - VerticalLayout { - alignment: center; spacing: 2px; - Text { text: "Demo library"; color: TempoTheme.text-primary; font-weight: 600; font-size: 12px; } - Text { text: "Local sample data"; color: TempoTheme.text-secondary; font-size: 10px; } - } - } - } - } - } - - VerticalLayout { - horizontal-stretch: 1; - HorizontalLayout { - padding-left: root.gutter; padding-right: root.gutter; - padding-top: 12px; padding-bottom: 10px; - spacing: 10px; - VerticalLayout { - horizontal-stretch: 1; alignment: center; spacing: 2px; - Text { text: root.compact ? "FMusic Next" : "YOUR MUSIC / TEMPO UI"; color: TempoTheme.text-primary; font-size: root.compact ? 16px : 12px; font-weight: 800; } - if root.compact : Text { text: "Tempo UI preview"; color: TempoTheme.text-secondary; font-size: 10px; } - } - TempoTag { label: "UI PREVIEW"; variant: primary; cross-axis-self-alignment: center; } - TempoIconButton { - size: 42px; variant: outline; - icon: root.dark ? @image-url("assets/sun.svg") : @image-url("assets/moon.svg"); - label: root.dark ? "Switch to light theme" : "Switch to dark theme"; - activated => { root.dark = !root.dark; } - } - } - scroller := ScrollView { - vertical-stretch: 1; - content-width: self.visible-width; - content := VerticalLayout { - padding-left: root.gutter; - padding-right: root.gutter; - padding-top: 6px; - padding-bottom: 18px; - spacing: 16px; - - if root.page == 0 : Rectangle { - clip: true; - height: root.compact ? 153px : 180px; - border-radius: TempoTokens.radius-xl; - Rectangle { - cache-rendering-hint: true; - background: @linear-gradient(110deg, #21284f 0%, #34467b 56%, #525f9c 100%); - Rectangle { - x: parent.width - self.width + (root.compact ? 43px : 19px); - y: root.compact ? -12px : -49px; - width: root.compact ? 178px : 315px; - height: self.width; - clip: true; - border-radius: 999px; - opacity: root.compact ? 0.48 : 0.86; - Image { source: @image-url("assets/cover-0.svg"); image-fit: cover; } - } - } - VerticalLayout { - padding: root.compact ? 15px : 22px; - alignment: center; - spacing: 7px; - Text { text: "THE LOCAL COLLECTION"; color: #bbcafa; font-size: 10px; font-weight: 800; } - Text { text: "Your music library"; color: #ffffff; font-size: root.compact ? 25px : 35px; font-weight: 800; } - Text { text: "A quiet space for your own collection."; color: #e3e9ff; font-size: root.compact ? 11px : 13px; } - HorizontalLayout { - alignment: start; - TempoButton { - min-height: 32px; - compact: true; - label: root.playing ? "Pause preview" : "Play preview"; - icon: root.playing ? @image-url("assets/pause.svg") : @image-url("assets/play.svg"); - activated => { root.playing = !root.playing; } - } - } - } - } - if root.page != 3 : VerticalLayout { - spacing: 10px; - HorizontalLayout { - height: 33px; spacing: 8px; - Text { - text: root.page == 0 ? "Tracks" : root.page == 1 ? "Search library" : "Playback queue"; - font-size: root.compact ? 20px : 23px; font-weight: 800; - color: TempoTheme.text-primary; vertical-alignment: center; - horizontal-stretch: 1; - } - TempoTag { - label: (root.page == 2 ? root.tracks.length : root.shown-tracks.length) + " tracks"; - cross-axis-self-alignment: center; - } - } - if root.page != 2 : TempoSearch { - icon: @image-url("assets/search.svg"); - placeholder: "Filter by song, artist, or album"; - text <=> root.query; - } - TempoSurface { - VerticalLayout { - padding: 5px; - if root.extended : HorizontalLayout { - height: 33px; padding-left: 15px; padding-right: 17px; spacing: 10px; - Text { width: 24px; text: "#"; color: TempoTheme.text-secondary; font-size: 11px; vertical-alignment: center; } - Text { text: "TITLE"; color: TempoTheme.text-secondary; font-size: 11px; font-weight: 700; horizontal-stretch: 1; vertical-alignment: center; } - Text { width: 135px; text: "ALBUM"; color: TempoTheme.text-secondary; font-size: 11px; font-weight: 700; vertical-alignment: center; } - Text { width: 58px; text: "FORMAT"; color: TempoTheme.text-secondary; font-size: 11px; font-weight: 700; vertical-alignment: center; } - Rectangle { width: 16px; } - Text { width: 34px; text: "TIME"; color: TempoTheme.text-secondary; font-size: 11px; font-weight: 700; vertical-alignment: center; horizontal-alignment: right; } - } - for track[index] in (root.page == 2 ? root.tracks : root.shown-tracks) : TrackRow { - track: track; - number: index + 1; - active: track.title == root.tracks[root.current].title; - playing: root.playing; - wide: root.extended; - activated => { root.choose(track.title); } - } - if root.page != 2 && root.shown-tracks.length == 0 : TempoEmptyState { - icon: @image-url("assets/search.svg"); - title: "No matching tracks"; - message: "Try a different song, artist, or album."; - action-label: "Clear search"; - action => { root.query = ""; } - } - } - } - } - if root.page == 3 : VerticalLayout { - spacing: 12px; - Text { text: "Settings"; font-size: 24px; font-weight: 800; color: TempoTheme.text-primary; } - TempoSection { - title: "Appearance"; - VerticalLayout { - padding: 14px; - TempoSegmentedControl { - selected: root.dark ? 1 : 0; - items: [ - { label: "Light", icon: @image-url("assets/sun.svg") }, - { label: "Dark", icon: @image-url("assets/moon.svg") }, - ]; - selected-index(i) => { root.dark = i == 1; } - } - } - TempoDivider {} - TempoTile { - label: "Demo library"; - subtitle: "View the sample tracks"; - icon: @image-url("assets/library.svg"); - trailing-icon: @image-url("assets/chevron.svg"); - activated => { root.page = 0; } - } - } - TempoSection { - title: "Tempo UI component samples"; - TempoSelectionTile { - label: "Keep tracks available offline"; - subtitle: "Checkbox sample only"; - check-icon: @image-url("assets/check.svg"); - checked <=> root.keep-offline; - } - TempoDivider {} - TempoSelectionTile { - label: "Show button variants"; - check-icon: @image-url("assets/check.svg"); - checked <=> root.show-button-states; - } - if root.show-button-states : VerticalLayout { - padding: 12px; spacing: 8px; - HorizontalLayout { - spacing: 6px; - TempoButton { label: "Primary"; compact: true; } - TempoButton { label: "Secondary"; compact: true; variant: secondary; } - } - HorizontalLayout { - spacing: 6px; - TempoButton { label: "Ghost"; compact: true; variant: ghost; } - TempoButton { label: "Danger"; compact: true; variant: danger; } - } - HorizontalLayout { - alignment: start; spacing: 6px; - TempoTag { label: "Neutral"; } - TempoTag { label: "Success"; variant: success; } - TempoTag { label: "Warning"; variant: warning; } - TempoTag { label: "Danger"; variant: danger; } - } - TempoProgressBar { value: root.position; } - } - } - } - } - content-height: content.preferred-height; - } - } - } - PlayerDock { - track: root.tracks[root.current]; - wide: !root.compact; - playing: root.playing; - position <=> root.position; - volume <=> root.volume; - toggle => { root.playing = !root.playing; } - previous => { root.step(-1); } - next => { root.step(1); } - queue => { root.page = 2; } - } - if root.compact : Rectangle { - height: TempoTokens.bottom-tab-height; - background: TempoTheme.surface; - Rectangle { height: 1px; y: 0px; background: TempoTheme.border; } - TempoNav { - destinations: root.nav-items; selected: root.page; bottom: true; - selected-index(i) => { root.page = i; } - } - } - } - changed query => { root.filter(root.query); } - changed page => { scroller.content-y = 0px; } - changed playing => { root.playback-changed(root.playing); } -} - -export { TempoCatalogWindow } from "catalog.slint"; diff --git a/scripts/check.sh b/scripts/check.sh index 6ecad01..df41bcf 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -15,10 +15,8 @@ fi for renderer in "${renderers[@]}"; do export SLINT_BACKEND="$renderer" - "$showcase" --music --smoke - "$showcase" --music --compact --dark --smoke - "$showcase" --catalog --smoke - "$showcase" --catalog --compact --dark --smoke + "$showcase" --smoke + "$showcase" --compact --dark --smoke "$showcase" --layout --wide --smoke "$showcase" --motion-smoke "$showcase" --motion-smoke --compact --dark diff --git a/src/fonts.rs b/src/fonts.rs index 7ec81df..2c2bdbe 100644 --- a/src/fonts.rs +++ b/src/fonts.rs @@ -1,44 +1,202 @@ +use std::sync::OnceLock; + use slint::fontique_012::{fontique, set_shared_collection}; -/// Prefer the same installed CJK fallback families as FinUI without bundling platform fonts. -/// Call before constructing a Slint window. -pub fn configure_finui_fallbacks() -> Result<(), slint::PlatformError> { - let mut collection = fontique::Collection::new(fontique::CollectionOptions { - shared: true, - ..Default::default() - }); - for (script, preferences) in [ - ( - *b"Hani", - &["Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC"][..], - ), - ( - *b"Hira", - &["Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP"][..], - ), - ( - *b"Kana", - &["Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP"][..], - ), - ( - *b"Hang", - &["Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR"][..], - ), - ] { - let key = fontique::FallbackKey::new(fontique::Script::from_bytes(script), None); - let mut families: Vec<_> = preferences - .iter() - .filter_map(|name| collection.family_by_name(name).map(|family| family.id())) +static CONFIGURED: OnceLock<()> = OnceLock::new(); + +const HANI_SC_PREFERENCES: &[&str] = &[ + "Microsoft YaHei UI", + "Microsoft YaHei", + "PingFang SC", + "Noto Sans CJK SC", + "Noto Sans SC", + "Source Han Sans SC", + "Source Han Sans CN", + "HarmonyOS Sans SC", + "MiSans", + "Sarasa Gothic SC", + "WenQuanYi Micro Hei", + "WenQuanYi Zen Hei", + "Hiragino Sans GB", + "SimHei", + "Droid Sans Fallback", +]; + +const HANI_TC_PREFERENCES: &[&str] = &[ + "Microsoft JhengHei UI", + "Microsoft JhengHei", + "PingFang TC", + "Noto Sans CJK TC", + "Noto Sans TC", + "Source Han Sans TC", + "Source Han Sans TW", + "Noto Sans CJK HK", + "WenQuanYi Micro Hei", +]; + +const JP_PREFERENCES: &[&str] = &[ + "Hiragino Sans", + "Yu Gothic UI", + "Yu Gothic", + "Meiryo", + "Noto Sans CJK JP", + "Noto Sans JP", + "Source Han Sans JP", +]; + +const KR_PREFERENCES: &[&str] = &[ + "Apple SD Gothic Neo", + "Malgun Gothic", + "Noto Sans CJK KR", + "Noto Sans KR", + "Source Han Sans KR", +]; + +fn resolve_preferred_ids( + collection: &mut fontique::Collection, + preferences: &[&str], +) -> Vec { + let mut ids = Vec::new(); + for name in preferences { + if let Some(family) = collection.family_by_name(name) { + let id = family.id(); + if !ids.contains(&id) { + ids.push(id); + } + } + } + // Fallback heuristic for distros/devices with differently cased or regional CJK family names. + if ids.is_empty() { + let candidates: Vec = collection + .family_names() + .filter(|name| { + let lower = name.to_ascii_lowercase(); + lower.contains("cjk") + || lower.contains("han sans") + || lower.contains("yahei") + || lower.contains("pingfang") + || lower.contains("wenquanyi") + || lower.contains("noto sans sc") + || lower.contains("noto sans tc") + || lower.contains("droid sans fallback") + }) + .map(str::to_owned) .collect(); - if !families.is_empty() { - let existing: Vec<_> = collection.fallback_families(key).collect(); - for id in existing { - if !families.contains(&id) { - families.push(id); + for name in candidates { + if let Some(family) = collection.family_by_name(&name) { + let id = family.id(); + if !ids.contains(&id) { + ids.push(id); } } - collection.set_fallbacks(key, families.into_iter()); } } - set_shared_collection(collection) + ids +} + +fn apply_script_fallbacks( + collection: &mut fontique::Collection, + script: [u8; 4], + locales: &[Option<&str>], + preferred: &[fontique::FamilyId], +) { + if preferred.is_empty() { + return; + } + let script = fontique::Script::from_bytes(script); + for locale in locales { + let parsed = locale.and_then(|tag| fontique::Language::parse(tag).ok()); + let key = fontique::FallbackKey::new(script, parsed.as_ref()); + let mut merged = preferred.to_vec(); + let existing: Vec<_> = collection.fallback_families(key).collect(); + for id in existing { + if !merged.contains(&id) { + merged.push(id); + } + } + collection.set_fallbacks(key, merged.into_iter()); + } +} + +/// Configure reliable cross-platform CJK font fallbacks for Slint/fontique +/// across Linux, Windows, macOS, and Android without bundling font files. +/// +/// Safe to call more than once; call before constructing a Slint window. +pub fn configure_cjk_fallbacks() -> Result<(), slint::PlatformError> { + if CONFIGURED.get().is_some() { + return Ok(()); + } + let mut collection = fontique::Collection::new(fontique::CollectionOptions { + shared: true, + ..Default::default() + }); + + let sc = resolve_preferred_ids(&mut collection, HANI_SC_PREFERENCES); + let tc = resolve_preferred_ids(&mut collection, HANI_TC_PREFERENCES); + let jp = resolve_preferred_ids(&mut collection, JP_PREFERENCES); + let kr = resolve_preferred_ids(&mut collection, KR_PREFERENCES); + + // Register both locale-less and locale-qualified keys so Slint/parley + // resolves Simplified/Traditional Chinese, Japanese, and Korean reliably. + apply_script_fallbacks( + &mut collection, + *b"Hani", + &[ + None, + Some("zh"), + Some("zh-Hans"), + Some("zh-CN"), + Some("zh-SG"), + ], + &sc, + ); + apply_script_fallbacks( + &mut collection, + *b"Hani", + &[Some("zh-Hant"), Some("zh-TW"), Some("zh-HK"), Some("zh-MO")], + if tc.is_empty() { &sc } else { &tc }, + ); + apply_script_fallbacks( + &mut collection, + *b"Hira", + &[None, Some("ja"), Some("ja-JP")], + &jp, + ); + apply_script_fallbacks( + &mut collection, + *b"Kana", + &[None, Some("ja"), Some("ja-JP")], + &jp, + ); + apply_script_fallbacks( + &mut collection, + *b"Hang", + &[None, Some("ko"), Some("ko-KR")], + &kr, + ); + + // Append CJK families to GenericFamily::SansSerif so mixed Latin + CJK runs + // always have an explicit CJK fallback in the default sans-serif chain. + if !sc.is_empty() { + collection.append_generic_families(fontique::GenericFamily::SansSerif, sc.into_iter()); + } + + let result = set_shared_collection(collection); + if result.is_ok() { + let _ = CONFIGURED.set(()); + } + result +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn configure_cjk_fallbacks_is_idempotent() { + let first = configure_cjk_fallbacks(); + let second = configure_cjk_fallbacks(); + assert!(first.is_ok()); + assert!(second.is_ok()); + } } diff --git a/src/lib.rs b/src/lib.rs index 516cae2..b226f42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ -//! Host-side support for the Tempo UI Slint component library. +//! Rust host helpers for Tempo UI (route stacks and cross-platform CJK font fallbacks). -#[cfg(feature = "finui-font-fallback")] +#[cfg(feature = "cjk-font-fallback")] pub mod fonts; pub mod navigation; diff --git a/ui/auxiliary.slint b/ui/auxiliary.slint index d19b737..c5216ff 100644 --- a/ui/auxiliary.slint +++ b/ui/auxiliary.slint @@ -82,7 +82,7 @@ export component TempoButtonGroupTabBar inherits Rectangle { height: 36px; border-radius: TempoTokens.radius-sm; background: TempoTheme.primary; - animate x, width { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.normal; easing: cubic-bezier(0.215, 0.61, 0.355, 1.0); } + animate x, width { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.motion-medium; easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); } } tab-row := HorizontalLayout { spacing: TempoTokens.gap4; diff --git a/ui/controls.slint b/ui/controls.slint index c7d1935..3fef036 100644 --- a/ui/controls.slint +++ b/ui/controls.slint @@ -1,5 +1,6 @@ import { TempoMotionSettings } from "motion.slint"; -import { Spinner } from "std-widgets.slint"; +import { ScrollView, Spinner } from "std-widgets.slint"; +import { TempoIcons } from "icons.slint"; import { TempoTheme, TempoTokens } from "theme.slint"; component TempoControlFocus inherits FocusScope { @@ -63,7 +64,7 @@ export component TempoIcon inherits Image { image-fit: contain; } -export enum TempoButtonVariant { primary, secondary, ghost, danger } +export enum TempoButtonVariant { primary, secondary, outline, ghost, success, warning, danger } export enum TempoIconButtonVariant { ghost, soft, outline, danger } export enum TempoTagVariant { neutral, primary, success, warning, danger } @@ -77,18 +78,28 @@ export component TempoButton inherits TempoAction { private property icon-size: root.compact ? TempoTokens.icon-sm : TempoTokens.icon-md; private property ink: !root.enabled ? TempoTheme.text-disabled : root.variant == primary ? TempoTheme.text-inverse - : root.variant == danger ? TempoTheme.danger : TempoTheme.primary; + : root.variant == danger ? TempoTheme.danger + : root.variant == success ? TempoTheme.success + : root.variant == warning ? TempoTheme.warning + : root.variant == outline ? TempoTheme.text-primary : TempoTheme.primary; min-height: root.compact ? TempoTokens.small-button-height : TempoTokens.button-height; preferred-width: root.icon-only ? self.min-height : inner.preferred-width; - border-radius: TempoTokens.radius-md; - border-width: root.enabled && (root.variant == secondary || root.variant == danger) ? TempoTokens.border-width : 0px; - border-color: root.variant == danger ? TempoTheme.danger.with-alpha(0.35) : TempoTheme.primary.with-alpha(0.25); + border-radius: root.compact ? TempoTokens.radius-sm : TempoTokens.radius-md; + border-width: root.enabled && root.variant != primary && root.variant != ghost ? TempoTokens.border-width : 0px; + border-color: root.variant == danger ? TempoTheme.danger.with-alpha(0.35) + : root.variant == success ? TempoTheme.success.with-alpha(0.35) + : root.variant == warning ? TempoTheme.warning.with-alpha(0.38) + : root.variant == outline ? (root.hovered ? TempoTheme.border-strong : TempoTheme.border) + : TempoTheme.primary.with-alpha(0.25); background: !root.enabled ? (root.variant == ghost ? transparent : TempoTheme.border) : root.variant == primary ? (root.pressed ? TempoTheme.primary-pressed : root.hovered ? TempoTheme.primary-hover : TempoTheme.primary) - : root.variant == danger ? TempoTheme.danger-soft - : root.variant == secondary ? TempoTheme.primary-soft - : root.hovered ? TempoTheme.primary-soft : transparent; - animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + : root.variant == danger ? (root.pressed || root.hovered ? TempoTheme.danger-subtle : TempoTheme.danger-soft) + : root.variant == success ? (root.pressed || root.hovered ? TempoTheme.success.with-alpha(TempoTheme.dark ? 0.24 : 0.16) : TempoTheme.success-soft) + : root.variant == warning ? (root.pressed || root.hovered ? TempoTheme.warning.with-alpha(TempoTheme.dark ? 0.24 : 0.18) : TempoTheme.warning-soft) + : root.variant == outline ? (root.pressed ? TempoTheme.surface-pressed : root.hovered ? TempoTheme.surface-alt : TempoTheme.surface) + : root.variant == secondary ? (root.pressed || root.hovered ? TempoTheme.primary-subtle : TempoTheme.primary-soft) + : root.pressed ? TempoTheme.surface-pressed : root.hovered ? TempoTheme.primary-soft : transparent; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } inner := HorizontalLayout { alignment: center; cross-axis-alignment: center; @@ -125,10 +136,11 @@ export component TempoIconButton inherits TempoAction { border-radius: TempoTokens.radius-sm; border-width: root.variant == outline || root.variant == danger ? 1px : 0px; border-color: root.variant == danger ? TempoTheme.danger.with-alpha(0.28) : TempoTheme.border; - background: root.variant == soft ? TempoTheme.primary-soft - : root.variant == outline ? TempoTheme.surface - : root.variant == danger ? TempoTheme.danger-soft - : root.hovered && root.enabled ? TempoTheme.surface-alt : transparent; + background: !root.enabled ? (root.variant == ghost ? transparent : TempoTheme.surface-alt) + : root.variant == soft ? (root.pressed || root.hovered ? TempoTheme.primary-subtle : TempoTheme.primary-soft) + : root.variant == outline ? (root.pressed ? TempoTheme.surface-pressed : root.hovered ? TempoTheme.surface-alt : TempoTheme.surface) + : root.variant == danger ? (root.pressed || root.hovered ? TempoTheme.danger-subtle : TempoTheme.danger-soft) + : root.pressed ? TempoTheme.surface-pressed : root.hovered ? TempoTheme.surface-alt : transparent; animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } if root.loading : Spinner { width: root.icon-size; height: root.icon-size; indeterminate: true; } if !root.loading : TempoIcon { @@ -144,10 +156,14 @@ export component TempoIconButton inherits TempoAction { } export component TempoSurface inherits Rectangle { - background: TempoTheme.surface; - border-color: TempoTheme.border; + in property elevated: false; + background: root.elevated ? TempoTheme.surface-elevated : TempoTheme.surface; + border-color: root.elevated && TempoTheme.dark ? TempoTheme.border-strong : TempoTheme.border; border-width: TempoTokens.border-width; border-radius: TempoTokens.radius-lg; + drop-shadow-blur: root.elevated ? 22px : 0px; + drop-shadow-offset-y: root.elevated ? 8px : 0px; + drop-shadow-color: root.elevated ? TempoTheme.shadow : transparent; @children } @@ -158,6 +174,11 @@ export component TempoTag inherits Rectangle { height: 24px; preferred-width: inner.preferred-width; border-radius: TempoTokens.radius-full; + border-width: TempoTokens.border-width; + border-color: root.variant == primary ? TempoTheme.primary.with-alpha(0.18) + : root.variant == success ? TempoTheme.success.with-alpha(0.20) + : root.variant == warning ? TempoTheme.warning.with-alpha(0.22) + : root.variant == danger ? TempoTheme.danger.with-alpha(0.20) : TempoTheme.border; background: root.variant == primary ? TempoTheme.primary-soft : root.variant == success ? TempoTheme.success-soft : root.variant == warning ? TempoTheme.warning-soft @@ -186,6 +207,9 @@ export component TempoTextField inherits VerticalLayout { in property error; in property icon; in property enabled: true; + in property clearable: false; + in property reveal-toggle: root.input-type == InputType.password; + private property revealed: false; in property field-height: 50px; in property input-type: InputType.text; in property input-hints: { auto-correct: true, auto-complete: true }; @@ -200,13 +224,16 @@ export component TempoTextField inherits VerticalLayout { Rectangle { height: root.field-height; background: root.enabled ? TempoTheme.surface : TempoTheme.surface-alt; - border-radius: TempoTokens.radius-md; - border-color: root.error != "" ? TempoTheme.danger : input.has-focus ? TempoTheme.primary : TempoTheme.border; - border-width: input.has-focus ? 1.4px : 1px; + border-radius: TempoTokens.radius-sm; + border-color: root.error != "" ? TempoTheme.danger : input.has-focus ? TempoTheme.border-strong : TempoTheme.border; + border-width: 1px; + clip: true; + animate border-color, background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } HorizontalLayout { padding-left: 12px; padding-right: 12px; spacing: 8px; if root.icon.width > 0 : TempoIcon { source: root.icon; width: 20px; height: 20px; cross-axis-self-alignment: center; + tint: input.has-focus ? TempoTheme.primary : TempoTheme.text-secondary; } Rectangle { horizontal-stretch: 1; @@ -214,13 +241,13 @@ export component TempoTextField inherits VerticalLayout { visible: input.text == ""; text: root.placeholder; x: 0px; width: parent.width; height: parent.height; horizontal-alignment: left; vertical-alignment: center; - color: TempoTheme.text-tertiary; font-size: root.field-height == 44px ? 13px : 16px; + color: TempoTheme.text-tertiary; font-size: root.field-height == 44px ? 13px : 15px; } input := TextInput { enabled: root.enabled; - input-type: root.input-type; + input-type: root.input-type == InputType.password && root.revealed ? InputType.text : root.input-type; input-method-hints: root.input-hints; - single-line: true; font-size: root.field-height == 44px ? 13px : 16px; + single-line: true; font-size: root.field-height == 44px ? 13px : 15px; color: root.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; selection-background-color: TempoTheme.primary; selection-foreground-color: TempoTheme.text-inverse; @@ -231,8 +258,36 @@ export component TempoTextField inherits VerticalLayout { accepted => { root.submitted(self.text); } } } + if root.clearable && root.enabled && input.text != "" : TempoIconButton { + label: "Clear"; + icon: TempoIcons.close; + size: 26px; + icon-size: 14px; + cross-axis-self-alignment: center; + activated => { + input.text = ""; + root.edited(""); + } + } + if root.reveal-toggle && root.enabled : TempoIconButton { + label: root.revealed ? "Hide password" : "Show password"; + icon: root.revealed ? TempoIcons.visibility-off : TempoIcons.visibility; + size: 26px; + icon-size: 16px; + cross-axis-self-alignment: center; + activated => { root.revealed = !root.revealed; } + } @children } + // Bottom accent focus bar + Rectangle { + x: 0px; + y: parent.height - 2px; + width: parent.width; + height: input.has-focus || root.error != "" ? 2px : 0px; + background: root.error != "" ? TempoTheme.danger : TempoTheme.primary; + animate height { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + } } if root.error != "" : Text { text: root.error; color: TempoTheme.danger; font-size: 12px; wrap: word-wrap; } } @@ -240,10 +295,47 @@ export component TempoTextField inherits VerticalLayout { export component TempoSearch inherits TempoTextField { placeholder: "Search"; field-height: TempoTokens.input-height; + clearable: true; input-type: search; input-hints: { auto-correct: false, auto-complete: true }; } +export component TempoSwitch inherits TempoAction { + in-out property checked: false; + callback toggled(bool); + label: "Switch"; + accessible-role: switch; + accessible-checked: root.checked; + width: 42px; + height: 22px; + border-radius: TempoTokens.radius-full; + border-width: root.checked ? 0px : TempoTokens.border-width; + border-color: root.hovered && root.enabled ? TempoTheme.text-secondary : TempoTheme.border-strong; + background: !root.enabled ? TempoTheme.border + : root.checked ? (root.pressed ? TempoTheme.primary-pressed : root.hovered ? TempoTheme.primary-hover : TempoTheme.primary) + : root.pressed ? TempoTheme.surface-pressed + : root.hovered ? TempoTheme.surface-alt : TempoTheme.surface; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { + root.checked = !root.checked; + root.toggled(root.checked); + } + Rectangle { + width: root.pressed && root.enabled ? 18px : 16px; + height: 16px; + x: root.checked ? parent.width - self.width - 3px : 3px; + y: (parent.height - self.height) / 2; + border-radius: TempoTokens.radius-full; + background: root.checked ? TempoTheme.text-inverse + : root.enabled ? TempoTheme.text-secondary : TempoTheme.text-disabled; + animate x, width, background { + enabled: !TempoMotionSettings.reduced; + duration: TempoTokens.motion-short; + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); + } + } +} + export component TempoSlider inherits Rectangle { in-out property value: 0; in property label: "Progress"; @@ -273,27 +365,39 @@ export component TempoSlider inherits Rectangle { accessible-action-increment => { root.nudge(1); } accessible-action-decrement => { root.nudge(-1); } Rectangle { - x: 5px; - width: max(0px, root.width - 10px); + x: 9px; + y: (parent.height - self.height) / 2; + width: max(0px, root.width - 18px); height: 4px; border-radius: 2px; - background: TempoTheme.primary-soft; + background: TempoTheme.border; Rectangle { x: 0px; width: parent.width * root.bounded; height: parent.height; border-radius: 2px; - background: TempoTheme.primary; + background: root.enabled ? TempoTheme.primary : TempoTheme.text-disabled; } } + // Elevated circular thumb with animated inner accent dot (no blur shader overhead while dragging) Rectangle { x: max(0px, root.width - self.width) * root.bounded; - width: 10px; - height: 10px; - border-radius: 5px; - border-width: keys.ring-visible ? 2px : 0px; - border-color: TempoTheme.text-primary; - background: TempoTheme.primary; + y: (parent.height - self.height) / 2; + width: 18px; + height: 18px; + border-radius: 9px; + border-width: keys.ring-visible ? 2px : 1.5px; + border-color: keys.ring-visible ? TempoTheme.primary : TempoTheme.border-strong; + background: TempoTheme.surface-elevated; + Rectangle { + width: touch.pressed ? 8px : touch.has-hover ? 12px : 10px; + height: self.width; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + border-radius: self.width / 2; + background: root.enabled ? TempoTheme.primary : TempoTheme.text-disabled; + animate width, height { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + } } keys := TempoControlFocus { enabled: root.enabled; @@ -307,11 +411,11 @@ export component TempoSlider inherits Rectangle { enabled: root.enabled; mouse-cursor: pointer; moved => { - if self.pressed { root.set-fraction((self.mouse-x - 5px) / max(1px, self.width - 10px)); } + if self.pressed { root.set-fraction((self.mouse-x - 9px) / max(1px, self.width - 18px)); } } clicked => { keys.focus-from-pointer(); - root.set-fraction((self.mouse-x - 5px) / max(1px, self.width - 10px)); + root.set-fraction((self.mouse-x - 9px) / max(1px, self.width - 18px)); } } } @@ -323,3 +427,600 @@ export component TempoClickableSurface inherits TempoAction { border-radius: TempoTokens.radius-lg; @children } + +export component TempoTextArea inherits VerticalLayout { + in property label; + in property placeholder; + in property error; + in property enabled: true; + in property area-height: 92px; + in-out property text <=> input.text; + callback edited(string); + forward-focus: input; + spacing: TempoTokens.gap6; + if root.label != "" : Text { + text: root.label; color: TempoTheme.text-secondary; font-size: TempoTokens.text-sm; font-weight: 600; + } + Rectangle { + height: root.area-height; + background: root.enabled ? TempoTheme.surface : TempoTheme.surface-alt; + border-radius: TempoTokens.radius-sm; + border-color: root.error != "" ? TempoTheme.danger : input.has-focus ? TempoTheme.border-strong : TempoTheme.border; + border-width: 1px; + clip: true; + animate border-color, background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + ScrollView { + x: 10px; y: 8px; + width: parent.width - 20px; + height: parent.height - 16px; + content-width: self.visible-width; + content-height: max(self.visible-height, input.preferred-height); + if input.text == "" && root.placeholder != "" : Text { + x: 0px; y: 0px; + width: parent.width; + text: root.placeholder; + color: TempoTheme.text-tertiary; + font-size: TempoTokens.text-md; + wrap: word-wrap; + } + input := TextInput { + x: 0px; y: 0px; + width: parent.width; + height: max(parent.height, self.preferred-height); + enabled: root.enabled; + single-line: false; + wrap: word-wrap; + font-size: TempoTokens.text-md; + color: root.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; + selection-background-color: TempoTheme.primary; + selection-foreground-color: TempoTheme.text-inverse; + accessible-label: root.label != "" ? root.label : root.placeholder; + edited => { root.edited(self.text); } + } + } + Rectangle { + x: 0px; y: parent.height - 2px; + width: parent.width; + height: input.has-focus || root.error != "" ? 2px : 0px; + background: root.error != "" ? TempoTheme.danger : TempoTheme.primary; + animate height { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + } + } + if root.error != "" : Text { text: root.error; color: TempoTheme.danger; font-size: TempoTokens.text-sm; wrap: word-wrap; } +} + +export component TempoCheckBox inherits TempoAction { + in-out property checked: false; + callback toggled(bool); + accessible-role: checkbox; + accessible-checked: root.checked; + min-height: 28px; + border-radius: TempoTokens.radius-xs; + activated => { + root.checked = !root.checked; + root.toggled(root.checked); + } + HorizontalLayout { + spacing: TempoTokens.gap8; + cross-axis-alignment: center; + Rectangle { + width: 18px; height: 18px; + border-radius: TempoTokens.radius-xs; + border-width: TempoTokens.border-width; + border-color: !root.enabled ? TempoTheme.border + : root.checked ? TempoTheme.primary + : root.hovered ? TempoTheme.primary : TempoTheme.border-strong; + background: !root.enabled ? TempoTheme.surface-alt + : root.checked ? (root.pressed ? TempoTheme.primary-pressed : root.hovered ? TempoTheme.primary-hover : TempoTheme.primary) + : root.pressed ? TempoTheme.surface-pressed + : root.hovered ? TempoTheme.surface-alt : TempoTheme.surface; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + if root.checked : TempoIcon { + source: TempoIcons.checkmark-small; + tint: TempoTheme.text-inverse; + width: 13px; height: 13px; + } + } + if root.label != "" : Text { + text: root.label; + font-size: TempoTokens.text-md; + color: root.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; + vertical-alignment: center; + } + } +} + +export component TempoRadioButton inherits TempoAction { + in-out property checked: false; + callback selected(); + accessible-role: radio-button; + accessible-checked: root.checked; + min-height: 28px; + border-radius: TempoTokens.radius-xs; + activated => { + if !root.checked { + root.checked = true; + root.selected(); + } + } + HorizontalLayout { + spacing: TempoTokens.gap8; + cross-axis-alignment: center; + Rectangle { + width: 18px; height: 18px; + border-radius: TempoTokens.radius-full; + border-width: TempoTokens.border-width; + border-color: !root.enabled ? TempoTheme.border + : root.checked ? TempoTheme.primary + : root.hovered ? TempoTheme.primary : TempoTheme.border-strong; + background: !root.enabled ? TempoTheme.surface-alt + : root.checked ? TempoTheme.primary + : root.pressed ? TempoTheme.surface-pressed + : root.hovered ? TempoTheme.surface-alt : TempoTheme.surface; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + if root.checked : Rectangle { + width: 7px; height: 7px; + border-radius: TempoTokens.radius-full; + background: TempoTheme.text-inverse; + } + } + if root.label != "" : Text { + text: root.label; + font-size: TempoTokens.text-md; + color: root.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; + vertical-alignment: center; + } + } +} + +export component TempoSpinBox inherits VerticalLayout { + in property label; + in-out property value: 0; + in property minimum: 0; + in property maximum: 100; + in property step: 1; + in property enabled: true; + callback edited(int); + spacing: TempoTokens.gap6; + function step-by(delta: int) { + if root.enabled { + let next = clamp(root.value + delta, root.minimum, root.maximum); + if next != root.value { + root.value = next; + root.edited(next); + } + } + } + if root.label != "" : Text { + text: root.label; color: TempoTheme.text-secondary; font-size: TempoTokens.text-sm; font-weight: 600; + } + Rectangle { + height: 36px; + preferred-width: 136px; + border-radius: TempoTokens.radius-sm; + border-width: TempoTokens.border-width; + border-color: spin-keys.has-focus ? TempoTheme.primary : TempoTheme.border; + background: root.enabled ? TempoTheme.surface : TempoTheme.surface-alt; + clip: true; + animate border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + spin-keys := TempoControlFocus { + enabled: root.enabled; + handle-key(e) => { + if e.text == Key.UpArrow { root.step-by(root.step); return accept; } + if e.text == Key.DownArrow { root.step-by(-root.step); return accept; } + return reject; + } + } + HorizontalLayout { + TempoAction { + label: "Decrease"; + width: 34px; + enabled: root.enabled && root.value > root.minimum; + background: self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { root.step-by(-root.step); } + Text { + text: "−"; + font-size: 16px; font-weight: 600; + color: parent.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; + horizontal-alignment: center; vertical-alignment: center; + } + } + Rectangle { width: TempoTokens.border-width; background: TempoTheme.border; } + Text { + horizontal-stretch: 1; + text: root.value; + font-size: TempoTokens.text-md; + font-weight: 600; + color: root.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; + horizontal-alignment: center; + vertical-alignment: center; + } + Rectangle { width: TempoTokens.border-width; background: TempoTheme.border; } + TempoAction { + label: "Increase"; + width: 34px; + enabled: root.enabled && root.value < root.maximum; + background: self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { root.step-by(root.step); } + Text { + text: "+"; + font-size: 16px; font-weight: 600; + color: parent.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; + horizontal-alignment: center; vertical-alignment: center; + } + } + } + } +} + +export component TempoBadge inherits Rectangle { + in property count: 0; + in property max-count: 99; + in property dot-only: false; + in property show-zero: false; + in property variant: danger; + private property visible-badge: root.dot-only || root.count > 0 || root.show-zero; + private property badge-bg: root.variant == primary ? TempoTheme.primary + : root.variant == success ? TempoTheme.success + : root.variant == warning ? TempoTheme.warning + : root.variant == neutral ? TempoTheme.text-secondary : TempoTheme.danger; + private property badge-text: root.count > root.max-count ? root.max-count + "+" : "" + root.count; + preferred-width: content.preferred-width; + preferred-height: content.preferred-height; + content := HorizontalLayout { + @children + } + if root.visible-badge : Rectangle { + x: parent.width - self.width + (root.dot-only ? 2px : 5px); + y: root.dot-only ? -2px : -5px; + min-width: root.dot-only ? 9px : 18px; + width: root.dot-only ? 9px : max(18px, badge-label.preferred-width + 10px); + height: root.dot-only ? 9px : 18px; + border-radius: TempoTokens.radius-full; + border-width: 1.5px; + border-color: TempoTheme.surface; + background: root.badge-bg; + badge-label := Text { + visible: !root.dot-only; + text: root.dot-only ? "" : root.badge-text; + color: #F8FAFC; + font-size: 10px; + font-weight: 700; + horizontal-alignment: center; + vertical-alignment: center; + } + } +} + +export component TempoChip inherits TempoAction { + in-out property selected: false; + in property selectable: true; + in property closable: false; + in property icon; + callback toggled(bool); + callback closed(); + height: 30px; + preferred-width: inner.preferred-width; + border-radius: TempoTokens.radius-sm; + border-width: TempoTokens.border-width; + border-color: root.selected ? TempoTheme.primary.with-alpha(0.35) + : root.hovered ? TempoTheme.border-strong : TempoTheme.border; + background: !root.enabled ? TempoTheme.surface-alt + : root.selected ? (root.pressed || root.hovered ? TempoTheme.primary-subtle : TempoTheme.primary-soft) + : root.pressed ? TempoTheme.surface-pressed + : root.hovered ? TempoTheme.surface-alt : TempoTheme.surface; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { + if root.selectable { + root.selected = !root.selected; + root.toggled(root.selected); + } + } + inner := HorizontalLayout { + padding-left: 10px; + padding-right: root.closable ? 4px : 10px; + spacing: TempoTokens.gap6; + cross-axis-alignment: center; + if root.icon.width > 0 : TempoIcon { + source: root.icon; + tint: root.selected ? TempoTheme.primary : TempoTheme.text-secondary; + width: 14px; height: 14px; + } + Text { + text: root.label; + font-size: TempoTokens.text-sm; + font-weight: root.selected ? 600 : 500; + color: !root.enabled ? TempoTheme.text-disabled + : root.selected ? TempoTheme.primary : TempoTheme.text-primary; + } + if root.closable : TempoIconButton { + label: "Remove " + root.label; + icon: TempoIcons.close; + size: 20px; + icon-size: 12px; + enabled: root.enabled; + activated => { root.closed(); } + } + } +} + +export component TempoRate inherits HorizontalLayout { + in-out property value: 0; + in property count: 5; + in property enabled: true; + callback changed-value(int); + private property hover-index: 0; + spacing: TempoTokens.gap4; + alignment: start; + cross-axis-alignment: center; + for idx in root.count : star := TempoAction { + private property rank: idx + 1; + private property filled: rank <= (root.hover-index > 0 ? root.hover-index : root.value); + label: rank + " star"; + enabled: root.enabled; + width: 26px; + height: 26px; + border-radius: TempoTokens.radius-xs; + background: self.hovered && root.enabled ? TempoTheme.surface-alt : transparent; + activated => { + root.value = rank; + root.changed-value(rank); + } + Path { + width: 18px; height: 18px; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + viewbox-width: 24; viewbox-height: 24; + fill: filled ? TempoTheme.warning : transparent; + stroke: filled ? TempoTheme.warning : TempoTheme.border-strong; + stroke-width: 1.6px; + MoveTo { x: 12; y: 2.5; } + LineTo { x: 14.9; y: 8.4; } + LineTo { x: 21.4; y: 9.3; } + LineTo { x: 16.7; y: 13.9; } + LineTo { x: 17.8; y: 20.4; } + LineTo { x: 12; y: 17.3; } + LineTo { x: 6.2; y: 20.4; } + LineTo { x: 7.3; y: 13.9; } + LineTo { x: 2.6; y: 9.3; } + LineTo { x: 9.1; y: 8.4; } + Close {} + } + } +} + +export component TempoSkeleton inherits Rectangle { + in property bar-height: 14px; + in property circle: false; + height: root.bar-height; + width: root.circle ? root.bar-height : 120px; + border-radius: root.circle ? TempoTokens.radius-full : TempoTokens.radius-xs; + background: TempoTheme.surface-pressed; +} + +export component TempoSplitButton inherits Rectangle { + in property label; + in property icon; + in property enabled: true; + in property primary-style: false; + callback activated(); + callback menu-requested(); + height: TempoTokens.small-button-height; + preferred-width: inner.preferred-width; + border-radius: TempoTokens.radius-sm; + border-width: root.primary-style ? 0px : TempoTokens.border-width; + border-color: TempoTheme.border; + background: root.primary-style ? TempoTheme.primary : TempoTheme.surface; + clip: true; + inner := HorizontalLayout { + TempoAction { + label: root.label; + enabled: root.enabled; + background: !root.enabled ? transparent + : root.primary-style ? (self.pressed ? TempoTheme.primary-pressed : self.hovered ? TempoTheme.primary-hover : transparent) + : self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { root.activated(); } + HorizontalLayout { + padding-left: 12px; padding-right: 12px; + spacing: TempoTokens.gap6; + cross-axis-alignment: center; + if root.icon.width > 0 : TempoIcon { + source: root.icon; + tint: !root.enabled ? TempoTheme.text-disabled : root.primary-style ? TempoTheme.text-inverse : TempoTheme.text-primary; + width: TempoTokens.icon-sm; height: TempoTokens.icon-sm; + } + Text { + text: root.label; + font-size: 13px; + font-weight: 600; + color: !root.enabled ? TempoTheme.text-disabled : root.primary-style ? TempoTheme.text-inverse : TempoTheme.text-primary; + } + } + } + Rectangle { + width: TempoTokens.border-width; + background: root.primary-style ? TempoTheme.text-inverse.with-alpha(0.25) : TempoTheme.border; + } + TempoAction { + label: root.label + " options"; + enabled: root.enabled; + width: 30px; + background: !root.enabled ? transparent + : root.primary-style ? (self.pressed ? TempoTheme.primary-pressed : self.hovered ? TempoTheme.primary-hover : transparent) + : self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { root.menu-requested(); } + TempoIcon { + source: TempoIcons.chevron-down; + tint: !root.enabled ? TempoTheme.text-disabled : root.primary-style ? TempoTheme.text-inverse : TempoTheme.text-secondary; + width: 15px; height: 15px; + } + } + } +} + +export component TempoLink inherits TempoAction { + in property external: false; + height: 26px; + preferred-width: inner.preferred-width; + border-radius: TempoTokens.radius-xs; + background: self.pressed ? TempoTheme.primary-soft : transparent; + inner := HorizontalLayout { + padding-left: 4px; padding-right: 4px; + spacing: TempoTokens.gap4; + cross-axis-alignment: center; + Text { + text: root.label; + font-size: 13px; + font-weight: 600; + color: !root.enabled ? TempoTheme.text-disabled + : root.pressed ? TempoTheme.primary-pressed + : root.hovered ? TempoTheme.primary-hover : TempoTheme.primary; + vertical-alignment: center; + } + if root.external : TempoIcon { + source: TempoIcons.open; + tint: !root.enabled ? TempoTheme.text-disabled : TempoTheme.primary; + width: 13px; height: 13px; + } + } +} + +export component TempoKeyCap inherits Rectangle { + in property text; + height: 24px; + preferred-width: max(24px, lbl.preferred-width + 12px); + border-radius: TempoTokens.radius-xs; + border-width: TempoTokens.border-width; + border-color: TempoTheme.border-strong; + background: TempoTheme.surface-alt; + lbl := Text { + text: root.text; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-xs; + font-weight: 700; + horizontal-alignment: center; + vertical-alignment: center; + } +} + +export component TempoRangeSlider inherits Rectangle { + in-out property low: 0.2; + in-out property high: 0.8; + in property minimum: 0.0; + in property maximum: 1.0; + in property enabled: true; + callback range-changed(float, float); + private property span: max(0.0001, root.maximum - root.minimum); + private property low-frac: clamp((root.low - root.minimum) / root.span, 0.0, 1.0); + private property high-frac: clamp((root.high - root.minimum) / root.span, root.low-frac, 1.0); + private property active-thumb: 0; // 1 = low, 2 = high + min-height: 28px; + function update-at(x: length) { + if !root.enabled { return; } + let frac = clamp((x - 9px) / max(1px, root.width - 18px), 0.0, 1.0); + let val = root.minimum + frac * root.span; + if root.active-thumb == 1 { + root.low = min(val, root.high); + root.range-changed(root.low, root.high); + } else if root.active-thumb == 2 { + root.high = max(val, root.low); + root.range-changed(root.low, root.high); + } + } + Rectangle { + x: 9px; + y: (parent.height - self.height) / 2; + width: max(0px, root.width - 18px); + height: 4px; + border-radius: 2px; + background: TempoTheme.border; + Rectangle { + x: parent.width * root.low-frac; + width: max(0px, parent.width * (root.high-frac - root.low-frac)); + height: parent.height; + border-radius: 2px; + background: root.enabled ? TempoTheme.primary : TempoTheme.text-disabled; + } + } + // Low thumb + Rectangle { + x: max(0px, root.width - self.width) * root.low-frac; + y: (parent.height - self.height) / 2; + width: 18px; height: 18px; + border-radius: 9px; + border-width: 1.5px; + border-color: TempoTheme.border-strong; + background: TempoTheme.surface-elevated; + Rectangle { + width: root.active-thumb == 1 && touch.pressed ? 8px : touch.has-hover ? 12px : 10px; + height: self.width; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + border-radius: self.width / 2; + background: root.enabled ? TempoTheme.primary : TempoTheme.text-disabled; + animate width, height { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + } + } + // High thumb + Rectangle { + x: max(0px, root.width - self.width) * root.high-frac; + y: (parent.height - self.height) / 2; + width: 18px; height: 18px; + border-radius: 9px; + border-width: 1.5px; + border-color: TempoTheme.border-strong; + background: TempoTheme.surface-elevated; + Rectangle { + width: root.active-thumb == 2 && touch.pressed ? 8px : touch.has-hover ? 12px : 10px; + height: self.width; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + border-radius: self.width / 2; + background: root.enabled ? TempoTheme.primary : TempoTheme.text-disabled; + animate width, height { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + } + } + touch := TouchArea { + enabled: root.enabled; + mouse-cursor: pointer; + pointer-event(e) => { + if e.kind == PointerEventKind.down { + let frac = clamp((self.mouse-x - 9px) / max(1px, self.width - 18px), 0.0, 1.0); + root.active-thumb = abs(frac - root.low-frac) <= abs(frac - root.high-frac) ? 1 : 2; + root.update-at(self.mouse-x); + } else if e.kind == PointerEventKind.up { + root.active-thumb = 0; + } + } + moved => { + if self.pressed { root.update-at(self.mouse-x); } + } + } +} + +export component TempoStatusDot inherits HorizontalLayout { + in property label; + in property variant: success; + private property dot-color: root.variant == success ? TempoTheme.success + : root.variant == warning ? TempoTheme.warning + : root.variant == danger ? TempoTheme.danger + : root.variant == primary ? TempoTheme.primary : TempoTheme.text-tertiary; + spacing: TempoTokens.gap6; + cross-axis-alignment: center; + alignment: start; + Rectangle { + width: 8px; height: 8px; + border-radius: TempoTokens.radius-full; + background: root.dot-color; + } + if root.label != "" : Text { + text: root.label; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + font-weight: 600; + } +} diff --git a/ui/icons.slint b/ui/icons.slint index 398ea61..7ecb878 100644 --- a/ui/icons.slint +++ b/ui/icons.slint @@ -1,4 +1,4 @@ -// FinUI aliases mapped to Fluent System Icons 1.1.347. See LICENSES/Fluent-System-Icons-MIT.txt. +// Fluent System Icons 1.1.347. See LICENSES/Fluent-System-Icons-MIT.txt. export global TempoIcons { out property home: @image-url("icons/home_24_regular.svg"); out property home-filled: @image-url("icons/home_24_filled.svg"); diff --git a/ui/index.slint b/ui/index.slint index 8c7cdfa..3e7e891 100644 --- a/ui/index.slint +++ b/ui/index.slint @@ -1,10 +1,10 @@ export { TempoTheme, TempoTokens, TempoAccent } from "theme.slint"; -export { TempoAction, TempoIcon, TempoButton, TempoButtonVariant, TempoIconButton, TempoIconButtonVariant, TempoTagVariant, TempoSurface, TempoClickableSurface, TempoTag, TempoTextField, TempoSearch, TempoSlider } from "controls.slint"; +export { TempoAction, TempoIcon, TempoButton, TempoButtonVariant, TempoIconButton, TempoIconButtonVariant, TempoTagVariant, TempoSurface, TempoClickableSurface, TempoTag, TempoChip, TempoRate, TempoSkeleton, TempoSplitButton, TempoLink, TempoKeyCap, TempoStatusDot, TempoTextField, TempoTextArea, TempoSearch, TempoSwitch, TempoCheckBox, TempoRadioButton, TempoSpinBox, TempoBadge, TempoSlider, TempoRangeSlider } from "controls.slint"; export { TempoDestination, TempoNav, TempoNavItem } from "navigation.slint"; -export { TempoDivider, TempoSection, TempoTile, TempoSelectionTile, TempoRadioTile, TempoSegment, TempoSegmentedControl, TempoProgressBar, TempoEmptyState } from "patterns.slint"; +export { TempoDivider, TempoCard, TempoInfoBar, TempoExpander, TempoPagination, TempoStepBar, TempoBreadcrumb, TempoAvatar, TempoStatCard, TempoProgressRing, TempoTimeline, TempoTimelineEntry, TempoKeyValue, TempoBanner, TempoTabBar, TempoLoadingOverlay, TempoTable, TempoTreeView, TempoTreeNode, TempoColorPicker, TempoCalendar, TempoCarousel, TempoTransfer, TempoSection, TempoTile, TempoSelectionTile, TempoRadioTile, TempoSwitchTile, TempoSegment, TempoSegmentedControl, TempoProgressBar, TempoEmptyState } from "patterns.slint"; export { TempoIcons } from "icons.slint"; -export { TempoChoice, TempoComboBox, TempoDialog, TempoDialogAction, TempoSheet, TempoToastHost, TempoToastType } from "overlays.slint"; +export { TempoChoice, TempoComboBox, TempoDialog, TempoDialogAction, TempoSheet, TempoDrawer, TempoPopover, TempoDatePicker, TempoTimePicker, TempoImageViewer, TempoToastHost, TempoToastType } from "overlays.slint"; export { TempoFloatingActionButton, TempoGroupTab, TempoButtonGroupTabBar, TempoRefresh, TempoRefreshState, TempoRefreshText, TempoRefreshLabels } from "auxiliary.slint"; -export { TempoInsets, TempoNavigationContent, TempoAppBar, TempoPageHead, TempoPage, TempoNavigationShell, TempoAdaptiveSplit, TempoDetailPresentation } from "layout.slint"; +export { TempoInsets, TempoNavigationContent, TempoAppBar, TempoPageHead, TempoPage, TempoNavigationShell, TempoAdaptiveSplit, TempoDetailPresentation, TempoSplitPane } from "layout.slint"; export { TempoVirtualList, TempoIndexedStack, TempoStackPage, TempoMenuEntry, TempoMenuButton, TempoReorderItem, TempoReorderList } from "primitives.slint"; -export { TempoMotionSettings, TempoPresence, TempoRouteMotion } from "motion.slint"; +export { TempoMotionSettings, TempoPresence, TempoRouteMotion, TempoRouteTransition } from "motion.slint"; diff --git a/ui/layout.slint b/ui/layout.slint index 95873dc..fdbd2a0 100644 --- a/ui/layout.slint +++ b/ui/layout.slint @@ -1,4 +1,5 @@ import { ScrollView } from "std-widgets.slint"; +import { TempoMotionSettings } from "motion.slint"; import { TempoTheme, TempoTokens } from "theme.slint"; import { TempoIconButton } from "controls.slint"; import { TempoIcons } from "icons.slint"; @@ -32,7 +33,7 @@ export component TempoAppBar inherits Rectangle { spacing: TempoTokens.gap8; cross-axis-alignment: center; if root.show-back : TempoIconButton { - icon: TempoIcons.chevron-left; label: root.back-label; + icon: TempoIcons.chevron-left; variant: outline; label: root.back-label; activated => { root.back(); } } VerticalLayout { @@ -42,6 +43,7 @@ export component TempoAppBar inherits Rectangle { } @children } + Rectangle { y: parent.height - 1px; height: 1px; background: TempoTheme.border; } } export component TempoPageHead inherits HorizontalLayout { @@ -90,34 +92,34 @@ export component TempoPage inherits Rectangle { export component TempoNavigationShell inherits Rectangle { in property <[TempoDestination]> destinations; + in property <[TempoDestination]> footer-destinations; in-out property selected; + in property selected-footer: -1; in property insets; in property auto-extend: true; in property show-bottom-bar: true; out property compact: root.width < TempoTokens.rail-breakpoint; out property extended: root.auto-extend && root.width >= TempoTokens.extended-rail-breakpoint; + private property rail-width: root.compact ? 0px + : (root.extended ? TempoTokens.desktop-nav-rail-extended-width : TempoTokens.desktop-nav-rail-width) + root.insets.left; + animate rail-width { + enabled: !TempoMotionSettings.reduced; + duration: TempoTokens.motion-medium; + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); + } callback selected-index(int); + callback footer-selected(int); background: TempoTheme.background; VerticalLayout { x: 0px; y: 0px; width: root.width; height: root.height; - HorizontalLayout { + Rectangle { vertical-stretch: 1; - if !root.compact : Rectangle { - width: (root.extended ? TempoTokens.desktop-nav-rail-extended-width : TempoTokens.desktop-nav-rail-width) + root.insets.left; - background: TempoTheme.surface; - Rectangle { x: parent.width - 1px; width: 1px; background: TempoTheme.border; } - VerticalLayout { - padding-left: root.insets.left + 10px; padding-right: 10px; - padding-top: root.insets.top + 16px; padding-bottom: root.insets.bottom + 4px; - TempoNav { - destinations: root.destinations; selected: root.selected; extended: root.extended; - selected-index(i) => { root.selected = i; root.selected-index(i); } - } - Rectangle { vertical-stretch: 1; } - } - } + // Content painted first so the NavRail's right drop-shadow casts cleanly over the body. TempoNavigationContent { - horizontal-stretch: 1; + x: root.rail-width; + y: 0px; + width: max(0px, parent.width - root.rail-width); + height: parent.height; insets: { left: root.compact ? root.insets.left : 0px, right: root.insets.right, @@ -126,10 +128,62 @@ export component TempoNavigationShell inherits Rectangle { }; @children } + if !root.compact : Rectangle { + x: 0px; + y: 0px; + width: root.rail-width; + height: parent.height; + background: TempoTheme.background-alt; + drop-shadow-blur: TempoTheme.dark ? 22px : 14px; + drop-shadow-offset-x: TempoTheme.dark ? 4px : 2px; + drop-shadow-color: TempoTheme.dark ? #06080CC8 : TempoTheme.shadow; + Rectangle { + x: parent.width - 1px; + width: 1px; + background: TempoTheme.dark ? TempoTheme.border-strong.with-alpha(0.6) : TempoTheme.border.with-alpha(0.75); + } + VerticalLayout { + padding-left: root.insets.left + (root.extended ? 8px : 6px); + padding-right: root.extended ? 8px : 6px; + padding-top: root.insets.top + 12px; + padding-bottom: root.insets.bottom + 10px; + spacing: TempoTokens.gap6; + TempoNav { + destinations: root.destinations; + selected: root.selected >= 0 && root.selected < root.destinations.length ? root.selected : -1; + extended: root.extended; + selected-index(i) => { root.selected = i; root.selected-index(i); } + } + Rectangle { vertical-stretch: 1; } + if root.footer-destinations.length > 0 : HorizontalLayout { + padding-left: 6px; padding-right: 6px; + padding-top: 2px; padding-bottom: 2px; + Rectangle { + height: TempoTokens.border-width; + background: TempoTheme.border.with-alpha(0.65); + } + } + if root.footer-destinations.length > 0 : TempoNav { + destinations: root.footer-destinations; + selected: root.selected-footer >= 0 + ? root.selected-footer + : (root.selected >= root.destinations.length ? root.selected - root.destinations.length : -1); + extended: root.extended; + selected-index(i) => { + root.selected = root.destinations.length + i; + root.selected-index(root.destinations.length + i); + root.footer-selected(i); + } + } + } + } } if root.compact && root.show-bottom-bar : Rectangle { height: TempoTokens.bottom-tab-height + root.insets.bottom; - background: TempoTheme.surface; + background: TempoTheme.surface-elevated; + drop-shadow-blur: TempoTheme.dark ? 20px : 14px; + drop-shadow-offset-y: TempoTheme.dark ? -4px : -2px; + drop-shadow-color: TempoTheme.dark ? #06080CC8 : TempoTheme.shadow; Rectangle { y: 0px; height: 1px; background: TempoTheme.border; } TempoNav { x: root.insets.left; y: 0px; @@ -187,3 +241,48 @@ export component TempoAdaptiveSplit inherits Rectangle { if root.three-pane : Rectangle { x: root.supplementary-x - 1px; width: 1px; background: TempoTheme.border; } @children } + + +export component TempoSplitPane inherits Rectangle { + in-out property ratio: 0.45; + in property min-ratio: 0.2; + in property max-ratio: 0.8; + private property handle-width: 8px; + out property first-width: max(0px, (root.width - root.handle-width) * clamp(root.ratio, root.min-ratio, root.max-ratio)); + out property second-x: root.first-width + root.handle-width; + out property second-width: max(0px, root.width - root.second-x); + clip: true; + @children + Rectangle { + x: root.first-width; + y: 0px; + width: root.handle-width; + height: parent.height; + background: handle-touch.pressed || handle-touch.has-hover ? TempoTheme.primary-soft : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + Rectangle { + x: (parent.width - self.width) / 2; + y: 0px; + width: 1px; + height: parent.height; + background: handle-touch.pressed || handle-touch.has-hover ? TempoTheme.primary : TempoTheme.border; + } + Rectangle { + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + width: 3px; + height: 28px; + border-radius: TempoTokens.radius-full; + background: handle-touch.pressed || handle-touch.has-hover ? TempoTheme.primary : TempoTheme.border-strong; + } + handle-touch := TouchArea { + mouse-cursor: col-resize; + moved => { + if self.pressed && root.width > root.handle-width { + let abs-x = root.first-width + self.mouse-x; + root.ratio = clamp(abs-x / (root.width - root.handle-width), root.min-ratio, root.max-ratio); + } + } + } + } +} diff --git a/ui/motion.slint b/ui/motion.slint index dab5022..4705218 100644 --- a/ui/motion.slint +++ b/ui/motion.slint @@ -5,53 +5,87 @@ export global TempoMotionSettings { in-out property reduced: false; } +/// Page transition presets supporting sibling fade, shared-axis hierarchy, +/// and instant switching for dense desktop views or reduced motion. +export enum TempoRouteTransition { + /// Instant switch without animation. + none, + /// Opacity-only entry for sibling / top-level destinations without + /// implying a horizontal hierarchy. + fade-through, + /// Short horizontal travel + fade for hierarchical push (`direction: 1`) + /// and pop (`direction: -1`). + shared-axis-x, + /// Short vertical travel + fade for sub-flows or sheet-like page entries. + shared-axis-y, +} + export component TempoPresence inherits Rectangle { in property active; - in property enter-time: TempoTokens.normal; - in property exit-time: TempoTokens.fast; + in property enter-time: TempoTokens.motion-medium; + in property exit-time: TempoTokens.motion-short; out property progress: root.active ? 1.0 : 0.0; out property present: root.active || root.progress > 0.0; callback exited(); animate progress { enabled: !TempoMotionSettings.reduced; duration: root.active ? root.enter-time : root.exit-time; - easing: cubic-bezier(0.215, 0.61, 0.355, 1.0); + // Emphasized decelerate curve. + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); } changed present => { if !root.present { root.exited(); } } } -// A changed destination gets a fresh, bounded enter transition, without keeping -// an animation tick alive while the page is idle. The host owns the route stack. +// A changed destination gets a fresh, bounded enter transition without +// keeping an animation tick alive while the page is idle. +// The host owns the route stack. export component TempoRouteMotion inherits Rectangle { in property route-key; + // Transition preset: `fade-through` for sibling tabs, `shared-axis-x` for + // hierarchical push/pop, `shared-axis-y` for vertical sub-flows, `none` for instant switch. + in property transition: TempoRouteTransition.shared-axis-x; + // Direction for shared-axis transitions (+1 forward/push, -1 back/pop, 0 neutral fade). in property direction: 1; in property enabled: true; - in property travel: 22px; + in property travel: TempoTokens.motion-axis-distance; + in property enter-time: TempoTokens.motion-medium; + private property active-motion: root.enabled && !TempoMotionSettings.reduced && root.transition != TempoRouteTransition.none; private property moving: false; private property enter-direction: 1; - out property progress: root.moving ? 0.0 : 1.0; - animate progress { - enabled: !root.moving && root.enabled && !TempoMotionSettings.reduced; - duration: 240ms; - easing: cubic-bezier(0.2, 0.65, 0.3, 1.0); + private property enter-transition: TempoRouteTransition.shared-axis-x; + private property enter-progress: root.moving ? 0.0 : 1.0; + out property progress: root.active-motion ? root.enter-progress : 1.0; + animate enter-progress { + enabled: !root.moving && root.active-motion; + duration: root.enter-time; + // Emphasized decelerate curve: fast initial response, smooth settle. + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); } changed route-key => { - if root.enabled && !TempoMotionSettings.reduced { - root.enter-direction = root.direction; + if root.active-motion { + root.enter-transition = root.transition; + root.enter-direction = clamp(root.direction, -1, 1); root.moving = true; kickoff.running = true; } } kickoff := Timer { + // Give Slint one frame to apply the reset before easing in. interval: 16ms; running: false; triggered => { self.running = false; root.moving = false; } } clip: true; Rectangle { - x: (1.0 - root.progress) * root.travel * root.enter-direction; - width: root.width; height: root.height; - opacity: 0.7 + 0.3 * root.progress; + x: root.enter-transition == TempoRouteTransition.shared-axis-x + ? (1.0 - root.progress) * root.travel * root.enter-direction + : 0px; + y: root.enter-transition == TempoRouteTransition.shared-axis-y + ? (1.0 - root.progress) * root.travel * root.enter-direction + : 0px; + width: root.width; + height: root.height; + opacity: root.active-motion ? root.progress : 1.0; @children } } diff --git a/ui/navigation.slint b/ui/navigation.slint index 730e8c4..d06ad0f 100644 --- a/ui/navigation.slint +++ b/ui/navigation.slint @@ -8,16 +8,18 @@ component TempoNavIcon inherits Rectangle { in property icon; in property ink; in property badge; - in property size: 22px; - width: 38px; - height: 30px; + in property size: 20px; + width: 30px; + height: 26px; TempoIcon { source: root.icon; tint: root.ink; width: root.size; height: root.size; } if root.badge : Rectangle { - x: (root.width + root.size) / 2 - 7px; - y: (root.height - root.size) / 2; + x: (root.width + root.size) / 2 - 5px; + y: (root.height - root.size) / 2 - 1px; width: 7px; height: 7px; border-radius: TempoTokens.radius-full; background: TempoTheme.danger; + border-width: 1.5px; + border-color: TempoTheme.surface; } } @@ -30,76 +32,117 @@ export component TempoNavItem inherits TempoAction { in property bottom; in property extended; private property visible-icon: root.active && root.selected-icon.width > 0 ? root.selected-icon : root.icon; - private property ink: root.active ? TempoTheme.primary : TempoTheme.text-tertiary; + private property icon-ink: root.active ? TempoTheme.primary + : root.hovered ? TempoTheme.text-primary : TempoTheme.text-secondary; + private property label-ink: root.active ? TempoTheme.primary + : root.hovered ? TempoTheme.text-primary : TempoTheme.text-secondary; accessible-role: tab; accessible-item-selectable: true; accessible-item-selected: root.active; - border-radius: TempoTokens.radius-lg; - height: root.bottom ? TempoTokens.bottom-tab-height : root.extended ? 46px : 62px; + border-radius: TempoTokens.radius-sm; + height: root.bottom ? TempoTokens.bottom-tab-height : root.extended ? 38px : 50px; + + // Crisp active surface + subtle hover/press feedback + border-width: !root.bottom && root.active ? TempoTokens.border-width : 0px; + border-color: root.active ? TempoTheme.primary.with-alpha(TempoTheme.dark ? 0.28 : 0.20) : transparent; background: root.bottom ? transparent - : root.pressed ? TempoTheme.surface-pressed + : root.pressed ? (root.active ? TempoTheme.primary-subtle : TempoTheme.surface-pressed) : root.active && root.hovered ? TempoTheme.primary-subtle : root.active ? TempoTheme.primary-soft : root.hovered ? TempoTheme.surface-alt : transparent; - animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + // Mobile Bottom Bar: clean icon + label (no oval pill background or border) if root.bottom : VerticalLayout { alignment: center; + spacing: 4px; HorizontalLayout { alignment: center; - Rectangle { - width: root.active ? 26px : 0px; - height: 3px; - border-radius: TempoTokens.radius-full; - background: TempoTheme.primary; - animate width { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; easing: ease-out; } + TempoNavIcon { + icon: root.visible-icon; + ink: root.icon-ink; + badge: root.badge; + size: 22px; } } - Rectangle { height: 8px; } - HorizontalLayout { - alignment: center; - TempoIcon { source: root.visible-icon; tint: root.ink; width: 22px; height: 22px; } - } - Rectangle { height: 4px; } Text { - text: root.label; color: root.ink; font-size: 10px; + text: root.label; + color: root.label-ink; + font-size: 11px; font-weight: root.active ? 700 : 500; - horizontal-alignment: center; overflow: elide; + horizontal-alignment: center; + overflow: elide; } } - if !root.bottom : HorizontalLayout { - padding-right: root.extended ? 12px : 6px; + + // Desktop Extended Sidebar: left accent indicator + icon and label row + if !root.bottom && root.extended : HorizontalLayout { + padding-left: 6px; + padding-right: 12px; cross-axis-alignment: center; + spacing: 8px; + // Vertical accent pill (centered, 3px x 18px) Rectangle { - width: 6px; height: 28px; + width: 3px; + height: 20px; Rectangle { - width: 3px; height: root.active ? 28px : 0px; + x: 0px; + y: (parent.height - self.height) / 2; + width: 3px; + height: root.active ? 18px : 0px; border-radius: TempoTokens.radius-full; background: TempoTheme.primary; - animate height { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; easing: ease-out; } + animate height { + enabled: !TempoMotionSettings.reduced; + duration: TempoTokens.motion-short; + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); + } } } - if root.extended : HorizontalLayout { + TempoNavIcon { icon: root.visible-icon; ink: root.icon-ink; badge: root.badge; size: 19px; } + Text { + text: root.label; + color: root.label-ink; + font-size: 13px; + font-weight: root.active ? 700 : 500; + overflow: elide; horizontal-stretch: 1; - padding-left: 6px; spacing: 10px; - cross-axis-alignment: center; - TempoNavIcon { icon: root.visible-icon; ink: root.ink; badge: root.badge; } - Text { - text: root.label; color: root.ink; font-size: 13px; - font-weight: root.active ? 700 : 600; overflow: elide; - horizontal-stretch: 1; + } + } + + // Desktop Compact Rail: left accent indicator + centered icon & label + if !root.bottom && !root.extended : Rectangle { + // Vertical accent pill on the inner-left edge + Rectangle { + x: 3px; + y: (parent.height - self.height) / 2; + width: 3px; + height: root.active ? 20px : 0px; + border-radius: TempoTokens.radius-full; + background: TempoTheme.primary; + animate height { + enabled: !TempoMotionSettings.reduced; + duration: TempoTokens.motion-short; + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); } } - if !root.extended : VerticalLayout { - horizontal-stretch: 1; spacing: 2px; - alignment: center; cross-axis-alignment: center; - TempoNavIcon { icon: root.visible-icon; ink: root.ink; badge: root.badge; } + VerticalLayout { + x: 0px; y: 0px; width: parent.width; height: parent.height; + spacing: 2px; + alignment: center; + cross-axis-alignment: center; + TempoNavIcon { icon: root.visible-icon; ink: root.icon-ink; badge: root.badge; size: 20px; } Text { - text: root.label; color: root.ink; font-size: 10px; - font-weight: root.active ? 600 : 500; overflow: elide; + text: root.label; + color: root.label-ink; + font-size: 10px; + font-weight: root.active ? 700 : 500; + horizontal-alignment: center; + overflow: elide; } } } + if !root.bottom && !root.extended : Tooltip { Text { text: root.tooltip == "" ? root.label : root.tooltip; } } } @@ -109,21 +152,30 @@ export component TempoNav inherits Rectangle { in property bottom; in property extended; callback selected-index(int); + vertical-stretch: 0; + preferred-height: root.bottom + ? TempoTokens.bottom-tab-height + : root.destinations.length * (root.extended ? 38px : 50px) + max(0, root.destinations.length - 1) * 3px; + min-height: self.preferred-height; accessible-role: navigation; accessible-label: "Main navigation"; if root.bottom : HorizontalLayout { + padding-left: 6px; + padding-right: 6px; + spacing: 2px; for destination[index] in root.destinations : TempoNavItem { horizontal-stretch: 1; label: destination.label; icon: destination.icon; selected-icon: destination.selected-icon; + badge: destination.badge; active: index == root.selected; bottom: true; activated => { root.selected-index(index); } } } if !root.bottom : VerticalLayout { - spacing: 6px; + spacing: 3px; for destination[index] in root.destinations : TempoNavItem { label: destination.label; icon: destination.icon; diff --git a/ui/overlays.slint b/ui/overlays.slint index f849eee..bbc9835 100644 --- a/ui/overlays.slint +++ b/ui/overlays.slint @@ -1,8 +1,8 @@ import { ScrollView } from "std-widgets.slint"; import { TempoTheme, TempoTokens } from "theme.slint"; -import { TempoAction, TempoButton, TempoButtonVariant, TempoIcon, TempoIconButton, TempoSurface } from "controls.slint"; -import { TempoDivider } from "patterns.slint"; -import { TempoPresence } from "motion.slint"; +import { TempoAction, TempoButton, TempoButtonVariant, TempoIcon, TempoIconButton, TempoSpinBox, TempoSurface } from "controls.slint"; +import { TempoCalendar, TempoDivider } from "patterns.slint"; +import { TempoMotionSettings, TempoPresence } from "motion.slint"; import { TempoIcons } from "icons.slint"; export struct TempoChoice { label: string, enabled: bool } @@ -20,13 +20,13 @@ export component TempoComboBox inherits VerticalLayout { callback selected-index(int); out property opened: popup.is-open; private property highlighted: -1; - in property use-bottom-sheet: root.sheet-width > 0px && root.sheet-width < TempoTokens.rail-breakpoint; + in property use-bottom-sheet: false; out property is-bottom-sheet: root.use-bottom-sheet && root.sheet-width > 0px && root.sheet-height > 0px; private property popup-gap: TempoTokens.gap4; private property space-above: max(0px, trigger.absolute-position.y - root.sheet-origin.y - root.popup-gap); private property space-below: max(0px, root.sheet-origin.y + root.sheet-height - root.bottom-inset - trigger.absolute-position.y - trigger.height - root.popup-gap); - private property dropdown-height: min(264px, root.items.length * 42px + 8px); + private property dropdown-height: min(264px, root.items.length * 38px + 8px); out property opens-above: !root.is-bottom-sheet && root.sheet-height > 0px && root.space-below < root.dropdown-height && root.space-above > root.space-below; private property panel-height: root.is-bottom-sheet @@ -66,10 +66,11 @@ export component TempoComboBox inherits VerticalLayout { accessible-action-expand => { root.open(); } accessible-value: root.valid ? root.items[root.selected].label : ""; height: TempoTokens.input-height; - background: TempoTheme.surface; + background: self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : TempoTheme.surface; border-radius: TempoTokens.radius-md; border-width: 1px; - border-color: TempoTheme.border; + border-color: popup.is-open ? TempoTheme.primary : self.hovered ? TempoTheme.border-strong : TempoTheme.border; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } activated => { if popup.is-open { root.close(); } else { root.open(); } } HorizontalLayout { padding-left: 12px; padding-right: 12px; spacing: 8px; @@ -79,10 +80,10 @@ export component TempoComboBox inherits VerticalLayout { horizontal-stretch: 1; font-size: 14px; overflow: elide; color: !root.enabled ? TempoTheme.text-disabled : root.valid ? TempoTheme.text-primary : TempoTheme.text-tertiary; } - TempoIcon { source: TempoIcons.chevron-down; width: 18px; height: 18px; } + TempoIcon { source: popup.is-open ? TempoIcons.chevron-up : TempoIcons.chevron-down; width: 18px; height: 18px; } } } - entry-motion := TempoPresence { active: popup.is-open; enter-time: root.is-bottom-sheet ? 240ms : 120ms; } + entry-motion := TempoPresence { active: popup.is-open; enter-time: root.is-bottom-sheet ? 240ms : TempoTokens.motion-short; } popup := PopupWindow { x: root.is-bottom-sheet ? root.sheet-origin.x - root.absolute-position.x : 0px; y: root.is-bottom-sheet ? root.sheet-origin.y - root.absolute-position.y @@ -104,10 +105,13 @@ export component TempoComboBox inherits VerticalLayout { TouchArea { clicked => { root.close(); } } } TempoSurface { + elevated: true; width: parent.width; height: root.panel-height; x: 0px; - y: parent.height - root.panel-height + (root.is-bottom-sheet ? (1 - entry-motion.progress) * root.panel-height : 0px); + y: root.is-bottom-sheet + ? parent.height - root.panel-height + (1 - entry-motion.progress) * root.panel-height + : (root.opens-above ? 6px : -6px) * (1 - entry-motion.progress); opacity: root.is-bottom-sheet ? 1 : entry-motion.progress; border-radius: root.is-bottom-sheet ? TempoTokens.radius-xl : TempoTokens.radius-lg; clip: true; @@ -124,19 +128,33 @@ export component TempoComboBox inherits VerticalLayout { content-width: self.visible-width; content-height: list.preferred-height; list := VerticalLayout { + spacing: 2px; for item[i] in root.items : TempoAction { private property highlighted: i == root.highlighted; changed highlighted => { if self.highlighted { self.ensure-visible(instant); } } label: item.label; enabled: item.enabled; - height: 42px; border-radius: TempoTokens.radius-sm; - background: i == root.selected || i == root.highlighted ? TempoTheme.primary-soft + height: 36px; border-radius: TempoTokens.radius-xs; + background: i == root.selected ? TempoTheme.primary-soft + : self.highlighted ? TempoTheme.surface-alt + : self.pressed && item.enabled ? TempoTheme.surface-pressed : self.hovered && item.enabled ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { root.choose(i); } + // Left accent pill on selected item + if i == root.selected : Rectangle { + x: 3px; + y: (parent.height - self.height) / 2; + width: 3px; + height: 16px; + border-radius: TempoTokens.radius-full; + background: TempoTheme.primary; + } Text { - x: 12px; width: parent.width - 24px; height: parent.height; - vertical-alignment: center; overflow: elide; text: item.label; font-size: 14px; + x: 14px; width: parent.width - 26px; height: parent.height; + vertical-alignment: center; overflow: elide; text: item.label; font-size: 13px; + font-weight: i == root.selected ? 600 : 400; color: !item.enabled ? TempoTheme.text-disabled : i == root.selected ? TempoTheme.primary : TempoTheme.text-primary; } - activated => { root.choose(i); } } } } @@ -184,8 +202,8 @@ export component TempoDialog inherits Rectangle { } presence := TempoPresence { active: root.opened; - enter-time: root.bottom-sheet ? 240ms : 180ms; - exit-time: root.bottom-sheet ? 180ms : 120ms; + enter-time: root.bottom-sheet ? 240ms : 200ms; + exit-time: root.bottom-sheet ? 170ms : 130ms; exited => { if !root.opened { modal.close(); } } } @@ -203,54 +221,104 @@ export component TempoDialog inherits Rectangle { Rectangle { background: #0007.with-alpha(0.47 * presence.progress); } TouchArea { clicked => { if root.dismiss-on-backdrop { root.close(); } } } TempoSurface { + elevated: true; opacity: root.bottom-sheet ? 1 : presence.progress; width: min(root.panel-width, max(0px, root.width - 32px)); x: (root.width - self.width) / 2; height: min(root.height - 32px, panel.preferred-height); y: root.bottom-sheet ? root.height - (self.height + 12px + root.bottom-inset) * presence.progress - : (root.height - self.height) / 2 + 18px * (1.0 - presence.progress); + : (root.height - self.height) / 2 + 12px * (1.0 - presence.progress); + border-radius: root.bottom-sheet ? TempoTokens.radius-xl : TempoTokens.radius-lg; clip: true; accessible-role: groupbox; accessible-label: root.title; // Intercept backdrop presses below the panel without blocking its controls. TouchArea {} panel := VerticalLayout { + if root.bottom-sheet : HorizontalLayout { + alignment: center; + padding-top: 8px; + Rectangle { + width: 36px; height: 4px; + border-radius: 2px; + background: TempoTheme.border-strong; + } + } HorizontalLayout { - padding: 16px; spacing: 10px; cross-axis-alignment: center; + padding-left: 20px; padding-right: 14px; + padding-top: root.bottom-sheet ? 10px : 18px; + padding-bottom: 10px; + spacing: 12px; + cross-axis-alignment: start; if root.icon.width > 0 : Rectangle { - width: 36px; height: 36px; background: TempoTheme.primary-soft; + width: 34px; height: 34px; + background: root.destructive ? TempoTheme.danger-soft : TempoTheme.primary-soft; border-radius: TempoTokens.radius-sm; - TempoIcon { source: root.icon; tint: TempoTheme.primary; width: 20px; height: 20px; } + border-width: TempoTokens.border-width; + border-color: root.destructive ? TempoTheme.danger.with-alpha(0.25) : TempoTheme.primary.with-alpha(0.20); + TempoIcon { + source: root.icon; + tint: root.destructive ? TempoTheme.danger : TempoTheme.primary; + width: 18px; height: 18px; + } } VerticalLayout { - horizontal-stretch: 1; spacing: 4px; - Text { text: root.title; color: TempoTheme.text-primary; font-size: 16px; font-weight: 700; wrap: word-wrap; } - if root.subtitle != "" : Text { text: root.subtitle; color: TempoTheme.text-secondary; font-size: 12px; wrap: word-wrap; } + horizontal-stretch: 1; spacing: 3px; + Text { + text: root.title; + color: TempoTheme.text-primary; + font-size: 16px; + font-weight: 700; + wrap: word-wrap; + } + if root.subtitle != "" : Text { + text: root.subtitle; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + wrap: word-wrap; + } + } + TempoIconButton { + label: "Close"; + icon: TempoIcons.close; + size: 28px; + icon-size: 15px; + enabled: root.opened; + activated => { root.close(); } } } - TempoDivider {} ScrollView { vertical-stretch: 1; - preferred-height: min(240px, inner.preferred-height); + preferred-height: min(260px, inner.preferred-height); content-width: self.visible-width; content-height: inner.preferred-height; - inner := VerticalLayout { padding: 16px; @children } + inner := VerticalLayout { + padding-left: 20px; padding-right: 20px; + padding-top: 4px; padding-bottom: 18px; + @children + } } if root.has-actions : TempoDivider {} - if root.has-actions : FlexboxLayout { - alignment: end; padding: 12px; spacing: 8px; - for action[i] in root.actions : TempoButton { - label: action.label; icon: action.icon; variant: action.variant; compact: true; - enabled: root.opened && action.enabled; - activated => { if action.close-on-click { root.close(); } root.action-selected(i); } - } - if root.actions.length == 0 && root.cancel-label != "" : TempoButton { - enabled: root.opened; label: root.cancel-label; variant: ghost; compact: true; - activated => { root.close(); root.cancelled(); } - } - if root.actions.length == 0 && root.confirm-label != "" : TempoButton { - enabled: root.opened; label: root.confirm-label; variant: root.destructive ? danger : primary; compact: true; - activated => { root.close(); root.confirmed(); } + if root.has-actions : Rectangle { + background: TempoTheme.surface-alt; + FlexboxLayout { + alignment: end; + padding-left: 16px; padding-right: 16px; + padding-top: 12px; padding-bottom: 12px; + spacing: 8px; + for action[i] in root.actions : TempoButton { + label: action.label; icon: action.icon; variant: action.variant; compact: true; + enabled: root.opened && action.enabled; + activated => { if action.close-on-click { root.close(); } root.action-selected(i); } + } + if root.actions.length == 0 && root.cancel-label != "" : TempoButton { + enabled: root.opened; label: root.cancel-label; variant: outline; compact: true; + activated => { root.close(); root.cancelled(); } + } + if root.actions.length == 0 && root.confirm-label != "" : TempoButton { + enabled: root.opened; label: root.confirm-label; variant: root.destructive ? danger : primary; compact: true; + activated => { root.close(); root.confirmed(); } + } } } } @@ -296,36 +364,553 @@ export component TempoToastHost inherits Rectangle { } expiry := Timer { running: false; interval: 2s; triggered => { root.dismiss(); } } presence := TempoPresence { active: root.showing; } - if presence.present : TempoSurface { - width: max(0px, min(520px, body.preferred-width, root.width - 32px - root.left-inset - root.right-inset)); - x: root.left-inset + (parent.width - self.width - root.left-inset - root.right-inset) / 2; - y: root.height - root.bottom-inset - self.height - 76px + (1.0 - presence.progress) * 26px; - height: 44px; - border-radius: TempoTokens.radius-full; - drop-shadow-blur: 18px; drop-shadow-offset-y: 8px; - drop-shadow-color: TempoTheme.dark ? #0005 : #0002; + private property desktop-growl: root.width >= TempoTokens.rail-breakpoint; + // Desktop: top-right notification card + if presence.present && root.desktop-growl : TempoSurface { + elevated: true; + clip: true; + width: min(360px, max(240px, root.width - 32px - root.left-inset - root.right-inset)); + height: max(46px, desktop-body.preferred-height); + x: root.width - root.right-inset - self.width - 16px + (1.0 - presence.progress) * 16px; + y: 16px; + border-radius: TempoTokens.radius-md; opacity: presence.progress; accessible-role: region; accessible-live-region: polite; accessible-label: root.headline + " " + root.message; - body := HorizontalLayout { - padding-left: 10px; padding-right: 8px; spacing: 8px; cross-axis-alignment: center; + Rectangle { + x: 0px; y: 0px; + width: 3px; height: parent.height; + background: root.ink; + } + desktop-body := HorizontalLayout { + padding-left: 14px; padding-right: 10px; + padding-top: 10px; padding-bottom: 10px; + spacing: 10px; + cross-axis-alignment: center; Rectangle { - width: 28px; height: 28px; border-radius: TempoTokens.radius-full; background: root.soft; + width: 28px; height: 28px; + border-radius: TempoTokens.radius-sm; + background: root.soft; TempoIcon { source: root.kind == error ? TempoIcons.error : root.kind == warning ? TempoIcons.warning : root.kind == success ? TempoIcons.check : TempoIcons.info; tint: root.ink; width: 17px; height: 17px; } } + VerticalLayout { + horizontal-stretch: 1; + spacing: 2px; + if root.headline != "" : Text { + text: root.headline; + color: TempoTheme.text-primary; + font-size: 13px; + font-weight: 700; + overflow: elide; + } + if root.message != "" : Text { + text: root.message; + color: root.headline != "" ? TempoTheme.text-secondary : TempoTheme.text-primary; + font-size: TempoTokens.text-sm; + font-weight: root.headline != "" ? 400 : 600; + wrap: word-wrap; + } + } + TempoIconButton { + enabled: root.showing; size: 26px; icon-size: 14px; label: "Dismiss toast"; icon: TempoIcons.close; + activated => { root.dismiss(); } + } + } + } + // Mobile / compact: concise bottom-centered bar with restrained radius + if presence.present && !root.desktop-growl : TempoSurface { + elevated: true; + clip: true; + width: max(0px, min(420px, mobile-body.preferred-width, root.width - 28px - root.left-inset - root.right-inset)); + height: 42px; + x: root.left-inset + (parent.width - self.width - root.left-inset - root.right-inset) / 2; + y: root.height - root.bottom-inset - self.height - 76px + (1.0 - presence.progress) * 16px; + border-radius: TempoTokens.radius-md; + opacity: presence.progress; + accessible-role: region; accessible-live-region: polite; + accessible-label: root.headline + " " + root.message; + mobile-body := HorizontalLayout { + padding-left: 10px; padding-right: 6px; + spacing: 8px; + cross-axis-alignment: center; + Rectangle { + width: 24px; height: 24px; + border-radius: TempoTokens.radius-xs; + background: root.soft; + TempoIcon { + source: root.kind == error ? TempoIcons.error : root.kind == warning ? TempoIcons.warning + : root.kind == success ? TempoIcons.check : TempoIcons.info; + tint: root.ink; width: 15px; height: 15px; + } + } Text { horizontal-stretch: 1; - text: root.headline != "" ? root.headline + " " + root.message : root.message; - color: TempoTheme.text-primary; font-size: 12px; font-weight: 700; overflow: elide; + text: root.headline != "" ? root.headline + " · " + root.message : root.message; + color: TempoTheme.text-primary; + font-size: TempoTokens.text-sm; + font-weight: 600; + overflow: elide; } TempoIconButton { - enabled: root.showing; size: 24px; icon-size: 16px; label: "Dismiss toast"; icon: TempoIcons.close; + enabled: root.showing; size: 24px; icon-size: 14px; label: "Dismiss toast"; icon: TempoIcons.close; activated => { root.dismiss(); } } } } } + + +export component TempoDrawer inherits Rectangle { + in property title; + in property subtitle; + in property drawer-width: 340px; + in property from-left: false; + in property dismiss-on-backdrop: true; + out property opened: false; + out property presented: modal.is-open; + callback dismissed(); + public function show() { + if !modal.is-open { modal.show(); } + root.opened = true; + } + public function close() { + if root.opened { + root.opened = false; + if !presence.present { modal.close(); } + } + } + changed presented => { + if !root.presented { + root.opened = false; + root.dismissed(); + } + } + presence := TempoPresence { + active: root.opened; + enter-time: TempoTokens.motion-medium; + exit-time: TempoTokens.motion-short; + exited => { if !root.opened { modal.close(); } } + } + modal := PopupWindow { + x: 0px; y: 0px; width: root.width; height: root.height; + close-policy: no-auto-close; + forward-focus: keys; + keys := FocusScope { + key-pressed(e) => { + if e.text == Key.Escape || e.text == Key.Back { root.close(); return accept; } + return reject; + } + Rectangle { background: #0B0E14.with-alpha(0.45 * presence.progress); } + TouchArea { clicked => { if root.dismiss-on-backdrop { root.close(); } } } + Rectangle { + width: min(root.drawer-width, max(0px, root.width - 40px)); + height: root.height; + x: root.from-left + ? -self.width * (1.0 - presence.progress) + : root.width - self.width * presence.progress; + y: 0px; + background: TempoTheme.surface-elevated; + drop-shadow-blur: 24px; + drop-shadow-offset-x: root.from-left ? 4px : -4px; + drop-shadow-color: TempoTheme.dark ? #06080CC8 : TempoTheme.shadow; + TouchArea {} + Rectangle { + x: root.from-left ? parent.width - 1px : 0px; + width: 1px; height: parent.height; + background: TempoTheme.border; + } + VerticalLayout { + HorizontalLayout { + padding-left: 18px; padding-right: 12px; + padding-top: 16px; padding-bottom: 14px; + spacing: 10px; + cross-axis-alignment: center; + VerticalLayout { + horizontal-stretch: 1; + spacing: 2px; + if root.title != "" : Text { + text: root.title; + color: TempoTheme.text-primary; + font-size: 16px; + font-weight: 700; + overflow: elide; + } + if root.subtitle != "" : Text { + text: root.subtitle; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + overflow: elide; + } + } + TempoIconButton { + label: "Close drawer"; + icon: TempoIcons.close; + variant: outline; + size: 30px; + icon-size: 15px; + enabled: root.opened; + activated => { root.close(); } + } + } + TempoDivider {} + ScrollView { + vertical-stretch: 1; + content-width: self.visible-width; + content-height: body.preferred-height; + body := VerticalLayout { + padding: 18px; + spacing: TempoTokens.gap12; + @children + } + } + } + } + } + } +} + + +export component TempoPopover inherits Rectangle { + in property title; + in property subtitle; + in property popover-width: 260px; + out property opened: popup.is-open; + public function show() { popup.show(); } + public function close() { popup.close(); } + public function toggle() { if popup.is-open { popup.close(); } else { popup.show(); } } + presence := TempoPresence { active: popup.is-open; enter-time: TempoTokens.motion-short; } + popup := PopupWindow { + x: 0px; + y: root.height + 6px; + width: root.popover-width; + height: content.preferred-height; + close-policy: close-on-click-outside; + TempoSurface { + elevated: true; + width: parent.width; + height: content.preferred-height; + y: -6px * (1.0 - presence.progress); + opacity: presence.progress; + clip: true; + content := VerticalLayout { + padding: 14px; + spacing: TempoTokens.gap8; + if root.title != "" : Text { + text: root.title; + color: TempoTheme.text-primary; + font-size: 13px; + font-weight: 700; + } + if root.subtitle != "" : Text { + text: root.subtitle; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + wrap: word-wrap; + } + @children + } + } + } +} + + +export component TempoDatePicker inherits VerticalLayout { + in property label; + in property month-label: "November 2026"; + in property value-text: "2026-11-28"; + in property days-in-month: 30; + in property first-weekday: 0; + in property today: 28; + in-out property selected-day: 28; + in property enabled: true; + in property sheet-width; + in property sheet-height; + in property sheet-origin; + in property bottom-inset; + callback day-selected(int); + callback prev-month(); + callback next-month(); + private property popup-width: 280px; + private property popup-height: 296px; + private property space-above: max(0px, trigger.absolute-position.y - root.sheet-origin.y - 6px); + private property space-below: max(0px, root.sheet-origin.y + root.sheet-height - root.bottom-inset + - trigger.absolute-position.y - trigger.height - 6px); + private property opens-above: root.sheet-height > 0px + && root.space-below < root.popup-height && root.space-above > root.space-below; + private property clamped-x: root.sheet-width > 0px + ? max( + root.sheet-origin.x - root.absolute-position.x + 8px, + min(0px, root.sheet-origin.x + root.sheet-width - root.absolute-position.x - root.popup-width - 8px) + ) + : 0px; + spacing: TempoTokens.gap6; + if root.label != "" : Text { + text: root.label; color: TempoTheme.text-secondary; font-size: TempoTokens.text-sm; font-weight: 600; + } + trigger := TempoAction { + label: root.label != "" ? root.label : "Select date"; + enabled: root.enabled; + height: TempoTokens.input-height; + border-radius: TempoTokens.radius-sm; + border-width: TempoTokens.border-width; + border-color: popup.is-open ? TempoTheme.primary : self.hovered ? TempoTheme.border-strong : TempoTheme.border; + background: self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : TempoTheme.surface; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { if popup.is-open { popup.close(); } else { popup.show(); } } + HorizontalLayout { + padding-left: 12px; padding-right: 12px; + spacing: TempoTokens.gap8; + cross-axis-alignment: center; + TempoIcon { source: TempoIcons.calendar; tint: popup.is-open ? TempoTheme.primary : TempoTheme.text-secondary; width: 18px; height: 18px; } + Text { + horizontal-stretch: 1; + text: root.value-text; + color: root.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; + font-size: TempoTokens.text-md; + overflow: elide; + } + TempoIcon { source: popup.is-open ? TempoIcons.chevron-up : TempoIcons.chevron-down; width: 16px; height: 16px; } + } + } + motion := TempoPresence { active: popup.is-open; enter-time: TempoTokens.motion-short; } + popup := PopupWindow { + x: root.clamped-x; + y: root.opens-above ? trigger.y - cal.preferred-height - 4px : trigger.y + trigger.height + 4px; + width: root.popup-width; + height: cal.preferred-height; + close-policy: close-on-click-outside; + cal := TempoCalendar { + elevated: true; + width: parent.width; + y: (root.opens-above ? 6px : -6px) * (1.0 - motion.progress); + opacity: motion.progress; + month-label: root.month-label; + days-in-month: root.days-in-month; + first-weekday: root.first-weekday; + today: root.today; + selected-day <=> root.selected-day; + day-selected(d) => { + popup.close(); + root.day-selected(d); + } + prev-month => { root.prev-month(); } + next-month => { root.next-month(); } + } + } +} + +export component TempoTimePicker inherits VerticalLayout { + in property label; + in-out property hour: 9; + in-out property minute: 30; + in property enabled: true; + in property sheet-width; + in property sheet-height; + in property sheet-origin; + in property bottom-inset; + callback time-changed(int, int); + private property formatted: (root.hour < 10 ? "0" : "") + root.hour + ":" + (root.minute < 10 ? "0" : "") + root.minute; + private property popup-width: 248px; + private property popup-height: 132px; + private property space-above: max(0px, trigger.absolute-position.y - root.sheet-origin.y - 6px); + private property space-below: max(0px, root.sheet-origin.y + root.sheet-height - root.bottom-inset + - trigger.absolute-position.y - trigger.height - 6px); + private property opens-above: root.sheet-height > 0px + && root.space-below < root.popup-height && root.space-above > root.space-below; + private property clamped-x: root.sheet-width > 0px + ? max( + root.sheet-origin.x - root.absolute-position.x + 8px, + min(0px, root.sheet-origin.x + root.sheet-width - root.absolute-position.x - root.popup-width - 8px) + ) + : 0px; + spacing: TempoTokens.gap6; + if root.label != "" : Text { + text: root.label; color: TempoTheme.text-secondary; font-size: TempoTokens.text-sm; font-weight: 600; + } + trigger := TempoAction { + label: root.label != "" ? root.label : "Select time"; + enabled: root.enabled; + height: TempoTokens.input-height; + border-radius: TempoTokens.radius-sm; + border-width: TempoTokens.border-width; + border-color: popup.is-open ? TempoTheme.primary : self.hovered ? TempoTheme.border-strong : TempoTheme.border; + background: self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : TempoTheme.surface; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { if popup.is-open { popup.close(); } else { popup.show(); } } + HorizontalLayout { + padding-left: 12px; padding-right: 12px; + spacing: TempoTokens.gap8; + cross-axis-alignment: center; + TempoIcon { source: TempoIcons.schedule; tint: popup.is-open ? TempoTheme.primary : TempoTheme.text-secondary; width: 18px; height: 18px; } + Text { + horizontal-stretch: 1; + text: root.formatted; + color: root.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; + font-size: TempoTokens.text-md; + font-weight: 600; + } + TempoIcon { source: popup.is-open ? TempoIcons.chevron-up : TempoIcons.chevron-down; width: 16px; height: 16px; } + } + } + motion := TempoPresence { active: popup.is-open; enter-time: TempoTokens.motion-short; } + popup := PopupWindow { + x: root.clamped-x; + y: root.opens-above ? trigger.y - panel.preferred-height - 4px : trigger.y + trigger.height + 4px; + width: root.popup-width; + height: panel.preferred-height; + close-policy: close-on-click-outside; + TempoSurface { + elevated: true; + width: parent.width; + height: panel.preferred-height; + y: (root.opens-above ? 6px : -6px) * (1.0 - motion.progress); + opacity: motion.progress; + panel := VerticalLayout { + padding: 12px; + spacing: TempoTokens.gap10; + HorizontalLayout { + spacing: TempoTokens.gap10; + TempoSpinBox { + horizontal-stretch: 1; + label: "Hour"; + minimum: 0; maximum: 23; + value <=> root.hour; + edited(h) => { root.time-changed(h, root.minute); } + } + TempoSpinBox { + horizontal-stretch: 1; + label: "Minute"; + minimum: 0; maximum: 59; + value <=> root.minute; + edited(m) => { root.time-changed(root.hour, m); } + } + } + HorizontalLayout { + alignment: end; + TempoButton { + label: "Done"; + compact: true; + activated => { popup.close(); } + } + } + } + } + } +} + +export component TempoImageViewer inherits Rectangle { + in property source; + in property title; + out property opened: false; + private property zoom: 1.0; + public function show() { + root.zoom = 1.0; + if !modal.is-open { modal.show(); } + root.opened = true; + } + public function close() { + if root.opened { + root.opened = false; + if !presence.present { modal.close(); } + } + } + presence := TempoPresence { + active: root.opened; + enter-time: TempoTokens.motion-medium; + exit-time: TempoTokens.motion-short; + exited => { if !root.opened { modal.close(); } } + } + modal := PopupWindow { + x: 0px; y: 0px; width: root.width; height: root.height; + close-policy: no-auto-close; + forward-focus: keys; + keys := FocusScope { + key-pressed(e) => { + if e.text == Key.Escape || e.text == Key.Back { root.close(); return accept; } + return reject; + } + Rectangle { background: #0B0E14.with-alpha(0.76 * presence.progress); } + TouchArea { clicked => { root.close(); } } + TempoSurface { + elevated: true; + opacity: presence.progress; + width: min(640px, max(240px, root.width - 48px)); + height: min(480px, max(220px, root.height - 64px)); + x: (root.width - self.width) / 2; + y: (root.height - self.height) / 2 + 12px * (1.0 - presence.progress); + clip: true; + TouchArea {} + VerticalLayout { + HorizontalLayout { + padding-left: 16px; padding-right: 10px; + padding-top: 10px; padding-bottom: 10px; + spacing: TempoTokens.gap8; + cross-axis-alignment: center; + Text { + horizontal-stretch: 1; + text: root.title != "" ? root.title : "Image preview"; + color: TempoTheme.text-primary; + font-size: 14px; + font-weight: 700; + overflow: elide; + } + TempoButton { + label: "−"; + variant: outline; + compact: true; + enabled: root.zoom > 0.5; + activated => { root.zoom = max(0.5, root.zoom - 0.25); } + } + Text { + text: round(root.zoom * 100) + "%"; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + font-weight: 600; + min-width: 40px; + horizontal-alignment: center; + } + TempoButton { + label: "+"; + variant: outline; + compact: true; + enabled: root.zoom < 2.0; + activated => { root.zoom = min(2.0, root.zoom + 0.25); } + } + TempoIconButton { + label: "Close viewer"; + icon: TempoIcons.close; + variant: outline; + size: 30px; + icon-size: 15px; + activated => { root.close(); } + } + } + TempoDivider {} + Rectangle { + vertical-stretch: 1; + background: TempoTheme.background; + clip: true; + if root.source.width > 0 : Image { + source: root.source; + width: parent.width * 0.8 * root.zoom; + height: parent.height * 0.8 * root.zoom; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + image-fit: contain; + } + if root.source.width == 0 : TempoIcon { + source: TempoIcons.apps; + tint: TempoTheme.primary; + width: 72px * root.zoom; + height: 72px * root.zoom; + } + } + } + } + } + } +} diff --git a/ui/patterns.slint b/ui/patterns.slint index 3b9e326..1971cbc 100644 --- a/ui/patterns.slint +++ b/ui/patterns.slint @@ -1,12 +1,126 @@ import { TempoMotionSettings } from "motion.slint"; -import { ProgressIndicator } from "std-widgets.slint"; +import { ProgressIndicator, ScrollView } from "std-widgets.slint"; import { TempoIcons } from "icons.slint"; import { TempoTheme, TempoTokens } from "theme.slint"; -import { TempoAction, TempoButton, TempoIcon, TempoSurface } from "controls.slint"; +import { TempoAction, TempoButton, TempoIcon, TempoIconButton, TempoSurface, TempoSwitch, TempoTagVariant } from "controls.slint"; export component TempoDivider inherits Rectangle { - height: TempoTokens.border-width; - background: TempoTheme.border; + in property label; + height: root.label == "" ? TempoTokens.border-width : 20px; + background: root.label == "" ? TempoTheme.border : transparent; + if root.label != "" : HorizontalLayout { + spacing: TempoTokens.gap10; + cross-axis-alignment: center; + Rectangle { horizontal-stretch: 1; height: TempoTokens.border-width; background: TempoTheme.border; } + Text { + text: root.label; + color: TempoTheme.text-tertiary; + font-size: TempoTokens.text-xs; + font-weight: 600; + } + Rectangle { horizontal-stretch: 1; height: TempoTokens.border-width; background: TempoTheme.border; } + } +} + +export component TempoCard inherits TempoSurface { + in property title; + in property subtitle; + clip: true; + VerticalLayout { + if root.title != "" || root.subtitle != "" : HorizontalLayout { + padding-left: 14px; padding-right: 14px; + padding-top: 12px; padding-bottom: 12px; + spacing: TempoTokens.gap8; + cross-axis-alignment: center; + VerticalLayout { + horizontal-stretch: 1; + spacing: 2px; + if root.title != "" : Text { + text: root.title; + color: TempoTheme.text-primary; + font-size: TempoTokens.text-md; + font-weight: 700; + overflow: elide; + } + if root.subtitle != "" : Text { + text: root.subtitle; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + overflow: elide; + } + } + } + if root.title != "" || root.subtitle != "" : TempoDivider {} + VerticalLayout { + padding: 14px; + spacing: TempoTokens.gap12; + @children + } + } +} + +export component TempoInfoBar inherits Rectangle { + in property title; + in property message; + in property variant: primary; + in property closable: false; + callback closed(); + private property accent: root.variant == success ? TempoTheme.success + : root.variant == warning ? TempoTheme.warning + : root.variant == danger ? TempoTheme.danger + : root.variant == neutral ? TempoTheme.text-secondary : TempoTheme.info; + private property tint-bg: root.variant == success ? TempoTheme.success-soft + : root.variant == warning ? TempoTheme.warning-soft + : root.variant == danger ? TempoTheme.danger-soft + : root.variant == neutral ? TempoTheme.surface-alt : TempoTheme.info-soft; + border-radius: TempoTokens.radius-md; + border-width: TempoTokens.border-width; + border-color: root.variant == neutral ? TempoTheme.border : root.accent.with-alpha(TempoTheme.dark ? 0.35 : 0.25); + background: root.tint-bg; + clip: true; + // Left semantic accent stripe + Rectangle { + x: 0px; y: 0px; + width: 3px; height: parent.height; + background: root.accent; + } + HorizontalLayout { + padding-left: 14px; padding-right: 10px; + padding-top: 10px; padding-bottom: 10px; + spacing: TempoTokens.gap10; + cross-axis-alignment: center; + TempoIcon { + source: root.variant == danger ? TempoIcons.error + : root.variant == warning ? TempoIcons.warning + : root.variant == success ? TempoIcons.check : TempoIcons.info; + tint: root.accent; + width: 18px; height: 18px; + } + VerticalLayout { + horizontal-stretch: 1; + spacing: 2px; + if root.title != "" : Text { + text: root.title; + color: TempoTheme.text-primary; + font-size: 13px; + font-weight: 700; + wrap: word-wrap; + } + if root.message != "" : Text { + text: root.message; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + wrap: word-wrap; + } + } + if root.closable : TempoIconButton { + label: "Close"; + icon: TempoIcons.close; + size: 26px; + icon-size: 14px; + activated => { root.closed(); } + } + } } export component TempoSection inherits VerticalLayout { @@ -30,7 +144,10 @@ export component TempoTile inherits TempoAction { in property trailing-icon; min-height: TempoTokens.tile-min-height; // The enclosing section clips row highlights to its own corners. - background: root.enabled && root.hovered ? TempoTheme.surface-alt : transparent; + background: !root.enabled ? transparent + : root.pressed ? TempoTheme.surface-pressed + : root.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } HorizontalLayout { padding-top: 10px; padding-bottom: 10px; padding-left: 14px; padding-right: 14px; @@ -68,7 +185,10 @@ export component TempoSelectionTile inherits TempoAction { accessible-checked: root.checked; min-height: TempoTokens.tile-min-height; // The enclosing section clips row highlights to its own corners. - background: root.enabled && root.hovered ? TempoTheme.surface-alt : transparent; + background: !root.enabled ? transparent + : root.pressed ? TempoTheme.surface-pressed + : root.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } activated => { root.checked = !root.checked; } HorizontalLayout { padding-top: 10px; padding-bottom: 10px; @@ -104,36 +224,110 @@ export component TempoRadioTile inherits TempoSelectionTile { activated => { root.checked = true; } } +export component TempoSwitchTile inherits TempoAction { + in-out property checked: false; + in property subtitle; + in property icon; + callback toggled(bool); + accessible-role: switch; + accessible-checked: root.checked; + min-height: TempoTokens.tile-min-height; + background: !root.enabled ? transparent + : root.pressed ? TempoTheme.surface-pressed + : root.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { + root.checked = !root.checked; + root.toggled(root.checked); + } + HorizontalLayout { + padding-top: 10px; padding-bottom: 10px; + padding-left: 14px; padding-right: 14px; + cross-axis-alignment: center; + spacing: 12px; + if root.icon.width > 0 : Rectangle { + width: 34px; height: 34px; + border-radius: TempoTokens.radius-sm; + background: TempoTheme.primary-soft; + TempoIcon { source: root.icon; tint: TempoTheme.primary; width: 18px; height: 18px; } + } + VerticalLayout { + horizontal-stretch: 1; + spacing: 2px; + Text { text: root.label; font-size: TempoTokens.text-md; font-weight: 600; color: root.enabled ? TempoTheme.text-primary : TempoTheme.text-disabled; overflow: elide; } + if root.subtitle != "" : Text { + text: root.subtitle; color: root.enabled ? TempoTheme.text-tertiary : TempoTheme.text-disabled; + font-size: TempoTokens.text-sm; overflow: elide; + } + } + TempoSwitch { + checked <=> root.checked; + enabled: root.enabled; + toggled(val) => { root.toggled(val); } + } + } +} + export struct TempoSegment { label: string, icon: image } -export component TempoSegmentedControl inherits HorizontalLayout { +export component TempoSegmentedControl inherits Rectangle { in property <[TempoSegment]> items; in property selected; callback selected-index(int); - spacing: TempoTokens.gap6; - for item[index] in root.items : segment := TempoAction { - private property active: index == root.selected; - private property ink: active ? TempoTheme.primary : TempoTheme.text-secondary; - horizontal-stretch: 1; - label: item.label; + private property count: max(1, root.items.length); + private property inner-width: max(0px, root.width - 6px); + private property slot-width: (root.inner-width - (root.count - 1) * TempoTokens.gap4) / root.count; + border-radius: TempoTokens.radius-md; + border-width: TempoTokens.border-width; + border-color: TempoTheme.border; + background: TempoTheme.surface-alt; + // Smooth sliding active thumb behind segments + if root.selected >= 0 && root.selected < root.items.length : Rectangle { + x: 3px + root.selected * (root.slot-width + TempoTokens.gap4); + y: 3px; + width: root.slot-width; + height: max(0px, parent.height - 6px); border-radius: TempoTokens.radius-sm; border-width: TempoTokens.border-width; - border-color: active ? TempoTheme.primary.with-alpha(0.45) : TempoTheme.border; - background: active ? TempoTheme.primary-soft : TempoTheme.surface; - animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } - activated => { root.selected-index(index); } - VerticalLayout { - padding-top: 8px; padding-bottom: 8px; - spacing: TempoTokens.gap4; - if item.icon.width > 0 : HorizontalLayout { - alignment: center; - TempoIcon { source: item.icon; tint: segment.ink; width: 18px; height: 18px; } - } - Text { - text: item.label; color: segment.ink; - font-size: item.icon.width > 0 ? 11px : 13px; - font-weight: segment.active ? 600 : 400; - horizontal-alignment: center; + border-color: TempoTheme.border; + background: TempoTheme.surface-elevated; + drop-shadow-blur: 6px; + drop-shadow-offset-y: 1px; + drop-shadow-color: TempoTheme.shadow; + animate x, width { + enabled: !TempoMotionSettings.reduced; + duration: TempoTokens.motion-short; + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); + } + } + HorizontalLayout { + padding: 3px; + spacing: TempoTokens.gap4; + for item[index] in root.items : segment := TempoAction { + private property active: index == root.selected; + private property ink: active ? TempoTheme.text-primary : TempoTheme.text-secondary; + horizontal-stretch: 1; + label: item.label; + border-radius: TempoTokens.radius-sm; + background: active ? transparent + : self.pressed ? TempoTheme.surface-pressed + : self.hovered ? TempoTheme.surface.with-alpha(0.55) : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { root.selected-index(index); } + VerticalLayout { + padding-top: 7px; padding-bottom: 7px; + padding-left: 8px; padding-right: 8px; + spacing: TempoTokens.gap4; + if item.icon.width > 0 : HorizontalLayout { + alignment: center; + TempoIcon { source: item.icon; tint: active ? TempoTheme.primary : segment.ink; width: 18px; height: 18px; } + } + Text { + text: item.label; color: active && item.icon.width > 0 ? TempoTheme.primary : segment.ink; + font-size: item.icon.width > 0 ? TempoTokens.text-xs : 13px; + font-weight: segment.active ? 600 : 500; + horizontal-alignment: center; + } } } } @@ -142,9 +336,9 @@ export component TempoSegmentedControl inherits HorizontalLayout { export component TempoProgressBar inherits Rectangle { in property value; in property indeterminate; - height: 6px; + height: 4px; border-radius: TempoTokens.radius-full; - background: TempoTheme.surface-alt; + background: TempoTheme.border; accessible-role: progress-indicator; accessible-value: root.indeterminate ? "" : round(clamp(root.value, 0, 1) * 100) + "%"; if root.indeterminate : ProgressIndicator { indeterminate: true; height: root.height; } @@ -153,6 +347,7 @@ export component TempoProgressBar inherits Rectangle { width: parent.width * clamp(root.value, 0, 1); border-radius: TempoTokens.radius-full; background: TempoTheme.primary; + animate width { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); } } } @@ -179,3 +374,1144 @@ export component TempoEmptyState inherits VerticalLayout { TempoButton { label: root.action-label; variant: secondary; activated => { root.action(); } } } } + + +export component TempoExpander inherits TempoSurface { + in property title; + in property subtitle; + in property icon; + in-out property expanded: false; + callback toggled(bool); + clip: true; + VerticalLayout { + TempoAction { + label: root.title; + min-height: 46px; + background: self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { + root.expanded = !root.expanded; + root.toggled(root.expanded); + } + HorizontalLayout { + padding-left: 14px; padding-right: 14px; + padding-top: 10px; padding-bottom: 10px; + spacing: TempoTokens.gap10; + cross-axis-alignment: center; + if root.icon.width > 0 : TempoIcon { + source: root.icon; + tint: TempoTheme.primary; + width: 18px; height: 18px; + } + VerticalLayout { + horizontal-stretch: 1; + spacing: 2px; + Text { + text: root.title; + color: TempoTheme.text-primary; + font-size: TempoTokens.text-md; + font-weight: 600; + overflow: elide; + } + if root.subtitle != "" : Text { + text: root.subtitle; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + overflow: elide; + } + } + TempoIcon { + source: root.expanded ? TempoIcons.chevron-up : TempoIcons.chevron-down; + tint: TempoTheme.text-secondary; + width: 18px; height: 18px; + } + } + } + if root.expanded : TempoDivider {} + Rectangle { + clip: true; + height: root.expanded ? body.preferred-height : 0px; + opacity: root.expanded ? 1.0 : 0.0; + animate height, opacity { + enabled: !TempoMotionSettings.reduced; + duration: TempoTokens.motion-short; + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); + } + body := VerticalLayout { + x: 0px; y: 0px; width: parent.width; + padding: 14px; + spacing: TempoTokens.gap10; + @children + } + } + } +} + +export component TempoPagination inherits HorizontalLayout { + in-out property current-page: 1; + in property page-count: 1; + callback page-changed(int); + spacing: TempoTokens.gap6; + alignment: start; + function select(page: int) { + let clamped = clamp(page, 1, max(1, root.page-count)); + if clamped != root.current-page { + root.current-page = clamped; + root.page-changed(clamped); + } + } + TempoIconButton { + label: "Previous page"; + icon: TempoIcons.chevron-left; + variant: outline; + size: 32px; + icon-size: 16px; + enabled: root.current-page > 1; + activated => { root.select(root.current-page - 1); } + } + for idx in min(root.page-count, 7) : TempoAction { + private property page-num: idx + 1; + private property active: page-num == root.current-page; + label: "Page " + page-num; + width: 32px; + height: 32px; + border-radius: TempoTokens.radius-sm; + border-width: TempoTokens.border-width; + border-color: active ? TempoTheme.primary : self.hovered ? TempoTheme.border-strong : TempoTheme.border; + background: active ? TempoTheme.primary + : self.pressed ? TempoTheme.surface-pressed + : self.hovered ? TempoTheme.surface-alt : TempoTheme.surface; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { root.select(page-num); } + Text { + text: page-num; + font-size: 13px; + font-weight: active ? 700 : 500; + color: active ? TempoTheme.text-inverse : TempoTheme.text-primary; + horizontal-alignment: center; + vertical-alignment: center; + } + } + TempoIconButton { + label: "Next page"; + icon: TempoIcons.chevron-right; + variant: outline; + size: 32px; + icon-size: 16px; + enabled: root.current-page < root.page-count; + activated => { root.select(root.current-page + 1); } + } +} + + +export component TempoStepBar inherits HorizontalLayout { + in property <[string]> steps; + in property current: 0; + spacing: 0px; + for step[idx] in root.steps : HorizontalLayout { + horizontal-stretch: idx < root.steps.length - 1 ? 1 : 0; + cross-axis-alignment: center; + spacing: TempoTokens.gap8; + VerticalLayout { + spacing: 4px; + alignment: center; + HorizontalLayout { + alignment: center; + Rectangle { + private property done: idx < root.current; + private property active: idx == root.current; + width: 26px; height: 26px; + border-radius: TempoTokens.radius-full; + border-width: done || active ? 0px : TempoTokens.border-width; + border-color: TempoTheme.border-strong; + background: done ? TempoTheme.primary-soft + : active ? TempoTheme.primary : TempoTheme.surface; + if done : TempoIcon { + source: TempoIcons.checkmark-small; + tint: TempoTheme.primary; + width: 14px; height: 14px; + } + if !done : Text { + text: idx + 1; + font-size: TempoTokens.text-sm; + font-weight: 700; + color: active ? TempoTheme.text-inverse : TempoTheme.text-secondary; + horizontal-alignment: center; + vertical-alignment: center; + } + } + } + Text { + text: step; + font-size: TempoTokens.text-xs; + font-weight: idx == root.current ? 700 : 500; + color: idx <= root.current ? TempoTheme.text-primary : TempoTheme.text-tertiary; + horizontal-alignment: center; + } + } + if idx < root.steps.length - 1 : Rectangle { + horizontal-stretch: 1; + height: 2px; + border-radius: 1px; + background: idx < root.current ? TempoTheme.primary : TempoTheme.border; + } + } +} + +export component TempoBreadcrumb inherits HorizontalLayout { + in property <[string]> items; + callback activated(int); + spacing: TempoTokens.gap4; + alignment: start; + cross-axis-alignment: center; + for item[idx] in root.items : HorizontalLayout { + spacing: TempoTokens.gap4; + cross-axis-alignment: center; + if idx > 0 : TempoIcon { + source: TempoIcons.chevron-right; + tint: TempoTheme.text-tertiary; + width: 14px; height: 14px; + } + crumb := TempoAction { + private property is-last: idx == root.items.length - 1; + label: item; + enabled: !is-last; + height: 26px; + border-radius: TempoTokens.radius-xs; + background: !is-last && self.pressed ? TempoTheme.surface-pressed + : !is-last && self.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { root.activated(idx); } + HorizontalLayout { + padding-left: 6px; padding-right: 6px; + cross-axis-alignment: center; + Text { + text: item; + font-size: 13px; + font-weight: is-last ? 700 : 500; + color: is-last ? TempoTheme.text-primary + : crumb.hovered ? TempoTheme.primary : TempoTheme.text-secondary; + } + } + } + } +} + +export component TempoAvatar inherits Rectangle { + in property source; + in property initials; + in property size: 36px; + in property rounded-square: false; + in property online: false; + width: root.size; + height: root.size; + Rectangle { + width: parent.width; + height: parent.height; + border-radius: root.rounded-square ? TempoTokens.radius-md : TempoTokens.radius-full; + border-width: TempoTokens.border-width; + border-color: TempoTheme.border; + background: TempoTheme.primary-soft; + clip: true; + if root.source.width > 0 : Image { + source: root.source; + width: parent.width; + height: parent.height; + image-fit: cover; + } + if root.source.width == 0 && root.initials != "" : Text { + text: root.initials; + color: TempoTheme.primary; + font-size: root.size * 0.38; + font-weight: 700; + horizontal-alignment: center; + vertical-alignment: center; + } + if root.source.width == 0 && root.initials == "" : TempoIcon { + source: TempoIcons.person; + tint: TempoTheme.primary; + width: root.size * 0.52; + height: self.width; + } + } + if root.online : Rectangle { + x: parent.width - 10px; + y: parent.height - 10px; + width: 10px; height: 10px; + border-radius: TempoTokens.radius-full; + border-width: 2px; + border-color: TempoTheme.surface; + background: TempoTheme.success; + } +} + +export component TempoStatCard inherits TempoSurface { + in property icon; + in property label; + in property value; + in property hint; + in property hint-variant: neutral; + private property hint-color: root.hint-variant == success ? TempoTheme.success + : root.hint-variant == warning ? TempoTheme.warning + : root.hint-variant == danger ? TempoTheme.danger + : root.hint-variant == primary ? TempoTheme.primary : TempoTheme.text-tertiary; + VerticalLayout { + padding: 14px; + spacing: TempoTokens.gap8; + HorizontalLayout { + spacing: TempoTokens.gap8; + cross-axis-alignment: center; + Text { + horizontal-stretch: 1; + text: root.label; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + font-weight: 600; + overflow: elide; + } + if root.icon.width > 0 : Rectangle { + width: 28px; height: 28px; + border-radius: TempoTokens.radius-sm; + background: TempoTheme.primary-soft; + TempoIcon { source: root.icon; tint: TempoTheme.primary; width: 16px; height: 16px; } + } + } + Text { + text: root.value; + color: TempoTheme.text-primary; + font-size: 22px; + font-weight: 800; + overflow: elide; + } + if root.hint != "" : Text { + text: root.hint; + color: root.hint-color; + font-size: TempoTokens.text-xs; + font-weight: 600; + overflow: elide; + } + } +} + + +export component TempoProgressRing inherits Rectangle { + in property value: 0.0; + in property size: 56px; + in property stroke-width: 5px; + in property show-label: true; + in property variant: primary; + private property clamped: clamp(root.value, 0.0, 0.9999); + private property shown: root.clamped; + animate shown { + enabled: !TempoMotionSettings.reduced; + duration: TempoTokens.motion-medium; + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); + } + private property ring-color: root.variant == success ? TempoTheme.success + : root.variant == warning ? TempoTheme.warning + : root.variant == danger ? TempoTheme.danger + : root.variant == neutral ? TempoTheme.text-secondary : TempoTheme.primary; + private property sweep-angle: root.shown * 360deg; + width: root.size; + height: root.size; + accessible-role: progress-indicator; + accessible-value: round(clamp(root.value, 0.0, 1.0) * 100) + "%"; + // Track ring + Path { + width: parent.width; height: parent.height; + viewbox-width: 100; viewbox-height: 100; + stroke: TempoTheme.border; + stroke-width: root.stroke-width; + fill: transparent; + MoveTo { x: 50; y: 10; } + ArcTo { radius-x: 40; radius-y: 40; x: 50; y: 90; sweep: true; } + ArcTo { radius-x: 40; radius-y: 40; x: 50; y: 10; sweep: true; } + } + // Active arc + if root.shown > 0.001 : Path { + width: parent.width; height: parent.height; + viewbox-width: 100; viewbox-height: 100; + stroke: root.ring-color; + stroke-width: root.stroke-width; + stroke-line-cap: round; + fill: transparent; + MoveTo { x: 50; y: 10; } + ArcTo { + radius-x: 40; radius-y: 40; + x: 50 + 40 * sin(root.sweep-angle); + y: 50 - 40 * cos(root.sweep-angle); + sweep: true; + large-arc: root.shown > 0.5; + } + } + if root.show-label : Text { + text: round(clamp(root.value, 0.0, 1.0) * 100) + "%"; + color: TempoTheme.text-primary; + font-size: root.size * 0.22; + font-weight: 700; + horizontal-alignment: center; + vertical-alignment: center; + } +} + +export struct TempoTimelineEntry { + title: string, + subtitle: string, + time: string, + variant: TempoTagVariant, +} + +export component TempoTimeline inherits VerticalLayout { + in property <[TempoTimelineEntry]> items; + spacing: 0px; + for item[idx] in root.items : HorizontalLayout { + spacing: TempoTokens.gap10; + VerticalLayout { + width: 16px; + alignment: start; + HorizontalLayout { + alignment: center; + padding-top: 4px; + Rectangle { + width: 10px; height: 10px; + border-radius: TempoTokens.radius-full; + border-width: 2px; + border-color: item.variant == success ? TempoTheme.success + : item.variant == warning ? TempoTheme.warning + : item.variant == danger ? TempoTheme.danger + : item.variant == neutral ? TempoTheme.text-tertiary : TempoTheme.primary; + background: TempoTheme.surface; + } + } + if idx < root.items.length - 1 : HorizontalLayout { + vertical-stretch: 1; + alignment: center; + padding-top: 4px; padding-bottom: 2px; + Rectangle { + width: 1.5px; + background: TempoTheme.border; + } + } + } + VerticalLayout { + horizontal-stretch: 1; + padding-bottom: idx < root.items.length - 1 ? 12px : 0px; + spacing: 2px; + HorizontalLayout { + spacing: TempoTokens.gap8; + cross-axis-alignment: center; + Text { + horizontal-stretch: 1; + text: item.title; + color: TempoTheme.text-primary; + font-size: 13px; + font-weight: 600; + overflow: elide; + } + if item.time != "" : Text { + text: item.time; + color: TempoTheme.text-tertiary; + font-size: TempoTokens.text-xs; + } + } + if item.subtitle != "" : Text { + text: item.subtitle; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + wrap: word-wrap; + } + } + } +} + +export component TempoKeyValue inherits HorizontalLayout { + in property label; + in property value; + in property copyable: false; + callback copied(string); + spacing: TempoTokens.gap12; + cross-axis-alignment: center; + min-height: 30px; + Text { + text: root.label; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + font-weight: 600; + min-width: 90px; + } + Text { + horizontal-stretch: 1; + text: root.value; + color: TempoTheme.text-primary; + font-size: 13px; + font-weight: 500; + horizontal-alignment: right; + overflow: elide; + } + if root.copyable : TempoIconButton { + label: "Copy " + root.label; + icon: TempoIcons.copy; + size: 24px; + icon-size: 14px; + activated => { root.copied(root.value); } + } +} + +export component TempoBanner inherits Rectangle { + in property message; + in property action-label; + in property variant: warning; + callback action(); + private property accent: root.variant == success ? TempoTheme.success + : root.variant == danger ? TempoTheme.danger + : root.variant == primary ? TempoTheme.primary + : root.variant == neutral ? TempoTheme.text-secondary : TempoTheme.warning; + private property bg: root.variant == success ? TempoTheme.success-soft + : root.variant == danger ? TempoTheme.danger-soft + : root.variant == primary ? TempoTheme.primary-soft + : root.variant == neutral ? TempoTheme.surface-alt : TempoTheme.warning-soft; + border-radius: TempoTokens.radius-md; + border-width: TempoTokens.border-width; + border-color: root.variant == neutral ? TempoTheme.border : root.accent.with-alpha(TempoTheme.dark ? 0.35 : 0.25); + background: root.bg; + HorizontalLayout { + padding-left: 12px; padding-right: 10px; + padding-top: 8px; padding-bottom: 8px; + spacing: TempoTokens.gap8; + cross-axis-alignment: center; + TempoIcon { + source: root.variant == danger ? TempoIcons.error + : root.variant == success ? TempoIcons.check + : root.variant == warning ? TempoIcons.warning : TempoIcons.info; + tint: root.accent; + width: 16px; height: 16px; + } + Text { + horizontal-stretch: 1; + text: root.message; + color: TempoTheme.text-primary; + font-size: TempoTokens.text-sm; + font-weight: 500; + wrap: word-wrap; + } + if root.action-label != "" : TempoButton { + label: root.action-label; + variant: outline; + compact: true; + activated => { root.action(); } + } + } +} + + +export component TempoTabBar inherits Rectangle { + in property <[string]> tabs; + in-out property selected: 0; + callback selected-index(int); + height: 38px; + Rectangle { + y: parent.height - 1px; + height: 1px; + background: TempoTheme.border; + } + HorizontalLayout { + spacing: TempoTokens.gap4; + alignment: start; + for title[idx] in root.tabs : tab-item := TempoAction { + private property active: idx == root.selected; + label: title; + height: 38px; + preferred-width: inner.preferred-width; + border-radius: TempoTokens.radius-xs; + background: self.pressed ? TempoTheme.surface-pressed + : self.hovered && !active ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { + root.selected = idx; + root.selected-index(idx); + } + inner := HorizontalLayout { + padding-left: 14px; padding-right: 14px; + cross-axis-alignment: center; + Text { + text: title; + font-size: 13px; + font-weight: active ? 700 : 500; + color: active ? TempoTheme.primary + : tab-item.hovered ? TempoTheme.text-primary : TempoTheme.text-secondary; + } + } + // Bottom active indicator + Rectangle { + x: (parent.width - self.width) / 2; + y: parent.height - 2px; + width: active ? max(0px, parent.width - 16px) : 0px; + height: 2px; + border-radius: 1px; + background: TempoTheme.primary; + animate width { + enabled: !TempoMotionSettings.reduced; + duration: TempoTokens.motion-short; + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); + } + } + } + } +} + +export component TempoLoadingOverlay inherits Rectangle { + in property loading: false; + in property message: "Loading…"; + visible: root.loading; + background: TempoTheme.surface.with-alpha(TempoTheme.dark ? 0.78 : 0.82); + if root.loading : TouchArea {} + if root.loading : VerticalLayout { + alignment: center; + cross-axis-alignment: center; + spacing: TempoTokens.gap10; + HorizontalLayout { + alignment: center; + TempoProgressBar { + width: 120px; + indeterminate: true; + } + } + if root.message != "" : Text { + text: root.message; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + font-weight: 600; + horizontal-alignment: center; + } + } +} + + +export component TempoTable inherits TempoSurface { + in property <[string]> columns; + in property <[[string]]> rows; + in-out property selected-row: -1; + in property zebra: true; + callback row-activated(int); + clip: true; + VerticalLayout { + // Header row + Rectangle { + height: 36px; + background: TempoTheme.surface-alt; + HorizontalLayout { + padding-left: 14px; padding-right: 14px; + spacing: TempoTokens.gap12; + cross-axis-alignment: center; + for col in root.columns : Text { + horizontal-stretch: 1; + text: col; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + font-weight: 700; + overflow: elide; + } + } + } + TempoDivider {} + for row[r] in root.rows : VerticalLayout { + if r > 0 : TempoDivider {} + TempoAction { + private property active: r == root.selected-row; + label: "Row " + (r + 1); + height: 38px; + background: active ? TempoTheme.primary-soft + : self.pressed ? TempoTheme.surface-pressed + : self.hovered ? TempoTheme.surface-alt + : (root.zebra && mod(r, 2) == 1) ? TempoTheme.surface-alt.with-alpha(0.45) : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { + root.selected-row = r; + root.row-activated(r); + } + if active : Rectangle { + x: 0px; y: 6px; + width: 3px; height: parent.height - 12px; + border-radius: TempoTokens.radius-full; + background: TempoTheme.primary; + } + HorizontalLayout { + padding-left: 14px; padding-right: 14px; + spacing: TempoTokens.gap12; + cross-axis-alignment: center; + for cell[c] in row : Text { + horizontal-stretch: 1; + text: cell; + color: active ? TempoTheme.primary : c == 0 ? TempoTheme.text-primary : TempoTheme.text-secondary; + font-size: 13px; + font-weight: active || c == 0 ? 600 : 400; + overflow: elide; + } + } + } + } + } +} + +export struct TempoTreeNode { + label: string, + depth: int, + has-children: bool, + expanded: bool, + hidden: bool, + icon: image, +} + +export component TempoTreeView inherits TempoSurface { + in property <[TempoTreeNode]> nodes; + in-out property selected: -1; + callback selected-index(int); + callback toggled(int); + clip: true; + VerticalLayout { + padding: 4px; + spacing: 2px; + for node[idx] in root.nodes : VerticalLayout { + if !node.hidden : TempoAction { + private property active: idx == root.selected; + label: node.label; + height: 34px; + border-radius: TempoTokens.radius-xs; + background: active ? TempoTheme.primary-soft + : self.pressed ? TempoTheme.surface-pressed + : self.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { + root.selected = idx; + root.selected-index(idx); + if node.has-children { root.toggled(idx); } + } + if active : Rectangle { + x: 2px; y: 8px; + width: 3px; height: parent.height - 16px; + border-radius: TempoTokens.radius-full; + background: TempoTheme.primary; + } + HorizontalLayout { + padding-left: 10px + node.depth * 18px; + padding-right: 10px; + spacing: TempoTokens.gap6; + cross-axis-alignment: center; + Rectangle { + width: 16px; height: 16px; + if node.has-children : TempoIcon { + source: node.expanded ? TempoIcons.chevron-down : TempoIcons.chevron-right; + tint: TempoTheme.text-tertiary; + width: 14px; height: 14px; + } + } + if node.icon.width > 0 : TempoIcon { + source: node.icon; + tint: active ? TempoTheme.primary : TempoTheme.text-secondary; + width: 16px; height: 16px; + } + Text { + horizontal-stretch: 1; + text: node.label; + color: active ? TempoTheme.primary : TempoTheme.text-primary; + font-size: 13px; + font-weight: active ? 600 : 400; + overflow: elide; + } + } + } + } + } +} + +export component TempoColorPicker inherits VerticalLayout { + in property label; + in property <[color]> swatches: [ + #326CF3, #2563EB, #0EA5E9, #14B8A6, + #16A34A, #84CC16, #EAB308, #F97316, + #EF4444, #EC4899, #8B5CF6, #64748B, + ]; + in-out property value: #326CF3; + callback color-changed(color); + spacing: TempoTokens.gap8; + if root.label != "" : Text { + text: root.label; + color: TempoTheme.text-secondary; + font-size: TempoTokens.text-sm; + font-weight: 600; + } + FlexboxLayout { + spacing: 8px; + flex-wrap: wrap; + for swatch in root.swatches : TempoAction { + private property active: swatch == root.value; + label: "Select color"; + width: 28px; + height: 28px; + border-radius: TempoTokens.radius-sm; + border-width: active ? 2px : 1px; + border-color: active ? TempoTheme.text-primary : swatch.darker(0.15); + background: swatch; + activated => { + root.value = swatch; + root.color-changed(swatch); + } + if active : TempoIcon { + source: TempoIcons.checkmark-small; + tint: #F8FAFC; + width: 14px; height: 14px; + } + } + } +} + + +export component TempoCalendar inherits TempoSurface { + in property month-label: "November 2026"; + in property days-in-month: 30; + in property first-weekday: 0; // 0 = Sun .. 6 = Sat + in property today: 28; + in-out property selected-day: 28; + callback day-selected(int); + callback prev-month(); + callback next-month(); + min-width: 240px; + preferred-width: 280px; + VerticalLayout { + padding: 12px; + spacing: TempoTokens.gap8; + HorizontalLayout { + spacing: TempoTokens.gap6; + cross-axis-alignment: center; + TempoIconButton { + label: "Previous month"; + icon: TempoIcons.chevron-left; + variant: outline; + size: 28px; + icon-size: 14px; + activated => { root.prev-month(); } + } + Text { + horizontal-stretch: 1; + text: root.month-label; + color: TempoTheme.text-primary; + font-size: 13px; + font-weight: 700; + horizontal-alignment: center; + } + TempoIconButton { + label: "Next month"; + icon: TempoIcons.chevron-right; + variant: outline; + size: 28px; + icon-size: 14px; + activated => { root.next-month(); } + } + } + HorizontalLayout { + spacing: 2px; + for wd in ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] : Text { + horizontal-stretch: 1; + text: wd; + color: TempoTheme.text-tertiary; + font-size: TempoTokens.text-xs; + font-weight: 600; + horizontal-alignment: center; + } + } + for week in 6 : HorizontalLayout { + spacing: 2px; + for col in 7 : Rectangle { + private property day-num: week * 7 + col - root.first-weekday + 1; + private property valid: day-num >= 1 && day-num <= root.days-in-month; + private property is-selected: valid && day-num == root.selected-day; + private property is-today: valid && day-num == root.today; + horizontal-stretch: 1; + height: 30px; + if valid : TempoAction { + width: parent.width; + height: parent.height; + label: "Day " + day-num; + border-radius: TempoTokens.radius-xs; + border-width: is-today && !is-selected ? TempoTokens.border-width : 0px; + border-color: TempoTheme.primary; + background: is-selected ? TempoTheme.primary + : self.pressed ? TempoTheme.surface-pressed + : self.hovered ? TempoTheme.surface-alt : transparent; + animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + activated => { + root.selected-day = day-num; + root.day-selected(day-num); + } + Text { + text: day-num; + font-size: TempoTokens.text-sm; + font-weight: is-selected || is-today ? 700 : 500; + color: is-selected ? TempoTheme.text-inverse + : is-today ? TempoTheme.primary : TempoTheme.text-primary; + horizontal-alignment: center; + vertical-alignment: center; + } + } + } + } + } +} + +export component TempoCarousel inherits TempoSurface { + in property count: 1; + in-out property current: 0; + in property viewport-height: 140px; + callback changed-index(int); + min-width: 200px; + function go(idx: int) { + if root.count > 0 { + let next = mod(idx + root.count, root.count); + if next != root.current { + root.current = next; + root.changed-index(next); + } + } + } + clip: true; + VerticalLayout { + Rectangle { + height: root.viewport-height; + clip: true; + @children + if root.count > 1 : TempoIconButton { + x: 8px; + y: (parent.height - self.height) / 2; + label: "Previous slide"; + icon: TempoIcons.chevron-left; + variant: outline; + size: 30px; + icon-size: 15px; + activated => { root.go(root.current - 1); } + } + if root.count > 1 : TempoIconButton { + x: parent.width - self.width - 8px; + y: (parent.height - self.height) / 2; + label: "Next slide"; + icon: TempoIcons.chevron-right; + variant: outline; + size: 30px; + icon-size: 15px; + activated => { root.go(root.current + 1); } + } + } + if root.count > 1 : TempoDivider {} + if root.count > 1 : HorizontalLayout { + alignment: center; + padding-top: 8px; padding-bottom: 8px; + spacing: TempoTokens.gap6; + for idx in root.count : TempoAction { + private property active: idx == root.current; + label: "Slide " + (idx + 1); + width: active ? 20px : 7px; + height: 7px; + border-radius: TempoTokens.radius-full; + background: active ? TempoTheme.primary + : self.hovered ? TempoTheme.text-tertiary : TempoTheme.border-strong; + animate width, background { + enabled: !TempoMotionSettings.reduced; + duration: TempoTokens.motion-short; + easing: cubic-bezier(0.05, 0.7, 0.1, 1.0); + } + activated => { root.go(idx); } + } + } + } +} + + +export component TempoTransfer inherits Rectangle { + in property source-title: "Available"; + in property target-title: "Selected"; + in property <[string]> source-items; + in property <[string]> target-items; + in property list-height: 168px; + in property compact: false; + callback move-to-target(int); + callback move-to-source(int); + private property source-selected: -1; + private property target-selected: -1; + preferred-height: root.compact ? root.list-height * 2 + 126px : root.list-height + 37px; + if !root.compact : HorizontalLayout { + spacing: TempoTokens.gap10; + cross-axis-alignment: center; + TempoSurface { + horizontal-stretch: 1; + clip: true; + VerticalLayout { + Rectangle { + height: 34px; + background: TempoTheme.surface-alt; + HorizontalLayout { + padding-left: 12px; padding-right: 12px; + cross-axis-alignment: center; + Text { horizontal-stretch: 1; text: root.source-title; color: TempoTheme.text-primary; font-size: TempoTokens.text-sm; font-weight: 700; } + Text { text: root.source-items.length; color: TempoTheme.text-tertiary; font-size: TempoTokens.text-xs; font-weight: 600; } + } + } + TempoDivider {} + ScrollView { + height: root.list-height; + content-width: self.visible-width; + content-height: src-list-wide.preferred-height; + src-list-wide := VerticalLayout { + padding: 4px; spacing: 2px; + for item[i] in root.source-items : TempoAction { + private property active: i == root.source-selected; + label: item; height: 34px; border-radius: TempoTokens.radius-xs; + background: active ? TempoTheme.primary-soft : self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : transparent; + activated => { root.source-selected = i; } + Text { + x: 10px; width: parent.width - 20px; height: parent.height; + vertical-alignment: center; overflow: elide; text: item; font-size: 13px; + font-weight: active ? 600 : 400; + color: active ? TempoTheme.primary : TempoTheme.text-primary; + } + } + } + } + } + } + VerticalLayout { + spacing: TempoTokens.gap6; + alignment: center; + TempoIconButton { + label: "Move to target"; icon: TempoIcons.chevron-right; variant: outline; size: 32px; icon-size: 16px; + enabled: root.source-selected >= 0 && root.source-selected < root.source-items.length; + activated => { let idx = root.source-selected; root.source-selected = -1; root.move-to-target(idx); } + } + TempoIconButton { + label: "Move to source"; icon: TempoIcons.chevron-left; variant: outline; size: 32px; icon-size: 16px; + enabled: root.target-selected >= 0 && root.target-selected < root.target-items.length; + activated => { let idx = root.target-selected; root.target-selected = -1; root.move-to-source(idx); } + } + } + TempoSurface { + horizontal-stretch: 1; + clip: true; + VerticalLayout { + Rectangle { + height: 34px; + background: TempoTheme.surface-alt; + HorizontalLayout { + padding-left: 12px; padding-right: 12px; + cross-axis-alignment: center; + Text { horizontal-stretch: 1; text: root.target-title; color: TempoTheme.text-primary; font-size: TempoTokens.text-sm; font-weight: 700; } + Text { text: root.target-items.length; color: TempoTheme.text-tertiary; font-size: TempoTokens.text-xs; font-weight: 600; } + } + } + TempoDivider {} + ScrollView { + height: root.list-height; + content-width: self.visible-width; + content-height: dst-list-wide.preferred-height; + dst-list-wide := VerticalLayout { + padding: 4px; spacing: 2px; + for item[i] in root.target-items : TempoAction { + private property active: i == root.target-selected; + label: item; height: 34px; border-radius: TempoTokens.radius-xs; + background: active ? TempoTheme.primary-soft : self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : transparent; + activated => { root.target-selected = i; } + Text { + x: 10px; width: parent.width - 20px; height: parent.height; + vertical-alignment: center; overflow: elide; text: item; font-size: 13px; + font-weight: active ? 600 : 400; + color: active ? TempoTheme.primary : TempoTheme.text-primary; + } + } + } + } + } + } + } + if root.compact : VerticalLayout { + spacing: TempoTokens.gap8; + TempoSurface { + clip: true; + VerticalLayout { + Rectangle { + height: 34px; background: TempoTheme.surface-alt; + HorizontalLayout { + padding-left: 12px; padding-right: 12px; cross-axis-alignment: center; + Text { horizontal-stretch: 1; text: root.source-title; color: TempoTheme.text-primary; font-size: TempoTokens.text-sm; font-weight: 700; } + Text { text: root.source-items.length; color: TempoTheme.text-tertiary; font-size: TempoTokens.text-xs; font-weight: 600; } + } + } + TempoDivider {} + ScrollView { + height: root.list-height; + content-width: self.visible-width; + content-height: src-list-compact.preferred-height; + src-list-compact := VerticalLayout { + padding: 4px; spacing: 2px; + for item[i] in root.source-items : TempoAction { + private property active: i == root.source-selected; + label: item; height: 38px; border-radius: TempoTokens.radius-xs; + background: active ? TempoTheme.primary-soft : self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : transparent; + activated => { root.source-selected = i; } + Text { + x: 10px; width: parent.width - 20px; height: parent.height; + vertical-alignment: center; overflow: elide; text: item; font-size: 13px; + font-weight: active ? 600 : 400; + color: active ? TempoTheme.primary : TempoTheme.text-primary; + } + } + } + } + } + } + HorizontalLayout { + alignment: center; + spacing: TempoTokens.gap10; + TempoIconButton { + label: "Move down"; icon: TempoIcons.chevron-down; variant: outline; size: 36px; icon-size: 16px; + enabled: root.source-selected >= 0 && root.source-selected < root.source-items.length; + activated => { let idx = root.source-selected; root.source-selected = -1; root.move-to-target(idx); } + } + TempoIconButton { + label: "Move up"; icon: TempoIcons.chevron-up; variant: outline; size: 36px; icon-size: 16px; + enabled: root.target-selected >= 0 && root.target-selected < root.target-items.length; + activated => { let idx = root.target-selected; root.target-selected = -1; root.move-to-source(idx); } + } + } + TempoSurface { + clip: true; + VerticalLayout { + Rectangle { + height: 34px; background: TempoTheme.surface-alt; + HorizontalLayout { + padding-left: 12px; padding-right: 12px; cross-axis-alignment: center; + Text { horizontal-stretch: 1; text: root.target-title; color: TempoTheme.text-primary; font-size: TempoTokens.text-sm; font-weight: 700; } + Text { text: root.target-items.length; color: TempoTheme.text-tertiary; font-size: TempoTokens.text-xs; font-weight: 600; } + } + } + TempoDivider {} + ScrollView { + height: root.list-height; + content-width: self.visible-width; + content-height: dst-list-compact.preferred-height; + dst-list-compact := VerticalLayout { + padding: 4px; spacing: 2px; + for item[i] in root.target-items : TempoAction { + private property active: i == root.target-selected; + label: item; height: 38px; border-radius: TempoTokens.radius-xs; + background: active ? TempoTheme.primary-soft : self.pressed ? TempoTheme.surface-pressed : self.hovered ? TempoTheme.surface-alt : transparent; + activated => { root.target-selected = i; } + Text { + x: 10px; width: parent.width - 20px; height: parent.height; + vertical-alignment: center; overflow: elide; text: item; font-size: 13px; + font-weight: active ? 600 : 400; + color: active ? TempoTheme.primary : TempoTheme.text-primary; + } + } + } + } + } + } + } +} diff --git a/ui/primitives.slint b/ui/primitives.slint index bdcc895..d5ab532 100644 --- a/ui/primitives.slint +++ b/ui/primitives.slint @@ -27,6 +27,7 @@ export struct TempoMenuEntry { label: string, icon: image, enabled: bool } export component TempoMenuButton inherits TempoAction { in property <[TempoMenuEntry]> items; in property icon: TempoIcons.more; + in property outline: false; in property menu-width: 208px; out property opened: popup.is-open; callback chosen(int); @@ -35,8 +36,12 @@ export component TempoMenuButton inherits TempoAction { height: 36px; label: "Actions"; border-radius: TempoTokens.radius-sm; - background: root.opened || root.hovered ? TempoTheme.surface-pressed : transparent; - animate background { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } + border-width: root.outline ? TempoTokens.border-width : 0px; + border-color: root.opened || root.hovered ? TempoTheme.border-strong : TempoTheme.border; + background: root.opened || root.pressed ? TempoTheme.surface-pressed + : root.hovered ? TempoTheme.surface-alt + : root.outline ? TempoTheme.surface : transparent; + animate background, border-color { enabled: !TempoMotionSettings.reduced; duration: TempoTokens.fast; } accessible-expandable: true; accessible-expanded: root.opened; accessible-action-expand => { root.open(); } @@ -48,7 +53,7 @@ export component TempoMenuButton inherits TempoAction { } } TempoIcon { source: root.icon; width: 20px; height: 20px; } - appearance := TempoPresence { active: popup.is-open; enter-time: TempoTokens.fast; } + appearance := TempoPresence { active: popup.is-open; enter-time: TempoTokens.motion-short; } popup := PopupWindow { x: root.width - root.menu-width; y: root.height + 4px; @@ -65,7 +70,9 @@ export component TempoMenuButton inherits TempoAction { return reject; } TempoSurface { + elevated: true; clip: true; + y: -6px * (1 - appearance.progress); opacity: appearance.progress; ScrollView { x: 4px; y: 4px; width: parent.width - 8px; height: parent.height - 8px; diff --git a/ui/theme.slint b/ui/theme.slint index fe8ed4f..6862123 100644 --- a/ui/theme.slint +++ b/ui/theme.slint @@ -1,6 +1,6 @@ import { Palette } from "std-widgets.slint"; -// FinUI palette and measurements adapted under MIT. See LICENSES/FinUI-MIT.txt. +// See LICENSES/FinUI-MIT.txt for third-party attribution. export struct TempoAccent { primary: color, hover: color, pressed: color, soft: color, subtle: color } export global TempoTheme { @@ -9,23 +9,25 @@ export global TempoTheme { in property follow-platform-accent; in property accent; private property platform-accent: Palette.accent-background; - out property primary: self.override-accent ? self.accent.primary : self.follow-platform-accent ? self.platform-accent : self.dark ? #8EA8FF : #3F63D8; - out property primary-hover: self.override-accent ? self.accent.hover : self.follow-platform-accent ? self.platform-accent.brighter(0.12) : self.dark ? #A3BAFF : #3451C0; - out property primary-pressed: self.override-accent ? self.accent.pressed : self.follow-platform-accent ? self.platform-accent.darker(0.14) : self.dark ? #7A97F0 : #2A41A0; - out property primary-soft: self.override-accent ? self.accent.soft : self.follow-platform-accent ? self.platform-accent.with-alpha(0.14) : self.dark ? #1A2240 : #EEF2FF; - out property primary-subtle: self.override-accent ? self.accent.subtle : self.follow-platform-accent ? self.platform-accent.with-alpha(0.22) : self.dark ? #1E2D5C : #DCE3FF; - out property background: self.dark ? #0F1115 : #F6F7F9; - out property background-alt: self.dark ? #141720 : #F0F3F8; - out property surface: self.dark ? #171A20 : #FFFFFF; - out property surface-alt: self.dark ? #1D2029 : #F8FAFC; - out property surface-pressed: self.dark ? #242833 : #F1F5F9; - out property border: self.dark ? #2A303A : #E1E4EA; - out property border-strong: self.dark ? #37404D : #CCD2DC; - out property text-primary: self.dark ? #EEF0F4 : #171A1F; - out property text-secondary: self.dark ? #A6ACB8 : #68707D; - out property text-tertiary: self.dark ? #8A909D : #8A93A3; - out property text-disabled: self.dark ? #58606D : #A8B1BF; - out property text-inverse: self.dark ? #141720 : #FFFFFF; + out property primary: self.override-accent ? self.accent.primary : self.follow-platform-accent ? self.platform-accent : self.dark ? #4C8DFF : #326CF3; + out property primary-hover: self.override-accent ? self.accent.hover : self.follow-platform-accent ? self.platform-accent.brighter(0.12) : self.dark ? #69A1FF : #255BE0; + out property primary-pressed: self.override-accent ? self.accent.pressed : self.follow-platform-accent ? self.platform-accent.darker(0.14) : self.dark ? #3878E8 : #1D4BC2; + out property primary-soft: self.override-accent ? self.accent.soft : self.follow-platform-accent ? self.platform-accent.with-alpha(0.14) : self.dark ? #182742 : #EBF2FF; + out property primary-subtle: self.override-accent ? self.accent.subtle : self.follow-platform-accent ? self.platform-accent.with-alpha(0.22) : self.dark ? #20355C : #D6E4FF; + out property background: self.dark ? #171A20 : #ECEEF2; + out property background-alt: self.dark ? #1E222A : #F6F7FA; + out property surface: self.dark ? #232832 : #FAFBFD; + out property surface-elevated: self.dark ? #2A303C : #FCFDFF; + out property surface-alt: self.dark ? #2B313D : #F1F3F7; + out property surface-pressed: self.dark ? #343B49 : #E5E8EF; + out property shadow: self.dark ? #0B0E1478 : #1B243618; + out property border: self.dark ? #323846 : #DCDFE6; + out property border-strong: self.dark ? #454D5E : #C2C8D4; + out property text-primary: self.dark ? #E8ECF2 : #22262E; + out property text-secondary: self.dark ? #A6AFBF : #5A6270; + out property text-tertiary: self.dark ? #7C8596 : #828B99; + out property text-disabled: self.dark ? #555D6B : #A8B0BE; + out property text-inverse: self.dark ? #171A20 : #F8FAFC; out property success: self.dark ? #34D399 : #168A5B; out property success-soft: self.dark ? #0C2E22 : #ECFDF5; out property warning: self.dark ? #FBBF24 : #D68D00; @@ -33,16 +35,17 @@ export global TempoTheme { out property danger: self.dark ? #F97066 : #D92D20; out property danger-hover: self.dark ? #EF4444 : #B42318; out property danger-soft: self.dark ? #2E1414 : #FEF3F2; + out property danger-subtle: self.dark ? #3D1A1A : #FEE4E2; out property info: self.dark ? #38BDF8 : #2E90FA; out property info-soft: self.dark ? #0A2330 : #EFF8FF; } export global TempoTokens { - out property radius-xs: 6px; - out property radius-sm: 10px; - out property radius-md: 12px; - out property radius-lg: 14px; - out property radius-xl: 18px; + out property radius-xs: 4px; + out property radius-sm: 6px; + out property radius-md: 8px; + out property radius-lg: 10px; + out property radius-xl: 14px; out property radius-full: 999px; out property gap2: 2px; out property gap4: 4px; @@ -62,15 +65,24 @@ export global TempoTokens { out property button-height: 42px; out property small-button-height: 34px; out property tile-min-height: 52px; - out property bottom-tab-height: 58px; - out property desktop-nav-rail-width: 78px; - out property desktop-nav-rail-extended-width: 220px; + out property bottom-tab-height: 66px; + out property desktop-nav-rail-width: 68px; + out property desktop-nav-rail-extended-width: 204px; out property icon-sm: 16px; out property icon-md: 20px; out property icon-lg: 24px; + out property text-xs: 11px; + out property text-sm: 12px; + out property text-md: 14px; + out property text-lg: 16px; + out property text-title: 20px; out property border-width: 1px; out property fast: 120ms; out property normal: 180ms; + out property motion-short: 150ms; + out property motion-medium: 220ms; + out property motion-emphasized: 300ms; + out property motion-axis-distance: 24px; out property rail-breakpoint: 720px; out property extended-rail-breakpoint: 1100px; }