Add interactivity to Checkbox
component (#3240)
This PR adds interactivity to the `Checkbox` component. They can now be checked and unchecked by clicking them. Release Notes: - N/A
This commit is contained in:
parent
254b369624
commit
d224f511fa
5 changed files with 108 additions and 58 deletions
|
@ -7,8 +7,8 @@ use theme2::ThemeSettings;
|
|||
|
||||
use crate::prelude::*;
|
||||
use crate::{
|
||||
static_livestream, v_stack, AssistantPanel, Button, ChatMessage, ChatPanel, CollabPanel,
|
||||
EditorPane, Label, LanguageSelector, NotificationsPanel, Pane, PaneGroup, Panel,
|
||||
static_livestream, v_stack, AssistantPanel, Button, ChatMessage, ChatPanel, Checkbox,
|
||||
CollabPanel, EditorPane, Label, LanguageSelector, NotificationsPanel, Pane, PaneGroup, Panel,
|
||||
PanelAllowedSides, PanelSide, ProjectPanel, SplitDirection, StatusBar, Terminal, TitleBar,
|
||||
Toast, ToastOrigin,
|
||||
};
|
||||
|
@ -42,6 +42,7 @@ pub struct Workspace {
|
|||
show_terminal: bool,
|
||||
show_debug: bool,
|
||||
show_language_selector: bool,
|
||||
test_checkbox_selection: Selection,
|
||||
debug: Gpui2UiDebug,
|
||||
}
|
||||
|
||||
|
@ -58,6 +59,7 @@ impl Workspace {
|
|||
show_language_selector: false,
|
||||
show_debug: false,
|
||||
show_notifications_panel: true,
|
||||
test_checkbox_selection: Selection::Unselected,
|
||||
debug: Gpui2UiDebug::default(),
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +219,23 @@ impl Render for Workspace {
|
|||
.text_color(cx.theme().colors().text)
|
||||
.bg(cx.theme().colors().background)
|
||||
.child(self.title_bar.clone())
|
||||
.child(
|
||||
div()
|
||||
.absolute()
|
||||
.top_12()
|
||||
.left_12()
|
||||
.z_index(99)
|
||||
.bg(cx.theme().colors().background)
|
||||
.child(
|
||||
Checkbox::new("test_checkbox", self.test_checkbox_selection).on_click(
|
||||
|selection, workspace: &mut Workspace, cx| {
|
||||
workspace.test_checkbox_selection = selection;
|
||||
|
||||
cx.notify();
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue