use freya::{
icons,
prelude::*,
};
fn main() {
launch(LaunchConfig::new().with_window(WindowConfig::new(app)))
}
fn app() -> impl IntoElement {
use_init_root_theme(|| DARK_THEME);
rect()
.expanded()
.vertical()
.spacing(20.)
.main_align(Alignment::Center)
.child(
// Icon showcase
rect()
.horizontal()
.spacing(16.)
.child(icon_demo(icons::lucide::heart(), (255, 100, 100)))
.child(icon_demo(icons::lucide::star(), (255, 215, 0)))
.child(icon_demo(icons::lucide::check_circle(), (100, 255, 100)))
.child(icon_demo(icons::lucide::alert_triangle(), (255, 165, 0)))
)
.child(
// Icon button row
rect()
.horizontal()
.spacing(8.)
.child(icon_button(icons::lucide::home(), "Home"))
.child(icon_button(icons::lucide::search(), "Search"))
.child(icon_button(icons::lucide::user(), "Profile"))
.child(icon_button(icons::lucide::settings(), "Settings"))
)
}
fn icon_demo(icon: bytes::Bytes, color: (u8, u8, u8)) -> impl IntoElement {
svg(icon)
.width(Size::px(48.))
.height(Size::px(48.))
.color(color)
}
fn icon_button(icon: bytes::Bytes, text: &str) -> impl IntoElement {
Button::new()
.on_press(move |_| println!("Clicked: {}", text))
.child(
rect()
.horizontal()
.spacing(8.)
.cross_align(Alignment::Center)
.child(
svg(icon)
.width(Size::px(20.))
.height(Size::px(20.))
.color((200, 200, 200)),
)
.child(text),
)
}