Skip to content

Commit

Permalink
clean up examples
Browse files Browse the repository at this point in the history
  • Loading branch information
LegitCamper committed Oct 11, 2024
1 parent d7f8901 commit 4b38e5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions examples/custom_widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() -> iced::Result {

#[derive(Debug, Clone)]
pub enum Message {
BrowserWidget(widgets::Message), // Passes messagees to Browser widgets
IcyBrowser(widgets::Message),
Update,
Tick,
}
Expand Down Expand Up @@ -61,8 +61,8 @@ impl Default for Browser {
impl Browser {
fn update(&mut self, message: Message) -> Task<Message> {
match message {
Message::BrowserWidget(msg) => self.icy_browser.update(msg).map(Message::BrowserWidget),
Message::Update => self.icy_browser.force_update().map(Message::BrowserWidget),
Message::IcyBrowser(msg) => self.icy_browser.update(msg).map(Message::IcyBrowser),
Message::Update => self.icy_browser.force_update().map(Message::IcyBrowser),
Message::Tick => Task::none(), // Tick
}
}
Expand All @@ -72,7 +72,7 @@ impl Browser {
let color_index = (elapsed * 2.0) as usize % self.custom_widget_state.border_colors.len();
let color = self.custom_widget_state.border_colors[color_index];

container(self.icy_browser.view().map(Message::BrowserWidget))
container(self.icy_browser.view().map(Message::IcyBrowser))
.center_x(Length::Fill)
.center_y(Length::Fill)
.padding(20)
Expand Down
16 changes: 8 additions & 8 deletions examples/keyboard_driven.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use iced::{Element, Settings, Subscription, Task};
use std::time::Duration;

use icy_browser::{
get_fonts, widgets, Bookmark, IcyBrowser, KeyType, Message as WidgetMessage, ShortcutBuilder,
ShortcutModifier, Ultralight,
get_fonts, widgets, Bookmark, IcyBrowser, KeyType, ShortcutBuilder, ShortcutModifier,
Ultralight,
};

fn main() -> iced::Result {
Expand All @@ -27,7 +27,7 @@ fn main() -> iced::Result {

#[derive(Debug, Clone)]
pub enum Message {
BrowserWidget(widgets::Message), // Passes messagees to Browser widgets
IcyBrowser(icy_browser::Message), // Passes messages to icy_browser
Update,
Event(Event),
}
Expand All @@ -40,7 +40,7 @@ impl Default for Browser {
fn default() -> Self {
let shortcuts = ShortcutBuilder::new()
.add_shortcut(
WidgetMessage::ToggleOverlay,
icy_browser::Message::ToggleOverlay,
vec![
KeyType::Modifier(ShortcutModifier::Ctrl),
KeyType::Key(iced::keyboard::Key::Character("e".into())),
Expand Down Expand Up @@ -69,17 +69,17 @@ impl Default for Browser {
impl Browser {
fn update(&mut self, message: Message) -> Task<Message> {
match message {
Message::BrowserWidget(msg) => self.icy_browser.update(msg).map(Message::BrowserWidget),
Message::Update => self.icy_browser.force_update().map(Message::BrowserWidget),
Message::IcyBrowser(msg) => self.icy_browser.update(msg).map(Message::IcyBrowser),
Message::Update => self.icy_browser.force_update().map(Message::IcyBrowser),
Message::Event(event) => self
.icy_browser
.update(widgets::Message::IcedEvent(Some(event)))
.map(Message::BrowserWidget),
.map(Message::IcyBrowser),
}
}

fn view(&self) -> Element<Message> {
self.icy_browser.view().map(Message::BrowserWidget)
self.icy_browser.view().map(Message::IcyBrowser)
}

fn subscription(&self) -> Subscription<Message> {
Expand Down

0 comments on commit 4b38e5f

Please sign in to comment.