diff --git a/README.md b/README.md index 72c4b0c..e7e6b15 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,79 @@ +## Iced library to create custom browsers + [![Build](https://github.com/LegitCamper/rust-browser/actions/workflows/ci.yml/badge.svg)](https://github.com/LegitCamper/rust-browser/actions/workflows/ci.yml) + - +### Supported Browser Engines +| Browser Engine | Support | +| ----------------- | --------- | +| WebKit/Ultralight | | +| Chromium/CEF | X Planned | -## Iced library to create custom browsers + +### Browser Widgets +- Navigation Bar +- Tab Bar +- Browser View + +### Examples +#### basic_browser.rs +![](https://github.com/LegitCamper/rust-browser/blob/main/assets/basic_browser.png) +``` Rust +use iced::{Sandbox, Settings, Theme}; +use iced_aw::BOOTSTRAP_FONT_BYTES; + +use icy_browser::{widgets, BrowserWidget, Ultralight}; + +fn main() -> Result<(), iced::Error> { + // This imports `icons` for widgets + let bootstrap_font = BOOTSTRAP_FONT_BYTES.into(); + let settings = Settings { + fonts: vec![bootstrap_font], + ..Default::default() + }; + Browser::run(settings) +} + +struct Browser { + widgets: BrowserWidget, +} + +#[derive(Debug, Clone)] +pub enum Message { + BrowserWidget(widgets::Message), +} + +impl Sandbox for Browser { + type Message = Message; + + fn new() -> Self { + let widgets = BrowserWidget::new_with_ultralight() + .with_tab_bar() + .with_nav_bar() + .with_browsesr_view() + .build(); + + Self { widgets } + } + + fn title(&self) -> String { + String::from("Basic Browser") + } + + fn theme(&self) -> Theme { + Theme::Dark + } + + fn update(&mut self, message: Self::Message) { + match message { + Message::BrowserWidget(msg) => { + self.widgets.update(msg); + } + } + } + + fn view(&self) -> iced::Element<'_, Self::Message> { + self.widgets.view().map(Message::BrowserWidget) + } +} +``` diff --git a/assets/basic_browser.png b/assets/basic_browser.png new file mode 100644 index 0000000..147b7ab Binary files /dev/null and b/assets/basic_browser.png differ