git_ui: Update git panel commit editor, start on quick commit

- Fixes commit editor issues & updates style
- Starts on quick commit (not hooked up to anything)
- Updates some panel styles
- Adds SwitchWithLabel
- 
Release Notes:

- N/A
This commit is contained in:
Nate Butler 2025-02-10 10:52:09 -05:00 committed by GitHub
parent 69d415c8d0
commit de8d4d00ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 586 additions and 120 deletions

View file

@ -450,6 +450,64 @@ impl RenderOnce for Switch {
}
}
/// A [`Switch`] that has a [`Label`].
#[derive(IntoElement)]
// #[component(scope = "input")]
pub struct SwitchWithLabel {
id: ElementId,
label: Label,
toggle_state: ToggleState,
on_click: Arc<dyn Fn(&ToggleState, &mut Window, &mut App) + 'static>,
disabled: bool,
}
impl SwitchWithLabel {
/// Creates a switch with an attached label.
pub fn new(
id: impl Into<ElementId>,
label: Label,
toggle_state: impl Into<ToggleState>,
on_click: impl Fn(&ToggleState, &mut Window, &mut App) + 'static,
) -> Self {
Self {
id: id.into(),
label,
toggle_state: toggle_state.into(),
on_click: Arc::new(on_click),
disabled: false,
}
}
/// Sets the disabled state of the [`SwitchWithLabel`].
pub fn disabled(mut self, disabled: bool) -> Self {
self.disabled = disabled;
self
}
}
impl RenderOnce for SwitchWithLabel {
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
h_flex()
.id(SharedString::from(format!("{}-container", self.id)))
.gap(DynamicSpacing::Base08.rems(cx))
.child(
Switch::new(self.id.clone(), self.toggle_state)
.disabled(self.disabled)
.on_click({
let on_click = self.on_click.clone();
move |checked, window, cx| {
(on_click)(checked, window, cx);
}
}),
)
.child(
div()
.id(SharedString::from(format!("{}-label", self.id)))
.child(self.label),
)
}
}
impl ComponentPreview for Checkbox {
fn preview(_window: &mut Window, _cx: &App) -> AnyElement {
v_flex()