Skip to content

Commit

Permalink
fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
LegitCamper committed Oct 1, 2024
1 parent a0d9ae9 commit 4bced06
Showing 1 changed file with 52 additions and 27 deletions.
79 changes: 52 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
## Iced library to create custom browsers

[![Build](https://github.com/LegitCamper/icy_browser/actions/workflows/ci.yml/badge.svg)](https://github.com/LegitCamper/icy_browser/actions/workflows/ci.yml)
<img src="https://raw.githubusercontent.com/gist/hecrj/ad7ecd38f6e47ff3688a38c79fd108f0/raw/74384875ecbad02ae2a926425e9bcafd0695bade/color.svg" width=10%>

### Supported Platforms
| Platform | Support |
| Windows | <span>&#10003;</span> |
| Linux | <span>&#10003;</span> |

[![Build](https://github.com/LegitCamper/icy_browser/actions/workflows/ci.yml/badge.svg)](https://github.com/LegitCamper/icy_browser/actions/workflows/ci.yml)

### Supported Browser Engines
| Browser Engine | Support |
Expand All @@ -23,32 +17,63 @@

### Examples
#### basic_browser.rs
<img src="https://github.com/LegitCamper/rust-browser/blob/main/assets/basic_browser.png" width=50%>
<img src="https://github.com/LegitCamper/icy_browser/blob/main/assets/basic_browser.png?raw=true" width=50%>

``` Rust
use iced::{Settings, Task, Theme};
use icy_browser::{get_fonts, BasicBrowser, Message};
use iced::{Sandbox, Settings, Theme};
use iced_aw::BOOTSTRAP_FONT_BYTES;

fn run() -> (BasicBrowser, Task<Message>) {
(
BasicBrowser::new_basic()
.with_tab_bar()
.with_nav_bar()
.build(),
Task::none(),
)
}
use icy_browser::{widgets, BrowserWidget, Ultralight};

fn main() -> iced::Result {
fn main() -> Result<(), iced::Error> {
// This imports `icons` for widgets
let bootstrap_font = BOOTSTRAP_FONT_BYTES.into();
let settings = Settings {
fonts: get_fonts(),
fonts: vec![bootstrap_font],
..Default::default()
};
Browser::run(settings)
}

struct Browser {
widgets: BrowserWidget<Ultralight>,
}

iced::application("Basic Browser", BasicBrowser::update, BasicBrowser::view)
.subscription(BasicBrowser::subscription)
.settings(settings)
.theme(|_| Theme::Dark)
.run_with(run)
#[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)
}
}```

0 comments on commit 4bced06

Please sign in to comment.