Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions src/app/tile.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This module handles the logic for the tile, AKA rustcast's main window
mod elm;
mod update;
pub mod elm;
pub mod update;

use crate::app::apps::App;
use crate::app::tile::elm::default_app_paths;
Expand All @@ -16,7 +16,7 @@ use global_hotkey::{GlobalHotKeyEvent, HotKeyState};
use iced::futures::SinkExt;
use iced::futures::channel::mpsc::{Sender, channel};
use iced::{
Element, Subscription, Task, Theme, futures,
Subscription, Theme, futures,
keyboard::{self, key::Named},
stream,
};
Expand Down Expand Up @@ -105,24 +105,6 @@ pub struct Tile {
}

impl Tile {
/// Initialise the base window
pub fn new(hotkey: HotKey, config: &Config) -> (Self, Task<Message>) {
elm::new(hotkey, config)
}

/// This handles the iced's updates, which have all the variants of [Message]
pub fn update(&mut self, message: Message) -> Task<Message> {
update::handle_update(self, message)
}

/// This is the view of the window. It handles the rendering of the window
///
/// The rendering of the window size (the resizing of the window) is handled by the
/// [`Tile::update`] function.
pub fn view(&self, wid: window::Id) -> Element<'_, Message> {
elm::view(self, wid)
}

/// This returns the theme of the window
pub fn theme(&self, _: window::Id) -> Option<Theme> {
Some(self.theme.clone())
Expand Down
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ mod utils;

use std::path::Path;

use crate::{app::tile::Tile, config::Config};
use crate::{
app::tile::{self, Tile},
config::Config,
};

use global_hotkey::GlobalHotKeyManager;

Expand Down Expand Up @@ -49,9 +52,9 @@ fn main() -> iced::Result {
.expect("Unable to register hotkey");

iced::daemon(
move || Tile::new(show_hide, &config),
Tile::update,
Tile::view,
move || tile::elm::new(show_hide, &config),
tile::update::handle_update,
tile::elm::view,
)
.subscription(Tile::subscription)
.theme(Tile::theme)
Expand Down
Loading