summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/navigation/view_navigation.rs
blob: beec81835e5933d7db12da2cd2fe3ffa70ba5fa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use iced::{widget::column, Element};

use super::{Message, Navigation};

pub fn view_navigation<'a, TOption>(
    navigation: &'a Navigation<TOption>,
) -> Element<'a, Message<TOption>>
where
    TOption: Clone + PartialEq + Into<Element<'a, Message<TOption>>>,
{
    let mut options = Vec::new();
    navigation
        .options_before_active
        .iter()
        .map(|option| navigation.button(&option))
        .for_each(|option| options.push(option));
    if let Some(active_option) = navigation.active_option.as_ref() {
        options.push(navigation.button(&active_option));
    }
    navigation
        .options_after_active
        .iter()
        .map(|option| navigation.button(&option))
        .for_each(|option| options.push(option));
    column(options).into()
}