use super::IconData;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum IconName {
Check,
Cross,
ArrowLeft,
ArrowRight,
ArrowUp,
ArrowDown,
Star,
Heart,
Settings,
Home,
Search,
Menu,
Close,
Plus,
Minus,
Info,
Warning,
Error,
User,
Mail,
Bell,
Edit,
Trash,
Share,
Refresh,
More,
Filter,
Lock,
Unlock,
Download,
Upload,
ChevronLeft,
ChevronRight,
ChevronUp,
ChevronDown,
FirstPage,
LastPage,
Folder,
FolderOpen,
File,
Save,
Copy,
Print,
Undo,
Redo,
Cut,
Paste,
Attachment,
Link,
Success,
Help,
Block,
Schedule,
Hourglass,
Play,
Pause,
Stop,
SkipNext,
VolumeUp,
VolumeOff,
Sort,
BarChart,
Calendar,
Table,
Chat,
Call,
Send,
NotificationsOff,
}
impl IconName {
pub fn as_str(&self) -> &'static str {
match self {
Self::Check => "check",
Self::Cross => "cross",
Self::ArrowLeft => "arrow_left",
Self::ArrowRight => "arrow_right",
Self::ArrowUp => "arrow_up",
Self::ArrowDown => "arrow_down",
Self::Star => "star",
Self::Heart => "heart",
Self::Settings => "settings",
Self::Home => "home",
Self::Search => "search",
Self::Menu => "menu",
Self::Close => "close",
Self::Plus => "plus",
Self::Minus => "minus",
Self::Info => "info",
Self::Warning => "warning",
Self::Error => "error",
Self::User => "user",
Self::Mail => "mail",
Self::Bell => "bell",
Self::Edit => "edit",
Self::Trash => "trash",
Self::Share => "share",
Self::Refresh => "refresh",
Self::More => "more",
Self::Filter => "filter",
Self::Lock => "lock",
Self::Unlock => "unlock",
Self::Download => "download",
Self::Upload => "upload",
Self::ChevronLeft => "chevron_left",
Self::ChevronRight => "chevron_right",
Self::ChevronUp => "chevron_up",
Self::ChevronDown => "chevron_down",
Self::FirstPage => "first_page",
Self::LastPage => "last_page",
Self::Folder => "folder",
Self::FolderOpen => "folder_open",
Self::File => "file",
Self::Save => "save",
Self::Copy => "copy",
Self::Print => "print",
Self::Undo => "undo",
Self::Redo => "redo",
Self::Cut => "cut",
Self::Paste => "paste",
Self::Attachment => "attachment",
Self::Link => "link",
Self::Success => "success",
Self::Help => "help",
Self::Block => "block",
Self::Schedule => "schedule",
Self::Hourglass => "hourglass",
Self::Play => "play",
Self::Pause => "pause",
Self::Stop => "stop",
Self::SkipNext => "skip_next",
Self::VolumeUp => "volume_up",
Self::VolumeOff => "volume_off",
Self::Sort => "sort",
Self::BarChart => "bar_chart",
Self::Calendar => "calendar",
Self::Table => "table",
Self::Chat => "chat",
Self::Call => "call",
Self::Send => "send",
Self::NotificationsOff => "notifications_off",
}
}
pub fn from_name(name: &str) -> Option<Self> {
match name {
"check" => Some(Self::Check),
"cross" => Some(Self::Cross),
"arrow_left" => Some(Self::ArrowLeft),
"arrow_right" => Some(Self::ArrowRight),
"arrow_up" => Some(Self::ArrowUp),
"arrow_down" => Some(Self::ArrowDown),
"star" => Some(Self::Star),
"heart" => Some(Self::Heart),
"settings" => Some(Self::Settings),
"home" => Some(Self::Home),
"search" => Some(Self::Search),
"menu" => Some(Self::Menu),
"close" => Some(Self::Close),
"plus" => Some(Self::Plus),
"minus" => Some(Self::Minus),
"info" => Some(Self::Info),
"warning" => Some(Self::Warning),
"error" => Some(Self::Error),
"user" => Some(Self::User),
"mail" => Some(Self::Mail),
"bell" => Some(Self::Bell),
"edit" => Some(Self::Edit),
"trash" => Some(Self::Trash),
"share" => Some(Self::Share),
"refresh" => Some(Self::Refresh),
"more" => Some(Self::More),
"filter" => Some(Self::Filter),
"lock" => Some(Self::Lock),
"unlock" => Some(Self::Unlock),
"download" => Some(Self::Download),
"upload" => Some(Self::Upload),
"chevron_left" => Some(Self::ChevronLeft),
"chevron_right" => Some(Self::ChevronRight),
"chevron_up" => Some(Self::ChevronUp),
"chevron_down" => Some(Self::ChevronDown),
"first_page" => Some(Self::FirstPage),
"last_page" => Some(Self::LastPage),
"folder" => Some(Self::Folder),
"folder_open" => Some(Self::FolderOpen),
"file" => Some(Self::File),
"save" => Some(Self::Save),
"copy" => Some(Self::Copy),
"print" => Some(Self::Print),
"undo" => Some(Self::Undo),
"redo" => Some(Self::Redo),
"cut" => Some(Self::Cut),
"paste" => Some(Self::Paste),
"attachment" => Some(Self::Attachment),
"link" => Some(Self::Link),
"success" => Some(Self::Success),
"help" => Some(Self::Help),
"block" => Some(Self::Block),
"schedule" => Some(Self::Schedule),
"hourglass" => Some(Self::Hourglass),
"play" => Some(Self::Play),
"pause" => Some(Self::Pause),
"stop" => Some(Self::Stop),
"skip_next" => Some(Self::SkipNext),
"volume_up" => Some(Self::VolumeUp),
"volume_off" => Some(Self::VolumeOff),
"sort" => Some(Self::Sort),
"bar_chart" => Some(Self::BarChart),
"calendar" => Some(Self::Calendar),
"table" => Some(Self::Table),
"chat" => Some(Self::Chat),
"call" => Some(Self::Call),
"send" => Some(Self::Send),
"notifications_off" => Some(Self::NotificationsOff),
_ => None,
}
}
pub fn all_tokens() -> [&'static str; 68] {
let mut tokens = [""; 68];
let mut index = 0;
let mut variant_index = 0;
while variant_index < Self::ALL.len() {
tokens[index] = Self::ALL[variant_index].as_str();
index += 1;
variant_index += 1;
}
tokens
}
pub const ALL: [IconName; 68] = [
Self::Check,
Self::Cross,
Self::ArrowLeft,
Self::ArrowRight,
Self::ArrowUp,
Self::ArrowDown,
Self::Star,
Self::Heart,
Self::Settings,
Self::Home,
Self::Search,
Self::Menu,
Self::Close,
Self::Plus,
Self::Minus,
Self::Info,
Self::Warning,
Self::Error,
Self::User,
Self::Mail,
Self::Bell,
Self::Edit,
Self::Trash,
Self::Share,
Self::Refresh,
Self::More,
Self::Filter,
Self::Lock,
Self::Unlock,
Self::Download,
Self::Upload,
Self::ChevronLeft,
Self::ChevronRight,
Self::ChevronUp,
Self::ChevronDown,
Self::FirstPage,
Self::LastPage,
Self::Folder,
Self::FolderOpen,
Self::File,
Self::Save,
Self::Copy,
Self::Print,
Self::Undo,
Self::Redo,
Self::Cut,
Self::Paste,
Self::Attachment,
Self::Link,
Self::Success,
Self::Help,
Self::Block,
Self::Schedule,
Self::Hourglass,
Self::Play,
Self::Pause,
Self::Stop,
Self::SkipNext,
Self::VolumeUp,
Self::VolumeOff,
Self::Sort,
Self::BarChart,
Self::Calendar,
Self::Table,
Self::Chat,
Self::Call,
Self::Send,
Self::NotificationsOff,
];
#[cfg(feature = "icons")]
pub fn data(self) -> IconData {
use crate::widget::icon_data::ICON_DATA;
let index = self as usize;
debug_assert_eq!(
ICON_DATA[index].name,
self.as_str(),
"ICON_DATA order must match IconName declaration order"
);
ICON_DATA[index]
}
#[cfg(feature = "icons")]
pub fn data_opt(self) -> Option<IconData> {
Some(self.data())
}
#[cfg(not(feature = "icons"))]
pub fn data_opt(self) -> Option<IconData> {
None
}
}