ssh: Clean up title bar indicator icon (#19328)

This PR cleans up the custom icon with indicator implementation in favor
of `IconWithIndicator`, which we already had. It seems like it isn't
super used still, but it's good to try to enforce some consistency
either way. I checked my changes against the REPL stuff (one instance
where its used) and everything's looking good so far. As far as SSH,
nothing has visually changed; we just have less code for this thing now.

<img width="800" alt="Screenshot 2024-10-17 at 2 15 47 AM"
src="https://github.com/user-attachments/assets/5c146757-501e-4242-b145-a576a8f289b5">

---

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2024-10-17 03:25:27 +02:00 committed by GitHub
parent a41e973782
commit 78093b8e76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 41 deletions

View file

@ -24,8 +24,8 @@ use smallvec::SmallVec;
use std::sync::Arc; use std::sync::Arc;
use theme::ActiveTheme; use theme::ActiveTheme;
use ui::{ use ui::{
h_flex, prelude::*, Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon, h_flex, prelude::*, Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon, IconName,
IconButtonShape, IconName, IconSize, Indicator, PopoverMenu, Tooltip, IconSize, IconWithIndicator, Indicator, PopoverMenu, Tooltip,
}; };
use util::ResultExt; use util::ResultExt;
use vcs_menu::{BranchList, OpenRecent as ToggleVcsMenu}; use vcs_menu::{BranchList, OpenRecent as ToggleVcsMenu};
@ -281,8 +281,6 @@ impl TitleBar {
} }
}; };
let indicator_border_color = cx.theme().colors().title_bar_background;
let icon_color = match self.project.read(cx).ssh_connection_state(cx)? { let icon_color = match self.project.read(cx).ssh_connection_state(cx)? {
remote::ConnectionState::Connecting => Color::Info, remote::ConnectionState::Connecting => Color::Info,
remote::ConnectionState::Connected => Color::Default, remote::ConnectionState::Connected => Color::Default,
@ -293,42 +291,22 @@ impl TitleBar {
let meta = SharedString::from(meta); let meta = SharedString::from(meta);
let indicator = h_flex()
// We're using the circle inside a circle approach because, otherwise, by using borders
// we'd get a very thin, leaking indicator color, which is not what we want.
.absolute()
.size_2p5()
.right_0()
.bottom_0()
.bg(indicator_border_color)
.size_2p5()
.rounded_full()
.items_center()
.justify_center()
.overflow_hidden()
.child(Indicator::dot().color(indicator_color));
Some( Some(
div() ButtonLike::new("ssh-server-icon")
.relative()
.child( .child(
IconButton::new("ssh-server-icon", IconName::Server) IconWithIndicator::new(
.icon_size(IconSize::Small) Icon::new(IconName::Server).color(icon_color),
.shape(IconButtonShape::Square) Some(Indicator::dot().color(indicator_color)),
.icon_color(icon_color) )
.tooltip(move |cx| { .indicator_border_color(Some(cx.theme().colors().title_bar_background))
Tooltip::with_meta( .into_any_element(),
"Remote Project",
Some(&OpenRemote),
meta.clone(),
cx,
)
})
.on_click(|_, cx| {
cx.dispatch_action(OpenRemote.boxed_clone());
}),
) )
.child(indicator) .tooltip(move |cx| {
Tooltip::with_meta("Remote Project", Some(&OpenRemote), meta.clone(), cx)
})
.on_click(|_, cx| {
cx.dispatch_action(OpenRemote.boxed_clone());
})
.into_any_element(), .into_any_element(),
) )
} }

View file

@ -473,13 +473,12 @@ impl RenderOnce for IconWithIndicator {
this.child( this.child(
div() div()
.absolute() .absolute()
.w_2() .size_2p5()
.h_2() .border_2()
.border_1()
.border_color(indicator_border_color) .border_color(indicator_border_color)
.rounded_full() .rounded_full()
.bottom_neg_0p5() .bottom_neg_0p5()
.right_neg_1() .right_neg_0p5()
.child(indicator), .child(indicator),
) )
}) })