frus 0.5.0

frus — the facade: a single dependency to write an application (shell + widgets + one entry point).
Documentation

frus

The one dependency a frus application declares: it re-exports the shell, the widgets and the main! entry point.

Layer: Application. The facade holds no logic of its own. See ARCHITECTURE.md.

What you reach for

  • FrusApp: an application whose whole declaration is a root component.
  • StatelessWidget, StatefulWidget and State, and the hooks on BuildContext (use_state, use_ref, use_memo, use_effect, use_interval): components, and the state they keep between rebuilds.
  • TextEditingController, ValueNotifier, ChangeNotifier: state that something outside a widget needs to read or write, and to listen to.
  • GoRouter, GoRoute, GoRouterState: routes, the stack of pages, redirects, and the page transition.
  • Application, Command, Subscription: the typed-message model FrusApp is built on, from frus-shell, for an application that wants explicit messages and effects.
  • Every widget, Theme, and the column! and row! macros, from frus-widgets.
  • main!: the entry point for every platform. frus::fonts registers an application's own faces.

Example

use frus::{button, column, text, BuildContext, FrusApp, Widget};

fn counter(cx: &BuildContext) -> Box<dyn Widget> {
    let count = cx.use_state(|| 0);
    let add = count.clone();
    Box::new(column![
        text(count.get().to_string()),
        button("+", move || add.update(|n| *n += 1)),
    ])
}

// Generates `run()` for the desktop, `android_main` for Android, and the web's start.
frus::main!(FrusApp::from_fn(counter));

fn main() -> frus::anyhow::Result<()> {
    run()
}

A complete version is frus-hello, and frus create my_app (cargo install frus-cli) starts a project from it.

Features

net and json add HTTP and typed JSON, and file-dialogs the system's open, save and folder dialogs on the desktop (FileDialog). The bundled-* features (all on by default) choose the fonts compiled in, and icons-outlined, icons-rounded and icons-sharp add icon styles. images (default) decodes embedded PNG and JPEG.

Part of frus

Add it with cargo add frus. See the workspace README and the getting-started guide. Licensed under MIT or Apache-2.0.