Refactor pages into separate files

This commit is contained in:
Jeremy Soller 2022-12-21 13:11:32 -07:00
parent e4af157406
commit 3f113016c5
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
8 changed files with 464 additions and 406 deletions

View file

@ -0,0 +1,91 @@
use cosmic::{
Element,
iced::Length,
iced::widget::{horizontal_space, row, text},
widget::{icon, list_column, settings},
};
use super::{Message, Page, SubPage, Window};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum SystemAndAccountsPage {
Users,
About,
Firmware,
}
impl SubPage for SystemAndAccountsPage {
//TODO: translate
fn title(&self) -> &'static str {
use SystemAndAccountsPage::*;
match self {
Users => "Users",
About => "About",
Firmware => "Firmware",
}
}
//TODO: translate
fn description(&self) -> &'static str {
use SystemAndAccountsPage::*;
match self {
Users => "Authentication and login, lock screen.",
About => "Device name, hardware information, operating system defaults.",
Firmware => "Firmware details.",
}
}
fn icon_name(&self) -> &'static str {
use SystemAndAccountsPage::*;
match self {
Users => "system-users-symbolic",
About => "help-about-symbolic",
Firmware => "firmware-manager-symbolic",
}
}
fn parent_page(&self) -> Page {
Page::SystemAndAccounts(None)
}
fn into_page(self) -> Page {
Page::SystemAndAccounts(Some(self))
}
}
impl Window {
pub(super) fn view_system_and_accounts_about(&self) -> Element<Message> {
settings::view_column(vec![
self.parent_page_button(SystemAndAccountsPage::About),
row!(
horizontal_space(Length::Fill),
icon("distributor-logo", 78),
horizontal_space(Length::Fill),
).into(),
list_column()
.add(settings::item("Device name", text("TODO")))
.into(),
settings::view_section("Hardware")
.add(settings::item("Hardware model", text("TODO")))
.add(settings::item("Memory", text("TODO")))
.add(settings::item("Processor", text("TODO")))
.add(settings::item("Graphics", text("TODO")))
.add(settings::item("Disk Capacity", text("TODO")))
.into(),
settings::view_section("Operating System")
.add(settings::item("Operating system", text("TODO")))
.add(settings::item("Operating system architecture", text("TODO")))
.add(settings::item("Desktop environment", text("TODO")))
.add(settings::item("Windowing system", text("TODO")))
.into(),
settings::view_section("Related settings")
.add(settings::item("Get support", text("TODO")))
.into(),
]).into()
}
}