-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update readme with picture of basic_browser
fix url and code block fix basic_brower catagory scale down browser view 50% fix codeblock
- Loading branch information
1 parent
7736f70
commit 8d7522c
Showing
2 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
<img src="https://raw.githubusercontent.com/gist/hecrj/ad7ecd38f6e47ff3688a38c79fd108f0/raw/74384875ecbad02ae2a926425e9bcafd0695bade/color.svg" width=8%> | ||
|
||
<img src="https://raw.githubusercontent.com/gist/hecrj/ad7ecd38f6e47ff3688a38c79fd108f0/raw/74384875ecbad02ae2a926425e9bcafd0695bade/color.svg" width=20% height=20%> | ||
### Supported Browser Engines | ||
| Browser Engine | Support | | ||
| ----------------- | --------- | | ||
| WebKit/Ultralight | <span>✓</span> | | ||
| Chromium/CEF | X Planned | | ||
|
||
## Iced library to create custom browsers | ||
|
||
### Browser Widgets | ||
- Navigation Bar | ||
- Tab Bar | ||
- Browser View | ||
|
||
### Examples | ||
#### basic_browser.rs | ||
<img src="https://github.com/LegitCamper/rust-browser/blob/main/assets/basic_browser.png" width=50%> | ||
|
||
``` 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<Ultralight>, | ||
} | ||
|
||
#[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) | ||
} | ||
}``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.