use iced::{
    application::StyleSheet,
    theme,
    widget::{button, row, text_input, TextInput},
    Element, Length, Padding,
};

use crate::*;
use crate::{message::Message::*, Counter};

pub fn search_bar(state: &Counter) -> Element<Message> {
    row![TextInput::new("Search", &state.input_val)
        .on_input(Message::InputChanged)
        .width(300)]
    .into()
}

fn menu_tab_button<'a>(label: &'a str, tab: Tab) -> Element<'a, Message> {
    button(label)
        .on_press(SwitchTab(tab))
        .padding(Padding::from([10, 20]))
        .width(Length::FillPortion(1))
        .into()
}

pub fn tabs(state: &Counter) -> Element<Message> {
    row![
        menu_tab_button("Content", Tab::Content),
        menu_tab_button("Settings", Tab::Settings),
    ]
    .padding(10)
    .spacing(20)
    .width(300)
    .height(Length::Shrink)
    .into()
}
