diff options
| author | Joe Carstairs <me@joeac.net> | 2025-08-13 07:50:21 +0000 |
|---|---|---|
| committer | joeac <me@joeac.net> | 2025-08-13 07:50:21 +0000 |
| commit | ee3cd780e21260257b401c3f5cbababd9e27a15a (patch) | |
| tree | b0571649a1a1a7644dbc50183cc4c3a29966a963 /schist_desktop_gui/src/gui/components/navigation/view_navigation_button.rs | |
| parent | 49342e8b553d5c92f1c043b3b0ce18bdf1c2cd44 (diff) | |
task-073
Co-authored-by: Joe Carstairs <jcarstairs@scottlogic.com>
Reviewed-on: https://git.joeac.net/joeac/schist/pulls/1
Co-authored-by: Joe Carstairs <me@joeac.net>
Co-committed-by: Joe Carstairs <me@joeac.net>
Diffstat (limited to 'schist_desktop_gui/src/gui/components/navigation/view_navigation_button.rs')
| -rw-r--r-- | schist_desktop_gui/src/gui/components/navigation/view_navigation_button.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/schist_desktop_gui/src/gui/components/navigation/view_navigation_button.rs b/schist_desktop_gui/src/gui/components/navigation/view_navigation_button.rs new file mode 100644 index 0000000..3132bf1 --- /dev/null +++ b/schist_desktop_gui/src/gui/components/navigation/view_navigation_button.rs @@ -0,0 +1,27 @@ +use iced::Element; + +use crate::gui::components::{active_button, inactive_button}; + +use super::{Message, Navigation}; + +pub fn view_navigation_button<'a, TOption>( + navigation: &'a Navigation<TOption>, + option: &'a TOption, +) -> Element<'a, Message<TOption>> +where + TOption: Clone + PartialEq + Into<Element<'a, Message<TOption>>>, +{ + if navigation + .active_option + .as_ref() + .is_some_and(|o| *o == *option) + { + active_button(Into::<Element<'a, Message<TOption>>>::into(option.clone())).into() + } else { + inactive_button( + Into::<Element<'a, Message<TOption>>>::into(option.clone()), + Message::SelectOption(option.clone()), + ) + .into() + } +} |
