Something went wrong. Try again.
Cross-platform and non-web GUI library for 🦀 Rust powered by 🎨 Skia. freyaui.dev
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465#![cfg_attr( all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows")]use freya::prelude::*;
fn main() { launch(LaunchConfig::new().with_window(WindowConfig::new(app)))}
fn app() -> impl IntoElement { let mut length = use_state(|| 15usize);
rect() .child( rect() .horizontal() .cross_align(Alignment::Center) .spacing(6.) .padding(6.) .child( Button::new() .on_press(move |_| *length.write() += 1) .child("Increase"), ) .child( Button::new() .on_press(move |_| { let mut length = length.write(); *length = length.saturating_sub(1); }) .child("Decrease"), ) .child(format!("Length: {}", length.read())), ) .child( VirtualScrollView::new(|item, _| { rect() .key(item.index) .width(Size::fill()) .height(Size::px(item.size)) .padding(6.) .child( rect() .expanded() .corner_radius(8.) .background((0, 119, 182)) .main_align(Alignment::center()) .cross_align(Alignment::center()) .child( label() .color(Color::WHITE) .text(format!("Item {}", item.index)), ), ) .into() }) .length(*length.read()) .item_size(100.) .height(Size::fill()) .min_height(Size::px(200.)) .max_height(Size::window_percent(50.)), )}