New icons, new side panel, table no longer shows playlists, as they are selectable seperately
This commit is contained in:
53
src/ui/gui/components/search_bar.rs
Normal file
53
src/ui/gui/components/search_bar.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use egui::Color32;
|
||||
|
||||
use super::ComponentUiMut;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct SearchBar {
|
||||
text: String
|
||||
}
|
||||
|
||||
pub enum SearchType {
|
||||
Generic,
|
||||
Song,
|
||||
Url,
|
||||
Source,
|
||||
}
|
||||
|
||||
impl SearchBar {
|
||||
pub fn get_search(&self) -> (SearchType, String) {
|
||||
if self.text.starts_with("source:") {
|
||||
(
|
||||
SearchType::Source,
|
||||
self.text.strip_prefix("source:").unwrap_or("").to_string().to_lowercase()
|
||||
)
|
||||
} else if self.text.starts_with("song:") {
|
||||
(
|
||||
SearchType::Song,
|
||||
self.text.strip_prefix("song:").unwrap_or("").to_string().to_lowercase()
|
||||
)
|
||||
} else if self.text.starts_with("url:") {
|
||||
(
|
||||
SearchType::Url,
|
||||
self.text.strip_prefix("url:").unwrap_or("").to_string().to_lowercase()
|
||||
)
|
||||
} else {
|
||||
(
|
||||
SearchType::Generic,
|
||||
self.text.clone()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ComponentUiMut for SearchBar {
|
||||
fn ui(&mut self, _: &mut crate::ui::gui::Gui, ui: &mut egui::Ui) {
|
||||
ui.vertical(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
let tint = Color32::from_hex("#333377").unwrap();
|
||||
ui.add(egui::Image::new(crate::data::SEARCH_ICON).tint(tint));
|
||||
ui.text_edit_singleline(&mut self.text);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user