Skip to content

Commit 1c2c6e6

Browse files
committed
improv: update ui to use crate::error::Error
1 parent d7f33bd commit 1c2c6e6

7 files changed

Lines changed: 16 additions & 27 deletions

File tree

src/ui/.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
debug/
44
target/
55

6-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8-
Cargo.lock
9-
106
# These are backup files generated by rustfmt
117
**/*.rs.bk
128

src/ui/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tokio = { version = "1.37.0", features = ["full"] }
2121
[dependencies.libcosmic]
2222
git = "https://github.com/pop-os/libcosmic.git"
2323
default-features = false
24-
features = ["dbus-config", "tokio", "winit", "wgpu"]
24+
features = ["dbus-config", "tokio", "winit", "wgpu", "desktop"]
2525

2626
[dependencies.i18n-embed]
2727
version = "0.14"

src/ui/src/app.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::collections::HashMap;
44

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

120120
nav.insert()
@@ -150,7 +150,7 @@ impl Application for Devmode {
150150
nav,
151151
};
152152

153-
(app, Command::none())
153+
(app, Task::none())
154154
}
155155

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

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

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

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

246-
Command::none()
246+
Task::none()
247247
}
248248
}
249249

@@ -266,7 +266,7 @@ impl Devmode {
266266
.push(icon)
267267
.push(title)
268268
.push(link)
269-
.align_items(Alignment::Center)
269+
.align_x(Alignment::Center)
270270
.spacing(space_xxs)
271271
.into()
272272
}

src/ui/src/pages/clone.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ impl ClonePage {
6363
.padding([spacing.space_none, spacing.space_xxs]);
6464

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

6969
let item_text = widget::editable_input(
7070
"",
@@ -78,7 +78,7 @@ impl ClonePage {
7878
.width(Length::Fill);
7979

8080
let row = widget::row::with_capacity(4)
81-
.align_items(Alignment::Center)
81+
.align_y(Alignment::Center)
8282
.spacing(spacing.space_xxs)
8383
.padding([spacing.space_xxxs, spacing.space_xxs])
8484
.push(item_checkbox)

src/ui/src/pages/config.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ impl ConfigPage {
3333
}
3434

3535
pub fn update(&self, message: Message) -> Vec<Command> {
36-
let mut commands = vec![];
37-
match message {}
38-
commands
36+
vec![]
3937
}
4038
}

src/ui/src/pages/open.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use cosmic::{
22
iced::{Alignment, Length},
33
theme, widget, Apply, Element,
44
};
5-
use slotmap::{DefaultKey, SecondaryMap, SlotMap};
65

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

4746
let row = widget::row::with_capacity(4)
48-
.align_items(Alignment::Center)
47+
.align_y(Alignment::Center)
4948
.spacing(spacing.space_xxs)
5049
.padding([spacing.space_xxxs, spacing.space_xxs])
5150
.push(item_text);
@@ -65,10 +64,6 @@ impl OpenPage {
6564
}
6665

6766
pub fn update(&self, message: Message) -> Vec<Command> {
68-
let mut commands = vec![];
69-
match message {
70-
Message::Select(_) => todo!(),
71-
}
72-
commands
67+
vec![]
7368
}
7469
}

src/ui/src/pages/workspaces.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl WorkspacesPage {
6060
.width(Length::Fill);
6161

6262
let row = widget::row::with_capacity(4)
63-
.align_items(Alignment::Center)
63+
.align_y(Alignment::Center)
6464
.spacing(spacing.space_xxs)
6565
.padding([spacing.space_xxxs, spacing.space_xxs])
6666
.push(item_text);

0 commit comments

Comments
 (0)