mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-01 04:18:14 +00:00
material: Components: added DropDownMenu (https://github.com/slint-ui/material-components/issues/131)
* Components: added DropDownMenu
* [autofix.ci] apply automated fixes
* REUSE
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Nigel Breslaw <nigel.breslaw@slint.dev>
Imported from 3ee890853a
This commit is contained in:
parent
36a34b4643
commit
9cc99316ea
61 changed files with 380 additions and 127 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use std::rc::Rc;
|
||||
|
||||
use slint::{Color, Model, ModelExt, VecModel};
|
||||
use slint::{Color, Image, Model, ModelExt, SharedString, VecModel};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
|
|
@ -56,9 +56,10 @@ fn navigation_view(ui: &MainWindow) {
|
|||
]);
|
||||
|
||||
adapter.on_search({
|
||||
let ui_weak = ui_weak.clone();
|
||||
move |text| {
|
||||
let colors = colors.clone();
|
||||
let text = text.to_lowercase();
|
||||
let colors = colors.clone();
|
||||
|
||||
let ui = ui_weak.unwrap();
|
||||
NavigationViewAdapter::get(&ui).set_search_items(
|
||||
|
|
@ -95,3 +96,12 @@ fn color_item(name: &str, red: u8, green: u8, blue: u8, ui: &MainWindow) -> List
|
|||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn menu_item(icon: Image, text: SharedString) -> MenuItem {
|
||||
MenuItem {
|
||||
enabled: true,
|
||||
icon,
|
||||
text,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ import {
|
|||
Slider,
|
||||
TextField,
|
||||
RadioButtonTile,
|
||||
Menu
|
||||
Menu,
|
||||
DropDownMenu,
|
||||
MenuItem
|
||||
} from "../../../../material.slint";
|
||||
|
||||
import { Group } from "../components/group.slint";
|
||||
|
|
@ -45,6 +47,7 @@ export global NavigationViewAdapter {
|
|||
in property <[bool]> radio_buttons: [ true, false, false ];
|
||||
|
||||
callback search(text: string);
|
||||
callback filter_icons(text: string);
|
||||
callback radio_button_clicked(index: int);
|
||||
}
|
||||
|
||||
|
|
@ -465,6 +468,24 @@ export component NavigationView {
|
|||
}
|
||||
}
|
||||
|
||||
ComponentCard {
|
||||
title: "DropDown menu";
|
||||
|
||||
Horizontal {
|
||||
DropDownMenu {
|
||||
label: "Icon";
|
||||
leading_icon: OutlinedIcons.search;
|
||||
items:
|
||||
[
|
||||
{ icon: OutlinedIcons.bookmark, text: "Bookmark", enabled: true },
|
||||
{ icon: OutlinedIcons.explore, text: "Explore", enabled: true },
|
||||
{ icon: OutlinedIcons.chat_bubble, text: "Chat", enabled: true },
|
||||
{ icon: OutlinedIcons.favorite, text: "Favorite", enabled: true },
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ComponentCard {
|
||||
title: "Switches";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue