more
This commit is contained in:
parent
76396a6b6c
commit
955aafacb6
2810
Cargo.lock
generated
2810
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,8 @@ description = "A shell for a computadora"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.20", features = ["debug", "derive"] }
|
clap = { version = "4.5.20", features = ["debug", "derive"] }
|
||||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", features = ["debug", "winit", "tokio", "xdg-portal", "dbus-config", "a11y", "wayland", "wgpu", "multi-window", "single-instance"] }
|
iced = { version = "0.13" }
|
||||||
|
iced_runtime = { version = "0.13", features = [ "multi-window" ] }
|
||||||
miette = { version = "7.2.0", features = ["fancy"] }
|
miette = { version = "7.2.0", features = ["fancy"] }
|
||||||
pretty_assertions = "1.4.1"
|
pretty_assertions = "1.4.1"
|
||||||
serde = { version = "1.0.213", features = ["derive"] }
|
serde = { version = "1.0.213", features = ["derive"] }
|
||||||
|
@ -19,4 +20,5 @@ dirs = "5.0.1"
|
||||||
tokio = "1.41.1"
|
tokio = "1.41.1"
|
||||||
crisp = { git = "https://git.tfcconnection.org/chris/crisp", version = "0.1.3" }
|
crisp = { git = "https://git.tfcconnection.org/chris/crisp", version = "0.1.3" }
|
||||||
iced_layershell = "0.13.0"
|
iced_layershell = "0.13.0"
|
||||||
|
chrono = "0.4.39"
|
||||||
|
|
||||||
|
|
4
justfile
4
justfile
|
@ -6,7 +6,11 @@ run:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
cargo build
|
cargo build
|
||||||
|
|
||||||
|
watch:
|
||||||
|
cargo watch -- cargo run
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
alias r := run
|
alias r := run
|
||||||
alias b := build
|
alias b := build
|
||||||
|
|
63
src/main.rs
63
src/main.rs
|
@ -1,27 +1,33 @@
|
||||||
mod applications;
|
use chrono::prelude::*;
|
||||||
use applications::{all_apps, App};
|
use iced::widget::{container, row, text};
|
||||||
use iced::widget::{container, row};
|
use iced::{Background, Border, Color, Element, Font, Length, Task};
|
||||||
use iced::{Color, Element, Task};
|
|
||||||
|
|
||||||
use iced_layershell::build_pattern::application;
|
use iced_layershell::build_pattern::{application, MainSettings};
|
||||||
use iced_layershell::reexport::Anchor;
|
use iced_layershell::reexport::Anchor;
|
||||||
use iced_layershell::settings::LayerShellSettings;
|
use iced_layershell::settings::LayerShellSettings;
|
||||||
use iced_layershell::to_layer_message;
|
use iced_layershell::to_layer_message;
|
||||||
|
|
||||||
fn main() -> iced_layershell::Result {
|
fn main() -> iced_layershell::Result {
|
||||||
application(Panel::namespace, Panel::update, Panel::view)
|
let settings = MainSettings {
|
||||||
.layer_settings(LayerShellSettings {
|
layer_settings: LayerShellSettings {
|
||||||
size: Some((600, 50)),
|
size: Some((1200, 30)),
|
||||||
anchor: Anchor::Bottom,
|
anchor: Anchor::Bottom,
|
||||||
margin: (0, 0, 10, 0),
|
margin: (0, 0, 10, 0),
|
||||||
|
exclusive_zone: 40,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
},
|
||||||
|
default_font: Font::with_name("VictorMono Nerd Font"),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
application(Panel::namespace, Panel::update, Panel::view)
|
||||||
|
.settings(settings)
|
||||||
.style(Panel::style)
|
.style(Panel::style)
|
||||||
.run_with(Panel::new)
|
.run_with(Panel::new)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Panel {
|
struct Panel {
|
||||||
apps: Vec<App>,
|
apps: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[to_layer_message]
|
#[to_layer_message]
|
||||||
|
@ -32,7 +38,7 @@ enum Message {
|
||||||
|
|
||||||
impl Panel {
|
impl Panel {
|
||||||
fn new() -> (Self, Task<Message>) {
|
fn new() -> (Self, Task<Message>) {
|
||||||
(Self { apps: all_apps() }, Task::none())
|
(Self { apps: vec![] }, Task::none())
|
||||||
}
|
}
|
||||||
fn namespace(&self) -> String {
|
fn namespace(&self) -> String {
|
||||||
String::from("bottom panel")
|
String::from("bottom panel")
|
||||||
|
@ -40,24 +46,35 @@ impl Panel {
|
||||||
|
|
||||||
fn update(&mut self, message: Message) -> Task<Message> {
|
fn update(&mut self, message: Message) -> Task<Message> {
|
||||||
match message {
|
match message {
|
||||||
Message::Launch(index) => {
|
Message::Launch(index) => Task::none(),
|
||||||
self.apps[index].launch();
|
|
||||||
Task::none()
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view(&self) -> Element<Message> {
|
fn view(&self) -> Element<Message> {
|
||||||
let bottom_vec: Vec<Element<Message>> = self
|
// let bottom_vec: Vec<Element<Message>> = self
|
||||||
.apps
|
// .apps
|
||||||
.iter()
|
// .iter()
|
||||||
.enumerate()
|
// .enumerate()
|
||||||
.map(|(index, app)| app.view(index, false))
|
// .map(|(index, app)| app.view(index, false))
|
||||||
.collect();
|
// .collect();
|
||||||
|
|
||||||
let row = row(bottom_vec);
|
let datetime: DateTime<Local> = Local::now();
|
||||||
container(row).into()
|
|
||||||
|
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 {
|
fn style(&self, theme: &iced::Theme) -> iced_layershell::Appearance {
|
||||||
|
|
Loading…
Reference in a new issue