diff --git a/core/src/egui/selection_panels.rs b/core/src/egui/selection_panels.rs index a97a455..d3445a8 100644 --- a/core/src/egui/selection_panels.rs +++ b/core/src/egui/selection_panels.rs @@ -82,6 +82,7 @@ pub struct SelectionPanel { pub value: V, pub build_heading: Option, pub build_footer: Option, + pub icons: Option<(RichText, RichText)>, } impl SelectionPanel { @@ -92,6 +93,10 @@ impl SelectionPanel { value, build_heading: None, build_footer: None, + icons: Some(( + RichText::new(egui_phosphor::bold::CHECK).heading(), + RichText::new(egui_phosphor::bold::DOT_OUTLINE).heading(), + )), } } pub fn heading(mut self, build_heading: impl FnOnce(&mut Ui) + 'static) -> Self { @@ -102,6 +107,10 @@ impl SelectionPanel { self.build_footer = Some(Box::new(build_footer)); self } + pub fn icons(mut self, icons: Option<(impl Into, impl Into)>) -> Self { + self.icons = icons.map(|(a, b)| (a.into(), b.into())); + self + } pub fn render( self, @@ -131,12 +140,10 @@ impl SelectionPanel { if let Some(build) = self.build_heading { (build)(ui); } - let icon = if selected { - egui_phosphor::bold::CHECK - } else { - egui_phosphor::bold::DOT_OUTLINE - }; - ui.label(RichText::new(icon).heading()); + if let Some((selected_icon, normal_icon)) = self.icons { + let icon = if selected { selected_icon } else { normal_icon }; + ui.label(icon); + } if let Some(build) = self.build_footer { //ui.visuals_mut().override_text_color = Some(Color32::WHITE); (build)(ui); @@ -223,6 +230,20 @@ impl SelectionPanels { .push(SelectionPanel::new(value, title, sub).footer(build_footer)); self } + pub fn add_icon_less( + mut self, + value: Value, + title: impl Into, + sub: impl Into, + build_footer: impl FnOnce(&mut Ui) + 'static, + ) -> Self { + self.panels.push( + SelectionPanel::new(value, title, sub) + .footer(build_footer) + .icons(None::<(RichText, RichText)>), + ); + self + } pub fn panel_min_height(mut self, min_height: f32) -> Self { self.panel_min_height = min_height; self diff --git a/core/src/modules/account_manager/estimator.rs b/core/src/modules/account_manager/estimator.rs index dda4615..1419ffa 100644 --- a/core/src/modules/account_manager/estimator.rs +++ b/core/src/modules/account_manager/estimator.rs @@ -109,7 +109,7 @@ impl<'context> Estimator<'context> { let mut fee_selection = SelectionPanels::new( 120.0, 150.0); - + let fee_mode = self.context.fee_mode; for mode in buckets.into_iter().flatten() { let bucket = mode.bucket(); let aggregate_mass = actual_estimate.aggregate_mass; @@ -119,7 +119,15 @@ impl<'context> Estimator<'context> { let total_kas = feerate * aggregate_mass as f64 * 1e-8; let total_sompi = (feerate * aggregate_mass as f64) as u64; let total_usd = usd_rate.map(|rate| total_kas * rate); - fee_selection = fee_selection.add_with_footer(mode, i18n(mode.to_string().as_str()), format_duration_estimate(seconds), move |ui| { + fee_selection = fee_selection.add_icon_less(mode, i18n(mode.to_string().as_str()), format_duration_estimate(seconds), move |ui| { + // icon + let icon = if mode == fee_mode { + RichText::new(egui_phosphor::bold::CHECK).strong() + } else { + RichText::new(egui_phosphor::bold::DOT_OUTLINE).strong() + }; + ui.label(icon); + ui.label(RichText::new(sompi_to_kaspa_string_with_suffix(total_sompi, &network_type)).strong()); if let Some(usd) = total_usd { let usd = format_currency(usd, 6);