faststep 0.1.0

UIKit-inspired embedded UI framework built on embedded-graphics
Documentation
use embedded_graphics::{draw_target::DrawTarget, pixelcolor::Rgb565, primitives::Rectangle};
use faststep::{FsTheme, I18n, Localized, TouchEvent, UiApp, ViewDelegate, ViewResponse};

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum AppView {
    Home,
    Detail,
}

struct DemoDelegate;

impl DemoDelegate {
    const fn new() -> Self {
        Self
    }
}

impl<'a> ViewDelegate<'a, AppView> for DemoDelegate {
    fn title(&self, view: AppView) -> Localized<'a> {
        match view {
            AppView::Home => Localized::new("home.title", "Home"),
            AppView::Detail => Localized::new("detail.title", "Detail"),
        }
    }

    fn draw_view<D>(
        &self,
        _view: AppView,
        _display: &mut D,
        _frame: Rectangle,
        _theme: &FsTheme,
        _i18n: &I18n<'a>,
    ) where
        D: DrawTarget<Color = Rgb565>,
    {
    }

    fn handle_view_touch(
        &mut self,
        view: AppView,
        _touch: TouchEvent,
        _frame: Rectangle,
        _theme: &FsTheme,
        _i18n: &I18n<'a>,
    ) -> ViewResponse<AppView> {
        match view {
            AppView::Home => ViewResponse::push(AppView::Detail),
            AppView::Detail => ViewResponse::pop(),
        }
    }
}

fn main() {
    let _ui = UiApp::<AppView, DemoDelegate, 8>::new(
        AppView::Home,
        DemoDelegate::new(),
        FsTheme::default(),
        I18n::new("en", "en", &[]),
    );
}