Skip to content

Commit 55f335f

Browse files
committed
fix readme
increase iced badge
1 parent a0d9ae9 commit 55f335f

File tree

1 file changed

+52
-27
lines changed

1 file changed

+52
-27
lines changed

README.md

+52-27
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
## Iced library to create custom browsers
2+
<img src="https://raw.githubusercontent.com/gist/hecrj/ad7ecd38f6e47ff3688a38c79fd108f0/raw/74384875ecbad02ae2a926425e9bcafd0695bade/color.svg" width=20%>
23

34
[![Build](https://github.com/LegitCamper/icy_browser/actions/workflows/ci.yml/badge.svg)](https://github.com/LegitCamper/icy_browser/actions/workflows/ci.yml)
4-
<img src="https://raw.githubusercontent.com/gist/hecrj/ad7ecd38f6e47ff3688a38c79fd108f0/raw/74384875ecbad02ae2a926425e9bcafd0695bade/color.svg" width=10%>
5-
6-
### Supported Platforms
7-
| Platform | Support |
8-
| Windows | <span>&#10003;</span> |
9-
| Linux | <span>&#10003;</span> |
10-
115

126
### Supported Browser Engines
137
| Browser Engine | Support |
@@ -23,32 +17,63 @@
2317

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

2822
``` Rust
29-
use iced::{Settings, Task, Theme};
30-
use icy_browser::{get_fonts, BasicBrowser, Message};
23+
use iced::{Sandbox, Settings, Theme};
24+
use iced_aw::BOOTSTRAP_FONT_BYTES;
3125

32-
fn run() -> (BasicBrowser, Task<Message>) {
33-
(
34-
BasicBrowser::new_basic()
35-
.with_tab_bar()
36-
.with_nav_bar()
37-
.build(),
38-
Task::none(),
39-
)
40-
}
26+
use icy_browser::{widgets, BrowserWidget, Ultralight};
4127

42-
fn main() -> iced::Result {
28+
fn main() -> Result<(), iced::Error> {
29+
// This imports `icons` for widgets
30+
let bootstrap_font = BOOTSTRAP_FONT_BYTES.into();
4331
let settings = Settings {
44-
fonts: get_fonts(),
32+
fonts: vec![bootstrap_font],
4533
..Default::default()
4634
};
35+
Browser::run(settings)
36+
}
37+
38+
struct Browser {
39+
widgets: BrowserWidget<Ultralight>,
40+
}
4741

48-
iced::application("Basic Browser", BasicBrowser::update, BasicBrowser::view)
49-
.subscription(BasicBrowser::subscription)
50-
.settings(settings)
51-
.theme(|_| Theme::Dark)
52-
.run_with(run)
42+
#[derive(Debug, Clone)]
43+
pub enum Message {
44+
BrowserWidget(widgets::Message),
5345
}
54-
```
46+
47+
impl Sandbox for Browser {
48+
type Message = Message;
49+
50+
fn new() -> Self {
51+
let widgets = BrowserWidget::new_with_ultralight()
52+
.with_tab_bar()
53+
.with_nav_bar()
54+
.with_browsesr_view()
55+
.build();
56+
57+
Self { widgets }
58+
}
59+
60+
fn title(&self) -> String {
61+
String::from("Basic Browser")
62+
}
63+
64+
fn theme(&self) -> Theme {
65+
Theme::Dark
66+
}
67+
68+
fn update(&mut self, message: Self::Message) {
69+
match message {
70+
Message::BrowserWidget(msg) => {
71+
self.widgets.update(msg);
72+
}
73+
}
74+
}
75+
76+
fn view(&self) -> iced::Element<'_, Self::Message> {
77+
self.widgets.view().map(Message::BrowserWidget)
78+
}
79+
}```

0 commit comments

Comments
 (0)