Skip to content

Commit

Permalink
improv: update ui to use crate::error::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
edfloreshz committed Oct 22, 2024
1 parent d7f33bd commit 1c2c6e6
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 27 deletions.
4 changes: 0 additions & 4 deletions src/ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

Expand Down
2 changes: 1 addition & 1 deletion src/ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tokio = { version = "1.37.0", features = ["full"] }
[dependencies.libcosmic]
git = "https://github.com/pop-os/libcosmic.git"
default-features = false
features = ["dbus-config", "tokio", "winit", "wgpu"]
features = ["dbus-config", "tokio", "winit", "wgpu", "desktop"]

[dependencies.i18n-embed]
version = "0.14"
Expand Down
16 changes: 8 additions & 8 deletions src/ui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::collections::HashMap;

use crate::{fl, pages};
use cosmic::app::{Command, Core};
use cosmic::app::{Core, Task};
use cosmic::iced::alignment::{Horizontal, Vertical};
use cosmic::iced::{Alignment, Length};
use cosmic::widget::{self, icon, menu, nav_bar};
Expand Down Expand Up @@ -114,7 +114,7 @@ impl Application for Devmode {
/// - `core` is used to passed on for you by libcosmic to use in the core of your own application.
/// - `flags` is used to pass in any data that your application needs to use before it starts.
/// - `Command` type is used to send messages to your application. `Command::none()` can be used to send no messages to your application.
fn init(core: Core, _flags: Self::Flags) -> (Self, Command<Self::Message>) {
fn init(core: Core, _flags: Self::Flags) -> (Self, Task<Self::Message>) {
let mut nav = nav_bar::Model::default();

nav.insert()
Expand Down Expand Up @@ -150,7 +150,7 @@ impl Application for Devmode {
nav,
};

(app, Command::none())
(app, Task::none())
}

/// Elements to pack at the start of the header bar.
Expand Down Expand Up @@ -189,7 +189,7 @@ impl Application for Devmode {
/// Application messages are handled here. The application state can be modified based on
/// what message was received. Commands may be returned for asynchronous execution on a
/// background thread managed by the application's executor.
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
fn update(&mut self, message: Self::Message) -> Task<Self::Message> {
match message {
Message::Clone(message) => {
for command in self.clone.update(message) {
Expand Down Expand Up @@ -220,7 +220,7 @@ impl Application for Devmode {
self.set_context_title(context_page.title());
}
}
Command::none()
Task::none()
}

/// Display a context drawer if the context page is requested.
Expand All @@ -235,15 +235,15 @@ impl Application for Devmode {
}

/// Called when a nav item is selected.
fn on_nav_select(&mut self, id: nav_bar::Id) -> Command<Self::Message> {
fn on_nav_select(&mut self, id: nav_bar::Id) -> Task<Self::Message> {
// Activate the page in the model.
self.nav.activate(id);

if let Some(page) = self.nav.active_data::<Page>() {
self.page = *page;
}

Command::none()
Task::none()
}
}

Expand All @@ -266,7 +266,7 @@ impl Devmode {
.push(icon)
.push(title)
.push(link)
.align_items(Alignment::Center)
.align_x(Alignment::Center)
.spacing(space_xxs)
.into()
}
Expand Down
6 changes: 3 additions & 3 deletions src/ui/src/pages/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ impl ClonePage {
.padding([spacing.space_none, spacing.space_xxs]);

for (id, item) in &self.repositories {
let item_checkbox =
widget::checkbox("", item.selected, move |value| Message::Select(id, value));
let item_checkbox = widget::checkbox("", item.selected)
.on_toggle(move |value| Message::Select(id, value));

let item_text = widget::editable_input(
"",
Expand All @@ -78,7 +78,7 @@ impl ClonePage {
.width(Length::Fill);

let row = widget::row::with_capacity(4)
.align_items(Alignment::Center)
.align_y(Alignment::Center)
.spacing(spacing.space_xxs)
.padding([spacing.space_xxxs, spacing.space_xxs])
.push(item_checkbox)
Expand Down
4 changes: 1 addition & 3 deletions src/ui/src/pages/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ impl ConfigPage {
}

pub fn update(&self, message: Message) -> Vec<Command> {
let mut commands = vec![];
match message {}
commands
vec![]
}
}
9 changes: 2 additions & 7 deletions src/ui/src/pages/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use cosmic::{
iced::{Alignment, Length},
theme, widget, Apply, Element,
};
use slotmap::{DefaultKey, SecondaryMap, SlotMap};

#[derive(Debug, Default)]
pub struct Repository {
Expand Down Expand Up @@ -45,7 +44,7 @@ impl OpenPage {
let item_text = widget::text(item).width(Length::Fill);

let row = widget::row::with_capacity(4)
.align_items(Alignment::Center)
.align_y(Alignment::Center)
.spacing(spacing.space_xxs)
.padding([spacing.space_xxxs, spacing.space_xxs])
.push(item_text);
Expand All @@ -65,10 +64,6 @@ impl OpenPage {
}

pub fn update(&self, message: Message) -> Vec<Command> {
let mut commands = vec![];
match message {
Message::Select(_) => todo!(),
}
commands
vec![]
}
}
2 changes: 1 addition & 1 deletion src/ui/src/pages/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl WorkspacesPage {
.width(Length::Fill);

let row = widget::row::with_capacity(4)
.align_items(Alignment::Center)
.align_y(Alignment::Center)
.spacing(spacing.space_xxs)
.padding([spacing.space_xxxs, spacing.space_xxs])
.push(item_text);
Expand Down

0 comments on commit 1c2c6e6

Please sign in to comment.