Skip to content

Commit 5c8d442

Browse files
committed
fix(settings - drawer): icon button widget color; cleanup comments
1 parent 19de643 commit 5c8d442

File tree

2 files changed

+10
-26
lines changed

2 files changed

+10
-26
lines changed

shell/crates/settings_drawer/src/ui/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ impl Render for SettingsDrawer {
129129
.icon(IconName::Settings)
130130
.icon_color(rgb(0xF4F4F4))
131131
.size((px(24.), px(24.)))
132-
// .bg_color(rgb(0x101010))
133132
.border(px(0.))
134133
.on_click(cx.listener(|_, _, _, _| {
135134
println!("settings clicked");
@@ -157,7 +156,6 @@ impl Render for SettingsDrawer {
157156
.icon(IconName::Power)
158157
.icon_color(rgb(0xF4F4F4))
159158
.size((px(24.), px(24.)))
160-
// .bg_color(rgb(0x101010))
161159
.border(px(0.))
162160
.on_click(cx.listener(|_, _, _, _| {
163161
println!("power clicked");
@@ -178,7 +176,6 @@ impl Render for SettingsDrawer {
178176
IconButton::new("id_rotation")
179177
.icon(rotation_icon)
180178
.active(self.rotation_on)
181-
// .icon_color(rotation_icon_color)
182179
.on_click(cx.listener(
183180
|this: &mut SettingsDrawer,
184181
_event: &ClickEvent,
@@ -211,7 +208,6 @@ impl Render for SettingsDrawer {
211208
IconButton::new("id_screen_mirroring")
212209
.icon(screen_mirroring_icon)
213210
.active(self.screen_mirrorring)
214-
// .icon_color(screen_mirroring_icon_color)
215211
.on_click(cx.listener(
216212
|this: &mut SettingsDrawer,
217213
_event: &ClickEvent,
@@ -326,7 +322,6 @@ impl Render for SettingsDrawer {
326322
.icon(IconName::BrightnessHigh)
327323
.icon_color(rgb(0xF4F4F4))
328324
.size((px(36.), px(36.)))
329-
// .bg_color(rgb(0x202020))
330325
.border(px(0.))
331326
.on_click(cx.listener(|_, _, _, _| {
332327
println!("brightness clicked");
@@ -369,7 +364,6 @@ impl Render for SettingsDrawer {
369364
.icon(IconName::VolumeMedium)
370365
.icon_color(rgb(0xF4F4F4))
371366
.size((px(36.), px(36.)))
372-
// .bg_color(rgb(0x202020))
373367
.border(px(0.))
374368
.on_click(cx.listener(|_, _, _, _| {
375369
println!("volume clicked");
@@ -390,7 +384,7 @@ impl Render for SettingsDrawer {
390384
.child(
391385
IconButton::new("id_wireless")
392386
.icon(self.wireless_details.icon.clone())
393-
.icon_color(rgb(0x4D4D4D))
387+
.icon_color(rgb(0x4D4D4D)) // changes as per wireless state
394388
.size((px(104.), px(104.)))
395389
.active(self.wireless_details.enalble)
396390
.label("Office wifi 1")

shell/crates/settings_drawer/src/ui/widgets/icon_button.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ use std::rc::Rc;
33
use crate::ui::icon::Icon;
44
use gpui::{prelude::FluentBuilder, *};
55

6-
use std::sync::LazyLock;
7-
8-
pub static ICON_COLOR: LazyLock<Rgba> = LazyLock::new(|| rgb(0x4D4D4D)); // default - gray | passed-white or active - blue
9-
pub static ACTIVE_ICON_COLOR: LazyLock<Rgba> = LazyLock::new(|| rgb(0x4892F1));
10-
pub static ACTIVE_BG_COLOR: LazyLock<Rgba> = LazyLock::new(|| rgb(0x202020));
11-
pub static PRESSED_BG_COLOR: LazyLock<Rgba> = LazyLock::new(|| rgb(0x363636)); // default - light gray | passed - yellow - xDB9200
6+
const ICON_COLOR: u32 = 0x4D4D4D; // default - gray | custom can be - white or active - blue
7+
const ACTIVE_ICON_COLOR: u32 = 0x4892F1;
8+
const ACTIVE_BG_COLOR: u32 = 0x202020;
9+
const PRESSED_BG_COLOR: u32 = 0x363636; // default - light gray | custom can be - yellow - xDB9200
1210

1311
#[derive(IntoElement)]
1412
pub struct IconButton {
@@ -108,37 +106,29 @@ impl RenderOnce for IconButton {
108106
// .opacity(0.2)
109107
.items_center()
110108
.justify_center()
111-
.when(self.pressed, |this| this.bg(PRESSED_BG_COLOR.to_owned())) // BG - light gray - pressed
109+
.when(self.pressed, |this| this.bg(rgb(PRESSED_BG_COLOR)))
112110
.when(!self.pressed && self.active, |this| {
113111
if let Some(active_bg_color) = self.active_bg_color {
114112
this.bg(active_bg_color)
115113
} else {
116-
this.bg(ACTIVE_BG_COLOR.to_owned())
114+
this.bg(rgb(ACTIVE_BG_COLOR))
117115
}
118-
119-
}) // BG - dark gray - active
116+
})
120117
.when_some(self.on_click, |this, on_click| {
121118
this.on_click(move |event, window, cx| (on_click)(event, window, cx))
122119
})
123-
// .when_some(self.icon, |this, icon| {
124-
// if let Some(icon_color) = self.icon_color {
125-
// this.child(icon.text_color(icon_color)) // passing gray for default
126-
// } else {
127-
// this.child(icon.text_color(rgb(0x4892F1))) // blue - icon color
128-
// }
129-
// })
130120
.when_some(self.icon, |this, icon| {
131121
let color: Hsla = if self.active {
132122
if let Some(active_icon_color) = self.active_icon_color {
133123
active_icon_color
134124
} else {
135-
ACTIVE_ICON_COLOR.to_owned().into()
125+
rgb(ACTIVE_ICON_COLOR).into()
136126
}
137127
} else {
138128
if let Some(icon_color) = self.icon_color {
139129
icon_color
140130
} else {
141-
ICON_COLOR.to_owned().into()
131+
rgb(ICON_COLOR).into()
142132
}
143133
};
144134
this.child(icon.text_color(color))

0 commit comments

Comments
 (0)