This commit is contained in:
Chris Cochrun 2025-01-08 09:52:21 -06:00
parent 76396a6b6c
commit 955aafacb6
4 changed files with 194 additions and 2687 deletions

2810
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,8 @@ description = "A shell for a computadora"
[dependencies]
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"] }
pretty_assertions = "1.4.1"
serde = { version = "1.0.213", features = ["derive"] }
@ -19,4 +20,5 @@ dirs = "5.0.1"
tokio = "1.41.1"
crisp = { git = "https://git.tfcconnection.org/chris/crisp", version = "0.1.3" }
iced_layershell = "0.13.0"
chrono = "0.4.39"

View file

@ -7,6 +7,10 @@ run:
build:
cargo build
watch:
cargo watch -- cargo run
alias r := run
alias b := build

View file

@ -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 {