Skip to content

Commit

Permalink
fix(bar): network widget spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
CtByte authored and LGUG2Z committed Dec 20, 2024
1 parent c64a42b commit 99353b8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions komorebi-bar/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,24 @@ impl Network {
impl BarWidget for Network {
fn render(&mut self, ctx: &Context, ui: &mut Ui, config: &mut RenderConfig) {
if self.enable {
// widget spacing: make sure to use the same config to call the apply_on_widget function
let mut render_config = config.clone();

if self.show_total_activity || self.show_activity {
let (activity, total_activity) = self.network_activity();

if self.show_total_activity {
for reading in total_activity {
config.apply_on_widget(true, ui, |ui| {
ui.add(self.reading_to_label(ctx, reading, render_config.clone()));
render_config.apply_on_widget(true, ui, |ui| {
ui.add(self.reading_to_label(ctx, reading, config.clone()));
});
}
}

if self.show_activity {
for reading in activity {
config.apply_on_widget(true, ui, |ui| {
ui.add(self.reading_to_label(ctx, reading, render_config.clone()));
render_config.apply_on_widget(true, ui, |ui| {
ui.add(self.reading_to_label(ctx, reading, config.clone()));
});
}
}
Expand Down Expand Up @@ -325,6 +326,9 @@ impl BarWidget for Network {
});
}
}

// widget spacing: pass on the config that was use for calling the apply_on_widget function
*config = render_config.clone();
}
}
}
Expand Down

0 comments on commit 99353b8

Please sign in to comment.