improv(networking): match page list item to design
Also includes various minor fixes.
This commit is contained in:
parent
85d9f9dbfc
commit
f0b80a90bd
8 changed files with 88 additions and 28 deletions
|
|
@ -931,6 +931,7 @@ impl SettingsApp {
|
|||
page_list.push(crate::widget::page_list_item(
|
||||
sub_page.title.as_str(),
|
||||
sub_page.description.as_str(),
|
||||
"",
|
||||
&sub_page.icon_name,
|
||||
entity,
|
||||
))
|
||||
|
|
|
|||
|
|
@ -81,20 +81,44 @@ impl page::Page<crate::pages::Message> for Page {
|
|||
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
|
||||
) -> Option<page::Content> {
|
||||
crate::slab!(descriptions {
|
||||
vpn_txt = fl!("connections-and-profiles", variant = "vpn");
|
||||
wifi_desc = fl!("connections-and-profiles", variant = "wifi");
|
||||
wired_desc = fl!("connections-and-profiles", variant = "wired");
|
||||
vpn_desc = fl!("connections-and-profiles", variant = "vpn");
|
||||
});
|
||||
|
||||
let device_list = Section::default().descriptions(descriptions).view::<Self>(
|
||||
move |_binder, page, section| {
|
||||
let descs = §ion.descriptions;
|
||||
|
||||
let multiple_wifi_adapters = page
|
||||
.devices
|
||||
.iter()
|
||||
.filter(|device| device.device_type == DeviceType::Wifi)
|
||||
.count()
|
||||
> 1;
|
||||
let multiple_wired_adapters = page
|
||||
.devices
|
||||
.iter()
|
||||
.filter(|device| device.device_type == DeviceType::Ethernet)
|
||||
.count()
|
||||
> 1;
|
||||
|
||||
let wifi_devices = page
|
||||
.devices
|
||||
.iter()
|
||||
.filter(|device| device.device_type == DeviceType::Wifi)
|
||||
.map(|device| {
|
||||
crate::widget::page_list_item(
|
||||
fl!("wifi", "adapter", id = device.interface.as_str()),
|
||||
if multiple_wifi_adapters {
|
||||
fl!("wifi", "adapter", id = device.interface.as_str())
|
||||
} else {
|
||||
fl!("wifi")
|
||||
},
|
||||
if multiple_wifi_adapters {
|
||||
""
|
||||
} else {
|
||||
&descs[wifi_desc]
|
||||
},
|
||||
match device.state {
|
||||
DeviceState::Activated => fl!("network-device-state", "activated"),
|
||||
DeviceState::Config => fl!("network-device-state", "config"),
|
||||
|
|
@ -132,7 +156,16 @@ impl page::Page<crate::pages::Message> for Page {
|
|||
.filter(|device| device.device_type == DeviceType::Ethernet)
|
||||
.map(|device| {
|
||||
crate::widget::page_list_item(
|
||||
fl!("wired", "adapter", id = device.interface.as_str()),
|
||||
if multiple_wired_adapters {
|
||||
fl!("wired", "adapter", id = device.interface.as_str())
|
||||
} else {
|
||||
fl!("wired")
|
||||
},
|
||||
if multiple_wired_adapters {
|
||||
""
|
||||
} else {
|
||||
&descs[wired_desc]
|
||||
},
|
||||
match device.state {
|
||||
DeviceState::Activated => fl!("network-device-state", "activated"),
|
||||
DeviceState::Config => fl!("network-device-state", "config"),
|
||||
|
|
@ -169,7 +202,8 @@ impl page::Page<crate::pages::Message> for Page {
|
|||
.fold(widget::column(), |column, device| column.push(device))
|
||||
.push(crate::widget::page_list_item(
|
||||
fl!("vpn"),
|
||||
&descs[vpn_txt],
|
||||
&descs[vpn_desc],
|
||||
"",
|
||||
"preferences-vpn-symbolic",
|
||||
Message::OpenPage {
|
||||
page: page.vpn,
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ pub fn display_container<'a, Message: 'a>(widget: Element<'a, Message>) -> Eleme
|
|||
pub fn page_list_item<'a, Message: 'static + Clone>(
|
||||
title: impl Into<Cow<'a, str>>,
|
||||
description: impl Into<Cow<'a, str>>,
|
||||
info: impl Into<Cow<'a, str>>,
|
||||
icon: &'a str,
|
||||
message: Message,
|
||||
) -> Element<'a, Message> {
|
||||
|
|
@ -135,13 +136,21 @@ pub fn page_list_item<'a, Message: 'static + Clone>(
|
|||
|
||||
let description = description.into();
|
||||
|
||||
let info = info.into();
|
||||
|
||||
if !description.is_empty() {
|
||||
builder = builder.description(description);
|
||||
}
|
||||
|
||||
builder
|
||||
.icon(icon::from_name(icon).size(20))
|
||||
.control(icon::from_name("go-next-symbolic").size(20))
|
||||
.control(
|
||||
row::with_capacity(2)
|
||||
.padding([8, 0]) // fixed value to set minimum height to 36
|
||||
.spacing(space_xxs)
|
||||
.push(text::body(info))
|
||||
.push(icon::from_name("go-next-symbolic").size(20)),
|
||||
)
|
||||
.padding([0, space_xxs])
|
||||
.spacing(space_s)
|
||||
.apply(container)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue