add tabs
This commit is contained in:
@@ -24,6 +24,7 @@ use gpui_native_core::toast::{Toast, ToastSeverity, Toasts, ToastsView};
|
||||
use gpui_native_core::toggle::Toggle;
|
||||
use gpui_native_core::tooltip::Tooltip;
|
||||
use gpui_native_data::list::{List, ListItem};
|
||||
use gpui_native_data::tabs::{Tab, Tabs};
|
||||
use gpui_native_data::tree::{Tree, TreeItem};
|
||||
use gpui_native_icons::{IconAssets, IconRole, icon};
|
||||
use gpui_native_theme::{ActiveTheme as _, Theme};
|
||||
@@ -46,6 +47,7 @@ struct Gallery {
|
||||
list_selected: Option<usize>,
|
||||
tree_nodes: Vec<GalleryNode>,
|
||||
tree_selected: Option<usize>,
|
||||
tab_selected: usize,
|
||||
}
|
||||
|
||||
/// A demo model for the tree section: the app owns the real tree and its
|
||||
@@ -472,6 +474,44 @@ impl Render for Gallery {
|
||||
.items(move |_, _| items.clone())
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(section_label(
|
||||
"tabs · native refs — NSTabView, WinUI TabView, Adwaita TabBar, Breeze",
|
||||
colors,
|
||||
))
|
||||
.child({
|
||||
let gallery = gallery.clone();
|
||||
Tabs::new("gallery-tabs")
|
||||
.selected(self.tab_selected)
|
||||
.on_change(move |selected, _, cx| {
|
||||
gallery.update(cx, |gallery, cx| {
|
||||
gallery.tab_selected = selected;
|
||||
cx.notify();
|
||||
});
|
||||
})
|
||||
.tabs(|_, _| {
|
||||
vec![
|
||||
Tab::new("Overview"),
|
||||
Tab::new("Details"),
|
||||
Tab::new("Settings"),
|
||||
Tab::new("Locked").disabled(true),
|
||||
]
|
||||
})
|
||||
})
|
||||
.child(match self.tab_selected {
|
||||
0 => div()
|
||||
.child("The overview panel is the app's business — the strip only reports.")
|
||||
.into_any_element(),
|
||||
1 => div()
|
||||
.child("Details: rows, lists and trees all live under their own tabs.")
|
||||
.into_any_element(),
|
||||
_ => div()
|
||||
.child("Settings: keyboard focus rides the strip; arrows switch tabs.")
|
||||
.into_any_element(),
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
@@ -1092,6 +1132,7 @@ fn main() {
|
||||
scroll: gpui::ScrollHandle::new(),
|
||||
list_selected: None,
|
||||
tree_selected: None,
|
||||
tab_selected: 0,
|
||||
tree_nodes: vec![
|
||||
GalleryNode {
|
||||
label: "Workspace".into(),
|
||||
|
||||
Reference in New Issue
Block a user