Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

marc2332/freya

Repository files navigation

Freya πŸ¦€

Freya logo

Discord Server Github Sponsors codecov

Website | Stable Documentation | Discord | Contact

Freya is a cross-platform and non-web GUI library for Rust powered by 🎨 Skia.

⚠️ I recently rewrote a huge percentage of Freya in #1351, so the main branch differs a lot from the latest stable release.

Counter example

fn app() -> impl IntoElement {
    let mut count = use_state(|| 4);

    let counter = rect()
        .width(Size::fill())
        .height(Size::percent(50.))
        .center()
        .color((255, 255, 255))
        .background((15, 163, 242))
        .font_weight(FontWeight::BOLD)
        .font_size(75.)
        .shadow((0., 4., 20., 4., (0, 0, 0, 80)))
        .child(count.read().to_string());

    let actions = rect()
        .horizontal()
        .width(Size::fill())
        .height(Size::percent(50.))
        .center()
        .spacing(8.0)
        .child(
            Button::new()
                .on_press(move |_| {
                    *count.write() += 1;
                })
                .child("Increase"),
        )
        .child(
            Button::new()
                .on_press(move |_| {
                    *count.write() -= 1;
                })
                .child("Decrease"),
        );

    rect().child(counter).child(actions)
}

Freya Demo

Features ✨

  • Component Model: Separate UI pieces by turning them into reusable components that. Each component takes some Input, might manage some inner State and ultimately returns a UI.
  • Headless Testing: Easily test your UI logic in a headless environment, supports all the normal features. In fact most of the internal components and features are tested with it.
  • i18n (Language Translation): Easily translate your apps with freya-i18 using the Fluent language.
  • Shaders: Render from simple to complex shaders using the Skia Shaders language (SlSl).
  • a11y (Accessibility): You can make your UI elements accessible by using the a11y attributes.
  • Built-in Components: Freya comes with a set of ready-to-use components, these include ScrollViews, VirtualScrollViews, Buttons, Switch, Slider, etc.
  • Animations: Easily animate your UI whether its a size or a color. You have full control over its behavior.
  • Text Editing: Freya supports from simple to rich text editing. You can even make cloned editors, virtualized editors, etc.
  • Cross-platform: Your app will render and behave the same in Windows, Linux and MacOS.
  • Efficient Global State: Efficiently manage a global state based on topics subscription using freya-radio.
  • Icons: Easily add icons to your app using freya-icons, currently only supports Lucide.
  • Devtools: Inspect your app UI tree to to debug, or see performance state.
  • Routing: Manage your app UI in separate routes using freya-router.

Trying it out

Make sure to have Development Setup ready.

⚠️ If you happen to be on Windows using windows-gnu and get compile errors, maybe go check this issue.

Clone this repo and run:

cargo run --example counter

You can also try freya-template

Usage πŸ“œ

main branch (Without Dioxus):

freya = { git = "https://github.com/marc2332/freya", branch = "main" }

Stable release (With Dioxus):

freya = "0.3"
dioxus = { version = "0.6", features = ["macro", "hooks"], default-features = false }

Contributing πŸ§™β€β™‚οΈ

If you are interested in contributing please make sure to have read the Contributing guide first!

Contact

You may contact me for questions, collaboration or anything that comes to your mind at [email protected].

Support πŸ€—

If you are interested in supporting the development of this project feel free to donate to my Github Sponsor page.

Thanks to my sponsors for supporting this project! πŸ˜„

User avatar: User avatar: ι«˜εΊ†δΈ°User avatar: Lino Le VanUser avatar: Huddy BuddyUser avatar: Gabriel JΓ΅eUser avatar: Mark

Special thanks πŸ’ͺ

  • Jonathan Kelley and Evan Almloff for making Dioxus and all their help, specially when I was still creating Freya.
  • Armin for making rust-skia and all his help and making the favor of hosting prebuilt binaries of skia for the combo of features use by Freya.
  • geom3trik for helping me figure out how to add incremental rendering.
  • Tropical for this contributions to improving accessibility and rendering.
  • Aiving for having made heavy contributions to rust-skia for better SVG support, and helped optimizing images rendering in Freya.
  • RobertasJ for having added nested parenthesis to the calc() function and also pushed for improvements in the animation APIs.
  • And to the rest of contributors and anybody who gave me any kind of feedback!

History with Dioxus

Freya 0.1, 0.2 and 0.3 were based on the core crates of Dioxus. Starting 0.4 Freya does no longer use Dioxus, instead it uses its own reactive core, partially inspired by Dioxus but yet with lots of differences.

License

MIT License