summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/account_navigation_entry.rs
blob: 6a582a7b8808fc017bf66e7543bfd3f8bed5ae7c (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
27
28
29
30
31
32
33
34
use iced::Element;
use schist_models::Account;

use crate::{
    gui::components::{navigation, Text},
    impl_focusable,
};

#[derive(Clone, Debug, PartialEq)]
pub struct AccountNavigationEntry {
    pub account: Account,
    is_focused: bool,
}

impl AccountNavigationEntry {
    pub fn new(account: Account) -> Self {
        Self {
            account,
            is_focused: false,
        }
    }
}

impl<'a> From<&'a AccountNavigationEntry>
    for Element<'a, navigation::Message<AccountNavigationEntry>>
{
    fn from(account_navigation_entry: &'a AccountNavigationEntry) -> Self {
        Text::default(&account_navigation_entry.account.name)
            .highlight_maybe(account_navigation_entry.is_focused)
            .into()
    }
}

impl_focusable!(AccountNavigationEntry);