more
This commit is contained in:
parent
76396a6b6c
commit
955aafacb6
4 changed files with 194 additions and 2687 deletions
63
src/main.rs
63
src/main.rs
|
@ -1,27 +1,33 @@
|
|||
mod applications;
|
||||
use applications::{all_apps, App};
|
||||
use iced::widget::{container, row};
|
||||
use iced::{Color, Element, Task};
|
||||
use chrono::prelude::*;
|
||||
use iced::widget::{container, row, text};
|
||||
use iced::{Background, Border, Color, Element, Font, Length, Task};
|
||||
|
||||
use iced_layershell::build_pattern::application;
|
||||
use iced_layershell::build_pattern::{application, MainSettings};
|
||||
use iced_layershell::reexport::Anchor;
|
||||
use iced_layershell::settings::LayerShellSettings;
|
||||
use iced_layershell::to_layer_message;
|
||||
|
||||
fn main() -> iced_layershell::Result {
|
||||
application(Panel::namespace, Panel::update, Panel::view)
|
||||
.layer_settings(LayerShellSettings {
|
||||
size: Some((600, 50)),
|
||||
let settings = MainSettings {
|
||||
layer_settings: LayerShellSettings {
|
||||
size: Some((1200, 30)),
|
||||
anchor: Anchor::Bottom,
|
||||
margin: (0, 0, 10, 0),
|
||||
exclusive_zone: 40,
|
||||
..Default::default()
|
||||
})
|
||||
},
|
||||
default_font: Font::with_name("VictorMono Nerd Font"),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
application(Panel::namespace, Panel::update, Panel::view)
|
||||
.settings(settings)
|
||||
.style(Panel::style)
|
||||
.run_with(Panel::new)
|
||||
}
|
||||
|
||||
struct Panel {
|
||||
apps: Vec<App>,
|
||||
apps: Vec<String>,
|
||||
}
|
||||
|
||||
#[to_layer_message]
|
||||
|
@ -32,7 +38,7 @@ enum Message {
|
|||
|
||||
impl Panel {
|
||||
fn new() -> (Self, Task<Message>) {
|
||||
(Self { apps: all_apps() }, Task::none())
|
||||
(Self { apps: vec![] }, Task::none())
|
||||
}
|
||||
fn namespace(&self) -> String {
|
||||
String::from("bottom panel")
|
||||
|
@ -40,24 +46,35 @@ impl Panel {
|
|||
|
||||
fn update(&mut self, message: Message) -> Task<Message> {
|
||||
match message {
|
||||
Message::Launch(index) => {
|
||||
self.apps[index].launch();
|
||||
Task::none()
|
||||
}
|
||||
Message::Launch(index) => Task::none(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
let bottom_vec: Vec<Element<Message>> = self
|
||||
.apps
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, app)| app.view(index, false))
|
||||
.collect();
|
||||
// let bottom_vec: Vec<Element<Message>> = self
|
||||
// .apps
|
||||
// .iter()
|
||||
// .enumerate()
|
||||
// .map(|(index, app)| app.view(index, false))
|
||||
// .collect();
|
||||
|
||||
let row = row(bottom_vec);
|
||||
container(row).into()
|
||||
let datetime: DateTime<Local> = Local::now();
|
||||
|
||||
let clock = text!("{}", datetime.format("%a %b %e, %r"));
|
||||
let clock = clock.color(Color::parse("#e2e4e5").unwrap());
|
||||
|
||||
// let row = row(bottom_vec);
|
||||
container(clock)
|
||||
.style(|t: &iced::Theme| {
|
||||
container::rounded_box(t)
|
||||
.border(Border::default().rounded(20))
|
||||
.background(
|
||||
Background::Color(Color::parse("#282a36").unwrap()).scale_alpha(0.95),
|
||||
)
|
||||
})
|
||||
.center(Length::Fill)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn style(&self, theme: &iced::Theme) -> iced_layershell::Appearance {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue